Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
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
41581021
Commit
41581021
authored
12 years ago
by
Tebjan Halm
Browse files
Options
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
79c12b63
220cac7f
master
netstandard2
nuget2.4.2
nuget2.4.1
nuget2.4
nuget2.3
nuget2.2.2
nuget2.2.1
nuget1.7
No related merge requests found
Changes
54
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
Source/SvgDocument.cs
+3
-6
Source/SvgDocument.cs
Source/SvgElement.cs
+49
-7
Source/SvgElement.cs
Source/SvgElementCollection.cs
+27
-0
Source/SvgElementCollection.cs
Source/SvgElementFactory.cs
+2
-3
Source/SvgElementFactory.cs
Source/Text/SvgText.cs
+123
-57
Source/Text/SvgText.cs
Source/Text/SvgTextSpan.cs
+80
-20
Source/Text/SvgTextSpan.cs
Source/Transforms/SvgMatrix.cs
+7
-0
Source/Transforms/SvgMatrix.cs
Source/Transforms/SvgRotate.cs
+6
-0
Source/Transforms/SvgRotate.cs
Source/Transforms/SvgScale.cs
+6
-0
Source/Transforms/SvgScale.cs
Source/Transforms/SvgShear.cs
+6
-0
Source/Transforms/SvgShear.cs
Source/Transforms/SvgSkew.cs
+6
-0
Source/Transforms/SvgSkew.cs
Source/Transforms/SvgTransform.cs
+3
-1
Source/Transforms/SvgTransform.cs
Source/Transforms/SvgTransformCollection.cs
+8
-0
Source/Transforms/SvgTransformCollection.cs
Source/Transforms/SvgTranslate.cs
+7
-0
Source/Transforms/SvgTranslate.cs
with
333 additions
and
94 deletions
+333
-94
Source/SvgDocument.cs
+
3
-
6
View file @
41581021
...
@@ -19,13 +19,9 @@ namespace Svg
...
@@ -19,13 +19,9 @@ namespace Svg
public
class
SvgDocument
:
SvgFragment
,
ITypeDescriptorContext
public
class
SvgDocument
:
SvgFragment
,
ITypeDescriptorContext
{
{
public
static
readonly
int
PPI
=
96
;
public
static
readonly
int
PPI
=
96
;
private
SvgElementIdManager
_idManager
;
/// <summary>
/// Gets a <see cref="string"/> containing the XLink namespace (http://www.w3.org/1999/xlink).
/// </summary>
public
static
readonly
string
XLinkNamespace
=
"http://www.w3.org/1999/xlink"
;
private
SvgElementIdManager
_idManager
;
/// <summary>
/// <summary>
/// Initializes a new instance of the <see cref="SvgDocument"/> class.
/// Initializes a new instance of the <see cref="SvgDocument"/> class.
...
@@ -340,7 +336,7 @@ namespace Svg
...
@@ -340,7 +336,7 @@ namespace Svg
var
size
=
GetDimensions
();
var
size
=
GetDimensions
();
var
bitmap
=
new
Bitmap
((
int
)
Math
.
Ceiling
(
size
.
Width
),
(
int
)
Math
.
Ceiling
(
size
.
Height
));
var
bitmap
=
new
Bitmap
((
int
)
Math
.
Ceiling
(
size
.
Width
),
(
int
)
Math
.
Ceiling
(
size
.
Height
));
// bitmap.SetResolution(300, 300);
try
try
{
{
Draw
(
bitmap
);
Draw
(
bitmap
);
...
@@ -406,5 +402,6 @@ namespace Svg
...
@@ -406,5 +402,6 @@ namespace Svg
this
.
Write
(
fs
);
this
.
Write
(
fs
);
}
}
}
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Source/SvgElement.cs
+
49
-
7
View file @
41581021
...
@@ -196,7 +196,7 @@ namespace Svg
...
@@ -196,7 +196,7 @@ namespace Svg
[
SvgAttribute
(
"transform"
)]
[
SvgAttribute
(
"transform"
)]
public
SvgTransformCollection
Transforms
public
SvgTransformCollection
Transforms
{
{
get
{
return
this
.
Attributes
.
GetAttribute
<
SvgTransformCollection
>(
"Transforms"
);
}
get
{
return
(
this
.
Attributes
.
GetAttribute
<
SvgTransformCollection
>(
"Transforms"
)
??
new
SvgTransformCollection
())
;
}
set
{
this
.
Attributes
[
"Transforms"
]
=
value
;
}
set
{
this
.
Attributes
[
"Transforms"
]
=
value
;
}
}
}
...
@@ -271,13 +271,20 @@ namespace Svg
...
@@ -271,13 +271,20 @@ namespace Svg
/// <summary>
/// <summary>
/// Initializes a new instance of the <see cref="SvgElement"/> class.
/// Initializes a new instance of the <see cref="SvgElement"/> class.
/// </summary>
/// </summary>
internal
SvgElement
()
public
SvgElement
()
{
{
this
.
_children
=
new
SvgElementCollection
(
this
);
this
.
_children
=
new
SvgElementCollection
(
this
);
this
.
_eventHandlers
=
new
EventHandlerList
();
this
.
_eventHandlers
=
new
EventHandlerList
();
this
.
_elementName
=
string
.
Empty
;
this
.
_elementName
=
string
.
Empty
;
}
}
public
virtual
void
InitialiseFromXML
(
XmlTextReader
reader
,
SvgDocument
document
)
{
}
/// <summary>
/// <summary>
/// Renders this element to the <see cref="SvgRenderer"/>.
/// Renders this element to the <see cref="SvgRenderer"/>.
/// </summary>
/// </summary>
...
@@ -299,9 +306,15 @@ namespace Svg
...
@@ -299,9 +306,15 @@ namespace Svg
writer
.
WriteStartElement
(
this
.
ElementName
);
writer
.
WriteStartElement
(
this
.
ElementName
);
if
(
this
.
ElementName
==
"svg"
)
if
(
this
.
ElementName
==
"svg"
)
{
{
writer
.
WriteAttributeString
(
"xmlns"
,
"http://www.w3.org/2000/svg"
);
foreach
(
var
ns
in
SvgAttributeAttribute
.
Namespaces
)
writer
.
WriteAttributeString
(
"version"
,
"1.1"
);
{
}
if
(
string
.
IsNullOrEmpty
(
ns
.
Key
))
writer
.
WriteAttributeString
(
"xmlns"
,
ns
.
Value
);
else
writer
.
WriteAttributeString
(
"xmlns:"
+
ns
.
Key
,
ns
.
Value
);
}
writer
.
WriteAttributeString
(
"version"
,
"1.1"
);
}
}
}
this
.
WriteAttributes
(
writer
);
this
.
WriteAttributes
(
writer
);
}
}
...
@@ -339,13 +352,13 @@ namespace Svg
...
@@ -339,13 +352,13 @@ namespace Svg
{
{
string
value
=
(
string
)
attr
.
Property
.
Converter
.
ConvertTo
(
propertyValue
,
typeof
(
string
));
string
value
=
(
string
)
attr
.
Property
.
Converter
.
ConvertTo
(
propertyValue
,
typeof
(
string
));
writer
.
WriteAttributeString
(
attr
.
Attribute
.
Name
,
value
);
writer
.
WriteAttributeString
(
attr
.
Attribute
.
Name
spaceAndName
,
value
);
}
}
}
}
else
if
(
attr
.
Attribute
.
Name
==
"fill"
)
//if fill equals null, write 'none'
else
if
(
attr
.
Attribute
.
Name
==
"fill"
)
//if fill equals null, write 'none'
{
{
string
value
=
(
string
)
attr
.
Property
.
Converter
.
ConvertTo
(
propertyValue
,
typeof
(
string
));
string
value
=
(
string
)
attr
.
Property
.
Converter
.
ConvertTo
(
propertyValue
,
typeof
(
string
));
writer
.
WriteAttributeString
(
attr
.
Attribute
.
Name
,
value
);
writer
.
WriteAttributeString
(
attr
.
Attribute
.
Name
spaceAndName
,
value
);
}
}
}
}
}
}
...
@@ -485,10 +498,39 @@ namespace Svg
...
@@ -485,10 +498,39 @@ namespace Svg
{
{
return
this
.
MemberwiseClone
();
return
this
.
MemberwiseClone
();
}
}
public
abstract
SvgElement
DeepCopy
();
public
virtual
SvgElement
DeepCopy
<
T
>()
where
T
:
SvgElement
,
new
()
{
var
newObj
=
new
T
();
newObj
.
Content
=
this
.
Content
;
newObj
.
ElementName
=
this
.
ElementName
;
// if (this.Parent != null)
// this.Parent.Children.Add(newObj);
if
(
this
.
Transforms
!=
null
)
{
newObj
.
Transforms
=
new
SvgTransformCollection
();
foreach
(
var
transform
in
this
.
Transforms
)
newObj
.
Transforms
.
Add
(
transform
.
Clone
()
as
SvgTransform
);
}
foreach
(
var
child
in
this
.
Children
)
{
newObj
.
Children
.
Add
(
child
.
DeepCopy
());
}
return
newObj
;
}
}
}
internal
interface
ISvgElement
internal
interface
ISvgElement
{
{
SvgElement
Parent
{
get
;}
SvgElementCollection
Children
{
get
;
}
void
Render
(
SvgRenderer
renderer
);
void
Render
(
SvgRenderer
renderer
);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Source/SvgElementCollection.cs
+
27
-
0
View file @
41581021
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
namespace
Svg
namespace
Svg
...
@@ -139,6 +140,32 @@ namespace Svg
...
@@ -139,6 +140,32 @@ namespace Svg
return
removed
;
return
removed
;
}
}
/// <summary>
/// expensive recursive search for nodes of type T
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public
IEnumerable
<
T
>
FindSvgElementsOf
<
T
>()
where
T
:
SvgElement
{
return
_elements
.
Where
(
x
=>
x
is
T
).
Select
(
x
=>
x
as
T
).
Concat
(
_elements
.
SelectMany
(
x
=>
x
.
Children
.
FindSvgElementsOf
<
T
>()));
}
/// <summary>
/// expensive recursive search for first node of type T
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public
T
FindSvgElementOf
<
T
>()
where
T
:
SvgElement
{
return
_elements
.
OfType
<
T
>().
FirstOrDefault
()
??
_elements
.
Select
(
x
=>
x
.
Children
.
FindSvgElementOf
<
T
>()).
FirstOrDefault
<
T
>(
x
=>
x
!=
null
);
}
public
T
GetSvgElementOf
<
T
>()
where
T
:
SvgElement
{
return
_elements
.
FirstOrDefault
(
x
=>
x
is
T
)
as
T
;
}
public
IEnumerator
<
SvgElement
>
GetEnumerator
()
public
IEnumerator
<
SvgElement
>
GetEnumerator
()
{
{
return
this
.
_elements
.
GetEnumerator
();
return
this
.
_elements
.
GetEnumerator
();
...
...
This diff is collapsed.
Click to expand it.
Source/SvgElementFactory.cs
+
2
-
3
View file @
41581021
...
@@ -100,8 +100,7 @@ namespace Svg
...
@@ -100,8 +100,7 @@ namespace Svg
if
(
createdElement
!=
null
)
if
(
createdElement
!=
null
)
{
{
createdElement
.
ElementName
=
elementName
;
SetAttributes
(
createdElement
,
reader
,
document
);
SetAttributes
(
createdElement
,
reader
,
document
);
}
}
//Trace.TraceInformation("End CreateElement");
//Trace.TraceInformation("End CreateElement");
...
@@ -135,7 +134,7 @@ namespace Svg
...
@@ -135,7 +134,7 @@ namespace Svg
SetPropertyValue
(
element
,
style
[
0
].
Trim
(),
style
[
1
].
Trim
(),
document
);
SetPropertyValue
(
element
,
style
[
0
].
Trim
(),
style
[
1
].
Trim
(),
document
);
}
}
continue
;
continue
;
}
}
SetPropertyValue
(
element
,
reader
.
LocalName
,
reader
.
Value
,
document
);
SetPropertyValue
(
element
,
reader
.
LocalName
,
reader
.
Value
,
document
);
...
...
This diff is collapsed.
Click to expand it.
Source/Text/SvgText.cs
+
123
-
57
View file @
41581021
...
@@ -5,6 +5,8 @@ using System.ComponentModel;
...
@@ -5,6 +5,8 @@ using System.ComponentModel;
using
System.Drawing
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Drawing.Drawing2D
;
using
System.Drawing.Text
;
using
System.Drawing.Text
;
using
Svg.DataTypes
;
using
System.Linq
;
namespace
Svg
namespace
Svg
{
{
...
@@ -19,12 +21,12 @@ namespace Svg
...
@@ -19,12 +21,12 @@ namespace Svg
private
SvgUnit
_letterSpacing
;
private
SvgUnit
_letterSpacing
;
private
SvgUnit
_wordSpacing
;
private
SvgUnit
_wordSpacing
;
private
SvgUnit
_fontSize
;
private
SvgUnit
_fontSize
;
private
SvgFontWeight
_fontWeight
;
private
string
_font
;
private
string
_font
;
private
string
_fontFamily
;
private
string
_fontFamily
;
private
GraphicsPath
_path
;
private
GraphicsPath
_path
;
private
SvgTextAnchor
_textAnchor
=
SvgTextAnchor
.
Start
;
private
SvgTextAnchor
_textAnchor
=
SvgTextAnchor
.
Start
;
private
static
readonly
SvgRenderer
_stringMeasure
;
private
static
readonly
SvgRenderer
_stringMeasure
;
/// <summary>
/// <summary>
/// Initializes the <see cref="SvgText"/> class.
/// Initializes the <see cref="SvgText"/> class.
/// </summary>
/// </summary>
...
@@ -135,6 +137,18 @@ namespace Svg
...
@@ -135,6 +137,18 @@ namespace Svg
set
{
this
.
_fontSize
=
value
;
this
.
IsPathDirty
=
true
;
}
set
{
this
.
_fontSize
=
value
;
this
.
IsPathDirty
=
true
;
}
}
}
/// <summary>
/// Refers to the boldness of the font.
/// </summary>
[
SvgAttribute
(
"font-weight"
)]
public
virtual
SvgFontWeight
FontWeight
{
get
{
return
this
.
_fontWeight
;
}
set
{
this
.
_fontWeight
=
value
;
this
.
IsPathDirty
=
true
;
}
}
/// <summary>
/// <summary>
/// Set all font information.
/// Set all font information.
/// </summary>
/// </summary>
...
@@ -205,7 +219,11 @@ namespace Svg
...
@@ -205,7 +219,11 @@ namespace Svg
get
get
{
{
// Make sure the path is always null if there is no text
// Make sure the path is always null if there is no text
if
(
_path
==
null
||
this
.
IsPathDirty
&&
!
string
.
IsNullOrEmpty
(
this
.
Text
))
//if (string.IsNullOrEmpty(this.Text))
// _path = null;
//NOT SURE WHAT THIS IS ABOUT - Path gets created again anyway - WTF?
if
(
_path
==
null
||
this
.
IsPathDirty
)
{
{
float
fontSize
=
this
.
FontSize
.
ToDeviceValue
(
this
);
float
fontSize
=
this
.
FontSize
.
ToDeviceValue
(
this
);
if
(
fontSize
==
0.0f
)
if
(
fontSize
==
0.0f
)
...
@@ -213,70 +231,118 @@ namespace Svg
...
@@ -213,70 +231,118 @@ namespace Svg
fontSize
=
1.0f
;
fontSize
=
1.0f
;
}
}
PointF
location
=
PointF
.
Empty
;
FontStyle
fontWeight
=
(
this
.
FontWeight
==
SvgFontWeight
.
bold
?
FontStyle
.
Bold
:
FontStyle
.
Regular
);
Font
font
=
new
Font
(
this
.
_fontFamily
,
fontSize
,
FontStyle
.
Regular
,
GraphicsUnit
.
Pixel
);
Font
font
=
new
Font
(
this
.
_fontFamily
,
fontSize
,
fontWeight
,
GraphicsUnit
.
Pixel
);
SizeF
stringBounds
=
_stringMeasure
.
MeasureString
(
this
.
Text
,
font
);
// Minus FontSize because the x/y coords mark the bottom left, not bottom top.
switch
(
this
.
TextAnchor
)
{
case
SvgTextAnchor
.
Start
:
location
=
new
PointF
(
this
.
X
.
ToDeviceValue
(
this
),
this
.
Y
.
ToDeviceValue
(
this
,
true
)
-
stringBounds
.
Height
);
break
;
case
SvgTextAnchor
.
Middle
:
location
=
new
PointF
(
this
.
X
.
ToDeviceValue
(
this
)
-
(
stringBounds
.
Width
/
2
),
this
.
Y
.
ToDeviceValue
(
this
,
true
)
-
stringBounds
.
Height
);
break
;
case
SvgTextAnchor
.
End
:
location
=
new
PointF
(
this
.
X
.
ToDeviceValue
(
this
)
-
stringBounds
.
Width
,
this
.
Y
.
ToDeviceValue
(
this
,
true
)
-
stringBounds
.
Height
);
break
;
}
_path
=
new
GraphicsPath
();
_path
=
new
GraphicsPath
();
_path
.
StartFigure
();
_path
.
StartFigure
();
// No way to do letter-spacing or word-spacing, so do manually
if
(!
string
.
IsNullOrEmpty
(
this
.
Text
))
if
(
this
.
LetterSpacing
.
Value
>
0.0f
||
this
.
WordSpacing
.
Value
>
0.0f
)
DrawString
(
_path
,
this
.
X
,
this
.
Y
,
SvgUnit
.
Empty
,
SvgUnit
.
Empty
,
font
,
fontSize
,
this
.
Text
);
{
// Cut up into words, or just leave as required
string
[]
words
=
(
this
.
WordSpacing
.
Value
>
0.0f
)
?
this
.
Text
.
Split
(
' '
)
:
new
string
[]
{
this
.
Text
};
float
wordSpacing
=
this
.
WordSpacing
.
ToDeviceValue
(
this
);
float
letterSpacing
=
this
.
LetterSpacing
.
ToDeviceValue
(
this
);
float
start
=
this
.
X
.
ToDeviceValue
(
this
);
foreach
(
string
word
in
words
)
{
// Only do if there is line spacing, just write the word otherwise
if
(
this
.
LetterSpacing
.
Value
>
0.0f
)
{
char
[]
characters
=
word
.
ToCharArray
();
foreach
(
char
currentCharacter
in
characters
)
{
_path
.
AddString
(
currentCharacter
.
ToString
(),
new
FontFamily
(
this
.
_fontFamily
),
0
,
fontSize
,
location
,
StringFormat
.
GenericTypographic
);
location
=
new
PointF
(
_path
.
GetBounds
().
Width
+
start
+
letterSpacing
,
location
.
Y
);
}
}
else
{
_path
.
AddString
(
word
,
new
FontFamily
(
this
.
_fontFamily
),
0
,
fontSize
,
location
,
StringFormat
.
GenericTypographic
);
}
// Move the location of the word to be written along
location
=
new
PointF
(
_path
.
GetBounds
().
Width
+
start
+
wordSpacing
,
location
.
Y
);
}
}
else
{
if
(!
string
.
IsNullOrEmpty
(
this
.
Text
))
{
_path
.
AddString
(
this
.
Text
,
new
FontFamily
(
this
.
_fontFamily
),
0
,
fontSize
,
location
,
StringFormat
.
GenericTypographic
);
}
}
_path
.
CloseFigure
();
foreach
(
var
tspan
in
this
.
Children
.
Where
(
x
=>
x
is
SvgTextSpan
).
Select
(
x
=>
x
as
SvgTextSpan
))
{
if
(!
string
.
IsNullOrEmpty
(
tspan
.
Text
))
DrawString
(
_path
,
tspan
.
X
==
SvgUnit
.
Empty
?
this
.
X
:
tspan
.
X
,
tspan
.
Y
==
SvgUnit
.
Empty
?
this
.
Y
:
tspan
.
Y
,
tspan
.
DX
,
tspan
.
DY
,
font
,
fontSize
,
tspan
.
Text
);
}
_path
.
CloseFigure
();
this
.
IsPathDirty
=
false
;
this
.
IsPathDirty
=
false
;
}
}
return
_path
;
return
_path
;
}
}
}
}
private
void
DrawString
(
GraphicsPath
path
,
SvgUnit
x
,
SvgUnit
y
,
SvgUnit
dx
,
SvgUnit
dy
,
Font
font
,
float
fontSize
,
string
text
)
{
PointF
location
=
PointF
.
Empty
;
SizeF
stringBounds
=
_stringMeasure
.
MeasureString
(
text
,
font
);
float
xToDevice
=
x
.
ToDeviceValue
(
this
)
+
dx
.
ToDeviceValue
(
this
);
float
yToDevice
=
y
.
ToDeviceValue
(
this
,
true
)
+
dy
.
ToDeviceValue
(
this
,
true
);
// Minus FontSize because the x/y coords mark the bottom left, not bottom top.
switch
(
this
.
TextAnchor
)
{
case
SvgTextAnchor
.
Start
:
location
=
new
PointF
(
xToDevice
,
yToDevice
-
stringBounds
.
Height
);
break
;
case
SvgTextAnchor
.
Middle
:
location
=
new
PointF
(
xToDevice
-
(
stringBounds
.
Width
/
2
),
yToDevice
-
stringBounds
.
Height
);
break
;
case
SvgTextAnchor
.
End
:
location
=
new
PointF
(
xToDevice
-
stringBounds
.
Width
,
yToDevice
-
stringBounds
.
Height
);
break
;
}
// No way to do letter-spacing or word-spacing, so do manually
if
(
this
.
LetterSpacing
.
Value
>
0.0f
||
this
.
WordSpacing
.
Value
>
0.0f
)
{
// Cut up into words, or just leave as required
string
[]
words
=
(
this
.
WordSpacing
.
Value
>
0.0f
)
?
text
.
Split
(
' '
)
:
new
string
[]
{
text
};
float
wordSpacing
=
this
.
WordSpacing
.
ToDeviceValue
(
this
);
float
letterSpacing
=
this
.
LetterSpacing
.
ToDeviceValue
(
this
);
float
start
=
this
.
X
.
ToDeviceValue
(
this
);
foreach
(
string
word
in
words
)
{
// Only do if there is line spacing, just write the word otherwise
if
(
this
.
LetterSpacing
.
Value
>
0.0f
)
{
char
[]
characters
=
word
.
ToCharArray
();
foreach
(
char
currentCharacter
in
characters
)
{
path
.
AddString
(
currentCharacter
.
ToString
(),
new
FontFamily
(
this
.
_fontFamily
),
(
int
)
font
.
Style
,
fontSize
,
location
,
StringFormat
.
GenericTypographic
);
location
=
new
PointF
(
path
.
GetBounds
().
Width
+
start
+
letterSpacing
,
location
.
Y
);
}
}
else
{
path
.
AddString
(
word
,
new
FontFamily
(
this
.
_fontFamily
),
(
int
)
font
.
Style
,
fontSize
,
location
,
StringFormat
.
GenericTypographic
);
}
// Move the location of the word to be written along
location
=
new
PointF
(
path
.
GetBounds
().
Width
+
start
+
wordSpacing
,
location
.
Y
);
}
}
else
{
if
(!
string
.
IsNullOrEmpty
(
text
))
{
path
.
AddString
(
text
,
new
FontFamily
(
this
.
_fontFamily
),
(
int
)
font
.
Style
,
fontSize
,
location
,
StringFormat
.
GenericTypographic
);
}
}
}
public
override
SvgElement
DeepCopy
()
{
return
DeepCopy
<
SvgText
>();
}
public
override
SvgElement
DeepCopy
<
T
>()
{
var
newObj
=
base
.
DeepCopy
<
T
>()
as
SvgText
;
newObj
.
TextAnchor
=
this
.
TextAnchor
;
newObj
.
WordSpacing
=
this
.
WordSpacing
;
newObj
.
LetterSpacing
=
this
.
LetterSpacing
;
newObj
.
Font
=
this
.
Font
;
newObj
.
FontFamily
=
this
.
FontFamily
;
newObj
.
FontSize
=
this
.
FontSize
;
newObj
.
FontWeight
=
this
.
FontWeight
;
newObj
.
X
=
this
.
X
;
newObj
.
Y
=
this
.
Y
;
return
newObj
;
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Source/Text/SvgTextSpan.cs
+
80
-
20
View file @
41581021
using
System
;
using
System
;
using
System.ComponentModel
;
using
System.ComponentModel
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing.Drawing2D
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
namespace
Svg
namespace
Svg
{
{
[
SvgElement
(
"tspan"
)]
[
SvgElement
(
"tspan"
)]
public
class
SvgTextSpan
:
Svg
Tex
t
public
class
SvgTextSpan
:
Svg
Elemen
t
{
{
/// <summary>
private
SvgUnit
_x
;
/// Gets or sets the X.
private
SvgUnit
_y
;
/// </summary>
private
SvgUnit
_dx
;
/// <value>The X.</value>
private
SvgUnit
_dy
;
[
Browsable
(
false
),
DesignerSerializationVisibility
(
DesignerSerializationVisibility
.
Hidden
)]
public
override
SvgUnit
X
/// <summary>
/// Gets or sets the X.
/// </summary>
/// <value>The X.</value>
[
SvgAttribute
(
"x"
)]
public
SvgUnit
X
{
{
get
{
return
base
.
X
;
}
get
{
return
this
.
_x
;
}
set
{
base
.
X
=
value
;
}
set
{
this
.
_x
=
value
;
}
}
}
/// <summary>
/// <summary>
/// Gets or sets the
Y
.
/// Gets or sets the
X
.
/// </summary>
/// </summary>
/// <value>The
Y
.</value>
/// <value>The
X
.</value>
[
Browsable
(
false
),
DesignerSerializationVisibility
(
DesignerSerializationVisibility
.
Hidden
)]
[
SvgAttribute
(
"y"
)]
public
override
SvgUnit
Y
public
SvgUnit
Y
{
{
get
{
return
base
.
Y
;
}
get
{
return
this
.
_y
;
}
set
{
base
.
Y
=
value
;
}
set
{
this
.
_y
=
value
;
}
}
}
/// <summary>
/// Gets or sets the deltaX from the containing text.
/// </summary>
/// <value>The dX.</value>
[
SvgAttribute
(
"dx"
)]
public
SvgUnit
DX
{
get
{
return
this
.
_dx
;
}
set
{
this
.
_dx
=
value
;
}
}
/// <summary>
/// Gets or sets the deltaY from the containing text.
/// </summary>
/// <value>The dY.</value>
[
SvgAttribute
(
"dy"
)]
public
SvgUnit
DY
{
get
{
return
this
.
_dy
;
}
set
{
this
.
_dy
=
value
;
}
}
/// <summary>
/// Gets or sets the text to be rendered.
/// </summary>
public
virtual
string
Text
{
get
{
return
base
.
Content
;
}
set
{
base
.
Content
=
value
;
this
.
Content
=
value
;
}
}
public
override
SvgElement
DeepCopy
()
{
return
DeepCopy
<
SvgTextSpan
>();
}
public
override
SvgElement
DeepCopy
<
T
>()
{
var
newObj
=
base
.
DeepCopy
<
T
>()
as
SvgTextSpan
;
newObj
.
X
=
this
.
X
;
newObj
.
Y
=
this
.
Y
;
newObj
.
DX
=
this
.
DX
;
newObj
.
DY
=
this
.
DY
;
newObj
.
Text
=
this
.
Text
;
return
newObj
;
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Source/Transforms/SvgMatrix.cs
+
7
-
0
View file @
41581021
...
@@ -45,5 +45,12 @@ namespace Svg.Transforms
...
@@ -45,5 +45,12 @@ namespace Svg.Transforms
{
{
this
.
points
=
m
;
this
.
points
=
m
;
}
}
public
override
object
Clone
()
{
return
new
SvgMatrix
(
this
.
Points
);
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Source/Transforms/SvgRotate.cs
+
6
-
0
View file @
41581021
...
@@ -54,5 +54,11 @@ namespace Svg.Transforms
...
@@ -54,5 +54,11 @@ namespace Svg.Transforms
this
.
CenterX
=
centerX
;
this
.
CenterX
=
centerX
;
this
.
CenterY
=
centerY
;
this
.
CenterY
=
centerY
;
}
}
public
override
object
Clone
()
{
return
new
SvgRotate
(
this
.
Angle
,
this
.
CenterX
,
this
.
CenterY
);
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Source/Transforms/SvgScale.cs
+
6
-
0
View file @
41581021
...
@@ -45,5 +45,11 @@ namespace Svg.Transforms
...
@@ -45,5 +45,11 @@ namespace Svg.Transforms
this
.
scaleFactorX
=
x
;
this
.
scaleFactorX
=
x
;
this
.
scaleFactorY
=
y
;
this
.
scaleFactorY
=
y
;
}
}
public
override
object
Clone
()
{
return
new
SvgScale
(
this
.
X
,
this
.
Y
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Source/Transforms/SvgShear.cs
+
6
-
0
View file @
41581021
...
@@ -48,5 +48,11 @@ namespace Svg.Transforms
...
@@ -48,5 +48,11 @@ namespace Svg.Transforms
this
.
shearFactorX
=
x
;
this
.
shearFactorX
=
x
;
this
.
shearFactorY
=
y
;
this
.
shearFactorY
=
y
;
}
}
public
override
object
Clone
()
{
return
new
SvgShear
(
this
.
X
,
this
.
Y
);
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Source/Transforms/SvgSkew.cs
+
6
-
0
View file @
41581021
...
@@ -35,5 +35,11 @@ namespace Svg.Transforms
...
@@ -35,5 +35,11 @@ namespace Svg.Transforms
AngleX
=
x
;
AngleX
=
x
;
AngleY
=
y
;
AngleY
=
y
;
}
}
public
override
object
Clone
()
{
return
new
SvgSkew
(
this
.
AngleX
,
this
.
AngleY
);
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Source/Transforms/SvgTransform.cs
+
3
-
1
View file @
41581021
...
@@ -6,9 +6,11 @@ using System.Drawing.Drawing2D;
...
@@ -6,9 +6,11 @@ using System.Drawing.Drawing2D;
namespace
Svg.Transforms
namespace
Svg.Transforms
{
{
public
abstract
class
SvgTransform
public
abstract
class
SvgTransform
:
ICloneable
{
{
public
abstract
Matrix
Matrix
{
get
;
}
public
abstract
Matrix
Matrix
{
get
;
}
public
abstract
string
WriteToString
();
public
abstract
string
WriteToString
();
public
abstract
object
Clone
();
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Source/Transforms/SvgTransformCollection.cs
+
8
-
0
View file @
41581021
...
@@ -31,6 +31,14 @@ namespace Svg.Transforms
...
@@ -31,6 +31,14 @@ namespace Svg.Transforms
return
transformMatrix
;
return
transformMatrix
;
}
}
public
override
bool
Equals
(
object
obj
)
{
if
(
this
.
Count
==
0
&&
this
.
Count
==
this
.
Count
)
//default will be an empty list
return
true
;
return
base
.
Equals
(
obj
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Source/Transforms/SvgTranslate.cs
+
7
-
0
View file @
41581021
...
@@ -47,5 +47,12 @@ namespace Svg.Transforms
...
@@ -47,5 +47,12 @@ namespace Svg.Transforms
:
this
(
x
,
0.0f
)
:
this
(
x
,
0.0f
)
{
{
}
}
public
override
object
Clone
()
{
return
new
SvgTranslate
(
this
.
x
,
this
.
y
);
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Prev
1
2
3
Next
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
Menu
Projects
Groups
Snippets
Help