Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ImportedProjects
SVG
Commits
b6abd3cb
Commit
b6abd3cb
authored
Feb 23, 2017
by
mrbean-bremen
Browse files
Add transform to bounds calculation in path based objects
see #281
parent
f6622b55
Changes
8
Hide whitespace changes
Inline
Side-by-side
Source/Basic Shapes/SvgCircle.cs
View file @
b6abd3cb
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
:
Svg
Visual
Element
public
class
SvgCircle
:
Svg
PathBased
Element
{
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>
...
...
Source/Basic Shapes/SvgEllipse.cs
View file @
b6abd3cb
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
:
Svg
Visual
Element
public
class
SvgEllipse
:
Svg
PathBased
Element
{
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>
...
...
Source/Basic Shapes/SvgLine.cs
View file @
b6abd3cb
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
:
Svg
Visual
Element
public
class
SvgLine
:
Svg
PathBased
Element
{
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
>();
...
...
Source/Basic Shapes/SvgPathBasedElement.cs
0 → 100644
View file @
b6abd3cb
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
();
}
}
}
}
Source/Basic Shapes/SvgPolygon.cs
View file @
b6abd3cb
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
:
Svg
Visual
Element
public
class
SvgPolygon
:
Svg
PathBased
Element
{
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
>();
...
...
Source/Basic Shapes/SvgRectangle.cs
View file @
b6abd3cb
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
:
Svg
Visual
Element
public
class
SvgRectangle
:
Svg
PathBased
Element
{
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>
...
...
Source/Svg.csproj
View file @
b6abd3cb
...
...
@@ -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"
/>
...
...
Source/Text/SvgGlyph.cs
View file @
b6abd3cb
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
:
Svg
Visual
Element
public
class
SvgGlyph
:
Svg
PathBased
Element
{
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>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment