fix memory issues
This commit is contained in:
parent
feec279622
commit
160cbc2516
1 changed files with 40 additions and 38 deletions
78
svg.xsl
78
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:choose>
|
<xsl:if
|
||||||
<xsl:when test="$idx > count(*)">
|
test="$idx lt count(*)">
|
||||||
<xsl:value-of select="$path" />
|
<xsl:variable
|
||||||
</xsl:when>
|
name="action" select="*[position() = $idx]" />
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:variable
|
|
||||||
name="currentNode" select="*[position() = $idx]" />
|
|
||||||
<xsl:variable
|
|
||||||
name="pos" select="concat($currentNode/@x, ' ', $currentNode/@y)" />
|
|
||||||
|
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="name($currentNode) = 'MOVETO'">
|
<!-- Déplacement -->
|
||||||
<xsl:call-template name="generatePath">
|
<xsl:when test="name($action) = 'MOVETO'">
|
||||||
<xsl:with-param name="idx" select="$idx + 1" />
|
<xsl:call-template name="generatePath">
|
||||||
<xsl:with-param name="path" select="concat($path, ' M', $pos)" />
|
<xsl:with-param name="idx" select="$idx + 1" />
|
||||||
</xsl:call-template>
|
<xsl:with-param name="x" select="$action/@x" />
|
||||||
</xsl:when>
|
<xsl:with-param name="y" select="$action/@y" />
|
||||||
<xsl:otherwise>
|
</xsl:call-template>
|
||||||
<xsl:call-template name="generatePath">
|
</xsl:when>
|
||||||
<xsl:with-param name="idx" select="$idx + 1" />
|
|
||||||
<xsl:with-param name="path" select="concat($path, ' L', $pos)" />
|
<!-- Ecriture -->
|
||||||
</xsl:call-template>
|
<xsl:when test="name($action) = 'LINETO'">
|
||||||
</xsl:otherwise>
|
<xsl:variable name="pos"
|
||||||
</xsl:choose>
|
select="concat($x, ' ', $y)" />
|
||||||
</xsl:otherwise>
|
<xsl:variable name="nouvellePos"
|
||||||
</xsl:choose>
|
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="x" select="$action/@x" />
|
||||||
|
<xsl:with-param name="y" select="$action/@y" />
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:when>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:if>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
</xsl:transform>
|
</xsl:transform>
|
||||||
|
|
Reference in a new issue