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
302ca29e
Commit
302ca29e
authored
Nov 01, 2010
by
owaits
Browse files
Adds support for linked gradient stops.
parent
4ad323d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Source/Clipping and Masking/SvgClipPath.cs
View file @
302ca29e
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
System.Text
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
Svg.Transforms
;
namespace
Svg
{
...
...
@@ -63,7 +64,18 @@ namespace Svg
if
(
graphicsElement
!=
null
&&
graphicsElement
.
Path
!=
null
)
{
path
.
FillMode
=
(
graphicsElement
.
ClipRule
==
SvgClipRule
.
NonZero
)
?
FillMode
.
Winding
:
FillMode
.
Alternate
;
path
.
AddPath
(
graphicsElement
.
Path
,
false
);
GraphicsPath
childPath
=
graphicsElement
.
Path
;
if
(
graphicsElement
.
Transforms
!=
null
)
{
foreach
(
SvgTransform
transform
in
graphicsElement
.
Transforms
)
{
childPath
.
Transform
(
transform
.
Matrix
);
}
}
path
.
AddPath
(
childPath
,
false
);
}
foreach
(
SvgElement
child
in
element
.
Children
)
...
...
Source/Painting/SvgGradientServer.cs
View file @
302ca29e
...
...
@@ -85,10 +85,18 @@ namespace Svg
set
{
this
.
_gradientUnits
=
value
;
}
}
/// <summary>
/// Gets or sets another gradient fill from which to inherit the stops from.
/// </summary>
[
SvgAttributeAttribute
(
"href"
)]
public
SvgGradientServer
InheritGradient
{
get
{
return
this
.
_inheritGradient
;
}
set
{
this
.
_inheritGradient
=
value
;
}
set
{
this
.
_inheritGradient
=
value
;
this
.
InheritStops
();
}
}
/// <summary>
...
...
@@ -161,22 +169,15 @@ namespace Svg
return
blend
;
}
protected
virtual
List
<
SvgGradientStop
>
InheritStops
()
/// <summary>
// If this gradient contains no stops then it will search any inherited gradients for stops.
/// </summary>
protected
virtual
void
InheritStops
()
{
List
<
SvgGradientStop
>
stops
=
new
List
<
SvgGradientStop
>();
if
(
this
.
Stops
.
Count
>
0
)
if
(
this
.
Stops
.
Count
==
0
&&
this
.
InheritGradient
!=
null
)
{
return
s
tops
;
_stops
.
AddRange
(
this
.
InheritGradient
.
S
tops
)
;
}
if
(
this
.
InheritGradient
!=
null
)
{
List
<
SvgGradientStop
>
ownerStops
=
this
.
InheritGradient
.
InheritStops
();
stops
.
AddRange
(
ownerStops
);
}
return
stops
;
}
}
}
\ No newline at end of file
Source/Painting/SvgPaintServerFactory.cs
View file @
302ca29e
...
...
@@ -33,6 +33,11 @@ namespace Svg
Uri
id
=
new
Uri
(
match
.
Groups
[
1
].
Value
,
UriKind
.
Relative
);
return
(
SvgPaintServer
)
document
.
IdManager
.
GetElementById
(
id
);
}
// If referenced to to a different (linear or radial) gradient
else
if
(
document
.
IdManager
.
GetElementById
(
value
)
!=
null
&&
document
.
IdManager
.
GetElementById
(
value
).
GetType
().
BaseType
==
typeof
(
SvgGradientServer
))
{
return
(
SvgPaintServer
)
document
.
IdManager
.
GetElementById
(
value
);
}
else
// Otherwise try and parse as colour
{
return
new
SvgColourServer
((
Color
)
_colourConverter
.
ConvertFrom
(
value
.
Trim
()));
...
...
Source/Paths/SvgPath.cs
View file @
302ca29e
...
...
@@ -62,14 +62,6 @@ namespace Svg
segment
.
AddToPath
(
_path
);
}
if
(
base
.
Transforms
!=
null
)
{
foreach
(
SvgTransform
transform
in
base
.
Transforms
)
{
_path
.
Transform
(
transform
.
Matrix
);
}
}
this
.
IsPathDirty
=
false
;
}
return
_path
;
...
...
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