Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split drawing code into separate files #934

Merged
merged 88 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
acde25e
Slit SvgCircle
wieslawsoltes Jan 6, 2022
7f6f35f
Split SvgEllipse
wieslawsoltes Jan 6, 2022
6ea1f2a
Split SvgLine
wieslawsoltes Jan 6, 2022
1713f5e
Split SvgMarkerElement
wieslawsoltes Jan 6, 2022
8680cd0
Split SvgPathBasedElement
wieslawsoltes Jan 6, 2022
f0484c5
Split SvgPolygon
wieslawsoltes Jan 6, 2022
e528424
Split SvgPolyline
wieslawsoltes Jan 6, 2022
3b87578
Split SvgRectangle
wieslawsoltes Jan 6, 2022
5f3c4a9
Split SvgVisualElement
wieslawsoltes Jan 6, 2022
24e5c7c
Rename file
wieslawsoltes Jan 6, 2022
795b5d2
Remove redundant qualifier
wieslawsoltes Jan 6, 2022
1ebebe0
Remove unused usings
wieslawsoltes Jan 6, 2022
e64b9c9
Split SvgClipPath
wieslawsoltes Jan 6, 2022
55b6226
Split SvgViewBox
wieslawsoltes Jan 6, 2022
49ead35
Split SvgDefinitionList
wieslawsoltes Jan 6, 2022
66726ca
Split SvgFragment
wieslawsoltes Jan 6, 2022
b7d191a
Split SvgGroup
wieslawsoltes Jan 6, 2022
920388c
Split SvgImage
wieslawsoltes Jan 6, 2022
c6256d8
Split SvgSwitch
wieslawsoltes Jan 6, 2022
cdaf669
Split SvgSymbol
wieslawsoltes Jan 6, 2022
e4db2e7
Split SvgUse
wieslawsoltes Jan 6, 2022
1d191a7
Split SvgForeignObject
wieslawsoltes Jan 6, 2022
51fba25
Split SvgBlend
wieslawsoltes Jan 6, 2022
5af262d
Split SvgColourMatrix
wieslawsoltes Jan 6, 2022
46f94f4
Split SvgComponentTransfer
wieslawsoltes Jan 6, 2022
3263059
Split SvgComposite
wieslawsoltes Jan 6, 2022
51584a5
Split SvgConvolveMatrix
wieslawsoltes Jan 6, 2022
e9ba940
Split SvgDiffuseLighting
wieslawsoltes Jan 6, 2022
007ad25
Split SvgDisplacementMap
wieslawsoltes Jan 6, 2022
55d05d8
Split SvgFlood
wieslawsoltes Jan 6, 2022
acf5272
Split SvgGaussianBlur
wieslawsoltes Jan 6, 2022
d238cb1
Split SvgImage
wieslawsoltes Jan 6, 2022
bd9f54f
Split SvgMerge
wieslawsoltes Jan 6, 2022
915b94a
Split SvgMorphology
wieslawsoltes Jan 6, 2022
d7e0ab2
Split SvgOffset
wieslawsoltes Jan 6, 2022
a86e559
Split SvgSpecularLighting
wieslawsoltes Jan 6, 2022
cf2dfed
Split SvgTile
wieslawsoltes Jan 6, 2022
7a9a4c0
Split SvgTurbulence
wieslawsoltes Jan 6, 2022
9ef1a36
Split SvgFilter
wieslawsoltes Jan 6, 2022
68ad87f
Split SvgDocumentMetadata
wieslawsoltes Jan 6, 2022
990018f
Split SvgGradientServer
wieslawsoltes Jan 6, 2022
d3952b5
Split SvgLinearGradientServer
wieslawsoltes Jan 6, 2022
1ed3cd9
Split SvgMarker
wieslawsoltes Jan 6, 2022
6340bf8
Split SvgDocument
wieslawsoltes Jan 6, 2022
251bd95
Split SvgPaintServer
wieslawsoltes Jan 6, 2022
3e2dca4
Add missing using
wieslawsoltes Jan 6, 2022
dd8bb12
Split SvgPatternServer
wieslawsoltes Jan 6, 2022
a4cc247
Split SvgRadialGradientServer
wieslawsoltes Jan 6, 2022
d0058c2
Split SvgArcSegment
wieslawsoltes Jan 6, 2022
4c2ec89
Split SvgClosePathSegment
wieslawsoltes Jan 6, 2022
45bfd07
Split SvgCubicCurveSegment
wieslawsoltes Jan 6, 2022
e9d38bb
Split SvgLineSegment
wieslawsoltes Jan 6, 2022
bf415c4
Split SvgMoveToSegment
wieslawsoltes Jan 6, 2022
a56299b
Split SvgPath
wieslawsoltes Jan 6, 2022
f29c354
Split SvgPathSegment
wieslawsoltes Jan 6, 2022
09408d8
Split SvgQuadraticCurveSegment
wieslawsoltes Jan 6, 2022
36ec5d5
Make entire ISvgClipable interface under NO_SDC if/def
wieslawsoltes Jan 6, 2022
8ecc45f
Make entire IGraphicsProvider interface under NO_SDC if/def
wieslawsoltes Jan 6, 2022
e271937
Make entire ISvgRenderer interface under NO_SDC if/def
wieslawsoltes Jan 6, 2022
7942057
Split SvgUnit
wieslawsoltes Jan 6, 2022
9ddeedc
Add NO_SDC if/def for ToDeviceValue
wieslawsoltes Jan 6, 2022
7bad9f7
Remove unused using
wieslawsoltes Jan 6, 2022
112db16
Split SvgColourServer
wieslawsoltes Jan 6, 2022
657eac4
Split SvgDeferredPaintServer
wieslawsoltes Jan 6, 2022
4bdaae7
Split SvgFallbackPaintServer
wieslawsoltes Jan 6, 2022
3eeb9e5
Split SvgElement
wieslawsoltes Jan 6, 2022
074aaa3
Split SvgElementStyle
wieslawsoltes Jan 6, 2022
93be4df
Make entire IFontDefn interface under NO_SDC if/def
wieslawsoltes Jan 6, 2022
ebeadb0
Make entire GdiFontDefn class under NO_SDC if/def
wieslawsoltes Jan 6, 2022
bc00259
Make entire SvgFontDefn class under NO_SDC if/def
wieslawsoltes Jan 6, 2022
2673327
Split SvgTextBase
wieslawsoltes Jan 6, 2022
a93d394
Split SvgFont
wieslawsoltes Jan 6, 2022
fa78113
Split SvgGlyph
wieslawsoltes Jan 6, 2022
9ce77c8
Split SvgTextPath
wieslawsoltes Jan 6, 2022
2f5632d
Simplify if/def
wieslawsoltes Jan 6, 2022
9ee3a16
Split SvgTextRef
wieslawsoltes Jan 6, 2022
0d4adb9
Split SvgMatrix
wieslawsoltes Jan 6, 2022
a1e5e96
Split SvgTransform
wieslawsoltes Jan 6, 2022
e27c58e
Split SvgRotate
wieslawsoltes Jan 6, 2022
ba6accb
Split SvgScale
wieslawsoltes Jan 6, 2022
fdf843b
Split SvgShear
wieslawsoltes Jan 6, 2022
d128393
Split SvgSkew
wieslawsoltes Jan 6, 2022
0cff3fb
Split SvgTransformCollection
wieslawsoltes Jan 6, 2022
aab4018
Split SvgTranslate
wieslawsoltes Jan 6, 2022
0b845ca
Split SvgPoint
wieslawsoltes Jan 6, 2022
b1b3921
Add NO_SDC if/def
wieslawsoltes Jan 6, 2022
e34ab16
Move implicit operator float to NO_SDC if/def
wieslawsoltes Jan 6, 2022
0d36376
Move GetRectangle method into NO_SDC if/def
wieslawsoltes Jan 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Source/Basic Shapes/SvgCircle.Drawing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#if !NO_SDC
using System.Drawing.Drawing2D;

