fix memory issues
This commit is contained in:
parent
feec279622
commit
160cbc2516
1 changed files with 40 additions and 38 deletions
66
svg.xsl
66
svg.xsl
|
@ -11,14 +11,6 @@
|
||||||
|
|
||||||
<!-- Template pour le traceur -->
|
<!-- Template pour le traceur -->
|
||||||
<xsl:template match="traceur">
|
<xsl:template match="traceur">
|
||||||
<!-- Tracé -->
|
|
||||||
<xsl:variable name="path">
|
|
||||||
<xsl:call-template name="generatePath">
|
|
||||||
<xsl:with-param name="idx" select="1" />
|
|
||||||
<xsl:with-param name="path" select="'M0 0 '" />
|
|
||||||
</xsl:call-template>
|
|
||||||
</xsl:variable>
|
|
||||||
|
|
||||||
<!-- Dimensions arbitraires -->
|
<!-- Dimensions arbitraires -->
|
||||||
<xsl:variable
|
<xsl:variable
|
||||||
name="width" select="1000" />
|
name="width" select="1000" />
|
||||||
|
@ -53,42 +45,52 @@
|
||||||
<!-- TODO : Faudrais faire en sorte que :
|
<!-- TODO : Faudrais faire en sorte que :
|
||||||
+ le scale est petit
|
+ le scale est petit
|
||||||
+ l'épaisseur du tracé est épais -->
|
+ l'épaisseur du tracé est épais -->
|
||||||
<g
|
<g stroke="black" fill="none"
|
||||||
transform="translate({$transX}, {$transY}) scale({$scale})">
|
transform="translate({$transX}, {$transY}) scale({$scale})">
|
||||||
<path d="{$path}" stroke="black" fill="none" />
|
<xsl:call-template name="generatePath" />
|
||||||
</g>
|
</g>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<!-- Fonction récursive terminale -->
|
<!-- Tracés -->
|
||||||
<xsl:template name="generatePath">
|
<xsl:template name="generatePath">
|
||||||
<xsl:param name="idx" />
|
<xsl:param name="idx"
|
||||||
<xsl:param name="path" />
|
select="1" />
|
||||||
|
<xsl:param name="x" select="0" />
|
||||||
|
<xsl:param name="y" select="0" />
|
||||||
|
|
||||||
|
<xsl:if
|
||||||
|
test="$idx lt count(*)">
|
||||||
|
<xsl:variable
|
||||||
|
name="action" select="*[position() = $idx]" />
|
||||||
|
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$idx > count(*)">
|
<!-- Déplacement -->
|
||||||
<xsl:value-of select="$path" />
|
<xsl:when test="name($action) = 'MOVETO'">
|
||||||
|
<xsl:call-template name="generatePath">
|
||||||
|
<xsl:with-param name="idx" select="$idx + 1" />
|
||||||
|
<xsl:with-param name="x" select="$action/@x" />
|
||||||
|
<xsl:with-param name="y" select="$action/@y" />
|
||||||
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:variable
|
|
||||||
name="currentNode" select="*[position() = $idx]" />
|
|
||||||
<xsl:variable
|
|
||||||
name="pos" select="concat($currentNode/@x, ' ', $currentNode/@y)" />
|
|
||||||
|
|
||||||
<xsl:choose>
|
<!-- Ecriture -->
|
||||||
<xsl:when test="name($currentNode) = 'MOVETO'">
|
<xsl:when test="name($action) = 'LINETO'">
|
||||||
<xsl:call-template name="generatePath">
|
<xsl:variable name="pos"
|
||||||
|
select="concat($x, ' ', $y)" />
|
||||||
|
<xsl:variable name="nouvellePos"
|
||||||
|
select="concat($action/@x, ' ', $action/@y)" />
|
||||||
|
|
||||||
|
<path
|
||||||
|
d="{concat('M', $pos, ' L', $nouvellePos)}" />
|
||||||
|
|
||||||
|
<xsl:call-template
|
||||||
|
name="generatePath">
|
||||||
<xsl:with-param name="idx" select="$idx + 1" />
|
<xsl:with-param name="idx" select="$idx + 1" />
|
||||||
<xsl:with-param name="path" select="concat($path, ' M', $pos)" />
|
<xsl:with-param name="x" select="$action/@x" />
|
||||||
|
<xsl:with-param name="y" select="$action/@y" />
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:call-template name="generatePath">
|
|
||||||
<xsl:with-param name="idx" select="$idx + 1" />
|
|
||||||
<xsl:with-param name="path" select="concat($path, ' L', $pos)" />
|
|
||||||
</xsl:call-template>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
|
</xsl:if>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
</xsl:transform>
|
</xsl:transform>
|
||||||
|
|
Reference in a new issue