summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2010-08-30 11:29:57 +0000
committerJazzyNico <nicoduf@yahoo.fr>2010-08-30 11:29:57 +0000
commit286c8740b3d6ab89960abce72383490f06a72038 (patch)
tree79cbf962f474f11f89b7545a2c9e42f769d5a281
parentFix file permissions (Bug #314381). (diff)
downloadinkscape-286c8740b3d6ab89960abce72383490f06a72038.tar.gz
inkscape-286c8740b3d6ab89960abce72383490f06a72038.zip
Extensions. Fix EOL inconsistencies (Bug #314381).
(bzr r9733)
-rw-r--r--share/extensions/aisvg.xslt72
-rw-r--r--share/extensions/colors.xml300
-rw-r--r--share/extensions/convert2dashes.inx32
-rw-r--r--share/extensions/guillotine.inx52
-rw-r--r--share/extensions/guillotine.py496
-rw-r--r--share/extensions/param_curves.inx78
-rw-r--r--share/extensions/param_curves.py504
-rw-r--r--share/extensions/render_alphabetsoup.py926
-rwxr-xr-xshare/extensions/svg2xaml.xsl2966
-rw-r--r--share/extensions/xaml2svg.xsl214
10 files changed, 2820 insertions, 2820 deletions
diff --git a/share/extensions/aisvg.xslt b/share/extensions/aisvg.xslt
index 62a10ee93..2faebc7f3 100644
--- a/share/extensions/aisvg.xslt
+++ b/share/extensions/aisvg.xslt
@@ -1,36 +1,36 @@
-<?xml version="1.0"?>
-<xsl:stylesheet xml:space="default" version="1.0"
-xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-xmlns="http://www.w3.org/2000/svg"
-xmlns:svg="http://www.w3.org/2000/svg"
-xmlns:xlink="http://www.w3.org/1999/xlink"
-xmlns:x="http://ns.adobe.com/Extensibility/1.0/"
-xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/"
-xmlns:graph="http://ns.adobe.com/Graphs/1.0/"
-xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
-xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
->
-<xsl:output indent="yes"/>
- <xsl:template match="/">
- <xsl:apply-templates />
- </xsl:template>
- <xsl:template match="svg:svg/svg:switch[count(*)=2][name(*[1])='foreignObject']">
- <xsl:apply-templates select="*[not(name()='foreignObject')]/*"/>
- </xsl:template>
- <xsl:template match="svg:svg/svg:g | svg:g[@i:extraneous='self']/svg:g">
- <xsl:copy>
- <xsl:attribute name="inkscape:groupmode">layer</xsl:attribute>
- <xsl:apply-templates select="@*|*"/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="*">
- <xsl:copy>
- <xsl:apply-templates select="@*|node()|text"/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="@*">
- <xsl:copy/>
- </xsl:template>
- <xsl:template match="i:*|@i:*|x:*|@x:*|graph:*|@graph:*|a:*|@a:*">
- </xsl:template>
-</xsl:stylesheet>
+<?xml version="1.0"?>
+<xsl:stylesheet xml:space="default" version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns="http://www.w3.org/2000/svg"
+xmlns:svg="http://www.w3.org/2000/svg"
+xmlns:xlink="http://www.w3.org/1999/xlink"
+xmlns:x="http://ns.adobe.com/Extensibility/1.0/"
+xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/"
+xmlns:graph="http://ns.adobe.com/Graphs/1.0/"
+xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
+xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+>
+<xsl:output indent="yes"/>
+ <xsl:template match="/">
+ <xsl:apply-templates />
+ </xsl:template>
+ <xsl:template match="svg:svg/svg:switch[count(*)=2][name(*[1])='foreignObject']">
+ <xsl:apply-templates select="*[not(name()='foreignObject')]/*"/>
+ </xsl:template>
+ <xsl:template match="svg:svg/svg:g | svg:g[@i:extraneous='self']/svg:g">
+ <xsl:copy>
+ <xsl:attribute name="inkscape:groupmode">layer</xsl:attribute>
+ <xsl:apply-templates select="@*|*"/>
+ </xsl:copy>
+ </xsl:template>
+ <xsl:template match="*">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()|text"/>
+ </xsl:copy>
+ </xsl:template>
+ <xsl:template match="@*">
+ <xsl:copy/>
+ </xsl:template>
+ <xsl:template match="i:*|@i:*|x:*|@x:*|graph:*|@graph:*|a:*|@a:*">
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/share/extensions/colors.xml b/share/extensions/colors.xml
index d877113d7..51167fdd7 100644
--- a/share/extensions/colors.xml
+++ b/share/extensions/colors.xml
@@ -1,150 +1,150 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<colors>
-<color name="aliceblue" hex="#f0f8ff" rgb="240,248,255" />
-<color name="antiquewhite" hex="#faebd7" rgb="250,235,215" />
-<color name="aqua" hex="#00ffff" rgb="0,255,255" />
-<color name="aquamarine" hex="#7fffd4" rgb="127,255,212" />
-<color name="azure" hex="#f0ffff" rgb="240,255,255" />
-<color name="beige" hex="#f5f5dc" rgb="245,245,220" />
-<color name="bisque" hex="#ffe4c4" rgb="255,228,196" />
-<color name="black" hex="#000000" rgb="0,0,0" />
-<color name="blanchedalmond" hex="#ffebcd" rgb="255,235,205" />
-<color name="blue" hex="#0000ff" rgb="0,0,255" />
-<color name="blueviolet" hex="#8a2be2" rgb="138,43,226" />
-<color name="brown" hex="#a52a2a" rgb="165,42,42" />
-<color name="burlywood" hex="#deb887" rgb="222,184,135" />
-<color name="cadetblue" hex="#5f9ea0" rgb="95,158,160" />
-<color name="chartreuse" hex="#7fff00" rgb="127,255,0" />
-<color name="chocolate" hex="#d2691e" rgb="210,105,30" />
-<color name="coral" hex="#ff7f50" rgb="255,127,80" />
-<color name="cornflowerblue" hex="#6495ed" rgb="100,149,237" />
-<color name="cornsilk" hex="#fff8dc" rgb="255,248,220" />
-<color name="crimson" hex="#dc143c" rgb="220,20,60" />
-<color name="cyan" hex="#00ffff" rgb="0,255,255" />
-<color name="darkblue" hex="#00008b" rgb="0,0,139" />
-<color name="darkcyan" hex="#008b8b" rgb="0,139,139" />
-<color name="darkgoldenrod" hex="#b8860b" rgb="184,134,11" />
-<color name="darkgray" hex="#a9a9a9" rgb="169,169,169" />
-<color name="darkgreen" hex="#006400" rgb="0,100,0" />
-<color name="darkgrey" hex="#a9a9a9" rgb="169,169,169" />
-<color name="darkkhaki" hex="#bdb76b" rgb="189,183,107" />
-<color name="darkmagenta" hex="#8b008b" rgb="139,0,139" />
-<color name="darkolivegreen" hex="#556b2f" rgb="85,107,47" />
-<color name="darkorange" hex="#ff8c00" rgb="255,140,0" />
-<color name="darkorchid" hex="#9932cc" rgb="153,50,204" />
-<color name="darkred" hex="#8b0000" rgb="139,0,0" />
-<color name="darksalmon" hex="#e9967a" rgb="233,150,122" />
-<color name="darkseagreen" hex="#8fbc8f" rgb="143,188,143" />
-<color name="darkslateblue" hex="#483d8b" rgb="72,61,139" />
-<color name="darkslategray" hex="#2f4f4f" rgb="47,79,79" />
-<color name="darkslategrey" hex="#2f4f4f" rgb="47,79,79" />
-<color name="darkturquoise" hex="#00ced1" rgb="0,206,209" />
-<color name="darkviolet" hex="#9400d3" rgb="148,0,211" />
-<color name="deeppink" hex="#ff1493" rgb="255,20,147" />
-<color name="deepskyblue" hex="#00bfff" rgb="0,191,255" />
-<color name="dimgray" hex="#696969" rgb="105,105,105" />
-<color name="dimgrey" hex="#696969" rgb="105,105,105" />
-<color name="dodgerblue" hex="#1e90ff" rgb="30,144,255" />
-<color name="firebrick" hex="#b22222" rgb="178,34,34" />
-<color name="floralwhite" hex="#fffaf0" rgb="255,250,240" />
-<color name="forestgreen" hex="#228b22" rgb="34,139,34" />
-<color name="fuchsia" hex="#ff00ff" rgb="255,0,255" />
-<color name="gainsboro" hex="#dcdcdc" rgb="220,220,220" />
-<color name="ghostwhite" hex="#f8f8ff" rgb="248,248,255" />
-<color name="gold" hex="#ffd700" rgb="255,215,0" />
-<color name="goldenrod" hex="#daa520" rgb="218,165,32" />
-<color name="gray" hex="#808080" rgb="128,128,128" />
-<color name="green" hex="#008000" rgb="0,128,0" />
-<color name="greenyellow" hex="#adff2f" rgb="173,255,47" />
-<color name="grey" hex="#808080" rgb="128,128,128" />
-<color name="honeydew" hex="#f0fff0" rgb="240,255,240" />
-<color name="hotpink" hex="#ff69b4" rgb="255,105,180" />
-<color name="indianred" hex="#cd5c5c" rgb="205,92,92" />
-<color name="indigo" hex="#4b0082" rgb="75,0,130" />
-<color name="ivory" hex="#fffff0" rgb="255,255,240" />
-<color name="khaki" hex="#f0e68c" rgb="240,230,140" />
-<color name="lavender" hex="#e6e6fa" rgb="230,230,250" />
-<color name="lavenderblush" hex="#fff0f5" rgb="255,240,245" />
-<color name="lawngreen" hex="#7cfc00" rgb="124,252,0" />
-<color name="lemonchiffon" hex="#fffacd" rgb="255,250,205" />
-<color name="lightblue" hex="#add8e6" rgb="173,216,230" />
-<color name="lightcoral" hex="#f08080" rgb="240,128,128" />
-<color name="lightcyan" hex="#e0ffff" rgb="224,255,255" />
-<color name="lightgoldenrodyellow" hex="#fafad2" rgb="250,250,210" />
-<color name="lightgray" hex="#d3d3d3" rgb="211,211,211" />
-<color name="lightgreen" hex="#90ee90" rgb="144,238,144" />
-<color name="lightgrey" hex="#d3d3d3" rgb="211,211,211" />
-<color name="lightpink" hex="#ffb6c1" rgb="255,182,193" />
-<color name="lightsalmon" hex="#ffa07a" rgb="255,160,122" />
-<color name="lightseagreen" hex="#20b2aa" rgb="32,178,170" />
-<color name="lightskyblue" hex="#87cefa" rgb="135,206,250" />
-<color name="lightslategray" hex="#778899" rgb="119,136,153" />
-<color name="lightslategrey" hex="#778899" rgb="119,136,153" />
-<color name="lightsteelblue" hex="#b0c4de" rgb="176,196,222" />
-<color name="lightyellow" hex="#ffffe0" rgb="255,255,224" />
-<color name="lime" hex="#00ff00" rgb="0,255,0" />
-<color name="limegreen" hex="#32cd32" rgb="50,205,50" />
-<color name="linen" hex="#faf0e6" rgb="250,240,230" />
-<color name="magenta" hex="#ff00ff" rgb="255,0,255" />
-<color name="maroon" hex="#800000" rgb="128,0,0" />
-<color name="mediumaquamarine" hex="#66cdaa" rgb="102,205,170" />
-<color name="mediumblue" hex="#0000cd" rgb="0,0,205" />
-<color name="mediumorchid" hex="#ba55d3" rgb="186,85,211" />
-<color name="mediumpurple" hex="#9370db" rgb="147,112,219" />
-<color name="mediumseagreen" hex="#3cb371" rgb="60,179,113" />
-<color name="mediumslateblue" hex="#7b68ee" rgb="123,104,238" />
-<color name="mediumspringgreen" hex="#00fa9a" rgb="0,250,154" />
-<color name="mediumturquoise" hex="#48d1cc" rgb="72,209,204" />
-<color name="mediumvioletred" hex="#c71585" rgb="199,21,133" />
-<color name="midnightblue" hex="#191970" rgb="25,25,112" />
-<color name="mintcream" hex="#f5fffa" rgb="245,255,250" />
-<color name="mistyrose" hex="#ffe4e1" rgb="255,228,225" />
-<color name="moccasin" hex="#ffe4b5" rgb="255,228,181" />
-<color name="navajowhite" hex="#ffdead" rgb="255,222,173" />
-<color name="navy" hex="#000080" rgb="0,0,128" />
-<color name="oldlace" hex="#fdf5e6" rgb="253,245,230" />
-<color name="olive" hex="#808000" rgb="128,128,0" />
-<color name="olivedrab" hex="#6b8e23" rgb="107,142,35" />
-<color name="orange" hex="#ffa500" rgb="255,165,0" />
-<color name="orangered" hex="#ff4500" rgb="255,69,0" />
-<color name="orchid" hex="#da70d6" rgb="218,112,214" />
-<color name="palegoldenrod" hex="#eee8aa" rgb="238,232,170" />
-<color name="palegreen" hex="#98fb98" rgb="152,251,152" />
-<color name="paleturquoise" hex="#afeeee" rgb="175,238,238" />
-<color name="palevioletred" hex="#db7093" rgb="219,112,147" />
-<color name="papayawhip" hex="#ffefd5" rgb="255,239,213" />
-<color name="peachpuff" hex="#ffdab9" rgb="255,218,185" />
-<color name="peru" hex="#cd853f" rgb="205,133,63" />
-<color name="pink" hex="#ffc0cb" rgb="255,192,203" />
-<color name="plum" hex="#dda0dd" rgb="221,160,221" />
-<color name="powderblue" hex="#b0e0e6" rgb="176,224,230" />
-<color name="purple" hex="#800080" rgb="128,0,128" />
-<color name="red" hex="#ff0000" rgb="255,0,0" />
-<color name="rosybrown" hex="#bc8f8f" rgb="188,143,143" />
-<color name="royalblue" hex="#4169e1" rgb="65,105,225" />
-<color name="saddlebrown" hex="#8b4513" rgb="139,69,19" />
-<color name="salmon" hex="#fa8072" rgb="250,128,114" />
-<color name="sandybrown" hex="#f4a460" rgb="244,164,96" />
-<color name="seagreen" hex="#2e8b57" rgb="46,139,87" />
-<color name="seashell" hex="#fff5ee" rgb="255,245,238" />
-<color name="sienna" hex="#a0522d" rgb="160,82,45" />
-<color name="silver" hex="#c0c0c0" rgb="192,192,192" />
-<color name="skyblue" hex="#87ceeb" rgb="135,206,235" />
-<color name="slateblue" hex="#6a5acd" rgb="106,90,205" />
-<color name="slategray" hex="#708090" rgb="112,128,144" />
-<color name="slategrey" hex="#708090" rgb="112,128,144" />
-<color name="snow" hex="#fffafa" rgb="255,250,250" />
-<color name="springgreen" hex="#00ff7f" rgb="0,255,127" />
-<color name="steelblue" hex="#4682b4" rgb="70,130,180" />
-<color name="tan" hex="#d2b48c" rgb="210,180,140" />
-<color name="teal" hex="#008080" rgb="0,128,128" />
-<color name="thistle" hex="#d8bfd8" rgb="216,191,216" />
-<color name="tomato" hex="#ff6347" rgb="255,99,71" />
-<color name="turquoise" hex="#40e0d0" rgb="64,224,208" />
-<color name="violet" hex="#ee82ee" rgb="238,130,238" />
-<color name="wheat" hex="#f5deb3" rgb="245,222,179" />
-<color name="white" hex="#ffffff" rgb="255,255,255" />
-<color name="whitesmoke" hex="#f5f5f5" rgb="245,245,245" />
-<color name="yellow" hex="#ffff00" rgb="255,255,0" />
-<color name="yellowgreen" hex="#9acd32" rgb="154,205,50" />
-</colors>
+<?xml version="1.0" encoding="UTF-8"?>
+<colors>
+<color name="aliceblue" hex="#f0f8ff" rgb="240,248,255" />
+<color name="antiquewhite" hex="#faebd7" rgb="250,235,215" />
+<color name="aqua" hex="#00ffff" rgb="0,255,255" />
+<color name="aquamarine" hex="#7fffd4" rgb="127,255,212" />
+<color name="azure" hex="#f0ffff" rgb="240,255,255" />
+<color name="beige" hex="#f5f5dc" rgb="245,245,220" />
+<color name="bisque" hex="#ffe4c4" rgb="255,228,196" />
+<color name="black" hex="#000000" rgb="0,0,0" />
+<color name="blanchedalmond" hex="#ffebcd" rgb="255,235,205" />
+<color name="blue" hex="#0000ff" rgb="0,0,255" />
+<color name="blueviolet" hex="#8a2be2" rgb="138,43,226" />
+<color name="brown" hex="#a52a2a" rgb="165,42,42" />
+<color name="burlywood" hex="#deb887" rgb="222,184,135" />
+<color name="cadetblue" hex="#5f9ea0" rgb="95,158,160" />
+<color name="chartreuse" hex="#7fff00" rgb="127,255,0" />
+<color name="chocolate" hex="#d2691e" rgb="210,105,30" />
+<color name="coral" hex="#ff7f50" rgb="255,127,80" />
+<color name="cornflowerblue" hex="#6495ed" rgb="100,149,237" />
+<color name="cornsilk" hex="#fff8dc" rgb="255,248,220" />
+<color name="crimson" hex="#dc143c" rgb="220,20,60" />
+<color name="cyan" hex="#00ffff" rgb="0,255,255" />
+<color name="darkblue" hex="#00008b" rgb="0,0,139" />
+<color name="darkcyan" hex="#008b8b" rgb="0,139,139" />
+<color name="darkgoldenrod" hex="#b8860b" rgb="184,134,11" />
+<color name="darkgray" hex="#a9a9a9" rgb="169,169,169" />
+<color name="darkgreen" hex="#006400" rgb="0,100,0" />
+<color name="darkgrey" hex="#a9a9a9" rgb="169,169,169" />
+<color name="darkkhaki" hex="#bdb76b" rgb="189,183,107" />
+<color name="darkmagenta" hex="#8b008b" rgb="139,0,139" />
+<color name="darkolivegreen" hex="#556b2f" rgb="85,107,47" />
+<color name="darkorange" hex="#ff8c00" rgb="255,140,0" />
+<color name="darkorchid" hex="#9932cc" rgb="153,50,204" />
+<color name="darkred" hex="#8b0000" rgb="139,0,0" />
+<color name="darksalmon" hex="#e9967a" rgb="233,150,122" />
+<color name="darkseagreen" hex="#8fbc8f" rgb="143,188,143" />
+<color name="darkslateblue" hex="#483d8b" rgb="72,61,139" />
+<color name="darkslategray" hex="#2f4f4f" rgb="47,79,79" />
+<color name="darkslategrey" hex="#2f4f4f" rgb="47,79,79" />
+<color name="darkturquoise" hex="#00ced1" rgb="0,206,209" />
+<color name="darkviolet" hex="#9400d3" rgb="148,0,211" />
+<color name="deeppink" hex="#ff1493" rgb="255,20,147" />
+<color name="deepskyblue" hex="#00bfff" rgb="0,191,255" />
+<color name="dimgray" hex="#696969" rgb="105,105,105" />
+<color name="dimgrey" hex="#696969" rgb="105,105,105" />
+<color name="dodgerblue" hex="#1e90ff" rgb="30,144,255" />
+<color name="firebrick" hex="#b22222" rgb="178,34,34" />
+<color name="floralwhite" hex="#fffaf0" rgb="255,250,240" />
+<color name="forestgreen" hex="#228b22" rgb="34,139,34" />
+<color name="fuchsia" hex="#ff00ff" rgb="255,0,255" />
+<color name="gainsboro" hex="#dcdcdc" rgb="220,220,220" />
+<color name="ghostwhite" hex="#f8f8ff" rgb="248,248,255" />
+<color name="gold" hex="#ffd700" rgb="255,215,0" />
+<color name="goldenrod" hex="#daa520" rgb="218,165,32" />
+<color name="gray" hex="#808080" rgb="128,128,128" />
+<color name="green" hex="#008000" rgb="0,128,0" />
+<color name="greenyellow" hex="#adff2f" rgb="173,255,47" />
+<color name="grey" hex="#808080" rgb="128,128,128" />
+<color name="honeydew" hex="#f0fff0" rgb="240,255,240" />
+<color name="hotpink" hex="#ff69b4" rgb="255,105,180" />
+<color name="indianred" hex="#cd5c5c" rgb="205,92,92" />
+<color name="indigo" hex="#4b0082" rgb="75,0,130" />
+<color name="ivory" hex="#fffff0" rgb="255,255,240" />
+<color name="khaki" hex="#f0e68c" rgb="240,230,140" />
+<color name="lavender" hex="#e6e6fa" rgb="230,230,250" />
+<color name="lavenderblush" hex="#fff0f5" rgb="255,240,245" />
+<color name="lawngreen" hex="#7cfc00" rgb="124,252,0" />
+<color name="lemonchiffon" hex="#fffacd" rgb="255,250,205" />
+<color name="lightblue" hex="#add8e6" rgb="173,216,230" />
+<color name="lightcoral" hex="#f08080" rgb="240,128,128" />
+<color name="lightcyan" hex="#e0ffff" rgb="224,255,255" />
+<color name="lightgoldenrodyellow" hex="#fafad2" rgb="250,250,210" />
+<color name="lightgray" hex="#d3d3d3" rgb="211,211,211" />
+<color name="lightgreen" hex="#90ee90" rgb="144,238,144" />
+<color name="lightgrey" hex="#d3d3d3" rgb="211,211,211" />
+<color name="lightpink" hex="#ffb6c1" rgb="255,182,193" />
+<color name="lightsalmon" hex="#ffa07a" rgb="255,160,122" />
+<color name="lightseagreen" hex="#20b2aa" rgb="32,178,170" />
+<color name="lightskyblue" hex="#87cefa" rgb="135,206,250" />
+<color name="lightslategray" hex="#778899" rgb="119,136,153" />
+<color name="lightslategrey" hex="#778899" rgb="119,136,153" />
+<color name="lightsteelblue" hex="#b0c4de" rgb="176,196,222" />
+<color name="lightyellow" hex="#ffffe0" rgb="255,255,224" />
+<color name="lime" hex="#00ff00" rgb="0,255,0" />
+<color name="limegreen" hex="#32cd32" rgb="50,205,50" />
+<color name="linen" hex="#faf0e6" rgb="250,240,230" />
+<color name="magenta" hex="#ff00ff" rgb="255,0,255" />
+<color name="maroon" hex="#800000" rgb="128,0,0" />
+<color name="mediumaquamarine" hex="#66cdaa" rgb="102,205,170" />
+<color name="mediumblue" hex="#0000cd" rgb="0,0,205" />
+<color name="mediumorchid" hex="#ba55d3" rgb="186,85,211" />
+<color name="mediumpurple" hex="#9370db" rgb="147,112,219" />
+<color name="mediumseagreen" hex="#3cb371" rgb="60,179,113" />
+<color name="mediumslateblue" hex="#7b68ee" rgb="123,104,238" />
+<color name="mediumspringgreen" hex="#00fa9a" rgb="0,250,154" />
+<color name="mediumturquoise" hex="#48d1cc" rgb="72,209,204" />
+<color name="mediumvioletred" hex="#c71585" rgb="199,21,133" />
+<color name="midnightblue" hex="#191970" rgb="25,25,112" />
+<color name="mintcream" hex="#f5fffa" rgb="245,255,250" />
+<color name="mistyrose" hex="#ffe4e1" rgb="255,228,225" />
+<color name="moccasin" hex="#ffe4b5" rgb="255,228,181" />
+<color name="navajowhite" hex="#ffdead" rgb="255,222,173" />
+<color name="navy" hex="#000080" rgb="0,0,128" />
+<color name="oldlace" hex="#fdf5e6" rgb="253,245,230" />
+<color name="olive" hex="#808000" rgb="128,128,0" />
+<color name="olivedrab" hex="#6b8e23" rgb="107,142,35" />
+<color name="orange" hex="#ffa500" rgb="255,165,0" />
+<color name="orangered" hex="#ff4500" rgb="255,69,0" />
+<color name="orchid" hex="#da70d6" rgb="218,112,214" />
+<color name="palegoldenrod" hex="#eee8aa" rgb="238,232,170" />
+<color name="palegreen" hex="#98fb98" rgb="152,251,152" />
+<color name="paleturquoise" hex="#afeeee" rgb="175,238,238" />
+<color name="palevioletred" hex="#db7093" rgb="219,112,147" />
+<color name="papayawhip" hex="#ffefd5" rgb="255,239,213" />
+<color name="peachpuff" hex="#ffdab9" rgb="255,218,185" />
+<color name="peru" hex="#cd853f" rgb="205,133,63" />
+<color name="pink" hex="#ffc0cb" rgb="255,192,203" />
+<color name="plum" hex="#dda0dd" rgb="221,160,221" />
+<color name="powderblue" hex="#b0e0e6" rgb="176,224,230" />
+<color name="purple" hex="#800080" rgb="128,0,128" />
+<color name="red" hex="#ff0000" rgb="255,0,0" />
+<color name="rosybrown" hex="#bc8f8f" rgb="188,143,143" />
+<color name="royalblue" hex="#4169e1" rgb="65,105,225" />
+<color name="saddlebrown" hex="#8b4513" rgb="139,69,19" />
+<color name="salmon" hex="#fa8072" rgb="250,128,114" />
+<color name="sandybrown" hex="#f4a460" rgb="244,164,96" />
+<color name="seagreen" hex="#2e8b57" rgb="46,139,87" />
+<color name="seashell" hex="#fff5ee" rgb="255,245,238" />
+<color name="sienna" hex="#a0522d" rgb="160,82,45" />
+<color name="silver" hex="#c0c0c0" rgb="192,192,192" />
+<color name="skyblue" hex="#87ceeb" rgb="135,206,235" />
+<color name="slateblue" hex="#6a5acd" rgb="106,90,205" />
+<color name="slategray" hex="#708090" rgb="112,128,144" />
+<color name="slategrey" hex="#708090" rgb="112,128,144" />
+<color name="snow" hex="#fffafa" rgb="255,250,250" />
+<color name="springgreen" hex="#00ff7f" rgb="0,255,127" />
+<color name="steelblue" hex="#4682b4" rgb="70,130,180" />
+<color name="tan" hex="#d2b48c" rgb="210,180,140" />
+<color name="teal" hex="#008080" rgb="0,128,128" />
+<color name="thistle" hex="#d8bfd8" rgb="216,191,216" />
+<color name="tomato" hex="#ff6347" rgb="255,99,71" />
+<color name="turquoise" hex="#40e0d0" rgb="64,224,208" />
+<color name="violet" hex="#ee82ee" rgb="238,130,238" />
+<color name="wheat" hex="#f5deb3" rgb="245,222,179" />
+<color name="white" hex="#ffffff" rgb="255,255,255" />
+<color name="whitesmoke" hex="#f5f5f5" rgb="245,245,245" />
+<color name="yellow" hex="#ffff00" rgb="255,255,0" />
+<color name="yellowgreen" hex="#9acd32" rgb="154,205,50" />
+</colors>
diff --git a/share/extensions/convert2dashes.inx b/share/extensions/convert2dashes.inx
index 9f3ff365e..1230ff2d8 100644
--- a/share/extensions/convert2dashes.inx
+++ b/share/extensions/convert2dashes.inx
@@ -1,16 +1,16 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
- <_name>Convert to Dashes</_name>
- <id>com.vaxxine.filter.dashes</id>
- <dependency type="executable" location="extensions">convert2dashes.py</dependency>
- <dependency type="executable" location="extensions">inkex.py</dependency>
- <effect>
- <object-type>path</object-type>
- <effects-menu>
- <submenu _name="Modify Path"/>
- </effects-menu>
- </effect>
- <script>
- <command reldir="extensions" interpreter="python">convert2dashes.py</command>
- </script>
-</inkscape-extension>
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Convert to Dashes</_name>
+ <id>com.vaxxine.filter.dashes</id>
+ <dependency type="executable" location="extensions">convert2dashes.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <effect>
+ <object-type>path</object-type>
+ <effects-menu>
+ <submenu _name="Modify Path"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">convert2dashes.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/guillotine.inx b/share/extensions/guillotine.inx
index ba88f668c..6e2aa000e 100644
--- a/share/extensions/guillotine.inx
+++ b/share/extensions/guillotine.inx
@@ -1,26 +1,26 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
- <_name>Guillotine</_name>
- <id>org.inkscape.guillotine</id>
-
- <dependency type="extension">org.inkscape.output.svg.inkscape</dependency>
-
- <dependency type="executable" location="extensions">guillotine.py</dependency>
- <dependency type="executable" location="extensions">inkex.py</dependency>
-
- <param name="directory" type="string" _gui-text="Directory to save images to">~/</param>
- <param name="image" type="string" _gui-text="Image name (without extension)">guillotined</param>
- <param name="ignore" type="boolean" _gui-text="Ignore these settings and use export hints?">false</param>
-
- <effect needs-live-preview="false">
- <object-type>all</object-type>
- <effects-menu>
- <submenu _name="Export"/>
- </effects-menu>
- </effect>
-
- <script>
- <command reldir="extensions" interpreter="python">guillotine.py</command>
- </script>
-
-</inkscape-extension>
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Guillotine</_name>
+ <id>org.inkscape.guillotine</id>
+
+ <dependency type="extension">org.inkscape.output.svg.inkscape</dependency>
+
+ <dependency type="executable" location="extensions">guillotine.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+
+ <param name="directory" type="string" _gui-text="Directory to save images to">~/</param>
+ <param name="image" type="string" _gui-text="Image name (without extension)">guillotined</param>
+ <param name="ignore" type="boolean" _gui-text="Ignore these settings and use export hints?">false</param>
+
+ <effect needs-live-preview="false">
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Export"/>
+ </effects-menu>
+ </effect>
+
+ <script>
+ <command reldir="extensions" interpreter="python">guillotine.py</command>
+ </script>
+
+</inkscape-extension>
diff --git a/share/extensions/guillotine.py b/share/extensions/guillotine.py
index 7c43daa6d..f0e3f4aaa 100644
--- a/share/extensions/guillotine.py
+++ b/share/extensions/guillotine.py
@@ -1,248 +1,248 @@
-#!/usr/bin/env python
-'''
-guillotine.py
-
-Copyright (C) 2010 Craig Marshall, craig9 [at] gmail.com
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
------------------------
-
-This script slices an inkscape drawing along the guides, similarly to
-the GIMP plugin called "guillotine". It can optionally export to the
-same directory as the SVG file with the same name, but with a number
-suffix. e.g.
-
-/home/foo/drawing.svg
-
-will export to:
-
-/home/foo/drawing0.png
-/home/foo/drawing1.png
-/home/foo/drawing2.png
-/home/foo/drawing3.png
-
-etc.
-
-'''
-
-import os
-import sys
-import inkex
-import simplestyle
-import locale
-
-locale.setlocale(locale.LC_ALL, '')
-
-try:
- from subprocess import Popen, PIPE
- bsubprocess = True
-except:
- bsubprocess = False
-
-def float_sort(a, b):
- '''
- This is used to sort the horizontal and vertical guide positions,
- which are floating point numbers, but which are held as text.
- '''
- return cmp(float(a), float(b))
-
-class Guillotine(inkex.Effect):
- """Exports slices made using guides"""
- def __init__(self):
- inkex.Effect.__init__(self)
- self.OptionParser.add_option("--directory", action="store",
- type="string", dest="directory",
- default=None, help="")
-
- self.OptionParser.add_option("--image", action="store",
- type="string", dest="image",
- default=None, help="")
-
- self.OptionParser.add_option("--ignore", action="store",
- type="inkbool", dest="ignore",
- default=None, help="")
-
- def get_guides(self):
- '''
- Returns all guide elements as an iterable collection
- '''
- root = self.document.getroot()
- guides = []
- xpath = self.document.xpath("//sodipodi:guide",
- namespaces=inkex.NSS)
- for g in xpath:
- guide = {}
- (x, y) = g.attrib['position'].split(',')
- if g.attrib['orientation'] == '0,1':
- guide['orientation'] = 'horizontal'
- guide['position'] = y
- guides.append(guide)
- elif g.attrib['orientation'] == '1,0':
- guide['orientation'] = 'vertical'
- guide['position'] = x
- guides.append(guide)
- return guides
-
- def get_all_horizontal_guides(self):
- '''
- Returns all horizontal guides as a list of floats stored as
- strings. Each value is the position from 0 in pixels.
- '''
- guides = []
- for g in self.get_guides():
- if g['orientation'] == 'horizontal':
- guides.append(g['position'])
- return guides
-
- def get_all_vertical_guides(self):
- '''
- Returns all vertical guides as a list of floats stored as
- strings. Each value is the position from 0 in pixels.
- '''
- guides = []
- for g in self.get_guides():
- if g['orientation'] == 'vertical':
- guides.append(g['position'])
- return guides
-
- def get_horizontal_slice_positions(self):
- '''
- Make a sorted list of all horizontal guide positions,
- including 0 and the document height, but not including
- those outside of the canvas
- '''
- root = self.document.getroot()
- horizontals = ['0']
- height = inkex.unittouu(root.attrib['height'])
- for h in self.get_all_horizontal_guides():
- if h >= 0 and float(h) <= float(height):
- horizontals.append(h)
- horizontals.append(height)
- horizontals.sort(cmp=float_sort)
- return horizontals
-
- def get_vertical_slice_positions(self):
- '''
- Make a sorted list of all vertical guide positions,
- including 0 and the document width, but not including
- those outside of the canvas.
- '''
- root = self.document.getroot()
- verticals = ['0']
- width = inkex.unittouu(root.attrib['width'])
- for v in self.get_all_vertical_guides():
- if v >= 0 and float(v) <= float(width):
- verticals.append(v)
- verticals.append(width)
- verticals.sort(cmp=float_sort)
- return verticals
-
- def get_slices(self):
- '''
- Returns a list of all "slices" as denoted by the guides
- on the page. Each slice is really just a 4 element list of
- floats (stored as strings), consisting of the X and Y start
- position and the X and Y end position.
- '''
- hs = self.get_horizontal_slice_positions()
- vs = self.get_vertical_slice_positions()
- slices = []
- for i in range(len(hs)-1):
- for j in range(len(vs)-1):
- slices.append([vs[j], hs[i], vs[j+1], hs[i+1]])
- return slices
-
- def get_filename_parts(self):
- '''
- Attempts to get directory and image as passed in by the inkscape
- dialog. If the boolean ignore flag is set, then it will ignore
- these settings and try to use the settings from the export
- filename.
- '''
-
- if self.options.ignore == False:
- return (self.options.directory, self.options.image)
- else:
- '''
- First get the export-filename from the document, if the
- document has been exported before (TODO: Will not work if it
- hasn't been exported yet), then uses this to return a tuple
- consisting of the directory to export to, and the filename
- without extension.
- '''
- svg = self.document.getroot()
- att = '{http://www.inkscape.org/namespaces/inkscape}export-filename'
- try:
- export_file = svg.attrib[att]
- except KeyError:
- inkex.errormsg("To use the export hints option, you " +
- "need to have previously exported the document. " +
- "Otherwise no export hints exist!")
- sys.exit(-1)
- dirname, filename = os.path.split(export_file)
- filename = filename.rsplit(".", 1)[0] # Without extension
- return (dirname, filename)
-
- def check_dir_exists(self, dir):
- if not os.path.isdir(dir):
- os.makedirs(dir)
-
- def get_localised_string(self, str):
- return locale.format("%.f", float(str), 0)
-
- def export_slice(self, s, filename):
- '''
- Runs inkscape's command line interface and exports the image
- slice from the 4 coordinates in s, and saves as the filename
- given.
- '''
- svg_file = self.args[-1]
- command = "inkscape -a %s:%s:%s:%s -e \"%s\" \"%s\" " % (self.get_localised_string(s[0]), self.get_localised_string(s[1]), self.get_localised_string(s[2]), self.get_localised_string(s[3]), filename, svg_file)
- if bsubprocess:
- p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
- return_code = p.wait()
- f = p.stdout
- err = p.stderr
- else:
- _, f, err = os.open3(command)
- f.close()
-
- def export_slices(self, slices):
- '''
- Takes the slices list and passes each one with a calculated
- filename/directory into export_slice.
- '''
- dirname, filename = self.get_filename_parts()
- if dirname == '' or dirname == None:
- dirname = './'
- inkex.errormsg(dirname)
- dirname = os.path.expanduser(dirname)
- dirname = os.path.expandvars(dirname)
- self.check_dir_exists(dirname)
- i = 0
- for s in slices:
- f = dirname + os.path.sep + filename + str(i) + ".png"
- self.export_slice(s, f)
- i += 1
-
- def effect(self):
- slices = self.get_slices()
- self.export_slices(slices)
-
-if __name__ == "__main__":
- e = Guillotine()
- e.affect()
-
+#!/usr/bin/env python
+'''
+guillotine.py
+
+Copyright (C) 2010 Craig Marshall, craig9 [at] gmail.com
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+-----------------------
+
+This script slices an inkscape drawing along the guides, similarly to
+the GIMP plugin called "guillotine". It can optionally export to the
+same directory as the SVG file with the same name, but with a number
+suffix. e.g.
+
+/home/foo/drawing.svg
+
+will export to:
+
+/home/foo/drawing0.png
+/home/foo/drawing1.png
+/home/foo/drawing2.png
+/home/foo/drawing3.png
+
+etc.
+
+'''
+
+import os
+import sys
+import inkex
+import simplestyle
+import locale
+
+locale.setlocale(locale.LC_ALL, '')
+
+try:
+ from subprocess import Popen, PIPE
+ bsubprocess = True
+except:
+ bsubprocess = False
+
+def float_sort(a, b):
+ '''
+ This is used to sort the horizontal and vertical guide positions,
+ which are floating point numbers, but which are held as text.
+ '''
+ return cmp(float(a), float(b))
+
+class Guillotine(inkex.Effect):
+ """Exports slices made using guides"""
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ self.OptionParser.add_option("--directory", action="store",
+ type="string", dest="directory",
+ default=None, help="")
+
+ self.OptionParser.add_option("--image", action="store",
+ type="string", dest="image",
+ default=None, help="")
+
+ self.OptionParser.add_option("--ignore", action="store",
+ type="inkbool", dest="ignore",
+ default=None, help="")
+
+ def get_guides(self):
+ '''
+ Returns all guide elements as an iterable collection
+ '''
+ root = self.document.getroot()
+ guides = []
+ xpath = self.document.xpath("//sodipodi:guide",
+ namespaces=inkex.NSS)
+ for g in xpath:
+ guide = {}
+ (x, y) = g.attrib['position'].split(',')
+ if g.attrib['orientation'] == '0,1':
+ guide['orientation'] = 'horizontal'
+ guide['position'] = y
+ guides.append(guide)
+ elif g.attrib['orientation'] == '1,0':
+ guide['orientation'] = 'vertical'
+ guide['position'] = x
+ guides.append(guide)
+ return guides
+
+ def get_all_horizontal_guides(self):
+ '''
+ Returns all horizontal guides as a list of floats stored as
+ strings. Each value is the position from 0 in pixels.
+ '''
+ guides = []
+ for g in self.get_guides():
+ if g['orientation'] == 'horizontal':
+ guides.append(g['position'])
+ return guides
+
+ def get_all_vertical_guides(self):
+ '''
+ Returns all vertical guides as a list of floats stored as
+ strings. Each value is the position from 0 in pixels.
+ '''
+ guides = []
+ for g in self.get_guides():
+ if g['orientation'] == 'vertical':
+ guides.append(g['position'])
+ return guides
+
+ def get_horizontal_slice_positions(self):
+ '''
+ Make a sorted list of all horizontal guide positions,
+ including 0 and the document height, but not including
+ those outside of the canvas
+ '''
+ root = self.document.getroot()
+ horizontals = ['0']
+ height = inkex.unittouu(root.attrib['height'])
+ for h in self.get_all_horizontal_guides():
+ if h >= 0 and float(h) <= float(height):
+ horizontals.append(h)
+ horizontals.append(height)
+ horizontals.sort(cmp=float_sort)
+ return horizontals
+
+ def get_vertical_slice_positions(self):
+ '''
+ Make a sorted list of all vertical guide positions,
+ including 0 and the document width, but not including
+ those outside of the canvas.
+ '''
+ root = self.document.getroot()
+ verticals = ['0']
+ width = inkex.unittouu(root.attrib['width'])
+ for v in self.get_all_vertical_guides():
+ if v >= 0 and float(v) <= float(width):
+ verticals.append(v)
+ verticals.append(width)
+ verticals.sort(cmp=float_sort)
+ return verticals
+
+ def get_slices(self):
+ '''
+ Returns a list of all "slices" as denoted by the guides
+ on the page. Each slice is really just a 4 element list of
+ floats (stored as strings), consisting of the X and Y start
+ position and the X and Y end position.
+ '''
+ hs = self.get_horizontal_slice_positions()
+ vs = self.get_vertical_slice_positions()
+ slices = []
+ for i in range(len(hs)-1):
+ for j in range(len(vs)-1):
+ slices.append([vs[j], hs[i], vs[j+1], hs[i+1]])
+ return slices
+
+ def get_filename_parts(self):
+ '''
+ Attempts to get directory and image as passed in by the inkscape
+ dialog. If the boolean ignore flag is set, then it will ignore
+ these settings and try to use the settings from the export
+ filename.
+ '''
+
+ if self.options.ignore == False:
+ return (self.options.directory, self.options.image)
+ else:
+ '''
+ First get the export-filename from the document, if the
+ document has been exported before (TODO: Will not work if it
+ hasn't been exported yet), then uses this to return a tuple
+ consisting of the directory to export to, and the filename
+ without extension.
+ '''
+ svg = self.document.getroot()
+ att = '{http://www.inkscape.org/namespaces/inkscape}export-filename'
+ try:
+ export_file = svg.attrib[att]
+ except KeyError:
+ inkex.errormsg("To use the export hints option, you " +
+ "need to have previously exported the document. " +
+ "Otherwise no export hints exist!")
+ sys.exit(-1)
+ dirname, filename = os.path.split(export_file)
+ filename = filename.rsplit(".", 1)[0] # Without extension
+ return (dirname, filename)
+
+ def check_dir_exists(self, dir):
+ if not os.path.isdir(dir):
+ os.makedirs(dir)
+
+ def get_localised_string(self, str):
+ return locale.format("%.f", float(str), 0)
+
+ def export_slice(self, s, filename):
+ '''
+ Runs inkscape's command line interface and exports the image
+ slice from the 4 coordinates in s, and saves as the filename
+ given.
+ '''
+ svg_file = self.args[-1]
+ command = "inkscape -a %s:%s:%s:%s -e \"%s\" \"%s\" " % (self.get_localised_string(s[0]), self.get_localised_string(s[1]), self.get_localised_string(s[2]), self.get_localised_string(s[3]), filename, svg_file)
+ if bsubprocess:
+ p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
+ return_code = p.wait()
+ f = p.stdout
+ err = p.stderr
+ else:
+ _, f, err = os.open3(command)
+ f.close()
+
+ def export_slices(self, slices):
+ '''
+ Takes the slices list and passes each one with a calculated
+ filename/directory into export_slice.
+ '''
+ dirname, filename = self.get_filename_parts()
+ if dirname == '' or dirname == None:
+ dirname = './'
+ inkex.errormsg(dirname)
+ dirname = os.path.expanduser(dirname)
+ dirname = os.path.expandvars(dirname)
+ self.check_dir_exists(dirname)
+ i = 0
+ for s in slices:
+ f = dirname + os.path.sep + filename + str(i) + ".png"
+ self.export_slice(s, f)
+ i += 1
+
+ def effect(self):
+ slices = self.get_slices()
+ self.export_slices(slices)
+
+if __name__ == "__main__":
+ e = Guillotine()
+ e.affect()
+
diff --git a/share/extensions/param_curves.inx b/share/extensions/param_curves.inx
index 0d21329cd..e9d734fe1 100644
--- a/share/extensions/param_curves.inx
+++ b/share/extensions/param_curves.inx
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
- <_name>Parametric Curves</_name>
- <id>org.inkscape.effect.param_curves</id>
- <dependency type="executable" location="extensions">param_curves.py</dependency>
- <dependency type="executable" location="extensions">inkex.py</dependency>
- <param name="tab" type="notebook">
- <page name="sampling" _gui-text="Range and Sampling">
- <param name="t_start" type="float" min="-1000.0" max="1000.0" _gui-text="Start t-value">0.0</param>
- <param name="t_end" type="float" min="-1000.0" max="1000.0" _gui-text="End t-value">1.0</param>
- <param name="times2pi" type="boolean" _gui-text="Multiply t-range by 2*pi">true</param>
- <param name="xleft" type="float" min="-1000.0" max="1000.0" _gui-text="x-value of rectangle's left">-1.0</param>
- <param name="xright" type="float" min="-1000.0" max="1000.0" _gui-text="x-value of rectangle's right">1.0</param>
- <param name="ybottom" type="float" min="-1000.0" max="1000.0" _gui-text="y-value of rectangle's bottom">-1.0</param>
- <param name="ytop" type="float" min="-1000.0" max="1000.0" _gui-text="y-value of rectangle's top">1.0</param>
- <param name="samples" type="int" min="2" max="1000" _gui-text="Samples">30</param>
- <param name="isoscale" type="boolean" _gui-text="Isotropic scaling (uses smallest: width/xrange or height/yrange)">false</param>
- </page>
- <page name="use" _gui-text="Use">
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>Parametric Curves</_name>
+ <id>org.inkscape.effect.param_curves</id>
+ <dependency type="executable" location="extensions">param_curves.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="tab" type="notebook">
+ <page name="sampling" _gui-text="Range and Sampling">
+ <param name="t_start" type="float" min="-1000.0" max="1000.0" _gui-text="Start t-value">0.0</param>
+ <param name="t_end" type="float" min="-1000.0" max="1000.0" _gui-text="End t-value">1.0</param>
+ <param name="times2pi" type="boolean" _gui-text="Multiply t-range by 2*pi">true</param>
+ <param name="xleft" type="float" min="-1000.0" max="1000.0" _gui-text="x-value of rectangle's left">-1.0</param>
+ <param name="xright" type="float" min="-1000.0" max="1000.0" _gui-text="x-value of rectangle's right">1.0</param>
+ <param name="ybottom" type="float" min="-1000.0" max="1000.0" _gui-text="y-value of rectangle's bottom">-1.0</param>
+ <param name="ytop" type="float" min="-1000.0" max="1000.0" _gui-text="y-value of rectangle's top">1.0</param>
+ <param name="samples" type="int" min="2" max="1000" _gui-text="Samples">30</param>
+ <param name="isoscale" type="boolean" _gui-text="Isotropic scaling (uses smallest: width/xrange or height/yrange)">false</param>
+ </page>
+ <page name="use" _gui-text="Use">
<_param name="funcplotuse" type="description" xml:space="preserve">Select a rectangle before calling the extension,
it will determine X and Y scales.
-First derivatives are always determined numerically.</_param>
- </page>
- <page name="desc" _gui-text="Functions">
+First derivatives are always determined numerically.</_param>
+ </page>
+ <page name="desc" _gui-text="Functions">
<_param name="pythonfunctions" type="description" xml:space="preserve">Standard Python math functions are available:
ceil(x); fabs(x); floor(x); fmod(x,y); frexp(x); ldexp(x,i);
@@ -31,20 +31,20 @@ acos(x); asin(x); atan(x); atan2(y,x); hypot(x,y);
cos(x); sin(x); tan(x); degrees(x); radians(x);
cosh(x); sinh(x); tanh(x).
-The constants pi and e are also available.</_param>
- </page>
- </param>
- <param name="fofx" type="string" _gui-text="x-Function">cos(3*t)</param>
- <param name="fofy" type="string" _gui-text="y-Function">sin(5*t)</param>
- <param name="remove" type="boolean" _gui-text="Remove rectangle">true</param>
- <param name="drawaxis" type="boolean" _gui-text="Draw Axes">false</param>
- <effect>
- <object-type>rect</object-type>
- <effects-menu>
- <submenu _name="Render"/>
- </effects-menu>
- </effect>
- <script>
- <command reldir="extensions" interpreter="python">param_curves.py</command>
- </script>
-</inkscape-extension>
+The constants pi and e are also available.</_param>
+ </page>
+ </param>
+ <param name="fofx" type="string" _gui-text="x-Function">cos(3*t)</param>
+ <param name="fofy" type="string" _gui-text="y-Function">sin(5*t)</param>
+ <param name="remove" type="boolean" _gui-text="Remove rectangle">true</param>
+ <param name="drawaxis" type="boolean" _gui-text="Draw Axes">false</param>
+ <effect>
+ <object-type>rect</object-type>
+ <effects-menu>
+ <submenu _name="Render"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">param_curves.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/param_curves.py b/share/extensions/param_curves.py
index 32f4b8c80..7a8f384aa 100644
--- a/share/extensions/param_curves.py
+++ b/share/extensions/param_curves.py
@@ -1,252 +1,252 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2009 Michel Chatelain.
-Copyright (C) 2007 Tavmjong Bah, tavmjong@free.fr
-Copyright (C) 2006 Georg Wiora, xorx@quarkbox.de
-Copyright (C) 2006 Johan Engelen, johan@shouraizou.nl
-Copyright (C) 2005 Aaron Spike, aaron@ekips.org
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Changes:
- * This program is derived by Michel Chatelain from funcplot.py. His changes are in the Public Domain.
- * Michel Chatelain, 17-18 janvier 2009, a partir de funcplot.py
- * 20 janvier 2009 : adaptation a la version 0.46 a partir de la nouvelle version de funcplot.py
-
-'''
-
-import inkex, simplepath, simplestyle
-from math import *
-from random import *
-
-def drawfunction(t_start, t_end, xleft, xright, ybottom, ytop, samples, width, height, left, bottom,
- fx = "cos(3*t)", fy = "sin(5*t)", times2pi = False, isoscale = True, drawaxis = True):
-
- if times2pi == True:
- t_start = 2 * pi * t_start
- t_end = 2 * pi * t_end
-
- # coords and scales based on the source rect
- scalex = width / (xright - xleft)
- xoff = left
- coordx = lambda x: (x - xleft) * scalex + xoff #convert x-value to coordinate
- scaley = height / (ytop - ybottom)
- yoff = bottom
- coordy = lambda y: (ybottom - y) * scaley + yoff #convert y-value to coordinate
-
- # Check for isotropic scaling and use smaller of the two scales, correct ranges
- if isoscale:
- if scaley<scalex:
- # compute zero location
- xzero = coordx(0)
- # set scale
- scalex = scaley
- # correct x-offset
- xleft = (left-xzero)/scalex
- xright = (left+width-xzero)/scalex
- else :
- # compute zero location
- yzero = coordy(0)
- # set scale
- scaley = scalex
- # correct x-offset
- ybottom = (yzero-bottom)/scaley
- ytop = (bottom+height-yzero)/scaley
-
- # functions specified by the user
- if fx != "":
- f1 = eval('lambda t: ' + fx.strip('"'))
- if fy != "":
- f2 = eval('lambda t: ' + fy.strip('"'))
-
- # step is increment of t
- step = (t_end - t_start) / (samples-1)
- third = step / 3.0
- ds = step * 0.001 # Step used in calculating derivatives
-
- a = [] # path array
- # add axis
- if drawaxis :
- # check for visibility of x-axis
- if ybottom<=0 and ytop>=0:
- # xaxis
- a.append(['M ',[left, coordy(0)]])
- a.append([' l ',[width, 0]])
- # check for visibility of y-axis
- if xleft<=0 and xright>=0:
- # xaxis
- a.append([' M ',[coordx(0),bottom]])
- a.append([' l ',[0, -height]])
-
- # initialize functions and derivatives for 0;
- # they are carried over from one iteration to the next, to avoid extra function calculations.
- x0 = f1(t_start)
- y0 = f2(t_start)
-
- # numerical derivatives, using 0.001*step as the small differential
- t1 = t_start + ds # Second point AFTER first point (Good for first point)
- x1 = f1(t1)
- y1 = f2(t1)
- dx0 = (x1 - x0)/ds
- dy0 = (y1 - y0)/ds
-
- # Start curve
- a.append([' M ',[coordx(x0), coordy(y0)]]) # initial moveto
- for i in range(int(samples-1)):
- t1 = (i+1) * step + t_start
- t2 = t1 - ds # Second point BEFORE first point (Good for last point)
- x1 = f1(t1)
- x2 = f1(t2)
- y1 = f2(t1)
- y2 = f2(t2)
-
- # numerical derivatives
- dx1 = (x1 - x2)/ds
- dy1 = (y1 - y2)/ds
-
- # create curve
- a.append([' C ',
- [coordx(x0 + (dx0 * third)), coordy(y0 + (dy0 * third)),
- coordx(x1 - (dx1 * third)), coordy(y1 - (dy1 * third)),
- coordx(x1), coordy(y1)]
- ])
- t0 = t1 # Next segment's start is this segments end
- x0 = x1
- y0 = y1
- dx0 = dx1 # Assume the functions are smooth everywhere, so carry over the derivatives too
- dy0 = dy1
- return a
-
-class ParamCurves(inkex.Effect):
- def __init__(self):
- inkex.Effect.__init__(self)
- self.OptionParser.add_option("--t_start",
- action="store", type="float",
- dest="t_start", default=0.0,
- help="Start t-value")
- self.OptionParser.add_option("--t_end",
- action="store", type="float",
- dest="t_end", default=1.0,
- help="End t-value")
- self.OptionParser.add_option("--times2pi",
- action="store", type="inkbool",
- dest="times2pi", default=True,
- help="Multiply t-range by 2*pi")
- self.OptionParser.add_option("--xleft",
- action="store", type="float",
- dest="xleft", default=-1.0,
- help="x-value of rectangle's left")
- self.OptionParser.add_option("--xright",
- action="store", type="float",
- dest="xright", default=1.0,
- help="x-value of rectangle's right")
- self.OptionParser.add_option("--ybottom",
- action="store", type="float",
- dest="ybottom", default=-1.0,
- help="y-value of rectangle's bottom")
- self.OptionParser.add_option("--ytop",
- action="store", type="float",
- dest="ytop", default=1.0,
- help="y-value of rectangle's top")
- self.OptionParser.add_option("-s", "--samples",
- action="store", type="int",
- dest="samples", default=8,
- help="Samples")
- self.OptionParser.add_option("--fofx",
- action="store", type="string",
- dest="fofx", default="cos(3*t)",
- help="fx(t) for plotting")
- self.OptionParser.add_option("--fofy",
- action="store", type="string",
- dest="fofy", default="sin(5*t)",
- help="fy(t) for plotting")
- self.OptionParser.add_option("--remove",
- action="store", type="inkbool",
- dest="remove", default=True,
- help="If True, source rectangle is removed")
- self.OptionParser.add_option("--isoscale",
- action="store", type="inkbool",
- dest="isoscale", default=True,
- help="If True, isotropic scaling is used")
- self.OptionParser.add_option("--drawaxis",
- action="store", type="inkbool",
- dest="drawaxis", default=True,
- help="If True, axis are drawn")
- self.OptionParser.add_option("--tab",
- action="store", type="string",
- dest="tab", default="sampling",
- help="The selected UI-tab when OK was pressed")
- self.OptionParser.add_option("--paramcurvesuse",
- action="store", type="string",
- dest="paramcurvesuse", default="",
- help="dummy")
- self.OptionParser.add_option("--pythonfunctions",
- action="store", type="string",
- dest="pythonfunctions", default="",
- help="dummy")
-
- def effect(self):
- for id, node in self.selected.iteritems():
- if node.tag == inkex.addNS('rect','svg'):
- # create new path with basic dimensions of selected rectangle
- newpath = inkex.etree.Element(inkex.addNS('path','svg'))
- x = float(node.get('x'))
- y = float(node.get('y'))
- w = float(node.get('width'))
- h = float(node.get('height'))
-
- #copy attributes of rect
- s = node.get('style')
- if s:
- newpath.set('style', s)
-
- t = node.get('transform')
- if t:
- newpath.set('transform', t)
-
- # top and bottom were exchanged
- newpath.set('d', simplepath.formatPath(
- drawfunction(self.options.t_start,
- self.options.t_end,
- self.options.xleft,
- self.options.xright,
- self.options.ybottom,
- self.options.ytop,
- self.options.samples,
- w,h,x,y+h,
- self.options.fofx,
- self.options.fofy,
- self.options.times2pi,
- self.options.isoscale,
- self.options.drawaxis)))
- newpath.set('title', self.options.fofx + " " + self.options.fofy)
-
- #newpath.set('desc', '!func;' + self.options.fofx + ';' + self.options.fofy + ';'
- # + `self.options.t_start` + ';'
- # + `self.options.t_end` + ';'
- # + `self.options.samples`)
-
- # add path into SVG structure
- node.getparent().append(newpath)
- # option wether to remove the rectangle or not.
- if self.options.remove:
- node.getparent().remove(node)
-
-if __name__ == '__main__':
- e = ParamCurves()
- e.affect()
-
-
-# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
+#!/usr/bin/env python
+'''
+Copyright (C) 2009 Michel Chatelain.
+Copyright (C) 2007 Tavmjong Bah, tavmjong@free.fr
+Copyright (C) 2006 Georg Wiora, xorx@quarkbox.de
+Copyright (C) 2006 Johan Engelen, johan@shouraizou.nl
+Copyright (C) 2005 Aaron Spike, aaron@ekips.org
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Changes:
+ * This program is derived by Michel Chatelain from funcplot.py. His changes are in the Public Domain.
+ * Michel Chatelain, 17-18 janvier 2009, a partir de funcplot.py
+ * 20 janvier 2009 : adaptation a la version 0.46 a partir de la nouvelle version de funcplot.py
+
+'''
+
+import inkex, simplepath, simplestyle
+from math import *
+from random import *
+
+def drawfunction(t_start, t_end, xleft, xright, ybottom, ytop, samples, width, height, left, bottom,
+ fx = "cos(3*t)", fy = "sin(5*t)", times2pi = False, isoscale = True, drawaxis = True):
+
+ if times2pi == True:
+ t_start = 2 * pi * t_start
+ t_end = 2 * pi * t_end
+
+ # coords and scales based on the source rect
+ scalex = width / (xright - xleft)
+ xoff = left
+ coordx = lambda x: (x - xleft) * scalex + xoff #convert x-value to coordinate
+ scaley = height / (ytop - ybottom)
+ yoff = bottom
+ coordy = lambda y: (ybottom - y) * scaley + yoff #convert y-value to coordinate
+
+ # Check for isotropic scaling and use smaller of the two scales, correct ranges
+ if isoscale:
+ if scaley<scalex:
+ # compute zero location
+ xzero = coordx(0)
+ # set scale
+ scalex = scaley
+ # correct x-offset
+ xleft = (left-xzero)/scalex
+ xright = (left+width-xzero)/scalex
+ else :
+ # compute zero location
+ yzero = coordy(0)
+ # set scale
+ scaley = scalex
+ # correct x-offset
+ ybottom = (yzero-bottom)/scaley
+ ytop = (bottom+height-yzero)/scaley
+
+ # functions specified by the user
+ if fx != "":
+ f1 = eval('lambda t: ' + fx.strip('"'))
+ if fy != "":
+ f2 = eval('lambda t: ' + fy.strip('"'))
+
+ # step is increment of t
+ step = (t_end - t_start) / (samples-1)
+ third = step / 3.0
+ ds = step * 0.001 # Step used in calculating derivatives
+
+ a = [] # path array
+ # add axis
+ if drawaxis :
+ # check for visibility of x-axis
+ if ybottom<=0 and ytop>=0:
+ # xaxis
+ a.append(['M ',[left, coordy(0)]])
+ a.append([' l ',[width, 0]])
+ # check for visibility of y-axis
+ if xleft<=0 and xright>=0:
+ # xaxis
+ a.append([' M ',[coordx(0),bottom]])
+ a.append([' l ',[0, -height]])
+
+ # initialize functions and derivatives for 0;
+ # they are carried over from one iteration to the next, to avoid extra function calculations.
+ x0 = f1(t_start)
+ y0 = f2(t_start)
+
+ # numerical derivatives, using 0.001*step as the small differential
+ t1 = t_start + ds # Second point AFTER first point (Good for first point)
+ x1 = f1(t1)
+ y1 = f2(t1)
+ dx0 = (x1 - x0)/ds
+ dy0 = (y1 - y0)/ds
+
+ # Start curve
+ a.append([' M ',[coordx(x0), coordy(y0)]]) # initial moveto
+ for i in range(int(samples-1)):
+ t1 = (i+1) * step + t_start
+ t2 = t1 - ds # Second point BEFORE first point (Good for last point)
+ x1 = f1(t1)
+ x2 = f1(t2)
+ y1 = f2(t1)
+ y2 = f2(t2)
+
+ # numerical derivatives
+ dx1 = (x1 - x2)/ds
+ dy1 = (y1 - y2)/ds
+
+ # create curve
+ a.append([' C ',
+ [coordx(x0 + (dx0 * third)), coordy(y0 + (dy0 * third)),
+ coordx(x1 - (dx1 * third)), coordy(y1 - (dy1 * third)),
+ coordx(x1), coordy(y1)]
+ ])
+ t0 = t1 # Next segment's start is this segments end
+ x0 = x1
+ y0 = y1
+ dx0 = dx1 # Assume the functions are smooth everywhere, so carry over the derivatives too
+ dy0 = dy1
+ return a
+
+class ParamCurves(inkex.Effect):
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ self.OptionParser.add_option("--t_start",
+ action="store", type="float",
+ dest="t_start", default=0.0,
+ help="Start t-value")
+ self.OptionParser.add_option("--t_end",
+ action="store", type="float",
+ dest="t_end", default=1.0,
+ help="End t-value")
+ self.OptionParser.add_option("--times2pi",
+ action="store", type="inkbool",
+ dest="times2pi", default=True,
+ help="Multiply t-range by 2*pi")
+ self.OptionParser.add_option("--xleft",
+ action="store", type="float",
+ dest="xleft", default=-1.0,
+ help="x-value of rectangle's left")
+ self.OptionParser.add_option("--xright",
+ action="store", type="float",
+ dest="xright", default=1.0,
+ help="x-value of rectangle's right")
+ self.OptionParser.add_option("--ybottom",
+ action="store", type="float",
+ dest="ybottom", default=-1.0,
+ help="y-value of rectangle's bottom")
+ self.OptionParser.add_option("--ytop",
+ action="store", type="float",
+ dest="ytop", default=1.0,
+ help="y-value of rectangle's top")
+ self.OptionParser.add_option("-s", "--samples",
+ action="store", type="int",
+ dest="samples", default=8,
+ help="Samples")
+ self.OptionParser.add_option("--fofx",
+ action="store", type="string",
+ dest="fofx", default="cos(3*t)",
+ help="fx(t) for plotting")
+ self.OptionParser.add_option("--fofy",
+ action="store", type="string",
+ dest="fofy", default="sin(5*t)",
+ help="fy(t) for plotting")
+ self.OptionParser.add_option("--remove",
+ action="store", type="inkbool",
+ dest="remove", default=True,
+ help="If True, source rectangle is removed")
+ self.OptionParser.add_option("--isoscale",
+ action="store", type="inkbool",
+ dest="isoscale", default=True,
+ help="If True, isotropic scaling is used")
+ self.OptionParser.add_option("--drawaxis",
+ action="store", type="inkbool",
+ dest="drawaxis", default=True,
+ help="If True, axis are drawn")
+ self.OptionParser.add_option("--tab",
+ action="store", type="string",
+ dest="tab", default="sampling",
+ help="The selected UI-tab when OK was pressed")
+ self.OptionParser.add_option("--paramcurvesuse",
+ action="store", type="string",
+ dest="paramcurvesuse", default="",
+ help="dummy")
+ self.OptionParser.add_option("--pythonfunctions",
+ action="store", type="string",
+ dest="pythonfunctions", default="",
+ help="dummy")
+
+ def effect(self):
+ for id, node in self.selected.iteritems():
+ if node.tag == inkex.addNS('rect','svg'):
+ # create new path with basic dimensions of selected rectangle
+ newpath = inkex.etree.Element(inkex.addNS('path','svg'))
+ x = float(node.get('x'))
+ y = float(node.get('y'))
+ w = float(node.get('width'))
+ h = float(node.get('height'))
+
+ #copy attributes of rect
+ s = node.get('style')
+ if s:
+ newpath.set('style', s)
+
+ t = node.get('transform')
+ if t:
+ newpath.set('transform', t)
+
+ # top and bottom were exchanged
+ newpath.set('d', simplepath.formatPath(
+ drawfunction(self.options.t_start,
+ self.options.t_end,
+ self.options.xleft,
+ self.options.xright,
+ self.options.ybottom,
+ self.options.ytop,
+ self.options.samples,
+ w,h,x,y+h,
+ self.options.fofx,
+ self.options.fofy,
+ self.options.times2pi,
+ self.options.isoscale,
+ self.options.drawaxis)))
+ newpath.set('title', self.options.fofx + " " + self.options.fofy)
+
+ #newpath.set('desc', '!func;' + self.options.fofx + ';' + self.options.fofy + ';'
+ # + `self.options.t_start` + ';'
+ # + `self.options.t_end` + ';'
+ # + `self.options.samples`)
+
+ # add path into SVG structure
+ node.getparent().append(newpath)
+ # option wether to remove the rectangle or not.
+ if self.options.remove:
+ node.getparent().remove(node)
+
+if __name__ == '__main__':
+ e = ParamCurves()
+ e.affect()
+
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
diff --git a/share/extensions/render_alphabetsoup.py b/share/extensions/render_alphabetsoup.py
index 7e4009328..ffc20323b 100644
--- a/share/extensions/render_alphabetsoup.py
+++ b/share/extensions/render_alphabetsoup.py
@@ -1,463 +1,463 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2001-2002 Matt Chisholm matt@theory.org
-Copyright (C) 2008 Joel Holdsworth joel@airwebreathe.org.uk
- for AP
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-'''
-
-import copy
-import inkex
-import simplestyle
-import math
-import cmath
-import string
-import random
-import render_alphabetsoup_config
-import bezmisc
-import simplepath
-import os
-import sys
-import gettext
-_ = gettext.gettext
-
-syntax = render_alphabetsoup_config.syntax
-alphabet = render_alphabetsoup_config.alphabet
-units = render_alphabetsoup_config.units
-font = render_alphabetsoup_config.font
-
-# Loads a super-path from a given SVG file
-def loadPath( svgPath ):
- extensionDir = os.path.normpath(
- os.path.join( os.getcwd(), os.path.dirname(__file__) )
- )
- # __file__ is better then sys.argv[0] because this file may be a module
- # for another one.
- tree = inkex.etree.parse( extensionDir + "/" + svgPath )
- root = tree.getroot()
- pathElement = root.find('{http://www.w3.org/2000/svg}path')
- if pathElement == None:
- return None, 0, 0
- d = pathElement.get("d")
- width = float(root.get("width"))
- height = float(root.get("height"))
- return simplepath.parsePath(d), width, height # Currently we only support a single path
-
-def combinePaths( pathA, pathB ):
- if pathA == None and pathB == None:
- return None
- elif pathA == None:
- return pathB
- elif pathB == None:
- return pathA
- else:
- return pathA + pathB
-
-def flipLeftRight( sp, width ):
- for cmd,params in sp:
- defs = simplepath.pathdefs[cmd]
- for i in range(defs[1]):
- if defs[3][i] == 'x':
- params[i] = width - params[i]
-
-def flipTopBottom( sp, height ):
- for cmd,params in sp:
- defs = simplepath.pathdefs[cmd]
- for i in range(defs[1]):
- if defs[3][i] == 'y':
- params[i] = height - params[i]
-
-def solveQuadratic(a, b, c):
- det = b*b - 4.0*a*c
- if det >= 0: # real roots
- sdet = math.sqrt(det)
- else: # complex roots
- sdet = cmath.sqrt(det)
- return (-b + sdet) / (2*a), (-b - sdet) / (2*a)
-
-def cbrt(x):
- if x >= 0:
- return x**(1.0/3.0)
- else:
- return -((-x)**(1.0/3.0))
-
-def findRealRoots(a,b,c,d):
- if a != 0:
- a, b, c, d = 1, b/float(a), c/float(a), d/float(a) # Divide through by a
- t = b / 3.0
- p, q = c - 3 * t**2, d - c * t + 2 * t**3
- u, v = solveQuadratic(1, q, -(p/3.0)**3)
- if type(u) == type(0j): # Complex Cubic Root
- r = math.sqrt(u.real**2 + u.imag**2)
- w = math.atan2(u.imag, u.real)
- y1 = 2 * cbrt(r) * math.cos(w / 3.0)
- else: # Complex Real Root
- y1 = cbrt(u) + cbrt(v)
-
- y2, y3 = solveQuadratic(1, y1, p + y1**2)
-
- if type(y2) == type(0j): # Are y2 and y3 complex?
- return [y1 - t]
- return [y1 - t, y2 - t, y3 - t]
- elif b != 0:
- det=c*c - 4.0*b*d
- if det >= 0:
- return [(-c + math.sqrt(det))/(2.0*b),(-c - math.sqrt(det))/(2.0*b)]
- elif c != 0:
- return [-d/c]
- return []
-
-def getPathBoundingBox( sp ):
-
- box = None
- last = None
- lostctrl = None
-
- for cmd,params in sp:
-
- segmentBox = None
-
- if cmd == 'M':
- # A move cannot contribute to the bounding box
- last = params[:]
- lastctrl = params[:]
- elif cmd == 'L':
- if last:
- segmentBox = (min(params[0], last[0]), max(params[0], last[0]), min(params[1], last[1]), max(params[1], last[1]))
- last = params[:]
- lastctrl = params[:]
- elif cmd == 'C':
- if last:
- segmentBox = (min(params[4], last[0]), max(params[4], last[0]), min(params[5], last[1]), max(params[5], last[1]))
-
- bx0, by0 = last[:]
- bx1, by1, bx2, by2, bx3, by3 = params[:]
-
- # Compute the x limits
- a = (-bx0 + 3*bx1 - 3*bx2 + bx3)*3
- b = (3*bx0 - 6*bx1 + 3*bx2)*2
- c = (-3*bx0 + 3*bx1)
- ts = findRealRoots(0, a, b, c)
- for t in ts:
- if t >= 0 and t <= 1:
- x = (-bx0 + 3*bx1 - 3*bx2 + bx3)*(t**3) + \
- (3*bx0 - 6*bx1 + 3*bx2)*(t**2) + \
- (-3*bx0 + 3*bx1)*t + \
- bx0
- segmentBox = (min(segmentBox[0], x), max(segmentBox[1], x), segmentBox[2], segmentBox[3])
-
- # Compute the y limits
- a = (-by0 + 3*by1 - 3*by2 + by3)*3
- b = (3*by0 - 6*by1 + 3*by2)*2
- c = (-3*by0 + 3*by1)
- ts = findRealRoots(0, a, b, c)
- for t in ts:
- if t >= 0 and t <= 1:
- y = (-by0 + 3*by1 - 3*by2 + by3)*(t**3) + \
- (3*by0 - 6*by1 + 3*by2)*(t**2) + \
- (-3*by0 + 3*by1)*t + \
- by0
- segmentBox = (segmentBox[0], segmentBox[1], min(segmentBox[2], y), max(segmentBox[3], y))
-
- last = params[-2:]
- lastctrl = params[2:4]
-
- elif cmd == 'Q':
- # Provisional
- if last:
- segmentBox = (min(params[0], last[0]), max(params[0], last[0]), min(params[1], last[1]), max(params[1], last[1]))
- last = params[-2:]
- lastctrl = params[2:4]
-
- elif cmd == 'A':
- # Provisional
- if last:
- segmentBox = (min(params[0], last[0]), max(params[0], last[0]), min(params[1], last[1]), max(params[1], last[1]))
- last = params[-2:]
- lastctrl = params[2:4]
-
- if segmentBox:
- if box:
- box = (min(segmentBox[0],box[0]), max(segmentBox[1],box[1]), min(segmentBox[2],box[2]), max(segmentBox[3],box[3]))
- else:
- box = segmentBox
- return box
-
-def mxfm( image, width, height, stack ): # returns possibly transformed image
- tbimage = image
- if ( stack[0] == "-" ): # top-bottom flip
- flipTopBottom(tbimage, height)
- stack.pop( 0 )
-
- lrimage = tbimage
- if ( stack[0] == "|" ): # left-right flip
- flipLeftRight(tbimage, width)
- stack.pop( 0 )
- return lrimage
-
-def comparerule( rule, nodes ): # compare node list to nodes in rule
- for i in range( 0, len(nodes)): # range( a, b ) = (a, a+1, a+2 ... b-2, b-1)
- if (nodes[i] == rule[i][0]):
- pass
- else: return 0
- return 1
-
-def findrule( state, nodes ): # find the rule which generated this subtree
- ruleset = syntax[state][1]
- nodelen = len(nodes)
- for rule in ruleset:
- rulelen = len(rule)
- if ((rulelen == nodelen) and (comparerule( rule, nodes ))):
- return rule
- return
-
-def generate( state ): # generate a random tree (in stack form)
- stack = [ state ]
- if ( len(syntax[state]) == 1 ): # if this is a stop symbol
- return stack
- else:
- stack.append( "[" )
- path = random.randint(0, (len(syntax[state][1])-1)) # choose randomly from next states
- for symbol in syntax[state][1][path]: # recurse down each non-terminal
- if ( symbol != 0 ): # 0 denotes end of list ###
- substack = generate( symbol[0] ) # get subtree
- for elt in substack:
- stack.append( elt )
- if (symbol[3]):stack.append( "-" ) # top-bottom flip
- if (symbol[4]):stack.append( "|" ) # left-right flip
- #else:
- #inkex.debug("found end of list in generate( state =", state, ")") # this should be deprecated/never happen
- stack.append("]")
- return stack
-
-def draw( stack ): # draw a character based on a tree stack
- state = stack.pop(0)
- #print state,
-
- image, width, height = loadPath( font+syntax[state][0] ) # load the image
- if (stack[0] != "["): # terminal stack element
- if (len(syntax[state]) == 1): # this state is a terminal node
- return image, width, height
- else:
- substack = generate( state ) # generate random substack
- return draw( substack ) # draw random substack
- else:
- #inkex.debug("[")
- stack.pop(0)
- images = [] # list of daughter images
- nodes = [] # list of daughter names
- while (stack[0] != "]"): # for all nodes in stack
- newstate = stack[0] # the new state
- newimage, width, height = draw( stack ) # draw the daughter state
- if (newimage):
- tfimage = mxfm( newimage, width, height, stack ) # maybe transform daughter state
- images.append( [tfimage, width, height] ) # list of daughter images
- nodes.append( newstate ) # list of daughter nodes
- else:
- #inkex.debug(("recurse on",newstate,"failed")) # this should never happen
- return None, 0, 0
- rule = findrule( state, nodes ) # find the rule for this subtree
-
- for i in range( 0, len(images)):
- currimg, width, height = images[i]
-
- if currimg:
- #box = getPathBoundingBox(currimg)
- dx = rule[i][1]*units
- dy = rule[i][2]*units
- #newbox = ((box[0]+dx),(box[1]+dy),(box[2]+dx),(box[3]+dy))
- simplepath.translatePath(currimg, dx, dy)
- image = combinePaths( image, currimg )
-
- stack.pop( 0 )
- return image, width, height
-
-def draw_crop_scale( stack, zoom ): # draw, crop and scale letter image
- image, width, height = draw(stack)
- bbox = getPathBoundingBox(image)
- simplepath.translatePath(image, -bbox[0], 0)
- simplepath.scalePath(image, zoom/units, zoom/units)
- return image, bbox[1] - bbox[0], bbox[3] - bbox[2]
-
-def randomize_input_string( str, zoom ): # generate list of images based on input string
- imagelist = []
-
- for i in range(0,len(str)):
- char = str[i]
- #if ( re.match("[a-zA-Z0-9?]", char)):
- if ( alphabet.has_key(char)):
- if ((i > 0) and (char == str[i-1])): # if this letter matches previous letter
- imagelist.append(imagelist[len(stack)-1])# make them the same image
- else: # generate image for letter
- stack = string.split( alphabet[char][random.randint(0,(len(alphabet[char])-1))] , "." )
- #stack = string.split( alphabet[char][random.randint(0,(len(alphabet[char])-2))] , "." )
- imagelist.append( draw_crop_scale( stack, zoom ))
- elif( char == " "): # add a " " space to the image list
- imagelist.append( " " )
- else: # this character is not in config.alphabet, skip it
- inkex.errormsg(_("bad character") + " = 0x%x" % ord(char))
- return imagelist
-
-def optikern( image, width, zoom ): # optical kerning algorithm
- left = []
- right = []
-
- for i in range( 0, 36 ):
- y = 0.5 * (i + 0.5) * zoom
- xmin = None
- xmax = None
-
- for cmd,params in image:
-
- segmentBox = None
-
- if cmd == 'M':
- # A move cannot contribute to the bounding box
- last = params[:]
- lastctrl = params[:]
- elif cmd == 'L':
- if (y >= last[1] and y <= params[1]) or (y >= params[1] and y <= last[1]):
- if params[0] == last[0]:
- x = params[0]
- else:
- a = (params[1] - last[1]) / (params[0] - last[0])
- b = last[1] - a * last[0]
- if a != 0:
- x = (y - b) / a
- else: x = None
-
- if x:
- if xmin == None or x < xmin: xmin = x
- if xmax == None or x > xmax: xmax = x
-
- last = params[:]
- lastctrl = params[:]
- elif cmd == 'C':
- if last:
- bx0, by0 = last[:]
- bx1, by1, bx2, by2, bx3, by3 = params[:]
-
- d = by0 - y
- c = -3*by0 + 3*by1
- b = 3*by0 - 6*by1 + 3*by2
- a = -by0 + 3*by1 - 3*by2 + by3
-
- ts = findRealRoots(a, b, c, d)
-
- for t in ts:
- if t >= 0 and t <= 1:
- x = (-bx0 + 3*bx1 - 3*bx2 + bx3)*(t**3) + \
- (3*bx0 - 6*bx1 + 3*bx2)*(t**2) + \
- (-3*bx0 + 3*bx1)*t + \
- bx0
- if xmin == None or x < xmin: xmin = x
- if xmax == None or x > xmax: xmax = x
-
- last = params[-2:]
- lastctrl = params[2:4]
-
- elif cmd == 'Q':
- # Quadratic beziers are ignored
- last = params[-2:]
- lastctrl = params[2:4]
-
- elif cmd == 'A':
- # Arcs are ignored
- last = params[-2:]
- lastctrl = params[2:4]
-
-
- if xmin != None and xmax != None:
- left.append( xmin ) # distance from left edge of region to left edge of bbox
- right.append( width - xmax ) # distance from right edge of region to right edge of bbox
- else:
- left.append( width )
- right.append( width )
-
- return (left, right)
-
-def layoutstring( imagelist, zoom ): # layout string of letter-images using optical kerning
- kernlist = []
- length = zoom
- for entry in imagelist:
- if (entry == " "): # leaving room for " " space characters
- length = length + (zoom * render_alphabetsoup_config.space)
- else:
- image, width, height = entry
- length = length + width + zoom # add letter length to overall length
- kernlist.append( optikern(image, width, zoom) ) # append kerning data for this image
-
- workspace = None
-
- position = zoom
- for i in range(0, len(kernlist)):
- while(imagelist[i] == " "):
- position = position + (zoom * render_alphabetsoup_config.space )
- imagelist.pop(i)
- image, width, height = imagelist[i]
-
- # set the kerning
- if i == 0: kern = 0 # for first image, kerning is zero
- else:
- kerncompare = [] # kerning comparison array
- for j in range( 0, len(kernlist[i][0])):
- kerncompare.append( kernlist[i][0][j]+kernlist[i-1][1][j] )
- kern = min( kerncompare )
-
- position = position - kern # move position back by kern amount
- thisimage = copy.deepcopy(image)
- simplepath.translatePath(thisimage, position, 0)
- workspace = combinePaths(workspace, thisimage)
- position = position + width + zoom # advance position by letter width
-
- return workspace
-
-class AlphabetSoup(inkex.Effect):
- def __init__(self):
- inkex.Effect.__init__(self)
- self.OptionParser.add_option("-t", "--text",
- action="store", type="string",
- dest="text", default="Inkscape",
- help="The text for alphabet soup")
- self.OptionParser.add_option("-z", "--zoom",
- action="store", type="float",
- dest="zoom", default="8.0",
- help="The zoom on the output graphics")
- self.OptionParser.add_option("-s", "--seed",
- action="store", type="int",
- dest="seed", default="0",
- help="The random seed for the soup")
-
- def effect(self):
- zoom = self.options.zoom
- random.seed(self.options.seed)
-
- imagelist = randomize_input_string(self.options.text, zoom)
- image = layoutstring( imagelist, zoom )
-
- if image:
- s = { 'stroke': 'none', 'fill': '#000000' }
-
- new = inkex.etree.Element(inkex.addNS('path','svg'))
- new.set('style', simplestyle.formatStyle(s))
-
- new.set('d', simplepath.formatPath(image))
- self.current_layer.append(new)
-
-if __name__ == '__main__':
- e = AlphabetSoup()
- e.affect()
-
+#!/usr/bin/env python
+'''
+Copyright (C) 2001-2002 Matt Chisholm matt@theory.org
+Copyright (C) 2008 Joel Holdsworth joel@airwebreathe.org.uk
+ for AP
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+'''
+
+import copy
+import inkex
+import simplestyle
+import math
+import cmath
+import string
+import random
+import render_alphabetsoup_config
+import bezmisc
+import simplepath
+import os
+import sys
+import gettext
+_ = gettext.gettext
+
+syntax = render_alphabetsoup_config.syntax
+alphabet = render_alphabetsoup_config.alphabet
+units = render_alphabetsoup_config.units
+font = render_alphabetsoup_config.font
+
+# Loads a super-path from a given SVG file
+def loadPath( svgPath ):
+ extensionDir = os.path.normpath(
+ os.path.join( os.getcwd(), os.path.dirname(__file__) )
+ )
+ # __file__ is better then sys.argv[0] because this file may be a module
+ # for another one.
+ tree = inkex.etree.parse( extensionDir + "/" + svgPath )
+ root = tree.getroot()
+ pathElement = root.find('{http://www.w3.org/2000/svg}path')
+ if pathElement == None:
+ return None, 0, 0
+ d = pathElement.get("d")
+ width = float(root.get("width"))
+ height = float(root.get("height"))
+ return simplepath.parsePath(d), width, height # Currently we only support a single path
+
+def combinePaths( pathA, pathB ):
+ if pathA == None and pathB == None:
+ return None
+ elif pathA == None:
+ return pathB
+ elif pathB == None:
+ return pathA
+ else:
+ return pathA + pathB
+
+def flipLeftRight( sp, width ):
+ for cmd,params in sp:
+ defs = simplepath.pathdefs[cmd]
+ for i in range(defs[1]):
+ if defs[3][i] == 'x':
+ params[i] = width - params[i]
+
+def flipTopBottom( sp, height ):
+ for cmd,params in sp:
+ defs = simplepath.pathdefs[cmd]
+ for i in range(defs[1]):
+ if defs[3][i] == 'y':
+ params[i] = height - params[i]
+
+def solveQuadratic(a, b, c):
+ det = b*b - 4.0*a*c
+ if det >= 0: # real roots
+ sdet = math.sqrt(det)
+ else: # complex roots
+ sdet = cmath.sqrt(det)
+ return (-b + sdet) / (2*a), (-b - sdet) / (2*a)
+
+def cbrt(x):
+ if x >= 0:
+ return x**(1.0/3.0)
+ else:
+ return -((-x)**(1.0/3.0))
+
+def findRealRoots(a,b,c,d):
+ if a != 0:
+ a, b, c, d = 1, b/float(a), c/float(a), d/float(a) # Divide through by a
+ t = b / 3.0
+ p, q = c - 3 * t**2, d - c * t + 2 * t**3
+ u, v = solveQuadratic(1, q, -(p/3.0)**3)
+ if type(u) == type(0j): # Complex Cubic Root
+ r = math.sqrt(u.real**2 + u.imag**2)
+ w = math.atan2(u.imag, u.real)
+ y1 = 2 * cbrt(r) * math.cos(w / 3.0)
+ else: # Complex Real Root
+ y1 = cbrt(u) + cbrt(v)
+
+ y2, y3 = solveQuadratic(1, y1, p + y1**2)
+
+ if type(y2) == type(0j): # Are y2 and y3 complex?
+ return [y1 - t]
+ return [y1 - t, y2 - t, y3 - t]
+ elif b != 0:
+ det=c*c - 4.0*b*d
+ if det >= 0:
+ return [(-c + math.sqrt(det))/(2.0*b),(-c - math.sqrt(det))/(2.0*b)]
+ elif c != 0:
+ return [-d/c]
+ return []
+
+def getPathBoundingBox( sp ):
+
+ box = None
+ last = None
+ lostctrl = None
+
+ for cmd,params in sp:
+
+ segmentBox = None
+
+ if cmd == 'M':
+ # A move cannot contribute to the bounding box
+ last = params[:]
+ lastctrl = params[:]
+ elif cmd == 'L':
+ if last:
+ segmentBox = (min(params[0], last[0]), max(params[0], last[0]), min(params[1], last[1]), max(params[1], last[1]))
+ last = params[:]
+ lastctrl = params[:]
+ elif cmd == 'C':
+ if last:
+ segmentBox = (min(params[4], last[0]), max(params[4], last[0]), min(params[5], last[1]), max(params[5], last[1]))
+
+ bx0, by0 = last[:]
+ bx1, by1, bx2, by2, bx3, by3 = params[:]
+
+ # Compute the x limits
+ a = (-bx0 + 3*bx1 - 3*bx2 + bx3)*3
+ b = (3*bx0 - 6*bx1 + 3*bx2)*2
+ c = (-3*bx0 + 3*bx1)
+ ts = findRealRoots(0, a, b, c)
+ for t in ts:
+ if t >= 0 and t <= 1:
+ x = (-bx0 + 3*bx1 - 3*bx2 + bx3)*(t**3) + \
+ (3*bx0 - 6*bx1 + 3*bx2)*(t**2) + \
+ (-3*bx0 + 3*bx1)*t + \
+ bx0
+ segmentBox = (min(segmentBox[0], x), max(segmentBox[1], x), segmentBox[2], segmentBox[3])
+
+ # Compute the y limits
+ a = (-by0 + 3*by1 - 3*by2 + by3)*3
+ b = (3*by0 - 6*by1 + 3*by2)*2
+ c = (-3*by0 + 3*by1)
+ ts = findRealRoots(0, a, b, c)
+ for t in ts:
+ if t >= 0 and t <= 1:
+ y = (-by0 + 3*by1 - 3*by2 + by3)*(t**3) + \
+ (3*by0 - 6*by1 + 3*by2)*(t**2) + \
+ (-3*by0 + 3*by1)*t + \
+ by0
+ segmentBox = (segmentBox[0], segmentBox[1], min(segmentBox[2], y), max(segmentBox[3], y))
+
+ last = params[-2:]
+ lastctrl = params[2:4]
+
+ elif cmd == 'Q':
+ # Provisional
+ if last:
+ segmentBox = (min(params[0], last[0]), max(params[0], last[0]), min(params[1], last[1]), max(params[1], last[1]))
+ last = params[-2:]
+ lastctrl = params[2:4]
+
+ elif cmd == 'A':
+ # Provisional
+ if last:
+ segmentBox = (min(params[0], last[0]), max(params[0], last[0]), min(params[1], last[1]), max(params[1], last[1]))
+ last = params[-2:]
+ lastctrl = params[2:4]
+
+ if segmentBox:
+ if box:
+ box = (min(segmentBox[0],box[0]), max(segmentBox[1],box[1]), min(segmentBox[2],box[2]), max(segmentBox[3],box[3]))
+ else:
+ box = segmentBox
+ return box
+
+def mxfm( image, width, height, stack ): # returns possibly transformed image
+ tbimage = image
+ if ( stack[0] == "-" ): # top-bottom flip
+ flipTopBottom(tbimage, height)
+ stack.pop( 0 )
+
+ lrimage = tbimage
+ if ( stack[0] == "|" ): # left-right flip
+ flipLeftRight(tbimage, width)
+ stack.pop( 0 )
+ return lrimage
+
+def comparerule( rule, nodes ): # compare node list to nodes in rule
+ for i in range( 0, len(nodes)): # range( a, b ) = (a, a+1, a+2 ... b-2, b-1)
+ if (nodes[i] == rule[i][0]):
+ pass
+ else: return 0
+ return 1
+
+def findrule( state, nodes ): # find the rule which generated this subtree
+ ruleset = syntax[state][1]
+ nodelen = len(nodes)
+ for rule in ruleset:
+ rulelen = len(rule)
+ if ((rulelen == nodelen) and (comparerule( rule, nodes ))):
+ return rule
+ return
+
+def generate( state ): # generate a random tree (in stack form)
+ stack = [ state ]
+ if ( len(syntax[state]) == 1 ): # if this is a stop symbol
+ return stack
+ else:
+ stack.append( "[" )
+ path = random.randint(0, (len(syntax[state][1])-1)) # choose randomly from next states
+ for symbol in syntax[state][1][path]: # recurse down each non-terminal
+ if ( symbol != 0 ): # 0 denotes end of list ###
+ substack = generate( symbol[0] ) # get subtree
+ for elt in substack:
+ stack.append( elt )
+ if (symbol[3]):stack.append( "-" ) # top-bottom flip
+ if (symbol[4]):stack.append( "|" ) # left-right flip
+ #else:
+ #inkex.debug("found end of list in generate( state =", state, ")") # this should be deprecated/never happen
+ stack.append("]")
+ return stack
+
+def draw( stack ): # draw a character based on a tree stack
+ state = stack.pop(0)
+ #print state,
+
+ image, width, height = loadPath( font+syntax[state][0] ) # load the image
+ if (stack[0] != "["): # terminal stack element
+ if (len(syntax[state]) == 1): # this state is a terminal node
+ return image, width, height
+ else:
+ substack = generate( state ) # generate random substack
+ return draw( substack ) # draw random substack
+ else:
+ #inkex.debug("[")
+ stack.pop(0)
+ images = [] # list of daughter images
+ nodes = [] # list of daughter names
+ while (stack[0] != "]"): # for all nodes in stack
+ newstate = stack[0] # the new state
+ newimage, width, height = draw( stack ) # draw the daughter state
+ if (newimage):
+ tfimage = mxfm( newimage, width, height, stack ) # maybe transform daughter state
+ images.append( [tfimage, width, height] ) # list of daughter images
+ nodes.append( newstate ) # list of daughter nodes
+ else:
+ #inkex.debug(("recurse on",newstate,"failed")) # this should never happen
+ return None, 0, 0
+ rule = findrule( state, nodes ) # find the rule for this subtree
+
+ for i in range( 0, len(images)):
+ currimg, width, height = images[i]
+
+ if currimg:
+ #box = getPathBoundingBox(currimg)
+ dx = rule[i][1]*units
+ dy = rule[i][2]*units
+ #newbox = ((box[0]+dx),(box[1]+dy),(box[2]+dx),(box[3]+dy))
+ simplepath.translatePath(currimg, dx, dy)
+ image = combinePaths( image, currimg )
+
+ stack.pop( 0 )
+ return image, width, height
+
+def draw_crop_scale( stack, zoom ): # draw, crop and scale letter image
+ image, width, height = draw(stack)
+ bbox = getPathBoundingBox(image)
+ simplepath.translatePath(image, -bbox[0], 0)
+ simplepath.scalePath(image, zoom/units, zoom/units)
+ return image, bbox[1] - bbox[0], bbox[3] - bbox[2]
+
+def randomize_input_string( str, zoom ): # generate list of images based on input string
+ imagelist = []
+
+ for i in range(0,len(str)):
+ char = str[i]
+ #if ( re.match("[a-zA-Z0-9?]", char)):
+ if ( alphabet.has_key(char)):
+ if ((i > 0) and (char == str[i-1])): # if this letter matches previous letter
+ imagelist.append(imagelist[len(stack)-1])# make them the same image
+ else: # generate image for letter
+ stack = string.split( alphabet[char][random.randint(0,(len(alphabet[char])-1))] , "." )
+ #stack = string.split( alphabet[char][random.randint(0,(len(alphabet[char])-2))] , "." )
+ imagelist.append( draw_crop_scale( stack, zoom ))
+ elif( char == " "): # add a " " space to the image list
+ imagelist.append( " " )
+ else: # this character is not in config.alphabet, skip it
+ inkex.errormsg(_("bad character") + " = 0x%x" % ord(char))
+ return imagelist
+
+def optikern( image, width, zoom ): # optical kerning algorithm
+ left = []
+ right = []
+
+ for i in range( 0, 36 ):
+ y = 0.5 * (i + 0.5) * zoom
+ xmin = None
+ xmax = None
+
+ for cmd,params in image:
+
+ segmentBox = None
+
+ if cmd == 'M':
+ # A move cannot contribute to the bounding box
+ last = params[:]
+ lastctrl = params[:]
+ elif cmd == 'L':
+ if (y >= last[1] and y <= params[1]) or (y >= params[1] and y <= last[1]):
+ if params[0] == last[0]:
+ x = params[0]
+ else:
+ a = (params[1] - last[1]) / (params[0] - last[0])
+ b = last[1] - a * last[0]
+ if a != 0:
+ x = (y - b) / a
+ else: x = None
+
+ if x:
+ if xmin == None or x < xmin: xmin = x
+ if xmax == None or x > xmax: xmax = x
+
+ last = params[:]
+ lastctrl = params[:]
+ elif cmd == 'C':
+ if last:
+ bx0, by0 = last[:]
+ bx1, by1, bx2, by2, bx3, by3 = params[:]
+
+ d = by0 - y
+ c = -3*by0 + 3*by1
+ b = 3*by0 - 6*by1 + 3*by2
+ a = -by0 + 3*by1 - 3*by2 + by3
+
+ ts = findRealRoots(a, b, c, d)
+
+ for t in ts:
+ if t >= 0 and t <= 1:
+ x = (-bx0 + 3*bx1 - 3*bx2 + bx3)*(t**3) + \
+ (3*bx0 - 6*bx1 + 3*bx2)*(t**2) + \
+ (-3*bx0 + 3*bx1)*t + \
+ bx0
+ if xmin == None or x < xmin: xmin = x
+ if xmax == None or x > xmax: xmax = x
+
+ last = params[-2:]
+ lastctrl = params[2:4]
+
+ elif cmd == 'Q':
+ # Quadratic beziers are ignored
+ last = params[-2:]
+ lastctrl = params[2:4]
+
+ elif cmd == 'A':
+ # Arcs are ignored
+ last = params[-2:]
+ lastctrl = params[2:4]
+
+
+ if xmin != None and xmax != None:
+ left.append( xmin ) # distance from left edge of region to left edge of bbox
+ right.append( width - xmax ) # distance from right edge of region to right edge of bbox
+ else:
+ left.append( width )
+ right.append( width )
+
+ return (left, right)
+
+def layoutstring( imagelist, zoom ): # layout string of letter-images using optical kerning
+ kernlist = []
+ length = zoom
+ for entry in imagelist:
+ if (entry == " "): # leaving room for " " space characters
+ length = length + (zoom * render_alphabetsoup_config.space)
+ else:
+ image, width, height = entry
+ length = length + width + zoom # add letter length to overall length
+ kernlist.append( optikern(image, width, zoom) ) # append kerning data for this image
+
+ workspace = None
+
+ position = zoom
+ for i in range(0, len(kernlist)):
+ while(imagelist[i] == " "):
+ position = position + (zoom * render_alphabetsoup_config.space )
+ imagelist.pop(i)
+ image, width, height = imagelist[i]
+
+ # set the kerning
+ if i == 0: kern = 0 # for first image, kerning is zero
+ else:
+ kerncompare = [] # kerning comparison array
+ for j in range( 0, len(kernlist[i][0])):
+ kerncompare.append( kernlist[i][0][j]+kernlist[i-1][1][j] )
+ kern = min( kerncompare )
+
+ position = position - kern # move position back by kern amount
+ thisimage = copy.deepcopy(image)
+ simplepath.translatePath(thisimage, position, 0)
+ workspace = combinePaths(workspace, thisimage)
+ position = position + width + zoom # advance position by letter width
+
+ return workspace
+
+class AlphabetSoup(inkex.Effect):
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ self.OptionParser.add_option("-t", "--text",
+ action="store", type="string",
+ dest="text", default="Inkscape",
+ help="The text for alphabet soup")
+ self.OptionParser.add_option("-z", "--zoom",
+ action="store", type="float",
+ dest="zoom", default="8.0",
+ help="The zoom on the output graphics")
+ self.OptionParser.add_option("-s", "--seed",
+ action="store", type="int",
+ dest="seed", default="0",
+ help="The random seed for the soup")
+
+ def effect(self):
+ zoom = self.options.zoom
+ random.seed(self.options.seed)
+
+ imagelist = randomize_input_string(self.options.text, zoom)
+ image = layoutstring( imagelist, zoom )
+
+ if image:
+ s = { 'stroke': 'none', 'fill': '#000000' }
+
+ new = inkex.etree.Element(inkex.addNS('path','svg'))
+ new.set('style', simplestyle.formatStyle(s))
+
+ new.set('d', simplepath.formatPath(image))
+ self.current_layer.append(new)
+
+if __name__ == '__main__':
+ e = AlphabetSoup()
+ e.affect()
+
diff --git a/share/extensions/svg2xaml.xsl b/share/extensions/svg2xaml.xsl
index cda6c7a97..1c663c11c 100755
--- a/share/extensions/svg2xaml.xsl
+++ b/share/extensions/svg2xaml.xsl
@@ -1,1483 +1,1483 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Copyright (c) 2005-2007 authors:
-Original version: Toine de Greef (a.degreef@chello.nl)
-Modified (2010) by Nicolas Dufour (nicoduf@yahoo.fr) (blur support, units
-convertion, comments, and some other fixes)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
--->
-
-<xsl:stylesheet version="1.0"
-xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-xmlns:xlink="http://www.w3.org/1999/xlink"
-xmlns:xs="http://www.w3.org/2001/XMLSchema"
-xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-xmlns:exsl="http://exslt.org/common"
-xmlns:libxslt="http://xmlsoft.org/XSLT/namespace"
-exclude-result-prefixes="rdf xlink xs exsl libxslt">
-
-<xsl:strip-space elements="*" />
-<xsl:output method="xml" encoding="UTF-8"/>
-
-<xsl:param name="silverlight_compatible" select="1" />
-
-<!-- Root template.
-Everything starts here! -->
-<xsl:template match="/">
- <xsl:choose>
- <xsl:when test="$silverlight_compatible = 1">
- <xsl:apply-templates mode="forward" />
- </xsl:when>
- <xsl:otherwise>
- <Viewbox Stretch="Uniform">
- <xsl:apply-templates mode="forward" />
- </Viewbox>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- SVG and groups
-(including layers) -->
-<xsl:template mode="forward" match="*[name(.) = 'svg' or name(.) = 'g']">
- <xsl:choose>
- <xsl:when test="name(.) = 'svg' or @transform or @viewBox or @id or @clip-path or (@style and contains(@style, 'clip-path:url(#')) or (@width and not(contains(@width, '%'))) or @x or @y or (@height and not(contains(@height, '%'))) or *[name(.) = 'linearGradient' or name(.) = 'radialGradient' or name(.) = 'defs' or name(.) = 'clipPath']">
- <Canvas>
- <xsl:apply-templates mode="id" select="." />
- <!--
- <xsl:apply-templates mode="clip" select="." />
- -->
- <xsl:if test="@style and contains(@style, 'display:none')"><xsl:attribute name="Visibility">Collapsed</xsl:attribute></xsl:if>
- <xsl:if test="@style and contains(@style, 'opacity:')">
- <xsl:attribute name="Opacity">
- <xsl:choose>
- <xsl:when test="contains(substring-after(@style, 'opacity:'), ';')"><xsl:value-of select="substring-before(substring-after(@style, 'opacity:'), ';')" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="substring-after(@style, 'opacity:')" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@width and not(contains(@width, '%'))">
- <xsl:attribute name="Width">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@width" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@height and not(contains(@height, '%'))">
- <xsl:attribute name="Height">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@height" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@x">
- <xsl:attribute name="Canvas.Left">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@x" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@y">
- <xsl:attribute name="Canvas.Top">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@y" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@viewBox">
- <xsl:variable name="viewBox"><xsl:value-of select="normalize-space(translate(@viewBox, ',', ' '))" /></xsl:variable>
- <xsl:attribute name="Width"><xsl:value-of select="substring-before(substring-after(substring-after($viewBox, ' '), ' '), ' ')" /></xsl:attribute>
- <xsl:attribute name="Height"><xsl:value-of select="substring-after(substring-after(substring-after($viewBox, ' '), ' '), ' ')" /></xsl:attribute>
- <Canvas.RenderTransform>
- <TranslateTransform>
- <xsl:attribute name="X"><xsl:value-of select="-number(substring-before($viewBox, ' '))" /></xsl:attribute>
- <xsl:attribute name="Y"><xsl:value-of select="-number(substring-before(substring-after($viewBox, ' '), ' '))" /></xsl:attribute>
- </TranslateTransform>
- </Canvas.RenderTransform>
- </xsl:if>
- <xsl:if test="@transform">
- <Canvas>
- <Canvas.RenderTransform>
- <TransformGroup><xsl:apply-templates mode="transform" select="." /></TransformGroup>
- </Canvas.RenderTransform>
- <xsl:apply-templates mode="forward" select="*" />
- </Canvas>
- </xsl:if>
-
- <xsl:if test="*[name(.) = 'linearGradient' or name(.) = 'radialGradient' or name(.) = 'defs' or name(.) = 'clipPath']">
- <Canvas.Resources>
- <xsl:apply-templates mode="forward" select="*[name(.) = 'linearGradient' or name(.) = 'radialGradient' or name(.) = 'defs' or name(.) = 'clipPath']" />
- </Canvas.Resources>
- </xsl:if>
- <xsl:if test="not(@transform)">
- <xsl:apply-templates mode="forward" select="*[name(.) != 'linearGradient' and name(.) != 'radialGradient' and name(.) != 'defs' and name(.) != 'clipPath']" />
- </xsl:if>
- </Canvas>
- </xsl:when>
- <xsl:when test="not(@transform)">
- <xsl:apply-templates mode="forward" select="*" />
- </xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!--
-// Resources (defs) //
-
-* Resources ids
-* Generic defs template
-* Generic filters template
-* Filter effects
-* Linked filter effects
-* Linear gradients
-* Radial gradients
-* Generic gradient stops
-* Clipping
--->
-
-<!-- Resources ids -->
-<xsl:template mode="resources" match="*">
- <!-- should be in-depth -->
- <xsl:if test="ancestor::*[name(.) = 'defs']"><xsl:attribute name="x:Key"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
-</xsl:template>
-
-<!-- Generic defs template -->
-<xsl:template mode="forward" match="defs">
- <xsl:apply-templates mode="forward" />
-</xsl:template>
-
-<!-- Generic filters template
-Limited to one filter (can be improved) -->
-<xsl:template mode="forward" match="*[name(.) = 'filter']">
- <xsl:if test="count(*) = 1">
- <xsl:apply-templates mode="forward" />
- </xsl:if>
-</xsl:template>
-
-<!-- Filter effects -->
-<xsl:template mode="forward" match="*[name(.) = 'feGaussianBlur']">
- <BlurEffect>
- <xsl:if test="../@id"><xsl:attribute name="x:Key"><xsl:value-of select="../@id" /></xsl:attribute></xsl:if>
- <xsl:if test="@stdDeviation"><xsl:attribute name="Radius"><xsl:value-of select="round(@stdDeviation * 3)" /></xsl:attribute></xsl:if>
- </BlurEffect>
-</xsl:template>
-
-<!-- Linked filter effect -->
-<xsl:template mode="filter_effect" match="*">
-<xsl:choose>
- <xsl:when test="@filter and starts-with(@filter, 'url(#')">
- <xsl:attribute name="Effect">
- <xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@filter, 'url(#'), ')'), '}')" />
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="@style and contains(@style, 'filter:url(#')">
- <xsl:attribute name="Effect">
- <xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@style, 'filter:url(#'), ')'), '}')" />
- </xsl:attribute>
- </xsl:when>
-</xsl:choose>
-</xsl:template>
-
-<!-- Linear gradient -->
-<xsl:template mode="forward" match="*[name(.) = 'linearGradient']">
- <LinearGradientBrush>
- <xsl:if test="@id"><xsl:attribute name="x:Key"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
- <xsl:attribute name="MappingMode">
- <xsl:choose>
- <xsl:when test="@gradientUnits = 'userSpaceOnUse' ">Absolute</xsl:when>
- <xsl:otherwise>RelativeToBoundingBox</xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:if test="@spreadMethod">
- <xsl:attribute name="SpreadMethod">
- <xsl:choose>
- <xsl:when test="@spreadMethod = 'pad'">Pad</xsl:when>
- <xsl:when test="@spreadMethod = 'reflect'">Reflect</xsl:when>
- <xsl:when test="@spreadMethod = 'repeat'">Repeat</xsl:when>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:choose>
- <xsl:when test="@x1 and @y1 and @x2 and @y2">
- <xsl:choose>
- <xsl:when test="contains(@x1, '%') and contains(@y1, '%')">
- <xsl:attribute name="StartPoint"><xsl:value-of select="concat(substring-before(@x1, '%') div 100, ',', substring-before(@y1,'%') div 100)" /></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="StartPoint"><xsl:value-of select="concat(@x1, ',', @y1)" /></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="contains(@x2, '%') and contains(@y2, '%')">
- <xsl:attribute name="EndPoint"><xsl:value-of select="concat(substring-before(@x2, '%') div 100, ',', substring-before(@y2,'%') div 100)" /></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="EndPoint"><xsl:value-of select="concat(@x2, ',', @y2)" /></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="StartPoint"><xsl:value-of select="'0,0'" /></xsl:attribute>
- <xsl:attribute name="EndPoint"><xsl:value-of select="'1,1'" /></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <LinearGradientBrush.GradientStops>
- <GradientStopCollection>
- <xsl:choose>
- <xsl:when test="@xlink:href">
- <xsl:variable name="reference_id" select="@xlink:href" />
- <xsl:apply-templates mode="forward" select="//*[name(.) = 'linearGradient' and $reference_id = concat('#', @id)]/*" />
- </xsl:when>
- <xsl:otherwise><xsl:apply-templates mode="forward" /></xsl:otherwise>
- </xsl:choose>
- </GradientStopCollection>
- </LinearGradientBrush.GradientStops>
- <xsl:if test="@gradientTransform">
- <LinearGradientBrush.Transform>
- <xsl:apply-templates mode="transform" select="." />
- </LinearGradientBrush.Transform>
- </xsl:if>
- </LinearGradientBrush>
-</xsl:template>
-
-<!-- Radial gradient -->
-<xsl:template mode="forward" match="*[name(.) = 'radialGradient']">
- <RadialGradientBrush>
- <xsl:if test="@id"><xsl:attribute name="x:Key"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
- <xsl:attribute name="MappingMode">
- <xsl:choose>
- <xsl:when test="@gradientUnits = 'userSpaceOnUse' ">Absolute</xsl:when>
- <xsl:otherwise>RelativeToBoundingBox</xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:if test="@spreadMethod">
- <xsl:attribute name="SpreadMethod">
- <xsl:choose>
- <xsl:when test="@spreadMethod = 'pad'">Pad</xsl:when>
- <xsl:when test="@spreadMethod = 'reflect'">Reflect</xsl:when>
- <xsl:when test="@spreadMethod = 'repeat'">Repeat</xsl:when>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@cx and @cy">
- <xsl:attribute name="Center">
- <xsl:choose>
- <xsl:when test="contains(@cx, '%') and contains(@cy, '%')">
- <xsl:value-of select="concat(number(substring-before(@cx, '%')) div 100, ',', number(substring-before(@cy, '%')) div 100)" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat(@cx, ',', @cy)" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@fx and @fy">
- <xsl:attribute name="GradientOrigin">
- <xsl:choose>
- <xsl:when test="contains(@fx, '%') and contains(@fy, '%')">
- <xsl:value-of select="concat(number(substring-before(@fx, '%')) div 100, ',', number(substring-before(@fy, '%')) div 100)" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat(@fx, ',', @fy)" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@r">
- <xsl:choose>
- <xsl:when test="contains(@r, '%')">
- <xsl:attribute name="RadiusX"><xsl:value-of select="number(substring-before(@r, '%')) div 100" /></xsl:attribute>
- <xsl:attribute name="RadiusY"><xsl:value-of select="number(substring-before(@r, '%')) div 100" /></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="RadiusX"><xsl:value-of select="@r" /></xsl:attribute>
- <xsl:attribute name="RadiusY"><xsl:value-of select="@r" /></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- <RadialGradientBrush.GradientStops>
- <GradientStopCollection>
- <xsl:choose>
- <xsl:when test="@xlink:href">
- <xsl:variable name="reference_id" select="@xlink:href" />
- <xsl:apply-templates mode="forward" select="//*[name(.) = 'linearGradient' and $reference_id = concat('#', @id)]/*" />
- </xsl:when>
- <xsl:otherwise><xsl:apply-templates mode="forward" /></xsl:otherwise>
- </xsl:choose>
- </GradientStopCollection>
- </RadialGradientBrush.GradientStops>
- <xsl:if test="@gradientTransform">
- <RadialGradientBrush.Transform>
- <xsl:apply-templates mode="transform" select="." />
- </RadialGradientBrush.Transform>
- </xsl:if>
- </RadialGradientBrush>
-</xsl:template>
-
-<!-- Generic gradient stops -->
-<xsl:template mode="forward" match="*[name(.) = 'stop']">
- <GradientStop>
- <!--xsl:apply-templates mode="stop_opacity" select="." /-->
- <xsl:apply-templates mode="stop_color" select="." />
- <xsl:apply-templates mode="offset" select="." />
- <xsl:apply-templates mode="forward" />
- </GradientStop>
-</xsl:template>
-
-<!-- Clipping -->
-<xsl:template mode="clip" match="*">
- <xsl:choose>
- <xsl:when test="@clip-path and defs/clipPath/path/@d"><xsl:attribute name="Clip"><xsl:value-of select="defs/clipPath/path/@d" /></xsl:attribute></xsl:when>
- <xsl:when test="@clip-path and starts-with(@clip-path, 'url(#')"><xsl:attribute name="Clip"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@clip-path, 'url(#'), ')'), '}')" /></xsl:attribute></xsl:when>
- <xsl:when test="@style and contains(@style, 'clip-path:url(#')"><xsl:attribute name="Clip"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@style, 'url(#'), ')'), '}')" /></xsl:attribute></xsl:when>
- <xsl:when test="clipPath"><xsl:apply-templates mode="forward" /></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!--
-// Misc templates //
-
-* Object description
-* Id converter
-* Decimal to hexadecimal converter
-* Unit to pixel converter
-* Title and description
-* Misc ignored stuff (markers, patterns, styles)
-* Symbols
-* Use
-* RDF and foreign objects
-* Unknows tags
--->
-
-<!-- Object description -->
-<xsl:template mode="desc" match="*">
- <xsl:if test="*[name(.) = 'desc']/text()"><xsl:attribute name="Tag"><xsl:value-of select="*[name(.) = 'desc']/text()" /></xsl:attribute></xsl:if>
-</xsl:template>
-
-<!-- Id converter. Removes "-" from the original id. -->
-<xsl:template mode="id" match="*">
-<xsl:if test="@id">
- <xsl:attribute name="Name"><xsl:value-of select="translate(@id, '- ', '')" /></xsl:attribute>
- <!--
- <xsl:attribute name="x:Key"><xsl:value-of select="translate(@id, '- ', '')" /></xsl:attribute>
- -->
-</xsl:if>
-</xsl:template>
-
-<!-- Decimal to hexadecimal converter -->
-<xsl:template name="to_hex">
- <xsl:param name="convert" />
- <xsl:value-of select="concat(substring('0123456789ABCDEF', 1 + floor(round($convert) div 16), 1), substring('0123456789ABCDEF', 1 + round($convert) mod 16, 1))" />
-</xsl:template>
-
-<!-- Unit to pixel converter
-Values with units (except %) are converted to pixels and rounded.
-Unknown units are kept. -->
-<xsl:template name="convert_unit">
- <xsl:param name="convert_value" />
- <xsl:choose>
- <xsl:when test="contains($convert_value, 'px')">
- <xsl:value-of select="round(translate($convert_value, 'px', ''))" />
- </xsl:when>
- <xsl:when test="contains($convert_value, 'pt')">
- <xsl:value-of select="round(translate($convert_value, 'pt', '') * 1.25)" />
- </xsl:when>
- <xsl:when test="contains($convert_value, 'pc')">
- <xsl:value-of select="round(translate($convert_value, 'pc', '') * 15)" />
- </xsl:when>
- <xsl:when test="contains($convert_value, 'mm')">
- <xsl:value-of select="round(translate($convert_value, 'mm', '') * 3.543307)" />
- </xsl:when>
- <xsl:when test="contains($convert_value, 'cm')">
- <xsl:value-of select="round(translate($convert_value, 'cm', '') * 35.43307)" />
- </xsl:when>
- <xsl:when test="contains($convert_value, 'in')">
- <xsl:value-of select="round(translate($convert_value, 'in', '') * 90)" />
- </xsl:when>
- <xsl:when test="contains($convert_value, 'ft')">
- <xsl:value-of select="round(translate($convert_value, 'ft', '') * 1080)" />
- </xsl:when>
- <xsl:when test="not(string(number($convert_value))='NaN')">
- <xsl:value-of select="round($convert_value)" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$convert_value" />
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- Title and description
-Blank template. Title is ignored and desc is converted to Tag in the mode="desc" template
--->
-<xsl:template mode="forward" match="*[name(.) = 'title' or name(.) = 'desc']">
- <!-- -->
-</xsl:template>
-
-<!-- Misc ignored stuff (markers, patterns, styles) -->
-<xsl:template mode="forward" match="*[name(.) = 'marker' or name(.) = 'pattern' or name(.) = 'style']">
- <!-- -->
-</xsl:template>
-
-<!-- Symbols -->
-<xsl:template mode="forward" match="*[name(.) = 'symbol']">
- <Style>
- <xsl:if test="@id"><xsl:attribute name="x:Key"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
- <Canvas>
- <xsl:apply-templates mode="forward" />
- </Canvas>
- </Style>
-</xsl:template>
-
-<!-- Use -->
-<xsl:template mode="forward" match="*[name(.) = 'use']">
- <Canvas>
- <xsl:if test="@xlink:href"><xsl:attribute name="Style"><xsl:value-of select="@xlink:href" /></xsl:attribute></xsl:if>
- <!--xsl:apply-templates mode="transform" select="." /-->
- <xsl:apply-templates mode="forward" />
- </Canvas>
-</xsl:template>
-
-<!-- RDF and foreign objects -->
-<xsl:template mode="forward" match="rdf:RDF | *[name(.) = 'foreignObject']">
- <!-- -->
-</xsl:template>
-
-<!-- Unknown tags -->
-<xsl:template match="*">
-<xsl:comment><xsl:value-of select="concat('Unknown tag: ', name(.))" /></xsl:comment>
-</xsl:template>
-
-
-<!--
-// Colors and patterns //
-
-* Generic color template
-* Fill
-* Fill opacity
-* Fill rule
-* Generic fill template
-* Stroke
-* Stroke opacity
-* Generic stroke template
-* Stroke width
-* Stroke mitterlimit
-* Stroke dasharray
-* Stroke dashoffset
-* Linejoin SVG to XAML converter
-* Stroke linejoin
-* Linecap SVG to XAML converter
-* Stroke linecap
-* Gradient stop
-* Gradient stop opacity
-* Gradient stop offset
--->
-
-<!-- Generic color template -->
-<xsl:template name="template_color">
- <xsl:param name="colorspec" />
- <xsl:param name="opacityspec" />
- <xsl:choose>
- <xsl:when test="starts-with($colorspec, 'rgb(') and not(contains($colorspec , '%'))">
- <xsl:value-of select="'#'" />
- <xsl:if test="$opacityspec != '' and number($opacityspec) != 1"><xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="round(number($opacityspec) * 255)" /></xsl:with-param></xsl:call-template></xsl:if>
- <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="substring-before(substring-after($colorspec, 'rgb('), ',')" /></xsl:with-param></xsl:call-template>
- <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="substring-before(substring-after(substring-after($colorspec, 'rgb('), ','), ',')" /></xsl:with-param></xsl:call-template>
- <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="substring-before(substring-after(substring-after(substring-after($colorspec, 'rgb('), ','), ','), ')')" /></xsl:with-param></xsl:call-template>
- </xsl:when>
- <xsl:when test="starts-with($colorspec, 'rgb(') and contains($colorspec , '%')">
- <xsl:value-of select="'#'" />
- <xsl:if test="$opacityspec != '' and number($opacityspec) != 1"><xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="round(number($opacityspec) * 255)" /></xsl:with-param></xsl:call-template></xsl:if>
- <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="number(substring-before(substring-after($colorspec, 'rgb('), '%,')) * 255 div 100" /></xsl:with-param></xsl:call-template>
- <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="number(substring-before(substring-after(substring-after($colorspec, 'rgb('), ','), '%,')) * 255 div 100" /></xsl:with-param></xsl:call-template>
- <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="number(substring-before(substring-after(substring-after(substring-after($colorspec, 'rgb('), ','), ','), '%)')) * 255 div 100" /></xsl:with-param></xsl:call-template>
- </xsl:when>
- <xsl:when test="starts-with($colorspec, '#')">
- <xsl:value-of select="'#'" />
- <xsl:if test="$opacityspec != ''"><xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="round(number($opacityspec) * 255)" /></xsl:with-param></xsl:call-template></xsl:if>
- <xsl:choose>
- <xsl:when test="string-length(substring-after($colorspec, '#')) = 3">
- <xsl:variable name="colorspec3"><xsl:value-of select="translate(substring-after($colorspec, '#'), 'abcdefgh', 'ABCDEFGH')" /></xsl:variable>
- <xsl:value-of select="concat(substring($colorspec3, 1, 1), substring($colorspec3, 1, 1))" />
- <xsl:value-of select="concat(substring($colorspec3, 2, 1), substring($colorspec3, 2, 1))" />
- <xsl:value-of select="concat(substring($colorspec3, 3, 1), substring($colorspec3, 3, 1))" />
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="translate(substring-after($colorspec, '#'), 'abcdefgh', 'ABCDEFGH')" /></xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="named_color_hex" select="document('colors.xml')/colors/color[@name = translate($colorspec, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]/@hex" />
- <xsl:choose>
- <xsl:when test="$named_color_hex and $named_color_hex != ''">
- <xsl:value-of select="'#'" />
- <xsl:if test="$opacityspec != '' and number($opacityspec) != 1"><xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="number($opacityspec) * 255" /></xsl:with-param></xsl:call-template></xsl:if>
- <xsl:value-of select="substring-after($named_color_hex, '#')" />
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$colorspec" /></xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- Fill -->
-<xsl:template mode="fill" match="*">
- <xsl:choose>
- <xsl:when test="@fill and starts-with(@fill, 'url(#')"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@fill, 'url(#'), ')'), '}')" /></xsl:when>
- <xsl:when test="@fill"><xsl:value-of select="@fill" /></xsl:when>
- <xsl:when test="@style and contains(@style, 'fill:') and starts-with(substring-after(@style, 'fill:'), 'url(#')"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@style, 'url(#'), ')'), '}')" /></xsl:when>
- <xsl:when test="@style and contains(@style, 'fill:')">
- <xsl:variable name="Fill" select="substring-after(@style, 'fill:')" />
- <xsl:choose>
- <xsl:when test="contains($Fill, ';')">
- <xsl:value-of select="substring-before($Fill, ';')" />
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$Fill" /></xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="fill" select="parent::*"/></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Fill opacity -->
-<xsl:template mode="fill_opacity" match="*">
- <xsl:choose>
- <xsl:when test="@fill-opacity"><xsl:value-of select="@fill-opacity" /></xsl:when>
- <xsl:when test="@style and contains(@style, 'fill-opacity:')">
- <xsl:variable name="Opacity" select="substring-after(@style, 'fill-opacity:')" />
- <xsl:choose>
- <xsl:when test="contains($Opacity, ';')"><xsl:value-of select="substring-before($Opacity, ';')" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="$Opacity" /></xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="fill_opacity" select="parent::*" /></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Fill rule -->
-<xsl:template mode="fill_rule" match="*">
- <xsl:choose>
- <xsl:when test="@fill-rule and (@fill-rule = 'nonzero' or @fill-rule = 'evenodd')"><xsl:attribute name="FillRule"><xsl:value-of select="@fill-rule" /></xsl:attribute></xsl:when>
- <xsl:when test="@style and contains(@style, 'fill-rule:')">
- <xsl:variable name="FillRule" select="substring-after(@style, 'fill-rule:')" />
- <xsl:choose>
- <xsl:when test="contains($FillRule, ';')">
- <xsl:if test="substring-before($FillRule, ';') = 'nonzero' or substring-before($FillRule, ';') = 'evenodd'"><xsl:attribute name="FillRule"><xsl:value-of select="substring-before($FillRule, ';')" /></xsl:attribute></xsl:if>
- </xsl:when>
- <xsl:when test="$FillRule = 'nonzero' or $FillRule = 'evenodd'"><xsl:attribute name="FillRule"><xsl:value-of select="$FillRule" /></xsl:attribute></xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="fill_rule" select="parent::*"/></xsl:when>
- <xsl:otherwise><xsl:attribute name="FillRule">NonZero</xsl:attribute></xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- Generic fill template -->
-<xsl:template mode="template_fill" match="*">
- <xsl:variable name="fill"><xsl:apply-templates mode="fill" select="." /></xsl:variable>
- <xsl:variable name="fill_opacity"><xsl:apply-templates mode="fill_opacity" select="." /></xsl:variable>
- <xsl:if test="not($fill = 'none')">
- <xsl:attribute name="Fill">
- <xsl:choose>
- <xsl:when test="$fill != ''">
- <xsl:call-template name="template_color">
- <xsl:with-param name="colorspec">
- <xsl:if test="$fill != 'none'"><xsl:value-of select="$fill" /></xsl:if>
- </xsl:with-param>
- <xsl:with-param name="opacityspec"><xsl:value-of select="$fill_opacity" /></xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>#000000</xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
-</xsl:template>
-
-<!-- Stroke -->
-<xsl:template mode="stroke" match="*">
- <xsl:choose>
- <xsl:when test="@stroke and starts-with(@stroke, 'url(#')"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@stroke, 'url(#'), ')'), '}')" /></xsl:when>
- <xsl:when test="@stroke and @stroke != 'none'"><xsl:value-of select="@stroke" /></xsl:when>
- <xsl:when test="@style and contains(@style, 'stroke:') and starts-with(substring-after(@style, 'stroke:'), 'url(#')"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@style, 'url(#'), ')'), '}')" /></xsl:when>
- <xsl:when test="@style and contains(@style, 'stroke:')">
- <xsl:variable name="Stroke" select="substring-after(@style, 'stroke:')" />
- <xsl:choose>
- <xsl:when test="contains($Stroke, ';')">
- <xsl:if test="substring-before($Stroke, ';') != 'none'"><xsl:value-of select="substring-before($Stroke, ';')" /></xsl:if>
- </xsl:when>
- <xsl:when test="$Stroke != 'none'"><xsl:value-of select="$Stroke" /></xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke" select="parent::*"/></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Stroke opacity -->
-<xsl:template mode="stroke_opacity" match="*">
- <xsl:choose>
- <xsl:when test="@stroke-opacity"><xsl:value-of select="@stroke-opacity" /></xsl:when>
- <xsl:when test="@style and contains(@style, 'stroke-opacity:')">
- <xsl:variable name="Opacity" select="substring-after(@style, 'stroke-opacity:')" />
- <xsl:choose>
- <xsl:when test="contains($Opacity, ';')"><xsl:value-of select="substring-before($Opacity, ';')" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="$Opacity" /></xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_opacity" select="parent::*" /></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Generic stroke template -->
-<xsl:template mode="template_stroke" match="*">
- <xsl:variable name="stroke"><xsl:apply-templates mode="stroke" select="." /></xsl:variable>
- <xsl:variable name="stroke_opacity"><xsl:apply-templates mode="stroke_opacity" select="." /></xsl:variable>
- <xsl:if test="$stroke != ''">
- <xsl:attribute name="Stroke">
- <xsl:call-template name="template_color">
- <xsl:with-param name="colorspec"><xsl:value-of select="$stroke" /></xsl:with-param>
- <xsl:with-param name="opacityspec"><xsl:value-of select="$stroke_opacity" /></xsl:with-param>
- </xsl:call-template>
- </xsl:attribute>
- </xsl:if>
-</xsl:template>
-
-<!-- Stroke width -->
-<xsl:template mode="stroke_width" match="*">
- <xsl:choose>
- <xsl:when test="@stroke-width">
- <xsl:attribute name="StrokeThickness"><xsl:value-of select="@stroke-width" /></xsl:attribute>
- </xsl:when>
- <xsl:when test="@style and contains(@style, 'stroke-width:')">
- <xsl:attribute name="StrokeThickness">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value">
- <xsl:choose>
- <xsl:when test="contains(substring-after(@style, 'stroke-width:'), ';')"><xsl:value-of select="substring-before(substring-after(@style, 'stroke-width:'), ';')" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="substring-after(@style, 'stroke-width:')" /></xsl:otherwise>
- </xsl:choose>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_width" select="parent::*"/></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Stroke miterlimit -->
-<xsl:template mode="stroke_miterlimit" match="*">
- <xsl:choose>
- <xsl:when test="@stroke-miterlimit"><xsl:attribute name="StrokeMiterLimit"><xsl:value-of select="@stroke-miterlimit" /></xsl:attribute></xsl:when>
- <xsl:when test="@style and contains(@style, 'stroke-miterlimit:')">
- <xsl:variable name="StrokeMiterLimit" select="substring-after(@style, 'stroke-miterlimit:')" />
- <xsl:attribute name="StrokeMiterLimit">
- <xsl:choose>
- <xsl:when test="contains($StrokeMiterLimit, ';')"><xsl:value-of select="substring-before($StrokeMiterLimit, ';')" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="$StrokeMiterLimit" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_miterlimit" select="parent::*"/></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Stroke dasharray -->
-<xsl:template mode="stroke_dasharray" match="*">
- <!-- stroke-dasharray="10,30,20,30" becomes StrokeDashArray="1 3 2 3" ?? -->
- <xsl:choose>
- <xsl:when test="@stroke-dasharray and @stroke-dasharray != 'none'"><xsl:attribute name="StrokeDashArray"><xsl:value-of select="@stroke-dasharray" /></xsl:attribute></xsl:when>
- <xsl:when test="@style and contains(@style, 'stroke-dasharray:')">
- <xsl:variable name="StrokeDashArray" select="substring-after(@style, 'stroke-dasharray:')" />
- <xsl:choose>
- <xsl:when test="contains($StrokeDashArray, ';')">
- <xsl:if test="substring-before($StrokeDashArray, ';') != 'none'"><xsl:attribute name="StrokeDashArray"><xsl:value-of select="substring-before($StrokeDashArray, ';')" /></xsl:attribute></xsl:if>
- </xsl:when>
- <xsl:when test="$StrokeDashArray != 'none'"><xsl:attribute name="StrokeDashArray"><xsl:value-of select="$StrokeDashArray" /></xsl:attribute></xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_dasharray" select="parent::*"/></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Stroke dashoffset -->
-<xsl:template mode="stroke_dashoffset" match="*">
- <xsl:choose>
- <xsl:when test="@stroke-dashoffset"><xsl:attribute name="StrokeDashOffset"><xsl:value-of select="@stroke-dashoffset" /></xsl:attribute></xsl:when>
- <xsl:when test="@style and contains(@style, 'stroke-dashoffset:')">
- <xsl:variable name="StrokeDashOffset" select="substring-after(@style, 'stroke-dashoffset:')" />
- <xsl:attribute name="StrokeDashOffset">
- <xsl:choose>
- <xsl:when test="contains($StrokeDashOffset, ';')"><xsl:value-of select="substring-before($StrokeDashOffset, ';')" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="$StrokeDashOffset" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_dashoffset" select="parent::*"/></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Linejoin SVG to XAML converter -->
-<xsl:template name="linejoin_svg_to_xaml">
- <xsl:param name="linejoin" />
- <xsl:choose>
- <xsl:when test="$linejoin = 'bevel'">Bevel</xsl:when>
- <xsl:when test="$linejoin = 'round'">Round</xsl:when>
- <xsl:otherwise>Miter</xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- Stroke linejoin -->
-<xsl:template mode="stroke_linejoin" match="*">
- <xsl:choose>
- <xsl:when test="@stroke-miterlimit">
- <xsl:attribute name="StrokeLineJoin">
- <xsl:call-template name="linejoin_svg_to_xaml"><xsl:with-param name="linejoin"><xsl:value-of select="@stroke-linejoin" /></xsl:with-param></xsl:call-template>
- </xsl:attribute></xsl:when>
- <xsl:when test="@style and contains(@style, 'stroke-linejoin:')">
- <xsl:variable name="StrokeLineJoin" select="substring-after(@style, 'stroke-linejoin:')" />
- <xsl:attribute name="StrokeLineJoin">
- <xsl:choose>
- <xsl:when test="contains($StrokeLineJoin, ';')">
- <xsl:call-template name="linejoin_svg_to_xaml"><xsl:with-param name="linejoin"><xsl:value-of select="substring-before($StrokeLineJoin, ';')" /></xsl:with-param></xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="linejoin_svg_to_xaml"><xsl:with-param name="linejoin"><xsl:value-of select="$StrokeLineJoin" /></xsl:with-param></xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_linejoin" select="parent::*"/></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Linecap SVG to XAML converter -->
-<xsl:template name="linecap_svg_to_xaml">
- <xsl:param name="linecap" />
- <xsl:choose>
- <xsl:when test="$linecap = 'round'">Round</xsl:when>
- <xsl:when test="$linecap = 'square'">Square</xsl:when>
- <xsl:otherwise>Flat</xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- Stroke linecap -->
-<xsl:template mode="stroke_linecap" match="*">
- <xsl:choose>
- <xsl:when test="@stroke-linecap">
- <xsl:attribute name="StrokeStartLineCap">
- <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="@stroke-linecap" /></xsl:with-param></xsl:call-template>
- </xsl:attribute>
- <xsl:attribute name="StrokeEndLineCap">
- <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="@stroke-linecap" /></xsl:with-param></xsl:call-template>
- </xsl:attribute></xsl:when>
- <xsl:when test="@style and contains(@style, 'stroke-linecap:')">
- <xsl:variable name="StrokeStartLineCap" select="substring-after(@style, 'stroke-linecap:')" />
- <xsl:variable name="StrokeEndLineCap" select="substring-after(@style, 'stroke-linecap:')" />
- <xsl:attribute name="StrokeStartLineCap">
- <xsl:choose>
- <xsl:when test="contains($StrokeStartLineCap, ';')">
- <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="substring-before($StrokeStartLineCap, ';')" /></xsl:with-param></xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="$StrokeStartLineCap" /></xsl:with-param></xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:attribute name="StrokeEndLineCap">
- <xsl:choose>
- <xsl:when test="contains($StrokeEndLineCap, ';')">
- <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="substring-before($StrokeEndLineCap, ';')" /></xsl:with-param></xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="$StrokeEndLineCap" /></xsl:with-param></xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_linecap" select="parent::*"/></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Gradient stops -->
-<xsl:template mode="stop_color" match="*">
- <xsl:variable name="Opacity">
- <xsl:choose>
- <xsl:when test="@stop-opacity"><xsl:value-of select="@stop-opacity" /></xsl:when>
- <xsl:when test="@style and contains(@style, 'stop-opacity:')">
- <xsl:variable name="temp_opacity" select="substring-after(@style, 'stop-opacity:')" />
- <xsl:choose>
- <xsl:when test="contains($temp_opacity, ';')"><xsl:value-of select="substring-before($temp_opacity, ';')" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="$temp_opacity" /></xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="''" /></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="hex_opacity">
- <xsl:choose>
- <xsl:when test="$Opacity != ''"><xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="number($Opacity) * 255" /></xsl:with-param></xsl:call-template> </xsl:when>
- <xsl:otherwise><xsl:value-of select="$Opacity" /></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="stopcolor">
- <xsl:choose>
- <xsl:when test="@stop-color">
- <xsl:call-template name="template_color"><xsl:with-param name="colorspec"><xsl:value-of select="@stop-color" /></xsl:with-param></xsl:call-template>
- </xsl:when>
- <xsl:when test="@style and contains(@style, 'stop-color:')">
- <xsl:variable name="Color" select="substring-after(@style, 'stop-color:')" />
- <xsl:choose>
- <xsl:when test="contains($Color, ';')">
- <xsl:call-template name="template_color"><xsl:with-param name="colorspec"><xsl:value-of select="substring-before($Color, ';')" /></xsl:with-param></xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="template_color"><xsl:with-param name="colorspec"><xsl:value-of select="$Color" /></xsl:with-param></xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stop_color" select="parent::*"/></xsl:when>
- <xsl:otherwise>#000</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:attribute name="Color">
- <xsl:choose>
- <xsl:when test="$hex_opacity != '' and starts-with($stopcolor, '#')"><xsl:value-of select="concat('#', $hex_opacity, substring-after($stopcolor, '#'))" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="$stopcolor" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-</xsl:template>
-
-<!-- Gradient stop opacity -->
-<xsl:template mode="stop_opacity" match="*">
- <xsl:choose>
- <xsl:when test="@stop-opacity"><xsl:attribute name="Opacity"><xsl:value-of select="@stop-opacity" /></xsl:attribute></xsl:when>
- <xsl:when test="@style and contains(@style, 'stop-opacity:')">
- <xsl:variable name="Opacity" select="substring-after(@style, 'stop-opacity:')" />
- <xsl:attribute name="Opacity">
- <xsl:choose>
- <xsl:when test="contains($Opacity, ';')"><xsl:value-of select="substring-before($Opacity, ';')" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="$Opacity" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stop_opacity" select="parent::*"/></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Gradient stop offset -->
-<xsl:template mode="offset" match="*">
- <xsl:choose>
- <xsl:when test="@offset">
- <xsl:attribute name="Offset">
- <xsl:choose>
- <xsl:when test="contains(@offset, '%')"><xsl:value-of select="number(substring-before(@offset, '%')) div 100" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="@offset" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="@style and contains(@style, 'offset:')">
- <xsl:variable name="Offset" select="substring-after(@style, 'offset:')" />
- <xsl:attribute name="Offset">
- <xsl:choose>
- <xsl:when test="contains($Offset, '%')"><xsl:value-of select="number(substring-before($Offset, '%')) div 100" /></xsl:when>
- <xsl:when test="contains($Offset, ';')"><xsl:value-of select="substring-before($Offset, ';')" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="$Offset" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stop_offset" select="parent::*"/></xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!--
-// Transforms //
-All the matrix, translate, rotate... stuff.
-Fixme: XAML transforms don't show the same result as SVG ones with the same values.
-
-* Parse transform
-* Apply transform
-* Apply transform v2
--->
-
-<!-- Parse transform -->
-<xsl:template name="parse_transform">
- <xsl:param name="input" />
- <xsl:choose>
- <xsl:when test="starts-with($input, 'matrix(')">
- <MatrixTransform><xsl:attribute name="Matrix"><xsl:value-of select="substring-before(substring-after($input, 'matrix('), ')')" /></xsl:attribute></MatrixTransform>
- <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
- </xsl:when>
- <xsl:when test="starts-with($input, 'scale(')">
- <ScaleTransform>
- <xsl:variable name="scale" select="substring-before(substring-after($input, 'scale('), ')')" />
- <xsl:choose>
- <xsl:when test="contains($scale, ',')">
- <xsl:attribute name="ScaleX"><xsl:value-of select="substring-before($scale, ',')" /></xsl:attribute>
- <xsl:attribute name="ScaleY"><xsl:value-of select="substring-after($scale, ',')" /></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="ScaleX"><xsl:value-of select="$scale" /></xsl:attribute>
- <xsl:attribute name="ScaleY"><xsl:value-of select="$scale" /></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </ScaleTransform>
- <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
- </xsl:when>
- <xsl:when test="starts-with($input, 'rotate(')">
- <RotateTransform>
- <xsl:attribute name="Angle"><xsl:value-of select="substring-before(substring-after($input, 'rotate('), ')')" /></xsl:attribute>
- <xsl:if test="@rx"><xsl:attribute name="CenterX"><xsl:value-of select="@rx" /></xsl:attribute></xsl:if>
- <xsl:if test="@ry"><xsl:attribute name="CenterY"><xsl:value-of select="@ry" /></xsl:attribute></xsl:if>
- </RotateTransform>
- <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
- </xsl:when>
- <xsl:when test="starts-with($input, 'skewX(')">
- <SkewTransform>
- <xsl:attribute name="AngleX"><xsl:value-of select="substring-before(substring-after($input, 'skewX('), ')')" /></xsl:attribute>
- <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
- </SkewTransform>
- </xsl:when>
- <xsl:when test="starts-with($input, 'skewY(')">
- <SkewTransform>
- <xsl:attribute name="AngleY"><xsl:value-of select="substring-before(substring-after($input, 'skewY('), ')')" /></xsl:attribute>
- <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
- </SkewTransform>
- </xsl:when>
- <xsl:when test="starts-with($input, 'translate(')">
- <TranslateTransform>
- <xsl:variable name="translate" select="substring-before(substring-after($input, 'translate('), ')')" />
- <xsl:choose>
- <xsl:when test="contains($translate, ',')">
- <xsl:attribute name="X"><xsl:value-of select="substring-before($translate, ',')" /></xsl:attribute>
- <xsl:attribute name="Y"><xsl:value-of select="substring-after($translate, ',')" /></xsl:attribute>
- </xsl:when>
- <xsl:when test="contains($translate, ' ')">
- <xsl:attribute name="X"><xsl:value-of select="substring-before($translate, ' ')" /></xsl:attribute>
- <xsl:attribute name="Y"><xsl:value-of select="substring-after($translate, ' ')" /></xsl:attribute>
- </xsl:when>
- <xsl:otherwise><xsl:attribute name="X"><xsl:value-of select="$translate" /></xsl:attribute></xsl:otherwise>
- </xsl:choose>
- </TranslateTransform>
- <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
- </xsl:when>
- </xsl:choose>
-</xsl:template>
-
-<!-- Apply transform -->
-<xsl:template mode="transform" match="*">
- <xsl:param name="mapped_type" />
- <xsl:if test="@transform or @gradientTransform">
- <xsl:variable name="transform">
- <xsl:choose>
- <xsl:when test="@transform"><xsl:value-of select="@transform" /></xsl:when>
- <xsl:otherwise><xsl:value-of select="@gradientTransform" /></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="transform_nodes">
- <xsl:call-template name="parse_transform">
- <xsl:with-param name="input" select="$transform" />
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:comment>
- <xsl:value-of select="name(.)" />
- </xsl:comment>
-
- <xsl:choose>
- <xsl:when test="$mapped_type and $mapped_type != ''">
- <xsl:element name="{$mapped_type}.RenderTransform">
- <xsl:choose>
- <xsl:when test="count(libxslt:node-set($transform_nodes)/*) = 1"><xsl:copy-of select="libxslt:node-set($transform_nodes)" /></xsl:when>
- <xsl:when test="count(libxslt:node-set($transform_nodes)/*) &gt; 1"><TransformGroup><xsl:copy-of select="libxslt:node-set($transform_nodes)" /></TransformGroup></xsl:when>
- </xsl:choose>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <!-- For instance LinearGradient.Transform -->
- <xsl:choose>
- <xsl:when test="count(libxslt:node-set($transform_nodes)/*) = 1"><xsl:copy-of select="libxslt:node-set($transform_nodes)" /></xsl:when>
- <xsl:when test="count(libxslt:node-set($transform_nodes)/*) &gt; 1"><TransformGroup><xsl:copy-of select="libxslt:node-set($transform_nodes)" /></TransformGroup></xsl:when>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-</xsl:template>
-
-<!-- Apply transform v2
-Fixme: is this template still in use? -->
-<xsl:template mode="transform2" match="*">
- <xsl:choose>
- <xsl:when test="@transform">
- <Canvas>
- <Canvas.RenderTransform>
- <TransformGroup><xsl:apply-templates mode="transform" select="." /></TransformGroup>
- </Canvas.RenderTransform>
- <xsl:apply-templates mode="forward" select="." />
- </Canvas>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="forward" select="." />
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!--
-// Objects //
-
-* Image
-* Text
-* Lines
-* Rectangle
-* Polygon
-* Polyline
-* Path
-* Ellipse
-* Circle
--->
-
-<!-- Image -->
-<xsl:template mode="forward" match="*[name(.) = 'image']">
- <Image>
- <xsl:apply-templates mode="id" select="." />
- <xsl:if test="@x"><xsl:attribute name="Canvas.Left">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@x" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@y"><xsl:attribute name="Canvas.Top">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@y" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:apply-templates mode="desc" select="." />
- <xsl:apply-templates mode="clip" select="." />
- <xsl:if test="@xlink:href"><xsl:attribute name="Source"><xsl:value-of select="@xlink:href" /></xsl:attribute></xsl:if>
- <xsl:if test="@width"><xsl:attribute name="Width">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@width" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@height"><xsl:attribute name="Height">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@height" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:apply-templates mode="transform" select=".">
- <xsl:with-param name="mapped_type" select="'Image'" />
- </xsl:apply-templates>
- <!--xsl:apply-templates mode="transform" /-->
- <xsl:apply-templates mode="forward" />
- </Image>
-</xsl:template>
-
-<!-- Text -->
-<xsl:template mode="forward" match="*[name(.) = 'text']">
- <TextBlock>
- <xsl:if test="@font-size"><xsl:attribute name="FontSize"><xsl:value-of select="@font-size" /></xsl:attribute></xsl:if>
- <xsl:if test="@style and contains(@style, 'font-size:')">
- <xsl:variable name="font_size" select="substring-after(@style, 'font-size:')" />
- <xsl:attribute name="FontSize">
- <xsl:choose>
- <xsl:when test="contains($font_size, ';')">
- <xsl:value-of select="substring-before($font_size, ';')" />
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$font_size" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@font-weight"><xsl:attribute name="FontWeight"><xsl:value-of select="@font-weight" /></xsl:attribute></xsl:if>
- <xsl:if test="@style and contains(@style, 'font-weight:')">
- <xsl:variable name="font_weight" select="substring-after(@style, 'font-weight:')" />
- <xsl:attribute name="FontWeight">
- <xsl:choose>
- <xsl:when test="contains($font_weight, ';')">
- <xsl:value-of select="substring-before($font_weight, ';')" />
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$font_weight" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@font-family"><xsl:attribute name="FontFamily"><xsl:value-of select="@font-family" /></xsl:attribute></xsl:if>
- <xsl:if test="@style and contains(@style, 'font-family:')">
- <xsl:variable name="font_family" select="substring-after(@style, 'font-family:')" />
- <xsl:attribute name="FontFamily">
- <xsl:choose>
- <xsl:when test="contains($font_family, ';')">
- <xsl:value-of select="substring-before($font_family, ';')" />
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$font_family" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@font-style"><xsl:attribute name="FontStyle"><xsl:value-of select="@font-style" /></xsl:attribute></xsl:if>
- <xsl:if test="@style and contains(@style, 'font-style:')">
- <xsl:variable name="font_style" select="substring-after(@style, 'font-style:')" />
- <xsl:attribute name="FontStyle">
- <xsl:choose>
- <xsl:when test="contains($font_style, ';')">
- <xsl:value-of select="substring-before($font_style, ';')" />
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$font_style" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@fill"><xsl:attribute name="Foreground"><xsl:value-of select="@fill" /></xsl:attribute></xsl:if>
- <xsl:if test="@style and contains(@style, 'fill')">
- <xsl:variable name="fill" select="substring-after(@style, 'fill:')" />
- <xsl:attribute name="Foreground">
- <xsl:choose>
- <xsl:when test="contains($fill, ';')">
- <xsl:value-of select="substring-before($fill, ';')" />
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$fill" /></xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@text-anchor">
- <xsl:attribute name="HorizontalAlignment">
- <xsl:choose>
- <xsl:when test="@text-anchor = 'start'">Left</xsl:when>
- <xsl:when test="@text-anchor = 'middle'">Center</xsl:when>
- <xsl:when test="@text-anchor = 'end'">Right</xsl:when>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@width"><xsl:attribute name="Width">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@width" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@height"><xsl:attribute name="Height">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@height" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@x"><xsl:attribute name="Canvas.Left">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@x" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@y"><xsl:attribute name="Canvas.Top">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@y" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:apply-templates mode="id" select="." />
- <xsl:apply-templates mode="filter_effect" select="." />
- <xsl:apply-templates mode="desc" select="." />
- <xsl:apply-templates mode="clip" select="." />
- <!--xsl:apply-templates mode="transform" select="." /-->
- <!--xsl:apply-templates mode="forward" /-->
- <xsl:if test="text()"><xsl:value-of select="text()" /></xsl:if>
- <xsl:if test="*[name(.) = 'tspan']/text()"><xsl:value-of select="*[name(.) = 'tspan']/text()" /></xsl:if>
- </TextBlock>
-</xsl:template>
-
-<!-- Lines -->
-<xsl:template mode="forward" match="*[name(.) = 'line']">
- <Line>
- <xsl:if test="@x1"><xsl:attribute name="X1"><xsl:value-of select="@x1" /></xsl:attribute></xsl:if>
- <xsl:if test="@y1"><xsl:attribute name="Y1"><xsl:value-of select="@y1" /></xsl:attribute></xsl:if>
- <xsl:if test="@x2"><xsl:attribute name="X2"><xsl:value-of select="@x2" /></xsl:attribute></xsl:if>
- <xsl:if test="@y2"><xsl:attribute name="Y2"><xsl:value-of select="@y2" /></xsl:attribute></xsl:if>
- <xsl:apply-templates mode="id" select="." />
- <xsl:apply-templates mode="template_fill" select="." />
- <xsl:apply-templates mode="template_stroke" select="." />
- <xsl:apply-templates mode="stroke_width" select="." />
- <xsl:apply-templates mode="stroke_miterlimit" select="." />
- <xsl:apply-templates mode="stroke_dasharray" select="." />
- <xsl:apply-templates mode="stroke_dashoffset" select="." />
- <xsl:apply-templates mode="stroke_linejoin" select="." />
- <xsl:apply-templates mode="stroke_linecap" select="." />
- <xsl:apply-templates mode="filter_effect" select="." />
- <xsl:apply-templates mode="desc" select="." />
-
- <xsl:apply-templates mode="transform" select=".">
- <xsl:with-param name="mapped_type" select="'Line'" />
- </xsl:apply-templates>
-
- <xsl:apply-templates mode="forward" />
- </Line>
-</xsl:template>
-
-<!-- Rectangle -->
-<xsl:template mode="forward" match="*[name(.) = 'rect']">
- <Rectangle>
- <xsl:if test="@x"><xsl:attribute name="Canvas.Left">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@x" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@y"><xsl:attribute name="Canvas.Top">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@y" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@width"><xsl:attribute name="Width">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@width" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@height"><xsl:attribute name="Height">
- <xsl:call-template name="convert_unit">
- <xsl:with-param name="convert_value" select="@height" />
- </xsl:call-template>
- </xsl:attribute></xsl:if>
- <xsl:if test="@rx"><xsl:attribute name="RadiusX"><xsl:value-of select="@rx" /></xsl:attribute></xsl:if>
- <xsl:if test="@ry"><xsl:attribute name="RadiusY"><xsl:value-of select="@ry" /></xsl:attribute></xsl:if>
- <xsl:if test="@rx and not(@ry)"><xsl:attribute name="RadiusX"><xsl:value-of select="@rx" /></xsl:attribute><xsl:attribute name="RadiusY"><xsl:value-of select="@rx" /></xsl:attribute></xsl:if>
- <xsl:if test="@ry and not(@rx)"><xsl:attribute name="RadiusX"><xsl:value-of select="@ry" /></xsl:attribute><xsl:attribute name="RadiusY"><xsl:value-of select="@ry" /></xsl:attribute></xsl:if>
-
- <xsl:apply-templates mode="id" select="." />
- <xsl:apply-templates mode="template_fill" select="." />
- <xsl:apply-templates mode="template_stroke" select="." />
- <xsl:apply-templates mode="stroke_width" select="." />
- <xsl:apply-templates mode="stroke_miterlimit" select="." />
- <xsl:apply-templates mode="stroke_dasharray" select="." />
- <xsl:apply-templates mode="stroke_dashoffset" select="." />
- <xsl:apply-templates mode="stroke_linejoin" select="." />
- <xsl:apply-templates mode="stroke_linecap" select="." />
- <xsl:apply-templates mode="filter_effect" select="." />
- <xsl:apply-templates mode="resources" select="." />
- <xsl:apply-templates mode="desc" select="." />
- <xsl:apply-templates mode="clip" select="." />
-
- <xsl:apply-templates mode="transform" select=".">
- <xsl:with-param name="mapped_type" select="'Rectangle'" />
- </xsl:apply-templates>
-
- <xsl:apply-templates mode="forward" />
- </Rectangle>
-</xsl:template>
-
-<!-- Polygon -->
-<xsl:template mode="forward" match="*[name(.) = 'polygon']">
- <Polygon>
- <xsl:if test="@points"><xsl:attribute name="Points"><xsl:value-of select="@points" /></xsl:attribute></xsl:if>
- <xsl:apply-templates mode="id" select="." />
- <xsl:apply-templates mode="fill_rule" select="." />
- <xsl:apply-templates mode="template_fill" select="." />
- <xsl:apply-templates mode="template_stroke" select="." />
- <xsl:apply-templates mode="stroke_width" select="." />
- <xsl:apply-templates mode="stroke_miterlimit" select="." />
- <xsl:apply-templates mode="stroke_dasharray" select="." />
- <xsl:apply-templates mode="stroke_dashoffset" select="." />
- <xsl:apply-templates mode="stroke_linejoin" select="." />
- <xsl:apply-templates mode="stroke_linecap" select="." />
- <xsl:apply-templates mode="filter_effect" select="." />
- <xsl:apply-templates mode="desc" select="." />
-
- <xsl:apply-templates mode="transform" select=".">
- <xsl:with-param name="mapped_type" select="'Polygon'" />
- </xsl:apply-templates>
-
- <xsl:apply-templates mode="forward" />
- </Polygon>
-</xsl:template>
-
-<!-- Polyline -->
-<xsl:template mode="forward" match="*[name(.) = 'polyline']">
- <Polyline>
- <xsl:if test="@points"><xsl:attribute name="Points"><xsl:value-of select="@points" /></xsl:attribute></xsl:if>
- <xsl:apply-templates mode="id" select="." />
- <xsl:apply-templates mode="fill_rule" select="." />
- <xsl:apply-templates mode="template_fill" select="." />
- <xsl:apply-templates mode="template_stroke" select="." />
- <xsl:apply-templates mode="stroke_width" select="." />
- <xsl:apply-templates mode="stroke_miterlimit" select="." />
- <xsl:apply-templates mode="stroke_dasharray" select="." />
- <xsl:apply-templates mode="stroke_dashoffset" select="." />
- <xsl:apply-templates mode="stroke_linejoin" select="." />
- <xsl:apply-templates mode="stroke_linecap" select="." />
- <xsl:apply-templates mode="filter_effect" select="." />
- <xsl:apply-templates mode="desc" select="." />
-
- <xsl:apply-templates mode="transform" select=".">
- <xsl:with-param name="mapped_type" select="'Polyline'" />
- </xsl:apply-templates>
-
- <xsl:apply-templates mode="forward" />
- </Polyline>
-</xsl:template>
-
-<!-- Path -->
-<xsl:template mode="forward" match="*[name(.) = 'path']">
- <Path>
- <xsl:apply-templates mode="id" select="." />
- <xsl:apply-templates mode="template_fill" select="." />
- <xsl:apply-templates mode="template_stroke" select="." />
- <xsl:apply-templates mode="stroke_width" select="." />
- <xsl:apply-templates mode="stroke_miterlimit" select="." />
- <xsl:apply-templates mode="stroke_dasharray" select="." />
- <xsl:apply-templates mode="stroke_dashoffset" select="." />
- <xsl:apply-templates mode="stroke_linejoin" select="." />
- <xsl:apply-templates mode="stroke_linecap" select="." />
- <xsl:apply-templates mode="filter_effect" select="." />
- <xsl:apply-templates mode="desc" select="." />
-
- <xsl:if test="@d">
- <xsl:choose>
- <xsl:when test="$silverlight_compatible = 1">
- <xsl:attribute name="Data">
- <xsl:value-of select="translate(@d , ',', ' ')" />
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <Path.Data>
- <PathGeometry>
- <xsl:attribute name="Figures">
- <xsl:value-of select="translate(@d , ',', ' ')" />
- </xsl:attribute>
- <xsl:apply-templates mode="fill_rule" select="." />
- </PathGeometry>
- </Path.Data>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-
- <xsl:apply-templates mode="transform" select=".">
- <xsl:with-param name="mapped_type" select="'Path'" />
- </xsl:apply-templates>
-
- <xsl:apply-templates mode="forward" />
- </Path>
-</xsl:template>
-
-<!-- Ellipse -->
-<xsl:template mode="forward" match="*[name(.) = 'ellipse']">
- <Ellipse>
- <xsl:variable name="cx">
- <xsl:choose>
- <xsl:when test="@cx"><xsl:value-of select="@cx" /></xsl:when>
- <xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="cy">
- <xsl:choose>
- <xsl:when test="@cy"><xsl:value-of select="@cy" /></xsl:when>
- <xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="@rx">
- <xsl:attribute name="Canvas.Left"><xsl:value-of select='format-number($cx - @rx, "#.#")' /></xsl:attribute>
- <xsl:attribute name="Width"><xsl:value-of select='format-number(2 * @rx, "#.#")' /></xsl:attribute>
- </xsl:if>
- <xsl:if test="@ry">
- <xsl:attribute name="Canvas.Top"><xsl:value-of select='format-number($cy - @ry, "#.#")' /></xsl:attribute>
- <xsl:attribute name="Height"><xsl:value-of select='format-number(2 * @ry, "#.#")' /></xsl:attribute>
- </xsl:if>
- <xsl:apply-templates mode="id" select="." />
- <xsl:apply-templates mode="template_fill" select="." />
- <xsl:apply-templates mode="template_stroke" select="." />
- <xsl:apply-templates mode="stroke_width" select="." />
- <xsl:apply-templates mode="stroke_miterlimit" select="." />
- <xsl:apply-templates mode="stroke_dasharray" select="." />
- <xsl:apply-templates mode="stroke_dashoffset" select="." />
- <xsl:apply-templates mode="stroke_linejoin" select="." />
- <xsl:apply-templates mode="stroke_linecap" select="." />
- <xsl:apply-templates mode="filter_effect" select="." />
- <xsl:apply-templates mode="desc" select="." />
- <xsl:apply-templates mode="clip" select="." />
-
- <xsl:apply-templates mode="transform" select=".">
- <xsl:with-param name="mapped_type" select="'Ellipse'" />
- </xsl:apply-templates>
-
- <xsl:apply-templates mode="forward" />
- </Ellipse>
-</xsl:template>
-
-<!-- Circle -->
-<xsl:template mode="forward" match="*[name(.) = 'circle']">
- <Ellipse>
- <xsl:variable name="cx">
- <xsl:choose>
- <xsl:when test="@cx"><xsl:value-of select="@cx" /></xsl:when>
- <xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="cy">
- <xsl:choose>
- <xsl:when test="@cy"><xsl:value-of select="@cy" /></xsl:when>
- <xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="@r">
- <xsl:attribute name="Canvas.Left"><xsl:value-of select='format-number($cx - @r, "#.#")' /></xsl:attribute>
- <xsl:attribute name="Canvas.Top"><xsl:value-of select='format-number($cy - @r, "#.#")' /></xsl:attribute>
- <xsl:attribute name="Width"><xsl:value-of select='format-number(2 * @r, "#.#")' /></xsl:attribute>
- <xsl:attribute name="Height"><xsl:value-of select='format-number(2 * @r, "#.#")' /></xsl:attribute>
- </xsl:if>
- <xsl:apply-templates mode="id" select="." />
- <xsl:apply-templates mode="template_fill" select="." />
- <xsl:apply-templates mode="template_stroke" select="." />
- <xsl:apply-templates mode="stroke_width" select="." />
- <xsl:apply-templates mode="stroke_miterlimit" select="." />
- <xsl:apply-templates mode="stroke_dasharray" select="." />
- <xsl:apply-templates mode="stroke_dashoffset" select="." />
- <xsl:apply-templates mode="stroke_linejoin" select="." />
- <xsl:apply-templates mode="stroke_linecap" select="." />
- <xsl:apply-templates mode="filter_effect" select="." />
- <xsl:apply-templates mode="desc" select="." />
- <xsl:apply-templates mode="clip" select="." />
-
- <xsl:apply-templates mode="transform" select=".">
- <xsl:with-param name="mapped_type" select="'Ellipse'" />
- </xsl:apply-templates>
-
- <xsl:apply-templates mode="forward" />
- </Ellipse>
-</xsl:template>
-
-<!--
-// Geometry //
-* Generic clip path template
-* Geometry for circle
-* Geometry for rectangle
--->
-
-<!-- Generic clip path template -->
-<xsl:template mode="forward" match="*[name(.) = 'clipPath']">
- <xsl:apply-templates mode="geometry" />
-</xsl:template>
-
-<!-- Geometry for circle -->
-<xsl:template mode="geometry" match="*[name(.) = 'circle']">
- <EllipseGeometry>
- <xsl:if test="../@id"><xsl:attribute name="x:Key"><xsl:value-of select="../@id" /></xsl:attribute></xsl:if>
- <xsl:if test="@cx and @cy"><xsl:attribute name="Center"><xsl:value-of select="concat(@cx, ',', @cy)" /></xsl:attribute></xsl:if>
- <xsl:if test="@r">
- <xsl:attribute name="RadiusX"><xsl:value-of select="@r" /></xsl:attribute>
- <xsl:attribute name="RadiusY"><xsl:value-of select="@r" /></xsl:attribute>
- </xsl:if>
- </EllipseGeometry>
-</xsl:template>
-
-<!-- Geometry for rectangle -->
-<xsl:template mode="geometry" match="*[name(.) = 'rect']">
- <RectangleGeometry>
- <xsl:if test="../@id"><xsl:attribute name="x:Key"><xsl:value-of select="../@id" /></xsl:attribute></xsl:if>
- <!--
- <xsl:if test="@x"><xsl:attribute name="Canvas.Left"><xsl:value-of select="@x" /></xsl:attribute></xsl:if>
- <xsl:if test="@y"><xsl:attribute name="Canvas.Top"><xsl:value-of select="@y" /></xsl:attribute></xsl:if>
- <xsl:if test="@width"><xsl:attribute name="Width"><xsl:value-of select="@width" /></xsl:attribute></xsl:if>
- <xsl:if test="@height"><xsl:attribute name="Height"><xsl:value-of select="@height" /></xsl:attribute></xsl:if>
- <xsl:if test="@rx"><xsl:attribute name="RadiusX"><xsl:value-of select="@rx" /></xsl:attribute></xsl:if>
- <xsl:if test="@ry"><xsl:attribute name="RadiusY"><xsl:value-of select="@ry" /></xsl:attribute></xsl:if>
- -->
- <xsl:attribute name="Rect"><xsl:value-of select="concat('0, 0, ', @width, ', ', @height)" /></xsl:attribute>
- </RectangleGeometry>
-</xsl:template>
-
-</xsl:stylesheet>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Copyright (c) 2005-2007 authors:
+Original version: Toine de Greef (a.degreef@chello.nl)
+Modified (2010) by Nicolas Dufour (nicoduf@yahoo.fr) (blur support, units
+convertion, comments, and some other fixes)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-->
+
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:xlink="http://www.w3.org/1999/xlink"
+xmlns:xs="http://www.w3.org/2001/XMLSchema"
+xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+xmlns:exsl="http://exslt.org/common"
+xmlns:libxslt="http://xmlsoft.org/XSLT/namespace"
+exclude-result-prefixes="rdf xlink xs exsl libxslt">
+
+<xsl:strip-space elements="*" />
+<xsl:output method="xml" encoding="UTF-8"/>
+
+<xsl:param name="silverlight_compatible" select="1" />
+
+<!-- Root template.
+Everything starts here! -->
+<xsl:template match="/">
+ <xsl:choose>
+ <xsl:when test="$silverlight_compatible = 1">
+ <xsl:apply-templates mode="forward" />
+ </xsl:when>
+ <xsl:otherwise>
+ <Viewbox Stretch="Uniform">
+ <xsl:apply-templates mode="forward" />
+ </Viewbox>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- SVG and groups
+(including layers) -->
+<xsl:template mode="forward" match="*[name(.) = 'svg' or name(.) = 'g']">
+ <xsl:choose>
+ <xsl:when test="name(.) = 'svg' or @transform or @viewBox or @id or @clip-path or (@style and contains(@style, 'clip-path:url(#')) or (@width and not(contains(@width, '%'))) or @x or @y or (@height and not(contains(@height, '%'))) or *[name(.) = 'linearGradient' or name(.) = 'radialGradient' or name(.) = 'defs' or name(.) = 'clipPath']">
+ <Canvas>
+ <xsl:apply-templates mode="id" select="." />
+ <!--
+ <xsl:apply-templates mode="clip" select="." />
+ -->
+ <xsl:if test="@style and contains(@style, 'display:none')"><xsl:attribute name="Visibility">Collapsed</xsl:attribute></xsl:if>
+ <xsl:if test="@style and contains(@style, 'opacity:')">
+ <xsl:attribute name="Opacity">
+ <xsl:choose>
+ <xsl:when test="contains(substring-after(@style, 'opacity:'), ';')"><xsl:value-of select="substring-before(substring-after(@style, 'opacity:'), ';')" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="substring-after(@style, 'opacity:')" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@width and not(contains(@width, '%'))">
+ <xsl:attribute name="Width">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@width" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@height and not(contains(@height, '%'))">
+ <xsl:attribute name="Height">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@height" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@x">
+ <xsl:attribute name="Canvas.Left">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@x" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@y">
+ <xsl:attribute name="Canvas.Top">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@y" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@viewBox">
+ <xsl:variable name="viewBox"><xsl:value-of select="normalize-space(translate(@viewBox, ',', ' '))" /></xsl:variable>
+ <xsl:attribute name="Width"><xsl:value-of select="substring-before(substring-after(substring-after($viewBox, ' '), ' '), ' ')" /></xsl:attribute>
+ <xsl:attribute name="Height"><xsl:value-of select="substring-after(substring-after(substring-after($viewBox, ' '), ' '), ' ')" /></xsl:attribute>
+ <Canvas.RenderTransform>
+ <TranslateTransform>
+ <xsl:attribute name="X"><xsl:value-of select="-number(substring-before($viewBox, ' '))" /></xsl:attribute>
+ <xsl:attribute name="Y"><xsl:value-of select="-number(substring-before(substring-after($viewBox, ' '), ' '))" /></xsl:attribute>
+ </TranslateTransform>
+ </Canvas.RenderTransform>
+ </xsl:if>
+ <xsl:if test="@transform">
+ <Canvas>
+ <Canvas.RenderTransform>
+ <TransformGroup><xsl:apply-templates mode="transform" select="." /></TransformGroup>
+ </Canvas.RenderTransform>
+ <xsl:apply-templates mode="forward" select="*" />
+ </Canvas>
+ </xsl:if>
+
+ <xsl:if test="*[name(.) = 'linearGradient' or name(.) = 'radialGradient' or name(.) = 'defs' or name(.) = 'clipPath']">
+ <Canvas.Resources>
+ <xsl:apply-templates mode="forward" select="*[name(.) = 'linearGradient' or name(.) = 'radialGradient' or name(.) = 'defs' or name(.) = 'clipPath']" />
+ </Canvas.Resources>
+ </xsl:if>
+ <xsl:if test="not(@transform)">
+ <xsl:apply-templates mode="forward" select="*[name(.) != 'linearGradient' and name(.) != 'radialGradient' and name(.) != 'defs' and name(.) != 'clipPath']" />
+ </xsl:if>
+ </Canvas>
+ </xsl:when>
+ <xsl:when test="not(@transform)">
+ <xsl:apply-templates mode="forward" select="*" />
+ </xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!--
+// Resources (defs) //
+
+* Resources ids
+* Generic defs template
+* Generic filters template
+* Filter effects
+* Linked filter effects
+* Linear gradients
+* Radial gradients
+* Generic gradient stops
+* Clipping
+-->
+
+<!-- Resources ids -->
+<xsl:template mode="resources" match="*">
+ <!-- should be in-depth -->
+ <xsl:if test="ancestor::*[name(.) = 'defs']"><xsl:attribute name="x:Key"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
+</xsl:template>
+
+<!-- Generic defs template -->
+<xsl:template mode="forward" match="defs">
+ <xsl:apply-templates mode="forward" />
+</xsl:template>
+
+<!-- Generic filters template
+Limited to one filter (can be improved) -->
+<xsl:template mode="forward" match="*[name(.) = 'filter']">
+ <xsl:if test="count(*) = 1">
+ <xsl:apply-templates mode="forward" />
+ </xsl:if>
+</xsl:template>
+
+<!-- Filter effects -->
+<xsl:template mode="forward" match="*[name(.) = 'feGaussianBlur']">
+ <BlurEffect>
+ <xsl:if test="../@id"><xsl:attribute name="x:Key"><xsl:value-of select="../@id" /></xsl:attribute></xsl:if>
+ <xsl:if test="@stdDeviation"><xsl:attribute name="Radius"><xsl:value-of select="round(@stdDeviation * 3)" /></xsl:attribute></xsl:if>
+ </BlurEffect>
+</xsl:template>
+
+<!-- Linked filter effect -->
+<xsl:template mode="filter_effect" match="*">
+<xsl:choose>
+ <xsl:when test="@filter and starts-with(@filter, 'url(#')">
+ <xsl:attribute name="Effect">
+ <xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@filter, 'url(#'), ')'), '}')" />
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@style and contains(@style, 'filter:url(#')">
+ <xsl:attribute name="Effect">
+ <xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@style, 'filter:url(#'), ')'), '}')" />
+ </xsl:attribute>
+ </xsl:when>
+</xsl:choose>
+</xsl:template>
+
+<!-- Linear gradient -->
+<xsl:template mode="forward" match="*[name(.) = 'linearGradient']">
+ <LinearGradientBrush>
+ <xsl:if test="@id"><xsl:attribute name="x:Key"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
+ <xsl:attribute name="MappingMode">
+ <xsl:choose>
+ <xsl:when test="@gradientUnits = 'userSpaceOnUse' ">Absolute</xsl:when>
+ <xsl:otherwise>RelativeToBoundingBox</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:if test="@spreadMethod">
+ <xsl:attribute name="SpreadMethod">
+ <xsl:choose>
+ <xsl:when test="@spreadMethod = 'pad'">Pad</xsl:when>
+ <xsl:when test="@spreadMethod = 'reflect'">Reflect</xsl:when>
+ <xsl:when test="@spreadMethod = 'repeat'">Repeat</xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="@x1 and @y1 and @x2 and @y2">
+ <xsl:choose>
+ <xsl:when test="contains(@x1, '%') and contains(@y1, '%')">
+ <xsl:attribute name="StartPoint"><xsl:value-of select="concat(substring-before(@x1, '%') div 100, ',', substring-before(@y1,'%') div 100)" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="StartPoint"><xsl:value-of select="concat(@x1, ',', @y1)" /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="contains(@x2, '%') and contains(@y2, '%')">
+ <xsl:attribute name="EndPoint"><xsl:value-of select="concat(substring-before(@x2, '%') div 100, ',', substring-before(@y2,'%') div 100)" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="EndPoint"><xsl:value-of select="concat(@x2, ',', @y2)" /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="StartPoint"><xsl:value-of select="'0,0'" /></xsl:attribute>
+ <xsl:attribute name="EndPoint"><xsl:value-of select="'1,1'" /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ <LinearGradientBrush.GradientStops>
+ <GradientStopCollection>
+ <xsl:choose>
+ <xsl:when test="@xlink:href">
+ <xsl:variable name="reference_id" select="@xlink:href" />
+ <xsl:apply-templates mode="forward" select="//*[name(.) = 'linearGradient' and $reference_id = concat('#', @id)]/*" />
+ </xsl:when>
+ <xsl:otherwise><xsl:apply-templates mode="forward" /></xsl:otherwise>
+ </xsl:choose>
+ </GradientStopCollection>
+ </LinearGradientBrush.GradientStops>
+ <xsl:if test="@gradientTransform">
+ <LinearGradientBrush.Transform>
+ <xsl:apply-templates mode="transform" select="." />
+ </LinearGradientBrush.Transform>
+ </xsl:if>
+ </LinearGradientBrush>
+</xsl:template>
+
+<!-- Radial gradient -->
+<xsl:template mode="forward" match="*[name(.) = 'radialGradient']">
+ <RadialGradientBrush>
+ <xsl:if test="@id"><xsl:attribute name="x:Key"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
+ <xsl:attribute name="MappingMode">
+ <xsl:choose>
+ <xsl:when test="@gradientUnits = 'userSpaceOnUse' ">Absolute</xsl:when>
+ <xsl:otherwise>RelativeToBoundingBox</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:if test="@spreadMethod">
+ <xsl:attribute name="SpreadMethod">
+ <xsl:choose>
+ <xsl:when test="@spreadMethod = 'pad'">Pad</xsl:when>
+ <xsl:when test="@spreadMethod = 'reflect'">Reflect</xsl:when>
+ <xsl:when test="@spreadMethod = 'repeat'">Repeat</xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@cx and @cy">
+ <xsl:attribute name="Center">
+ <xsl:choose>
+ <xsl:when test="contains(@cx, '%') and contains(@cy, '%')">
+ <xsl:value-of select="concat(number(substring-before(@cx, '%')) div 100, ',', number(substring-before(@cy, '%')) div 100)" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat(@cx, ',', @cy)" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@fx and @fy">
+ <xsl:attribute name="GradientOrigin">
+ <xsl:choose>
+ <xsl:when test="contains(@fx, '%') and contains(@fy, '%')">
+ <xsl:value-of select="concat(number(substring-before(@fx, '%')) div 100, ',', number(substring-before(@fy, '%')) div 100)" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat(@fx, ',', @fy)" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@r">
+ <xsl:choose>
+ <xsl:when test="contains(@r, '%')">
+ <xsl:attribute name="RadiusX"><xsl:value-of select="number(substring-before(@r, '%')) div 100" /></xsl:attribute>
+ <xsl:attribute name="RadiusY"><xsl:value-of select="number(substring-before(@r, '%')) div 100" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="RadiusX"><xsl:value-of select="@r" /></xsl:attribute>
+ <xsl:attribute name="RadiusY"><xsl:value-of select="@r" /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ <RadialGradientBrush.GradientStops>
+ <GradientStopCollection>
+ <xsl:choose>
+ <xsl:when test="@xlink:href">
+ <xsl:variable name="reference_id" select="@xlink:href" />
+ <xsl:apply-templates mode="forward" select="//*[name(.) = 'linearGradient' and $reference_id = concat('#', @id)]/*" />
+ </xsl:when>
+ <xsl:otherwise><xsl:apply-templates mode="forward" /></xsl:otherwise>
+ </xsl:choose>
+ </GradientStopCollection>
+ </RadialGradientBrush.GradientStops>
+ <xsl:if test="@gradientTransform">
+ <RadialGradientBrush.Transform>
+ <xsl:apply-templates mode="transform" select="." />
+ </RadialGradientBrush.Transform>
+ </xsl:if>
+ </RadialGradientBrush>
+</xsl:template>
+
+<!-- Generic gradient stops -->
+<xsl:template mode="forward" match="*[name(.) = 'stop']">
+ <GradientStop>
+ <!--xsl:apply-templates mode="stop_opacity" select="." /-->
+ <xsl:apply-templates mode="stop_color" select="." />
+ <xsl:apply-templates mode="offset" select="." />
+ <xsl:apply-templates mode="forward" />
+ </GradientStop>
+</xsl:template>
+
+<!-- Clipping -->
+<xsl:template mode="clip" match="*">
+ <xsl:choose>
+ <xsl:when test="@clip-path and defs/clipPath/path/@d"><xsl:attribute name="Clip"><xsl:value-of select="defs/clipPath/path/@d" /></xsl:attribute></xsl:when>
+ <xsl:when test="@clip-path and starts-with(@clip-path, 'url(#')"><xsl:attribute name="Clip"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@clip-path, 'url(#'), ')'), '}')" /></xsl:attribute></xsl:when>
+ <xsl:when test="@style and contains(@style, 'clip-path:url(#')"><xsl:attribute name="Clip"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@style, 'url(#'), ')'), '}')" /></xsl:attribute></xsl:when>
+ <xsl:when test="clipPath"><xsl:apply-templates mode="forward" /></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!--
+// Misc templates //
+
+* Object description
+* Id converter
+* Decimal to hexadecimal converter
+* Unit to pixel converter
+* Title and description
+* Misc ignored stuff (markers, patterns, styles)
+* Symbols
+* Use
+* RDF and foreign objects
+* Unknows tags
+-->
+
+<!-- Object description -->
+<xsl:template mode="desc" match="*">
+ <xsl:if test="*[name(.) = 'desc']/text()"><xsl:attribute name="Tag"><xsl:value-of select="*[name(.) = 'desc']/text()" /></xsl:attribute></xsl:if>
+</xsl:template>
+
+<!-- Id converter. Removes "-" from the original id. -->
+<xsl:template mode="id" match="*">
+<xsl:if test="@id">
+ <xsl:attribute name="Name"><xsl:value-of select="translate(@id, '- ', '')" /></xsl:attribute>
+ <!--
+ <xsl:attribute name="x:Key"><xsl:value-of select="translate(@id, '- ', '')" /></xsl:attribute>
+ -->
+</xsl:if>
+</xsl:template>
+
+<!-- Decimal to hexadecimal converter -->
+<xsl:template name="to_hex">
+ <xsl:param name="convert" />
+ <xsl:value-of select="concat(substring('0123456789ABCDEF', 1 + floor(round($convert) div 16), 1), substring('0123456789ABCDEF', 1 + round($convert) mod 16, 1))" />
+</xsl:template>
+
+<!-- Unit to pixel converter
+Values with units (except %) are converted to pixels and rounded.
+Unknown units are kept. -->
+<xsl:template name="convert_unit">
+ <xsl:param name="convert_value" />
+ <xsl:choose>
+ <xsl:when test="contains($convert_value, 'px')">
+ <xsl:value-of select="round(translate($convert_value, 'px', ''))" />
+ </xsl:when>
+ <xsl:when test="contains($convert_value, 'pt')">
+ <xsl:value-of select="round(translate($convert_value, 'pt', '') * 1.25)" />
+ </xsl:when>
+ <xsl:when test="contains($convert_value, 'pc')">
+ <xsl:value-of select="round(translate($convert_value, 'pc', '') * 15)" />
+ </xsl:when>
+ <xsl:when test="contains($convert_value, 'mm')">
+ <xsl:value-of select="round(translate($convert_value, 'mm', '') * 3.543307)" />
+ </xsl:when>
+ <xsl:when test="contains($convert_value, 'cm')">
+ <xsl:value-of select="round(translate($convert_value, 'cm', '') * 35.43307)" />
+ </xsl:when>
+ <xsl:when test="contains($convert_value, 'in')">
+ <xsl:value-of select="round(translate($convert_value, 'in', '') * 90)" />
+ </xsl:when>
+ <xsl:when test="contains($convert_value, 'ft')">
+ <xsl:value-of select="round(translate($convert_value, 'ft', '') * 1080)" />
+ </xsl:when>
+ <xsl:when test="not(string(number($convert_value))='NaN')">
+ <xsl:value-of select="round($convert_value)" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$convert_value" />
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Title and description
+Blank template. Title is ignored and desc is converted to Tag in the mode="desc" template
+-->
+<xsl:template mode="forward" match="*[name(.) = 'title' or name(.) = 'desc']">
+ <!-- -->
+</xsl:template>
+
+<!-- Misc ignored stuff (markers, patterns, styles) -->
+<xsl:template mode="forward" match="*[name(.) = 'marker' or name(.) = 'pattern' or name(.) = 'style']">
+ <!-- -->
+</xsl:template>
+
+<!-- Symbols -->
+<xsl:template mode="forward" match="*[name(.) = 'symbol']">
+ <Style>
+ <xsl:if test="@id"><xsl:attribute name="x:Key"><xsl:value-of select="@id" /></xsl:attribute></xsl:if>
+ <Canvas>
+ <xsl:apply-templates mode="forward" />
+ </Canvas>
+ </Style>
+</xsl:template>
+
+<!-- Use -->
+<xsl:template mode="forward" match="*[name(.) = 'use']">
+ <Canvas>
+ <xsl:if test="@xlink:href"><xsl:attribute name="Style"><xsl:value-of select="@xlink:href" /></xsl:attribute></xsl:if>
+ <!--xsl:apply-templates mode="transform" select="." /-->
+ <xsl:apply-templates mode="forward" />
+ </Canvas>
+</xsl:template>
+
+<!-- RDF and foreign objects -->
+<xsl:template mode="forward" match="rdf:RDF | *[name(.) = 'foreignObject']">
+ <!-- -->
+</xsl:template>
+
+<!-- Unknown tags -->
+<xsl:template match="*">
+<xsl:comment><xsl:value-of select="concat('Unknown tag: ', name(.))" /></xsl:comment>
+</xsl:template>
+
+
+<!--
+// Colors and patterns //
+
+* Generic color template
+* Fill
+* Fill opacity
+* Fill rule
+* Generic fill template
+* Stroke
+* Stroke opacity
+* Generic stroke template
+* Stroke width
+* Stroke mitterlimit
+* Stroke dasharray
+* Stroke dashoffset
+* Linejoin SVG to XAML converter
+* Stroke linejoin
+* Linecap SVG to XAML converter
+* Stroke linecap
+* Gradient stop
+* Gradient stop opacity
+* Gradient stop offset
+-->
+
+<!-- Generic color template -->
+<xsl:template name="template_color">
+ <xsl:param name="colorspec" />
+ <xsl:param name="opacityspec" />
+ <xsl:choose>
+ <xsl:when test="starts-with($colorspec, 'rgb(') and not(contains($colorspec , '%'))">
+ <xsl:value-of select="'#'" />
+ <xsl:if test="$opacityspec != '' and number($opacityspec) != 1"><xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="round(number($opacityspec) * 255)" /></xsl:with-param></xsl:call-template></xsl:if>
+ <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="substring-before(substring-after($colorspec, 'rgb('), ',')" /></xsl:with-param></xsl:call-template>
+ <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="substring-before(substring-after(substring-after($colorspec, 'rgb('), ','), ',')" /></xsl:with-param></xsl:call-template>
+ <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="substring-before(substring-after(substring-after(substring-after($colorspec, 'rgb('), ','), ','), ')')" /></xsl:with-param></xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($colorspec, 'rgb(') and contains($colorspec , '%')">
+ <xsl:value-of select="'#'" />
+ <xsl:if test="$opacityspec != '' and number($opacityspec) != 1"><xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="round(number($opacityspec) * 255)" /></xsl:with-param></xsl:call-template></xsl:if>
+ <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="number(substring-before(substring-after($colorspec, 'rgb('), '%,')) * 255 div 100" /></xsl:with-param></xsl:call-template>
+ <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="number(substring-before(substring-after(substring-after($colorspec, 'rgb('), ','), '%,')) * 255 div 100" /></xsl:with-param></xsl:call-template>
+ <xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="number(substring-before(substring-after(substring-after(substring-after($colorspec, 'rgb('), ','), ','), '%)')) * 255 div 100" /></xsl:with-param></xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($colorspec, '#')">
+ <xsl:value-of select="'#'" />
+ <xsl:if test="$opacityspec != ''"><xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="round(number($opacityspec) * 255)" /></xsl:with-param></xsl:call-template></xsl:if>
+ <xsl:choose>
+ <xsl:when test="string-length(substring-after($colorspec, '#')) = 3">
+ <xsl:variable name="colorspec3"><xsl:value-of select="translate(substring-after($colorspec, '#'), 'abcdefgh', 'ABCDEFGH')" /></xsl:variable>
+ <xsl:value-of select="concat(substring($colorspec3, 1, 1), substring($colorspec3, 1, 1))" />
+ <xsl:value-of select="concat(substring($colorspec3, 2, 1), substring($colorspec3, 2, 1))" />
+ <xsl:value-of select="concat(substring($colorspec3, 3, 1), substring($colorspec3, 3, 1))" />
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="translate(substring-after($colorspec, '#'), 'abcdefgh', 'ABCDEFGH')" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="named_color_hex" select="document('colors.xml')/colors/color[@name = translate($colorspec, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')]/@hex" />
+ <xsl:choose>
+ <xsl:when test="$named_color_hex and $named_color_hex != ''">
+ <xsl:value-of select="'#'" />
+ <xsl:if test="$opacityspec != '' and number($opacityspec) != 1"><xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="number($opacityspec) * 255" /></xsl:with-param></xsl:call-template></xsl:if>
+ <xsl:value-of select="substring-after($named_color_hex, '#')" />
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$colorspec" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Fill -->
+<xsl:template mode="fill" match="*">
+ <xsl:choose>
+ <xsl:when test="@fill and starts-with(@fill, 'url(#')"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@fill, 'url(#'), ')'), '}')" /></xsl:when>
+ <xsl:when test="@fill"><xsl:value-of select="@fill" /></xsl:when>
+ <xsl:when test="@style and contains(@style, 'fill:') and starts-with(substring-after(@style, 'fill:'), 'url(#')"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@style, 'url(#'), ')'), '}')" /></xsl:when>
+ <xsl:when test="@style and contains(@style, 'fill:')">
+ <xsl:variable name="Fill" select="substring-after(@style, 'fill:')" />
+ <xsl:choose>
+ <xsl:when test="contains($Fill, ';')">
+ <xsl:value-of select="substring-before($Fill, ';')" />
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$Fill" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="fill" select="parent::*"/></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Fill opacity -->
+<xsl:template mode="fill_opacity" match="*">
+ <xsl:choose>
+ <xsl:when test="@fill-opacity"><xsl:value-of select="@fill-opacity" /></xsl:when>
+ <xsl:when test="@style and contains(@style, 'fill-opacity:')">
+ <xsl:variable name="Opacity" select="substring-after(@style, 'fill-opacity:')" />
+ <xsl:choose>
+ <xsl:when test="contains($Opacity, ';')"><xsl:value-of select="substring-before($Opacity, ';')" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$Opacity" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="fill_opacity" select="parent::*" /></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Fill rule -->
+<xsl:template mode="fill_rule" match="*">
+ <xsl:choose>
+ <xsl:when test="@fill-rule and (@fill-rule = 'nonzero' or @fill-rule = 'evenodd')"><xsl:attribute name="FillRule"><xsl:value-of select="@fill-rule" /></xsl:attribute></xsl:when>
+ <xsl:when test="@style and contains(@style, 'fill-rule:')">
+ <xsl:variable name="FillRule" select="substring-after(@style, 'fill-rule:')" />
+ <xsl:choose>
+ <xsl:when test="contains($FillRule, ';')">
+ <xsl:if test="substring-before($FillRule, ';') = 'nonzero' or substring-before($FillRule, ';') = 'evenodd'"><xsl:attribute name="FillRule"><xsl:value-of select="substring-before($FillRule, ';')" /></xsl:attribute></xsl:if>
+ </xsl:when>
+ <xsl:when test="$FillRule = 'nonzero' or $FillRule = 'evenodd'"><xsl:attribute name="FillRule"><xsl:value-of select="$FillRule" /></xsl:attribute></xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="fill_rule" select="parent::*"/></xsl:when>
+ <xsl:otherwise><xsl:attribute name="FillRule">NonZero</xsl:attribute></xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Generic fill template -->
+<xsl:template mode="template_fill" match="*">
+ <xsl:variable name="fill"><xsl:apply-templates mode="fill" select="." /></xsl:variable>
+ <xsl:variable name="fill_opacity"><xsl:apply-templates mode="fill_opacity" select="." /></xsl:variable>
+ <xsl:if test="not($fill = 'none')">
+ <xsl:attribute name="Fill">
+ <xsl:choose>
+ <xsl:when test="$fill != ''">
+ <xsl:call-template name="template_color">
+ <xsl:with-param name="colorspec">
+ <xsl:if test="$fill != 'none'"><xsl:value-of select="$fill" /></xsl:if>
+ </xsl:with-param>
+ <xsl:with-param name="opacityspec"><xsl:value-of select="$fill_opacity" /></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>#000000</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+</xsl:template>
+
+<!-- Stroke -->
+<xsl:template mode="stroke" match="*">
+ <xsl:choose>
+ <xsl:when test="@stroke and starts-with(@stroke, 'url(#')"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@stroke, 'url(#'), ')'), '}')" /></xsl:when>
+ <xsl:when test="@stroke and @stroke != 'none'"><xsl:value-of select="@stroke" /></xsl:when>
+ <xsl:when test="@style and contains(@style, 'stroke:') and starts-with(substring-after(@style, 'stroke:'), 'url(#')"><xsl:value-of select="concat('{StaticResource ', substring-before(substring-after(@style, 'url(#'), ')'), '}')" /></xsl:when>
+ <xsl:when test="@style and contains(@style, 'stroke:')">
+ <xsl:variable name="Stroke" select="substring-after(@style, 'stroke:')" />
+ <xsl:choose>
+ <xsl:when test="contains($Stroke, ';')">
+ <xsl:if test="substring-before($Stroke, ';') != 'none'"><xsl:value-of select="substring-before($Stroke, ';')" /></xsl:if>
+ </xsl:when>
+ <xsl:when test="$Stroke != 'none'"><xsl:value-of select="$Stroke" /></xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke" select="parent::*"/></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Stroke opacity -->
+<xsl:template mode="stroke_opacity" match="*">
+ <xsl:choose>
+ <xsl:when test="@stroke-opacity"><xsl:value-of select="@stroke-opacity" /></xsl:when>
+ <xsl:when test="@style and contains(@style, 'stroke-opacity:')">
+ <xsl:variable name="Opacity" select="substring-after(@style, 'stroke-opacity:')" />
+ <xsl:choose>
+ <xsl:when test="contains($Opacity, ';')"><xsl:value-of select="substring-before($Opacity, ';')" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$Opacity" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_opacity" select="parent::*" /></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Generic stroke template -->
+<xsl:template mode="template_stroke" match="*">
+ <xsl:variable name="stroke"><xsl:apply-templates mode="stroke" select="." /></xsl:variable>
+ <xsl:variable name="stroke_opacity"><xsl:apply-templates mode="stroke_opacity" select="." /></xsl:variable>
+ <xsl:if test="$stroke != ''">
+ <xsl:attribute name="Stroke">
+ <xsl:call-template name="template_color">
+ <xsl:with-param name="colorspec"><xsl:value-of select="$stroke" /></xsl:with-param>
+ <xsl:with-param name="opacityspec"><xsl:value-of select="$stroke_opacity" /></xsl:with-param>
+ </xsl:call-template>
+ </xsl:attribute>
+ </xsl:if>
+</xsl:template>
+
+<!-- Stroke width -->
+<xsl:template mode="stroke_width" match="*">
+ <xsl:choose>
+ <xsl:when test="@stroke-width">
+ <xsl:attribute name="StrokeThickness"><xsl:value-of select="@stroke-width" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@style and contains(@style, 'stroke-width:')">
+ <xsl:attribute name="StrokeThickness">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value">
+ <xsl:choose>
+ <xsl:when test="contains(substring-after(@style, 'stroke-width:'), ';')"><xsl:value-of select="substring-before(substring-after(@style, 'stroke-width:'), ';')" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="substring-after(@style, 'stroke-width:')" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_width" select="parent::*"/></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Stroke miterlimit -->
+<xsl:template mode="stroke_miterlimit" match="*">
+ <xsl:choose>
+ <xsl:when test="@stroke-miterlimit"><xsl:attribute name="StrokeMiterLimit"><xsl:value-of select="@stroke-miterlimit" /></xsl:attribute></xsl:when>
+ <xsl:when test="@style and contains(@style, 'stroke-miterlimit:')">
+ <xsl:variable name="StrokeMiterLimit" select="substring-after(@style, 'stroke-miterlimit:')" />
+ <xsl:attribute name="StrokeMiterLimit">
+ <xsl:choose>
+ <xsl:when test="contains($StrokeMiterLimit, ';')"><xsl:value-of select="substring-before($StrokeMiterLimit, ';')" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$StrokeMiterLimit" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_miterlimit" select="parent::*"/></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Stroke dasharray -->
+<xsl:template mode="stroke_dasharray" match="*">
+ <!-- stroke-dasharray="10,30,20,30" becomes StrokeDashArray="1 3 2 3" ?? -->
+ <xsl:choose>
+ <xsl:when test="@stroke-dasharray and @stroke-dasharray != 'none'"><xsl:attribute name="StrokeDashArray"><xsl:value-of select="@stroke-dasharray" /></xsl:attribute></xsl:when>
+ <xsl:when test="@style and contains(@style, 'stroke-dasharray:')">
+ <xsl:variable name="StrokeDashArray" select="substring-after(@style, 'stroke-dasharray:')" />
+ <xsl:choose>
+ <xsl:when test="contains($StrokeDashArray, ';')">
+ <xsl:if test="substring-before($StrokeDashArray, ';') != 'none'"><xsl:attribute name="StrokeDashArray"><xsl:value-of select="substring-before($StrokeDashArray, ';')" /></xsl:attribute></xsl:if>
+ </xsl:when>
+ <xsl:when test="$StrokeDashArray != 'none'"><xsl:attribute name="StrokeDashArray"><xsl:value-of select="$StrokeDashArray" /></xsl:attribute></xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_dasharray" select="parent::*"/></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Stroke dashoffset -->
+<xsl:template mode="stroke_dashoffset" match="*">
+ <xsl:choose>
+ <xsl:when test="@stroke-dashoffset"><xsl:attribute name="StrokeDashOffset"><xsl:value-of select="@stroke-dashoffset" /></xsl:attribute></xsl:when>
+ <xsl:when test="@style and contains(@style, 'stroke-dashoffset:')">
+ <xsl:variable name="StrokeDashOffset" select="substring-after(@style, 'stroke-dashoffset:')" />
+ <xsl:attribute name="StrokeDashOffset">
+ <xsl:choose>
+ <xsl:when test="contains($StrokeDashOffset, ';')"><xsl:value-of select="substring-before($StrokeDashOffset, ';')" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$StrokeDashOffset" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_dashoffset" select="parent::*"/></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Linejoin SVG to XAML converter -->
+<xsl:template name="linejoin_svg_to_xaml">
+ <xsl:param name="linejoin" />
+ <xsl:choose>
+ <xsl:when test="$linejoin = 'bevel'">Bevel</xsl:when>
+ <xsl:when test="$linejoin = 'round'">Round</xsl:when>
+ <xsl:otherwise>Miter</xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Stroke linejoin -->
+<xsl:template mode="stroke_linejoin" match="*">
+ <xsl:choose>
+ <xsl:when test="@stroke-miterlimit">
+ <xsl:attribute name="StrokeLineJoin">
+ <xsl:call-template name="linejoin_svg_to_xaml"><xsl:with-param name="linejoin"><xsl:value-of select="@stroke-linejoin" /></xsl:with-param></xsl:call-template>
+ </xsl:attribute></xsl:when>
+ <xsl:when test="@style and contains(@style, 'stroke-linejoin:')">
+ <xsl:variable name="StrokeLineJoin" select="substring-after(@style, 'stroke-linejoin:')" />
+ <xsl:attribute name="StrokeLineJoin">
+ <xsl:choose>
+ <xsl:when test="contains($StrokeLineJoin, ';')">
+ <xsl:call-template name="linejoin_svg_to_xaml"><xsl:with-param name="linejoin"><xsl:value-of select="substring-before($StrokeLineJoin, ';')" /></xsl:with-param></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="linejoin_svg_to_xaml"><xsl:with-param name="linejoin"><xsl:value-of select="$StrokeLineJoin" /></xsl:with-param></xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_linejoin" select="parent::*"/></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Linecap SVG to XAML converter -->
+<xsl:template name="linecap_svg_to_xaml">
+ <xsl:param name="linecap" />
+ <xsl:choose>
+ <xsl:when test="$linecap = 'round'">Round</xsl:when>
+ <xsl:when test="$linecap = 'square'">Square</xsl:when>
+ <xsl:otherwise>Flat</xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Stroke linecap -->
+<xsl:template mode="stroke_linecap" match="*">
+ <xsl:choose>
+ <xsl:when test="@stroke-linecap">
+ <xsl:attribute name="StrokeStartLineCap">
+ <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="@stroke-linecap" /></xsl:with-param></xsl:call-template>
+ </xsl:attribute>
+ <xsl:attribute name="StrokeEndLineCap">
+ <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="@stroke-linecap" /></xsl:with-param></xsl:call-template>
+ </xsl:attribute></xsl:when>
+ <xsl:when test="@style and contains(@style, 'stroke-linecap:')">
+ <xsl:variable name="StrokeStartLineCap" select="substring-after(@style, 'stroke-linecap:')" />
+ <xsl:variable name="StrokeEndLineCap" select="substring-after(@style, 'stroke-linecap:')" />
+ <xsl:attribute name="StrokeStartLineCap">
+ <xsl:choose>
+ <xsl:when test="contains($StrokeStartLineCap, ';')">
+ <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="substring-before($StrokeStartLineCap, ';')" /></xsl:with-param></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="$StrokeStartLineCap" /></xsl:with-param></xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:attribute name="StrokeEndLineCap">
+ <xsl:choose>
+ <xsl:when test="contains($StrokeEndLineCap, ';')">
+ <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="substring-before($StrokeEndLineCap, ';')" /></xsl:with-param></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="linecap_svg_to_xaml"><xsl:with-param name="linecap"><xsl:value-of select="$StrokeEndLineCap" /></xsl:with-param></xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stroke_linecap" select="parent::*"/></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Gradient stops -->
+<xsl:template mode="stop_color" match="*">
+ <xsl:variable name="Opacity">
+ <xsl:choose>
+ <xsl:when test="@stop-opacity"><xsl:value-of select="@stop-opacity" /></xsl:when>
+ <xsl:when test="@style and contains(@style, 'stop-opacity:')">
+ <xsl:variable name="temp_opacity" select="substring-after(@style, 'stop-opacity:')" />
+ <xsl:choose>
+ <xsl:when test="contains($temp_opacity, ';')"><xsl:value-of select="substring-before($temp_opacity, ';')" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$temp_opacity" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="''" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="hex_opacity">
+ <xsl:choose>
+ <xsl:when test="$Opacity != ''"><xsl:call-template name="to_hex"><xsl:with-param name="convert"><xsl:value-of select="number($Opacity) * 255" /></xsl:with-param></xsl:call-template> </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$Opacity" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="stopcolor">
+ <xsl:choose>
+ <xsl:when test="@stop-color">
+ <xsl:call-template name="template_color"><xsl:with-param name="colorspec"><xsl:value-of select="@stop-color" /></xsl:with-param></xsl:call-template>
+ </xsl:when>
+ <xsl:when test="@style and contains(@style, 'stop-color:')">
+ <xsl:variable name="Color" select="substring-after(@style, 'stop-color:')" />
+ <xsl:choose>
+ <xsl:when test="contains($Color, ';')">
+ <xsl:call-template name="template_color"><xsl:with-param name="colorspec"><xsl:value-of select="substring-before($Color, ';')" /></xsl:with-param></xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="template_color"><xsl:with-param name="colorspec"><xsl:value-of select="$Color" /></xsl:with-param></xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stop_color" select="parent::*"/></xsl:when>
+ <xsl:otherwise>#000</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:attribute name="Color">
+ <xsl:choose>
+ <xsl:when test="$hex_opacity != '' and starts-with($stopcolor, '#')"><xsl:value-of select="concat('#', $hex_opacity, substring-after($stopcolor, '#'))" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$stopcolor" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+</xsl:template>
+
+<!-- Gradient stop opacity -->
+<xsl:template mode="stop_opacity" match="*">
+ <xsl:choose>
+ <xsl:when test="@stop-opacity"><xsl:attribute name="Opacity"><xsl:value-of select="@stop-opacity" /></xsl:attribute></xsl:when>
+ <xsl:when test="@style and contains(@style, 'stop-opacity:')">
+ <xsl:variable name="Opacity" select="substring-after(@style, 'stop-opacity:')" />
+ <xsl:attribute name="Opacity">
+ <xsl:choose>
+ <xsl:when test="contains($Opacity, ';')"><xsl:value-of select="substring-before($Opacity, ';')" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$Opacity" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stop_opacity" select="parent::*"/></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Gradient stop offset -->
+<xsl:template mode="offset" match="*">
+ <xsl:choose>
+ <xsl:when test="@offset">
+ <xsl:attribute name="Offset">
+ <xsl:choose>
+ <xsl:when test="contains(@offset, '%')"><xsl:value-of select="number(substring-before(@offset, '%')) div 100" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="@offset" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@style and contains(@style, 'offset:')">
+ <xsl:variable name="Offset" select="substring-after(@style, 'offset:')" />
+ <xsl:attribute name="Offset">
+ <xsl:choose>
+ <xsl:when test="contains($Offset, '%')"><xsl:value-of select="number(substring-before($Offset, '%')) div 100" /></xsl:when>
+ <xsl:when test="contains($Offset, ';')"><xsl:value-of select="substring-before($Offset, ';')" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$Offset" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="name(..) = 'g' or name(..) = 'svg'"><xsl:apply-templates mode="stop_offset" select="parent::*"/></xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!--
+// Transforms //
+All the matrix, translate, rotate... stuff.
+Fixme: XAML transforms don't show the same result as SVG ones with the same values.
+
+* Parse transform
+* Apply transform
+* Apply transform v2
+-->
+
+<!-- Parse transform -->
+<xsl:template name="parse_transform">
+ <xsl:param name="input" />
+ <xsl:choose>
+ <xsl:when test="starts-with($input, 'matrix(')">
+ <MatrixTransform><xsl:attribute name="Matrix"><xsl:value-of select="substring-before(substring-after($input, 'matrix('), ')')" /></xsl:attribute></MatrixTransform>
+ <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($input, 'scale(')">
+ <ScaleTransform>
+ <xsl:variable name="scale" select="substring-before(substring-after($input, 'scale('), ')')" />
+ <xsl:choose>
+ <xsl:when test="contains($scale, ',')">
+ <xsl:attribute name="ScaleX"><xsl:value-of select="substring-before($scale, ',')" /></xsl:attribute>
+ <xsl:attribute name="ScaleY"><xsl:value-of select="substring-after($scale, ',')" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="ScaleX"><xsl:value-of select="$scale" /></xsl:attribute>
+ <xsl:attribute name="ScaleY"><xsl:value-of select="$scale" /></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </ScaleTransform>
+ <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($input, 'rotate(')">
+ <RotateTransform>
+ <xsl:attribute name="Angle"><xsl:value-of select="substring-before(substring-after($input, 'rotate('), ')')" /></xsl:attribute>
+ <xsl:if test="@rx"><xsl:attribute name="CenterX"><xsl:value-of select="@rx" /></xsl:attribute></xsl:if>
+ <xsl:if test="@ry"><xsl:attribute name="CenterY"><xsl:value-of select="@ry" /></xsl:attribute></xsl:if>
+ </RotateTransform>
+ <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
+ </xsl:when>
+ <xsl:when test="starts-with($input, 'skewX(')">
+ <SkewTransform>
+ <xsl:attribute name="AngleX"><xsl:value-of select="substring-before(substring-after($input, 'skewX('), ')')" /></xsl:attribute>
+ <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
+ </SkewTransform>
+ </xsl:when>
+ <xsl:when test="starts-with($input, 'skewY(')">
+ <SkewTransform>
+ <xsl:attribute name="AngleY"><xsl:value-of select="substring-before(substring-after($input, 'skewY('), ')')" /></xsl:attribute>
+ <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
+ </SkewTransform>
+ </xsl:when>
+ <xsl:when test="starts-with($input, 'translate(')">
+ <TranslateTransform>
+ <xsl:variable name="translate" select="substring-before(substring-after($input, 'translate('), ')')" />
+ <xsl:choose>
+ <xsl:when test="contains($translate, ',')">
+ <xsl:attribute name="X"><xsl:value-of select="substring-before($translate, ',')" /></xsl:attribute>
+ <xsl:attribute name="Y"><xsl:value-of select="substring-after($translate, ',')" /></xsl:attribute>
+ </xsl:when>
+ <xsl:when test="contains($translate, ' ')">
+ <xsl:attribute name="X"><xsl:value-of select="substring-before($translate, ' ')" /></xsl:attribute>
+ <xsl:attribute name="Y"><xsl:value-of select="substring-after($translate, ' ')" /></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise><xsl:attribute name="X"><xsl:value-of select="$translate" /></xsl:attribute></xsl:otherwise>
+ </xsl:choose>
+ </TranslateTransform>
+ <xsl:call-template name="parse_transform"><xsl:with-param name="input" select="substring-after($input, ') ')" /></xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Apply transform -->
+<xsl:template mode="transform" match="*">
+ <xsl:param name="mapped_type" />
+ <xsl:if test="@transform or @gradientTransform">
+ <xsl:variable name="transform">
+ <xsl:choose>
+ <xsl:when test="@transform"><xsl:value-of select="@transform" /></xsl:when>
+ <xsl:otherwise><xsl:value-of select="@gradientTransform" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="transform_nodes">
+ <xsl:call-template name="parse_transform">
+ <xsl:with-param name="input" select="$transform" />
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:comment>
+ <xsl:value-of select="name(.)" />
+ </xsl:comment>
+
+ <xsl:choose>
+ <xsl:when test="$mapped_type and $mapped_type != ''">
+ <xsl:element name="{$mapped_type}.RenderTransform">
+ <xsl:choose>
+ <xsl:when test="count(libxslt:node-set($transform_nodes)/*) = 1"><xsl:copy-of select="libxslt:node-set($transform_nodes)" /></xsl:when>
+ <xsl:when test="count(libxslt:node-set($transform_nodes)/*) &gt; 1"><TransformGroup><xsl:copy-of select="libxslt:node-set($transform_nodes)" /></TransformGroup></xsl:when>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- For instance LinearGradient.Transform -->
+ <xsl:choose>
+ <xsl:when test="count(libxslt:node-set($transform_nodes)/*) = 1"><xsl:copy-of select="libxslt:node-set($transform_nodes)" /></xsl:when>
+ <xsl:when test="count(libxslt:node-set($transform_nodes)/*) &gt; 1"><TransformGroup><xsl:copy-of select="libxslt:node-set($transform_nodes)" /></TransformGroup></xsl:when>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:template>
+
+<!-- Apply transform v2
+Fixme: is this template still in use? -->
+<xsl:template mode="transform2" match="*">
+ <xsl:choose>
+ <xsl:when test="@transform">
+ <Canvas>
+ <Canvas.RenderTransform>
+ <TransformGroup><xsl:apply-templates mode="transform" select="." /></TransformGroup>
+ </Canvas.RenderTransform>
+ <xsl:apply-templates mode="forward" select="." />
+ </Canvas>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="forward" select="." />
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!--
+// Objects //
+
+* Image
+* Text
+* Lines
+* Rectangle
+* Polygon
+* Polyline
+* Path
+* Ellipse
+* Circle
+-->
+
+<!-- Image -->
+<xsl:template mode="forward" match="*[name(.) = 'image']">
+ <Image>
+ <xsl:apply-templates mode="id" select="." />
+ <xsl:if test="@x"><xsl:attribute name="Canvas.Left">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@x" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@y"><xsl:attribute name="Canvas.Top">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@y" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:apply-templates mode="desc" select="." />
+ <xsl:apply-templates mode="clip" select="." />
+ <xsl:if test="@xlink:href"><xsl:attribute name="Source"><xsl:value-of select="@xlink:href" /></xsl:attribute></xsl:if>
+ <xsl:if test="@width"><xsl:attribute name="Width">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@width" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@height"><xsl:attribute name="Height">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@height" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:apply-templates mode="transform" select=".">
+ <xsl:with-param name="mapped_type" select="'Image'" />
+ </xsl:apply-templates>
+ <!--xsl:apply-templates mode="transform" /-->
+ <xsl:apply-templates mode="forward" />
+ </Image>
+</xsl:template>
+
+<!-- Text -->
+<xsl:template mode="forward" match="*[name(.) = 'text']">
+ <TextBlock>
+ <xsl:if test="@font-size"><xsl:attribute name="FontSize"><xsl:value-of select="@font-size" /></xsl:attribute></xsl:if>
+ <xsl:if test="@style and contains(@style, 'font-size:')">
+ <xsl:variable name="font_size" select="substring-after(@style, 'font-size:')" />
+ <xsl:attribute name="FontSize">
+ <xsl:choose>
+ <xsl:when test="contains($font_size, ';')">
+ <xsl:value-of select="substring-before($font_size, ';')" />
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$font_size" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@font-weight"><xsl:attribute name="FontWeight"><xsl:value-of select="@font-weight" /></xsl:attribute></xsl:if>
+ <xsl:if test="@style and contains(@style, 'font-weight:')">
+ <xsl:variable name="font_weight" select="substring-after(@style, 'font-weight:')" />
+ <xsl:attribute name="FontWeight">
+ <xsl:choose>
+ <xsl:when test="contains($font_weight, ';')">
+ <xsl:value-of select="substring-before($font_weight, ';')" />
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$font_weight" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@font-family"><xsl:attribute name="FontFamily"><xsl:value-of select="@font-family" /></xsl:attribute></xsl:if>
+ <xsl:if test="@style and contains(@style, 'font-family:')">
+ <xsl:variable name="font_family" select="substring-after(@style, 'font-family:')" />
+ <xsl:attribute name="FontFamily">
+ <xsl:choose>
+ <xsl:when test="contains($font_family, ';')">
+ <xsl:value-of select="substring-before($font_family, ';')" />
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$font_family" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@font-style"><xsl:attribute name="FontStyle"><xsl:value-of select="@font-style" /></xsl:attribute></xsl:if>
+ <xsl:if test="@style and contains(@style, 'font-style:')">
+ <xsl:variable name="font_style" select="substring-after(@style, 'font-style:')" />
+ <xsl:attribute name="FontStyle">
+ <xsl:choose>
+ <xsl:when test="contains($font_style, ';')">
+ <xsl:value-of select="substring-before($font_style, ';')" />
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$font_style" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@fill"><xsl:attribute name="Foreground"><xsl:value-of select="@fill" /></xsl:attribute></xsl:if>
+ <xsl:if test="@style and contains(@style, 'fill')">
+ <xsl:variable name="fill" select="substring-after(@style, 'fill:')" />
+ <xsl:attribute name="Foreground">
+ <xsl:choose>
+ <xsl:when test="contains($fill, ';')">
+ <xsl:value-of select="substring-before($fill, ';')" />
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$fill" /></xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@text-anchor">
+ <xsl:attribute name="HorizontalAlignment">
+ <xsl:choose>
+ <xsl:when test="@text-anchor = 'start'">Left</xsl:when>
+ <xsl:when test="@text-anchor = 'middle'">Center</xsl:when>
+ <xsl:when test="@text-anchor = 'end'">Right</xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@width"><xsl:attribute name="Width">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@width" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@height"><xsl:attribute name="Height">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@height" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@x"><xsl:attribute name="Canvas.Left">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@x" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@y"><xsl:attribute name="Canvas.Top">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@y" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:apply-templates mode="id" select="." />
+ <xsl:apply-templates mode="filter_effect" select="." />
+ <xsl:apply-templates mode="desc" select="." />
+ <xsl:apply-templates mode="clip" select="." />
+ <!--xsl:apply-templates mode="transform" select="." /-->
+ <!--xsl:apply-templates mode="forward" /-->
+ <xsl:if test="text()"><xsl:value-of select="text()" /></xsl:if>
+ <xsl:if test="*[name(.) = 'tspan']/text()"><xsl:value-of select="*[name(.) = 'tspan']/text()" /></xsl:if>
+ </TextBlock>
+</xsl:template>
+
+<!-- Lines -->
+<xsl:template mode="forward" match="*[name(.) = 'line']">
+ <Line>
+ <xsl:if test="@x1"><xsl:attribute name="X1"><xsl:value-of select="@x1" /></xsl:attribute></xsl:if>
+ <xsl:if test="@y1"><xsl:attribute name="Y1"><xsl:value-of select="@y1" /></xsl:attribute></xsl:if>
+ <xsl:if test="@x2"><xsl:attribute name="X2"><xsl:value-of select="@x2" /></xsl:attribute></xsl:if>
+ <xsl:if test="@y2"><xsl:attribute name="Y2"><xsl:value-of select="@y2" /></xsl:attribute></xsl:if>
+ <xsl:apply-templates mode="id" select="." />
+ <xsl:apply-templates mode="template_fill" select="." />
+ <xsl:apply-templates mode="template_stroke" select="." />
+ <xsl:apply-templates mode="stroke_width" select="." />
+ <xsl:apply-templates mode="stroke_miterlimit" select="." />
+ <xsl:apply-templates mode="stroke_dasharray" select="." />
+ <xsl:apply-templates mode="stroke_dashoffset" select="." />
+ <xsl:apply-templates mode="stroke_linejoin" select="." />
+ <xsl:apply-templates mode="stroke_linecap" select="." />
+ <xsl:apply-templates mode="filter_effect" select="." />
+ <xsl:apply-templates mode="desc" select="." />
+
+ <xsl:apply-templates mode="transform" select=".">
+ <xsl:with-param name="mapped_type" select="'Line'" />
+ </xsl:apply-templates>
+
+ <xsl:apply-templates mode="forward" />
+ </Line>
+</xsl:template>
+
+<!-- Rectangle -->
+<xsl:template mode="forward" match="*[name(.) = 'rect']">
+ <Rectangle>
+ <xsl:if test="@x"><xsl:attribute name="Canvas.Left">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@x" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@y"><xsl:attribute name="Canvas.Top">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@y" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@width"><xsl:attribute name="Width">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@width" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@height"><xsl:attribute name="Height">
+ <xsl:call-template name="convert_unit">
+ <xsl:with-param name="convert_value" select="@height" />
+ </xsl:call-template>
+ </xsl:attribute></xsl:if>
+ <xsl:if test="@rx"><xsl:attribute name="RadiusX"><xsl:value-of select="@rx" /></xsl:attribute></xsl:if>
+ <xsl:if test="@ry"><xsl:attribute name="RadiusY"><xsl:value-of select="@ry" /></xsl:attribute></xsl:if>
+ <xsl:if test="@rx and not(@ry)"><xsl:attribute name="RadiusX"><xsl:value-of select="@rx" /></xsl:attribute><xsl:attribute name="RadiusY"><xsl:value-of select="@rx" /></xsl:attribute></xsl:if>
+ <xsl:if test="@ry and not(@rx)"><xsl:attribute name="RadiusX"><xsl:value-of select="@ry" /></xsl:attribute><xsl:attribute name="RadiusY"><xsl:value-of select="@ry" /></xsl:attribute></xsl:if>
+
+ <xsl:apply-templates mode="id" select="." />
+ <xsl:apply-templates mode="template_fill" select="." />
+ <xsl:apply-templates mode="template_stroke" select="." />
+ <xsl:apply-templates mode="stroke_width" select="." />
+ <xsl:apply-templates mode="stroke_miterlimit" select="." />
+ <xsl:apply-templates mode="stroke_dasharray" select="." />
+ <xsl:apply-templates mode="stroke_dashoffset" select="." />
+ <xsl:apply-templates mode="stroke_linejoin" select="." />
+ <xsl:apply-templates mode="stroke_linecap" select="." />
+ <xsl:apply-templates mode="filter_effect" select="." />
+ <xsl:apply-templates mode="resources" select="." />
+ <xsl:apply-templates mode="desc" select="." />
+ <xsl:apply-templates mode="clip" select="." />
+
+ <xsl:apply-templates mode="transform" select=".">
+ <xsl:with-param name="mapped_type" select="'Rectangle'" />
+ </xsl:apply-templates>
+
+ <xsl:apply-templates mode="forward" />
+ </Rectangle>
+</xsl:template>
+
+<!-- Polygon -->
+<xsl:template mode="forward" match="*[name(.) = 'polygon']">
+ <Polygon>
+ <xsl:if test="@points"><xsl:attribute name="Points"><xsl:value-of select="@points" /></xsl:attribute></xsl:if>
+ <xsl:apply-templates mode="id" select="." />
+ <xsl:apply-templates mode="fill_rule" select="." />
+ <xsl:apply-templates mode="template_fill" select="." />
+ <xsl:apply-templates mode="template_stroke" select="." />
+ <xsl:apply-templates mode="stroke_width" select="." />
+ <xsl:apply-templates mode="stroke_miterlimit" select="." />
+ <xsl:apply-templates mode="stroke_dasharray" select="." />
+ <xsl:apply-templates mode="stroke_dashoffset" select="." />
+ <xsl:apply-templates mode="stroke_linejoin" select="." />
+ <xsl:apply-templates mode="stroke_linecap" select="." />
+ <xsl:apply-templates mode="filter_effect" select="." />
+ <xsl:apply-templates mode="desc" select="." />
+
+ <xsl:apply-templates mode="transform" select=".">
+ <xsl:with-param name="mapped_type" select="'Polygon'" />
+ </xsl:apply-templates>
+
+ <xsl:apply-templates mode="forward" />
+ </Polygon>
+</xsl:template>
+
+<!-- Polyline -->
+<xsl:template mode="forward" match="*[name(.) = 'polyline']">
+ <Polyline>
+ <xsl:if test="@points"><xsl:attribute name="Points"><xsl:value-of select="@points" /></xsl:attribute></xsl:if>
+ <xsl:apply-templates mode="id" select="." />
+ <xsl:apply-templates mode="fill_rule" select="." />
+ <xsl:apply-templates mode="template_fill" select="." />
+ <xsl:apply-templates mode="template_stroke" select="." />
+ <xsl:apply-templates mode="stroke_width" select="." />
+ <xsl:apply-templates mode="stroke_miterlimit" select="." />
+ <xsl:apply-templates mode="stroke_dasharray" select="." />
+ <xsl:apply-templates mode="stroke_dashoffset" select="." />
+ <xsl:apply-templates mode="stroke_linejoin" select="." />
+ <xsl:apply-templates mode="stroke_linecap" select="." />
+ <xsl:apply-templates mode="filter_effect" select="." />
+ <xsl:apply-templates mode="desc" select="." />
+
+ <xsl:apply-templates mode="transform" select=".">
+ <xsl:with-param name="mapped_type" select="'Polyline'" />
+ </xsl:apply-templates>
+
+ <xsl:apply-templates mode="forward" />
+ </Polyline>
+</xsl:template>
+
+<!-- Path -->
+<xsl:template mode="forward" match="*[name(.) = 'path']">
+ <Path>
+ <xsl:apply-templates mode="id" select="." />
+ <xsl:apply-templates mode="template_fill" select="." />
+ <xsl:apply-templates mode="template_stroke" select="." />
+ <xsl:apply-templates mode="stroke_width" select="." />
+ <xsl:apply-templates mode="stroke_miterlimit" select="." />
+ <xsl:apply-templates mode="stroke_dasharray" select="." />
+ <xsl:apply-templates mode="stroke_dashoffset" select="." />
+ <xsl:apply-templates mode="stroke_linejoin" select="." />
+ <xsl:apply-templates mode="stroke_linecap" select="." />
+ <xsl:apply-templates mode="filter_effect" select="." />
+ <xsl:apply-templates mode="desc" select="." />
+
+ <xsl:if test="@d">
+ <xsl:choose>
+ <xsl:when test="$silverlight_compatible = 1">
+ <xsl:attribute name="Data">
+ <xsl:value-of select="translate(@d , ',', ' ')" />
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <Path.Data>
+ <PathGeometry>
+ <xsl:attribute name="Figures">
+ <xsl:value-of select="translate(@d , ',', ' ')" />
+ </xsl:attribute>
+ <xsl:apply-templates mode="fill_rule" select="." />
+ </PathGeometry>
+ </Path.Data>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:apply-templates mode="transform" select=".">
+ <xsl:with-param name="mapped_type" select="'Path'" />
+ </xsl:apply-templates>
+
+ <xsl:apply-templates mode="forward" />
+ </Path>
+</xsl:template>
+
+<!-- Ellipse -->
+<xsl:template mode="forward" match="*[name(.) = 'ellipse']">
+ <Ellipse>
+ <xsl:variable name="cx">
+ <xsl:choose>
+ <xsl:when test="@cx"><xsl:value-of select="@cx" /></xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="cy">
+ <xsl:choose>
+ <xsl:when test="@cy"><xsl:value-of select="@cy" /></xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:if test="@rx">
+ <xsl:attribute name="Canvas.Left"><xsl:value-of select='format-number($cx - @rx, "#.#")' /></xsl:attribute>
+ <xsl:attribute name="Width"><xsl:value-of select='format-number(2 * @rx, "#.#")' /></xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@ry">
+ <xsl:attribute name="Canvas.Top"><xsl:value-of select='format-number($cy - @ry, "#.#")' /></xsl:attribute>
+ <xsl:attribute name="Height"><xsl:value-of select='format-number(2 * @ry, "#.#")' /></xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates mode="id" select="." />
+ <xsl:apply-templates mode="template_fill" select="." />
+ <xsl:apply-templates mode="template_stroke" select="." />
+ <xsl:apply-templates mode="stroke_width" select="." />
+ <xsl:apply-templates mode="stroke_miterlimit" select="." />
+ <xsl:apply-templates mode="stroke_dasharray" select="." />
+ <xsl:apply-templates mode="stroke_dashoffset" select="." />
+ <xsl:apply-templates mode="stroke_linejoin" select="." />
+ <xsl:apply-templates mode="stroke_linecap" select="." />
+ <xsl:apply-templates mode="filter_effect" select="." />
+ <xsl:apply-templates mode="desc" select="." />
+ <xsl:apply-templates mode="clip" select="." />
+
+ <xsl:apply-templates mode="transform" select=".">
+ <xsl:with-param name="mapped_type" select="'Ellipse'" />
+ </xsl:apply-templates>
+
+ <xsl:apply-templates mode="forward" />
+ </Ellipse>
+</xsl:template>
+
+<!-- Circle -->
+<xsl:template mode="forward" match="*[name(.) = 'circle']">
+ <Ellipse>
+ <xsl:variable name="cx">
+ <xsl:choose>
+ <xsl:when test="@cx"><xsl:value-of select="@cx" /></xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="cy">
+ <xsl:choose>
+ <xsl:when test="@cy"><xsl:value-of select="@cy" /></xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:if test="@r">
+ <xsl:attribute name="Canvas.Left"><xsl:value-of select='format-number($cx - @r, "#.#")' /></xsl:attribute>
+ <xsl:attribute name="Canvas.Top"><xsl:value-of select='format-number($cy - @r, "#.#")' /></xsl:attribute>
+ <xsl:attribute name="Width"><xsl:value-of select='format-number(2 * @r, "#.#")' /></xsl:attribute>
+ <xsl:attribute name="Height"><xsl:value-of select='format-number(2 * @r, "#.#")' /></xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates mode="id" select="." />
+ <xsl:apply-templates mode="template_fill" select="." />
+ <xsl:apply-templates mode="template_stroke" select="." />
+ <xsl:apply-templates mode="stroke_width" select="." />
+ <xsl:apply-templates mode="stroke_miterlimit" select="." />
+ <xsl:apply-templates mode="stroke_dasharray" select="." />
+ <xsl:apply-templates mode="stroke_dashoffset" select="." />
+ <xsl:apply-templates mode="stroke_linejoin" select="." />
+ <xsl:apply-templates mode="stroke_linecap" select="." />
+ <xsl:apply-templates mode="filter_effect" select="." />
+ <xsl:apply-templates mode="desc" select="." />
+ <xsl:apply-templates mode="clip" select="." />
+
+ <xsl:apply-templates mode="transform" select=".">
+ <xsl:with-param name="mapped_type" select="'Ellipse'" />
+ </xsl:apply-templates>
+
+ <xsl:apply-templates mode="forward" />
+ </Ellipse>
+</xsl:template>
+
+<!--
+// Geometry //
+* Generic clip path template
+* Geometry for circle
+* Geometry for rectangle
+-->
+
+<!-- Generic clip path template -->
+<xsl:template mode="forward" match="*[name(.) = 'clipPath']">
+ <xsl:apply-templates mode="geometry" />
+</xsl:template>
+
+<!-- Geometry for circle -->
+<xsl:template mode="geometry" match="*[name(.) = 'circle']">
+ <EllipseGeometry>
+ <xsl:if test="../@id"><xsl:attribute name="x:Key"><xsl:value-of select="../@id" /></xsl:attribute></xsl:if>
+ <xsl:if test="@cx and @cy"><xsl:attribute name="Center"><xsl:value-of select="concat(@cx, ',', @cy)" /></xsl:attribute></xsl:if>
+ <xsl:if test="@r">
+ <xsl:attribute name="RadiusX"><xsl:value-of select="@r" /></xsl:attribute>
+ <xsl:attribute name="RadiusY"><xsl:value-of select="@r" /></xsl:attribute>
+ </xsl:if>
+ </EllipseGeometry>
+</xsl:template>
+
+<!-- Geometry for rectangle -->
+<xsl:template mode="geometry" match="*[name(.) = 'rect']">
+ <RectangleGeometry>
+ <xsl:if test="../@id"><xsl:attribute name="x:Key"><xsl:value-of select="../@id" /></xsl:attribute></xsl:if>
+ <!--
+ <xsl:if test="@x"><xsl:attribute name="Canvas.Left"><xsl:value-of select="@x" /></xsl:attribute></xsl:if>
+ <xsl:if test="@y"><xsl:attribute name="Canvas.Top"><xsl:value-of select="@y" /></xsl:attribute></xsl:if>
+ <xsl:if test="@width"><xsl:attribute name="Width"><xsl:value-of select="@width" /></xsl:attribute></xsl:if>
+ <xsl:if test="@height"><xsl:attribute name="Height"><xsl:value-of select="@height" /></xsl:attribute></xsl:if>
+ <xsl:if test="@rx"><xsl:attribute name="RadiusX"><xsl:value-of select="@rx" /></xsl:attribute></xsl:if>
+ <xsl:if test="@ry"><xsl:attribute name="RadiusY"><xsl:value-of select="@ry" /></xsl:attribute></xsl:if>
+ -->
+ <xsl:attribute name="Rect"><xsl:value-of select="concat('0, 0, ', @width, ', ', @height)" /></xsl:attribute>
+ </RectangleGeometry>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/share/extensions/xaml2svg.xsl b/share/extensions/xaml2svg.xsl
index c5f1cfd75..8c0e4a5c9 100644
--- a/share/extensions/xaml2svg.xsl
+++ b/share/extensions/xaml2svg.xsl
@@ -1,107 +1,107 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Copyright (c) 2005-2007 Toine de Greef (a.degreef@chello.nl)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-Version history:
-
-20070907 Initial release
-20070912 Removed NaN as viewBox values
-
--->
-
-<xsl:stylesheet version="1.0"
-xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-xmlns:xlink="http://www.w3.org/1999/xlink"
-xmlns:svg="http://www.w3.org/2000/svg"
-xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-xmlns:msxsl="urn:schemas-microsoft-com:xslt">
-<xsl:strip-space elements="*" />
-<xsl:output method="xml" encoding="UTF-8"/>
-<xsl:include href="xaml2svg/animation.xsl" />
-<xsl:include href="xaml2svg/brushes.xsl" />
-<xsl:include href="xaml2svg/canvas.xsl" />
-<xsl:include href="xaml2svg/geometry.xsl" />
-<xsl:include href="xaml2svg/properties.xsl" />
-<xsl:include href="xaml2svg/shapes.xsl" />
-<xsl:include href="xaml2svg/transform.xsl" />
-
-<xsl:template match="/">
- <svg>
- <xsl:attribute name="overflow">visible</xsl:attribute>
- <xsl:variable name="viewBox"><xsl:apply-templates mode="boundingbox" /></xsl:variable>
- <xsl:if test="system-property('xsl:vendor') = 'Microsoft' and (msxsl:node-set($viewBox)/boundingbox/@x1 != '') and (msxsl:node-set($viewBox)/boundingbox/@x2 != '') and (msxsl:node-set($viewBox)/boundingbox/@y1 != '') and (msxsl:node-set($viewBox)/boundingbox/@y2 != '')">
- <xsl:attribute name="viewBox">
- <xsl:value-of select="concat(msxsl:node-set($viewBox)/boundingbox/@x1, ' ')" />
- <xsl:value-of select="concat(msxsl:node-set($viewBox)/boundingbox/@y1, ' ')" />
- <xsl:value-of select="concat(msxsl:node-set($viewBox)/boundingbox/@x2 - msxsl:node-set($viewBox)/boundingbox/@x1, ' ')" />
- <xsl:value-of select="msxsl:node-set($viewBox)/boundingbox/@y2 - msxsl:node-set($viewBox)/boundingbox/@y1" />
- </xsl:attribute>
- </xsl:if>
- <xsl:apply-templates mode="svg" />
- </svg>
-</xsl:template>
-
-<xsl:template mode="forward" match="*[name(.) = 'Image']">
- <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="concat('&lt;svg x=&quot;', @Canvas.Left, '&quot; y=&quot;', @Canvas.Top, '&quot;&gt;')" /></xsl:if>
- <image>
- <xsl:if test="@Source"><xsl:attribute name="xlink:href"><xsl:value-of select="@Source" /></xsl:attribute></xsl:if>
- <xsl:if test="@Width"><xsl:attribute name="width"><xsl:value-of select="@Width" /></xsl:attribute></xsl:if>
- <xsl:if test="@Height"><xsl:attribute name="height"><xsl:value-of select="@Height" /></xsl:attribute></xsl:if>
- <xsl:call-template name="template_properties" />
- <xsl:call-template name="template_transform" />
- <xsl:apply-templates mode="forward" />
- </image>
- <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="'&lt;/svg&gt;&#13;'" /></xsl:if>
-</xsl:template>
-
-<xsl:template mode="forward" match="*[name(.) = 'TextBlock']">
- <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="concat('&lt;svg x=&quot;', @Canvas.Left, '&quot; y=&quot;', @Canvas.Top, '&quot;&gt;')" /></xsl:if>
- <text>
- <xsl:if test="@FontSize"><xsl:attribute name="font-size"><xsl:value-of select="@FontSize" /></xsl:attribute></xsl:if>
- <xsl:if test="@FontWeight"><xsl:attribute name="font-weight"><xsl:value-of select="@FontWeight" /></xsl:attribute></xsl:if>
- <xsl:if test="@FontFamily"><xsl:attribute name="font-family"><xsl:value-of select="@FontFamily" /></xsl:attribute></xsl:if>
- <xsl:if test="@FontStyle"><xsl:attribute name="font-style"><xsl:value-of select="@FontStyle" /></xsl:attribute></xsl:if>
- <xsl:if test="@Foreground"><xsl:attribute name="fill"><xsl:value-of select="@Foreground" /></xsl:attribute></xsl:if>
- <xsl:if test="@Width"><xsl:attribute name="width"><xsl:value-of select="@Width" /></xsl:attribute></xsl:if>
- <xsl:if test="@Height"><xsl:attribute name="height"><xsl:value-of select="@Height" /></xsl:attribute></xsl:if>
- <xsl:if test="@HorizontalAlignment">
- <xsl:attribute name="text-anchor">
- <xsl:choose>
- <xsl:when test="@HorizontalAlignment = 'Left'">start</xsl:when>
- <xsl:when test="@HorizontalAlignment = 'Center'">middle</xsl:when>
- <xsl:when test="@HorizontalAlignment = 'Right'">end</xsl:when>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:attribute name="dominant-baseline">hanging</xsl:attribute>
- <xsl:call-template name="template_properties" />
- <xsl:call-template name="template_transform" />
- <xsl:apply-templates />
- </text>
- <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="'&lt;/svg&gt;&#13;'" /></xsl:if>
-</xsl:template>
-
-<xsl:template match="*">
-<xsl:comment><xsl:value-of select="concat('Unknown tag: ', name(.))" /></xsl:comment>
-</xsl:template>
-
-</xsl:stylesheet>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Copyright (c) 2005-2007 Toine de Greef (a.degreef@chello.nl)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+Version history:
+
+20070907 Initial release
+20070912 Removed NaN as viewBox values
+
+-->
+
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:xlink="http://www.w3.org/1999/xlink"
+xmlns:svg="http://www.w3.org/2000/svg"
+xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+xmlns:msxsl="urn:schemas-microsoft-com:xslt">
+<xsl:strip-space elements="*" />
+<xsl:output method="xml" encoding="UTF-8"/>
+<xsl:include href="xaml2svg/animation.xsl" />
+<xsl:include href="xaml2svg/brushes.xsl" />
+<xsl:include href="xaml2svg/canvas.xsl" />
+<xsl:include href="xaml2svg/geometry.xsl" />
+<xsl:include href="xaml2svg/properties.xsl" />
+<xsl:include href="xaml2svg/shapes.xsl" />
+<xsl:include href="xaml2svg/transform.xsl" />
+
+<xsl:template match="/">
+ <svg>
+ <xsl:attribute name="overflow">visible</xsl:attribute>
+ <xsl:variable name="viewBox"><xsl:apply-templates mode="boundingbox" /></xsl:variable>
+ <xsl:if test="system-property('xsl:vendor') = 'Microsoft' and (msxsl:node-set($viewBox)/boundingbox/@x1 != '') and (msxsl:node-set($viewBox)/boundingbox/@x2 != '') and (msxsl:node-set($viewBox)/boundingbox/@y1 != '') and (msxsl:node-set($viewBox)/boundingbox/@y2 != '')">
+ <xsl:attribute name="viewBox">
+ <xsl:value-of select="concat(msxsl:node-set($viewBox)/boundingbox/@x1, ' ')" />
+ <xsl:value-of select="concat(msxsl:node-set($viewBox)/boundingbox/@y1, ' ')" />
+ <xsl:value-of select="concat(msxsl:node-set($viewBox)/boundingbox/@x2 - msxsl:node-set($viewBox)/boundingbox/@x1, ' ')" />
+ <xsl:value-of select="msxsl:node-set($viewBox)/boundingbox/@y2 - msxsl:node-set($viewBox)/boundingbox/@y1" />
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates mode="svg" />
+ </svg>
+</xsl:template>
+
+<xsl:template mode="forward" match="*[name(.) = 'Image']">
+ <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="concat('&lt;svg x=&quot;', @Canvas.Left, '&quot; y=&quot;', @Canvas.Top, '&quot;&gt;')" /></xsl:if>
+ <image>
+ <xsl:if test="@Source"><xsl:attribute name="xlink:href"><xsl:value-of select="@Source" /></xsl:attribute></xsl:if>
+ <xsl:if test="@Width"><xsl:attribute name="width"><xsl:value-of select="@Width" /></xsl:attribute></xsl:if>
+ <xsl:if test="@Height"><xsl:attribute name="height"><xsl:value-of select="@Height" /></xsl:attribute></xsl:if>
+ <xsl:call-template name="template_properties" />
+ <xsl:call-template name="template_transform" />
+ <xsl:apply-templates mode="forward" />
+ </image>
+ <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="'&lt;/svg&gt;&#13;'" /></xsl:if>
+</xsl:template>
+
+<xsl:template mode="forward" match="*[name(.) = 'TextBlock']">
+ <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="concat('&lt;svg x=&quot;', @Canvas.Left, '&quot; y=&quot;', @Canvas.Top, '&quot;&gt;')" /></xsl:if>
+ <text>
+ <xsl:if test="@FontSize"><xsl:attribute name="font-size"><xsl:value-of select="@FontSize" /></xsl:attribute></xsl:if>
+ <xsl:if test="@FontWeight"><xsl:attribute name="font-weight"><xsl:value-of select="@FontWeight" /></xsl:attribute></xsl:if>
+ <xsl:if test="@FontFamily"><xsl:attribute name="font-family"><xsl:value-of select="@FontFamily" /></xsl:attribute></xsl:if>
+ <xsl:if test="@FontStyle"><xsl:attribute name="font-style"><xsl:value-of select="@FontStyle" /></xsl:attribute></xsl:if>
+ <xsl:if test="@Foreground"><xsl:attribute name="fill"><xsl:value-of select="@Foreground" /></xsl:attribute></xsl:if>
+ <xsl:if test="@Width"><xsl:attribute name="width"><xsl:value-of select="@Width" /></xsl:attribute></xsl:if>
+ <xsl:if test="@Height"><xsl:attribute name="height"><xsl:value-of select="@Height" /></xsl:attribute></xsl:if>
+ <xsl:if test="@HorizontalAlignment">
+ <xsl:attribute name="text-anchor">
+ <xsl:choose>
+ <xsl:when test="@HorizontalAlignment = 'Left'">start</xsl:when>
+ <xsl:when test="@HorizontalAlignment = 'Center'">middle</xsl:when>
+ <xsl:when test="@HorizontalAlignment = 'Right'">end</xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:attribute name="dominant-baseline">hanging</xsl:attribute>
+ <xsl:call-template name="template_properties" />
+ <xsl:call-template name="template_transform" />
+ <xsl:apply-templates />
+ </text>
+ <xsl:if test="@Canvas.Left or @Canvas.Top"><xsl:value-of disable-output-escaping="yes" select="'&lt;/svg&gt;&#13;'" /></xsl:if>
+</xsl:template>
+
+<xsl:template match="*">
+<xsl:comment><xsl:value-of select="concat('Unknown tag: ', name(.))" /></xsl:comment>
+</xsl:template>
+
+</xsl:stylesheet>