namespace Svg
{
public partial class SvgCircle : SvgPathBasedElement
{
private GraphicsPath _path;

/// <summary>
/// Gets the <see cref="GraphicsPath"/> representing this element.
/// </summary>
public override GraphicsPath Path(ISvgRenderer renderer)
{
if (this._path == null || this.IsPathDirty)
{
var halfStrokeWidth = base.StrokeWidth / 2;

// If it is to render, don't need to consider stroke width.
// i.e stroke width only to be considered when calculating boundary
if (renderer != null)
{
halfStrokeWidth = 0;
this.IsPathDirty = false;
}

_path = new GraphicsPath();
_path.StartFigure();
var center = this.Center.ToDeviceValue(renderer, this);
var radius = this.Radius.ToDeviceValue(renderer, UnitRenderingType.Other, this) + halfStrokeWidth;
_path.AddEllipse(center.X - radius, center.Y - radius, 2 * radius, 2 * radius);
_path.CloseFigure();
}
return _path;
}

/// <summary>
/// Renders the circle using the specified <see cref="ISvgRenderer"/> object.
/// </summary>
/// <param name="renderer">The renderer object.</param>
protected override void Render(ISvgRenderer renderer)
{
// Don't draw if there is no radius set
if (this.Radius.Value > 0.0f)
{
base.Render(renderer);
}
}
}
}
#endif
50 changes: 1 addition & 49 deletions Source/Basic Shapes/SvgCircle.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#if !NO_SDC
using System.Drawing.Drawing2D;
#endif

