Commit b6abd3cb authored by mrbean-bremen's avatar mrbean-bremen
Browse files

Add transform to bounds calculation in path based objects

see #281
parent f6622b55
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace Svg
{
......@@ -13,7 +6,7 @@ namespace Svg
/// An SVG element to render circles to the document.
/// </summary>
[SvgElement("circle")]
public class SvgCircle : SvgVisualElement
public class SvgCircle : SvgPathBasedElement
{
private GraphicsPath _path;
......@@ -75,15 +68,6 @@ namespace Svg
}
}
/// <summary>
/// Gets the bounds of the circle.
/// </summary>
/// <value>The rectangular bounds of the circle.</value>
public override RectangleF Bounds
{
get { return this.Path(null).GetBounds(); }
}
/// <summary>
/// Gets the <see cref="GraphicsPath"/> representing this element.
/// </summary>
......
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml;
using System.ComponentModel;
namespace Svg
{
......@@ -12,7 +6,7 @@ namespace Svg
/// Represents and SVG ellipse element.
/// </summary>
[SvgElement("ellipse")]
public class SvgEllipse : SvgVisualElement
public class SvgEllipse : SvgPathBasedElement
{
private SvgUnit _radiusX;
private SvgUnit _radiusY;
......@@ -80,15 +74,6 @@ namespace Svg
}
}
/// <summary>
/// Gets the bounds of the element.
/// </summary>
/// <value>The bounds.</value>
public override RectangleF Bounds
{
get { return this.Path(null).GetBounds(); }
}
/// <summary>
/// Gets the <see cref="GraphicsPath"/> for this element.
/// </summary>
......
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using Svg.ExtensionMethods;
......@@ -12,7 +9,7 @@ namespace Svg
/// Represents and SVG line element.
/// </summary>
[SvgElement("line")]
public class SvgLine : SvgVisualElement
public class SvgLine : SvgPathBasedElement
{
private SvgUnit _startX;
private SvgUnit _startY;
......@@ -186,11 +183,6 @@ namespace Svg
return result;
}
public override System.Drawing.RectangleF Bounds
{
get { return this.Path(null).GetBounds(); }
}
public override SvgElement DeepCopy()
{
return DeepCopy<SvgLine>();
......
using System.Drawing.Drawing2D;
namespace Svg
{
/// <summary>
/// Represents an element that is using a GraphicsPath as rendering base.
/// </summary>
public abstract class SvgPathBasedElement : SvgVisualElement
{
public override System.Drawing.RectangleF Bounds
{
get
{
var path = this.Path(null);
if (Transforms != null)
{
path = (GraphicsPath)path.Clone();
path.Transform(Transforms.GetMatrix());
}
return path.GetBounds();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using Svg.ExtensionMethods;
using Svg.Pathing;
namespace Svg
{
......@@ -13,7 +9,7 @@ namespace Svg
/// SvgPolygon defines a closed shape consisting of a set of connected straight line segments.
/// </summary>
[SvgElement("polygon")]
public class SvgPolygon : SvgVisualElement
public class SvgPolygon : SvgPathBasedElement
{
private GraphicsPath _path;
......@@ -136,12 +132,6 @@ namespace Svg
return result;
}
public override RectangleF Bounds
{
get { return this.Path(null).GetBounds(); }
}
public override SvgElement DeepCopy()
{
return DeepCopy<SvgPolygon>();
......
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using Svg.Transforms;
namespace Svg
{
......@@ -9,7 +8,7 @@ namespace Svg
/// Represents an SVG rectangle that could also have rounded edges.
/// </summary>
[SvgElement("rect")]
public class SvgRectangle : SvgVisualElement
public class SvgRectangle : SvgPathBasedElement
{
private SvgUnit _cornerRadiusX;
private SvgUnit _cornerRadiusY;
......@@ -168,15 +167,6 @@ namespace Svg
}
}
/// <summary>
/// Gets the bounds of the element.
/// </summary>
/// <value>The bounds.</value>
public override RectangleF Bounds
{
get { return Path(null).GetBounds(); }
}
/// <summary>
/// Gets the <see cref="GraphicsPath"/> for this element.
/// </summary>
......
......@@ -89,6 +89,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Basic Shapes\SvgImage.cs" />
<Compile Include="Basic Shapes\SvgPathBasedElement.cs" />
<Compile Include="Basic Shapes\SvgVisualElement.cs" />
<Compile Include="Basic Shapes\SvgCircle.cs" />
<Compile Include="Basic Shapes\SvgEllipse.cs" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq;
using Svg.Pathing;
using System.Drawing.Drawing2D;
namespace Svg
{
[SvgElement("glyph")]
public class SvgGlyph : SvgVisualElement
public class SvgGlyph : SvgPathBasedElement
{
private GraphicsPath _path;
......@@ -79,15 +76,6 @@ namespace Svg
return _path;
}
/// <summary>
/// Gets the bounds of the element.
/// </summary>
/// <value>The bounds.</value>
public override System.Drawing.RectangleF Bounds
{
get { return this.Path(null).GetBounds(); }
}
/// <summary>
/// Initializes a new instance of the <see cref="SvgGlyph"/> class.
/// </summary>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment