for offset: use translate
This commit is contained in:
parent
436c41a5d0
commit
cbd29f50a6
1 changed files with 12 additions and 11 deletions
19
svg.xsl
19
svg.xsl
|
@ -12,26 +12,28 @@
|
|||
|
||||
<!-- Template pour le traceur -->
|
||||
<xsl:template match="traceur">
|
||||
<!-- TODO: usage temporaire d'un offset pour que l'image soit pas hors de
|
||||
l'écran, il faut trouver à l'avenir un moyen que ça soit automatique ?? -->
|
||||
<xsl:variable name="offset" select="500" />
|
||||
<xsl:variable name="path">
|
||||
<xsl:call-template name="generatePath">
|
||||
<xsl:with-param name="idx" select="1" />
|
||||
<xsl:with-param name="path" select="'M ' || $offset || ' ' || $offset" />
|
||||
<xsl:with-param name="offset" select="$offset" />
|
||||
<xsl:with-param name="path" select="'M 0 0 '" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
|
||||
<!-- TODO: usage temporaire d'un offset pour que l'image soit pas hors de
|
||||
l'écran, il faut trouver à l'avenir un moyen que ça soit automatique ?? -->
|
||||
<xsl:variable
|
||||
name="offset" select="250" />
|
||||
<g
|
||||
transform="translate({$offset}, {$offset})">
|
||||
<path
|
||||
d="{$path}" stroke="green" fill="none" />
|
||||
</g>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Fonction récursive terminale -->
|
||||
<xsl:template name="generatePath">
|
||||
<xsl:param name="idx" />
|
||||
<xsl:param name="path" />
|
||||
<xsl:param name="offset" />
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$idx > count(LINETO)">
|
||||
|
@ -39,14 +41,13 @@
|
|||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="x"
|
||||
select="LINETO[$idx]/@x + number($offset)" />
|
||||
select="LINETO[$idx]/@x" />
|
||||
<xsl:variable name="y"
|
||||
select="LINETO[$idx]/@y + number($offset)" />
|
||||
select="LINETO[$idx]/@y" />
|
||||
|
||||
<xsl:call-template name="generatePath">
|
||||
<xsl:with-param name="idx" select="$idx + 1" />
|
||||
<xsl:with-param name="path" select="concat($path, ' L ', $x, ' ', $y)" />
|
||||
<xsl:with-param name="offset" select="$offset" />
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
|
Reference in a new issue