namespace Svg
{
/// <summary>
Expand All @@ -13,9 +9,7 @@ public partial class SvgCircle : SvgPathBasedElement
private SvgUnit _centerX = 0f;
private SvgUnit _centerY = 0f;
private SvgUnit _radius = 0f;
#if !NO_SDC
private GraphicsPath _path;
#endif

/// <summary>
/// Gets the center point of the circle.
/// </summary>
Expand Down Expand Up @@ -45,48 +39,6 @@ public virtual SvgUnit Radius
get { return _radius; }
set { _radius = value; Attributes["r"] = value; IsPathDirty = true; }
}
#if !NO_SDC

/// <summary>
/// Gets the <see cref="GraphicsPath"/> representing this element.
/// </summary>
public override GraphicsPath Path(ISvgRenderer renderer)
{
if (this._path == null || this.IsPathDirty)
{
var halfStrokeWidth = base.StrokeWidth / 2;

// If it is to render, don't need to consider stroke width.
// i.e stroke width only to be considered when calculating boundary
if (renderer != null)
{
halfStrokeWidth = 0;
this.IsPathDirty = false;
}

_path = new GraphicsPath();
_path.StartFigure();
var center = this.Center.ToDeviceValue(renderer, this);
var radius = this.Radius.ToDeviceValue(renderer, UnitRenderingType.Other, this) + halfStrokeWidth;
_path.AddEllipse(center.X - radius, center.Y - radius, 2 * radius, 2 * radius);
_path.CloseFigure();
}
return _path;
}

/// <summary>
/// Renders the circle using the specified <see cref="ISvgRenderer"/> object.
/// </summary>
/// <param name="renderer">The renderer object.</param>
protected override void Render(ISvgRenderer renderer)
{
// Don't draw if there is no radius set
if (this.Radius.Value > 0.0f)
{
base.Render(renderer);
}
}
#endif

public override SvgElement DeepCopy()
{
Expand Down
53 changes: 53 additions & 0 deletions Source/Basic Shapes/SvgEllipse.Drawing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#if !NO_SDC
using System.Drawing.Drawing2D;

namespace Svg
{
public partial class SvgEllipse : SvgPathBasedElement
{
private GraphicsPath _path;

/// <summary>
/// Gets the <see cref="GraphicsPath"/> for this element.
/// </summary>
/// <value></value>
public override GraphicsPath Path(ISvgRenderer renderer)
{
if (this._path == null || this.IsPathDirty)
{
var halfStrokeWidth = base.StrokeWidth / 2;

// If it is to render, don't need to consider stroke width.
// i.e stroke width only to be considered when calculating boundary
if (renderer != null)
{
halfStrokeWidth = 0;
this.IsPathDirty = false;
}

var center = SvgUnit.GetDevicePoint(this.CenterX, this.CenterY, renderer, this);
var radiusX = this.RadiusX.ToDeviceValue(renderer, UnitRenderingType.Other, this) + halfStrokeWidth;
var radiusY = this.RadiusY.ToDeviceValue(renderer, UnitRenderingType.Other, this) + halfStrokeWidth;

this._path = new GraphicsPath();
_path.StartFigure();
_path.AddEllipse(center.X - radiusX, center.Y - radiusY, 2 * radiusX, 2 * radiusY);
_path.CloseFigure();
}
return _path;
}

/// <summary>
/// Renders the <see cref="SvgElement"/> and contents using the specified <see cref="ISvgRenderer"/> object.
/// </summary>
/// <param name="renderer">The <see cref="ISvgRenderer"/> object used for rendering.</param>
protected override void Render(ISvgRenderer renderer)
{
if (this.RadiusX.Value > 0.0f && this.RadiusY.Value > 0.0f)
{
base.Render(renderer);
}
}
}
}
#endif
52 changes: 0 additions & 52 deletions Source/Basic Shapes/SvgEllipse.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#if !NO_SDC
using System.Drawing.Drawing2D;
#endif

namespace Svg
{
/// <summary>
Expand All @@ -15,10 +11,6 @@ public partial class SvgEllipse : SvgPathBasedElement
private SvgUnit _radiusX = 0f;
private SvgUnit _radiusY = 0f;

#if !NO_SDC
private GraphicsPath _path;
#endif

[SvgAttribute("cx")]
public virtual SvgUnit CenterX
{
Expand Down Expand Up @@ -47,50 +39,6 @@ public virtual SvgUnit RadiusY
set { _radiusY = value; Attributes["ry"] = value; IsPathDirty = true; }
}

#if !NO_SDC
/// <summary>
/// Gets the <see cref="GraphicsPath"/> for this element.
/// </summary>
/// <value></value>
public override GraphicsPath Path(ISvgRenderer renderer)
{
if (this._path == null || this.IsPathDirty)
{
var halfStrokeWidth = base.StrokeWidth / 2;

// If it is to render, don't need to consider stroke width.
// i.e stroke width only to be considered when calculating boundary
if (renderer != null)
{
halfStrokeWidth = 0;
this.IsPathDirty = false;
}

var center = SvgUnit.GetDevicePoint(this.CenterX, this.CenterY, renderer, this);
var radiusX = this.RadiusX.ToDeviceValue(renderer, UnitRenderingType.Other, this) + halfStrokeWidth;
var radiusY = this.RadiusY.ToDeviceValue(renderer, UnitRenderingType.Other, this) + halfStrokeWidth;

this._path = new GraphicsPath();
_path.StartFigure();
_path.AddEllipse(center.X - radiusX, center.Y - radiusY, 2 * radiusX, 2 * radiusY);
_path.CloseFigure();
}
return _path;
}

/// <summary>
/// Renders the <see cref="SvgElement"/> and contents using the specified <see cref="ISvgRenderer"/> object.
/// </summary>
/// <param name="renderer">The <see cref="ISvgRenderer"/> object used for rendering.</param>
protected override void Render(ISvgRenderer renderer)
{
if (this.RadiusX.Value > 0.0f && this.RadiusY.Value > 0.0f)
{
base.Render(renderer);
}
}
#endif

public override SvgElement DeepCopy()
{
return DeepCopy<SvgEllipse>();
Expand Down
42 changes: 42 additions & 0 deletions Source/Basic Shapes/SvgLine.Drawing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#if !NO_SDC
using System.Drawing;
using System.Drawing.Drawing2D;

namespace Svg
{
public partial class SvgLine : SvgMarkerElement
{
private GraphicsPath _path;

public override GraphicsPath Path(ISvgRenderer renderer)
{
if ((this._path == null || this.IsPathDirty) && base.StrokeWidth > 0)
{
PointF start = new PointF(this.StartX.ToDeviceValue(renderer, UnitRenderingType.Horizontal, this),
this.StartY.ToDeviceValue(renderer, UnitRenderingType.Vertical, this));
PointF end = new PointF(this.EndX.ToDeviceValue(renderer, UnitRenderingType.Horizontal, this),
this.EndY.ToDeviceValue(renderer, UnitRenderingType.Vertical, this));

this._path = new GraphicsPath();

// If it is to render, don't need to consider stroke width.
// i.e stroke width only to be considered when calculating boundary
if (renderer != null)
{
this._path.AddLine(start, end);
this.IsPathDirty = false;
}
else
{ // only when calculating boundary
_path.StartFigure();
var radius = base.StrokeWidth / 2;
_path.AddEllipse(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
_path.AddEllipse(end.X - radius, end.Y - radius, 2 * radius, 2 * radius);
_path.CloseFigure();
}
}
return this._path;
}
}
}
#endif
43 changes: 0 additions & 43 deletions Source/Basic Shapes/SvgLine.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using System.Drawing;
#if !NO_SDC
using System.Drawing.Drawing2D;
#endif

namespace Svg
{
/// <summary>
Expand All @@ -16,12 +11,6 @@ public partial class SvgLine : SvgMarkerElement
private SvgUnit _endX = 0f;
private SvgUnit _endY = 0f;

#if !NO_SDC

private GraphicsPath _path;

#endif

[SvgAttribute("x1")]
public SvgUnit StartX
{
Expand Down Expand Up @@ -90,38 +79,6 @@ public override SvgPaintServer Fill
// Do nothing
}
}
#if !NO_SDC

public override System.Drawing.Drawing2D.GraphicsPath Path(ISvgRenderer renderer)
{
if ((this._path == null || this.IsPathDirty) && base.StrokeWidth > 0)
{
PointF start = new PointF(this.StartX.ToDeviceValue(renderer, UnitRenderingType.Horizontal, this),
this.StartY.ToDeviceValue(renderer, UnitRenderingType.Vertical, this));
PointF end = new PointF(this.EndX.ToDeviceValue(renderer, UnitRenderingType.Horizontal, this),
this.EndY.ToDeviceValue(renderer, UnitRenderingType.Vertical, this));

this._path = new GraphicsPath();

// If it is to render, don't need to consider stroke width.
// i.e stroke width only to be considered when calculating boundary
if (renderer != null)
{
this._path.AddLine(start, end);
this.IsPathDirty = false;
}
else
{ // only when calculating boundary
_path.StartFigure();
var radius = base.StrokeWidth / 2;
_path.AddEllipse(start.X - radius, start.Y - radius, 2 * radius, 2 * radius);
_path.AddEllipse(end.X - radius, end.Y - radius, 2 * radius, 2 * radius);
_path.CloseFigure();
}
}
return this._path;
}
#endif

public override SvgElement DeepCopy()
{
Expand Down
Loading