Jeni Tennison
I'm experimenting with XSLT and SVG:
http://www.pinkjuice.com/SVG/XSLT/fractals/
(those are working) Now I want to generate different colors for the
levels; forth and back in an array of colors. The
level can be set to any depth, and I don't want to
just go from blue to yellow for a result with 2 levels
as well as one with 10 levels; I'd rather have the
colors go from blue to yellow to blue to yellow and so
forth for the depth set in the input-doc ("up and
down").
(the opacity of the levels goes one way from low to
high for any depth; this works.) > I tried to write two recursing templates: the first is called
> "forth"; red and blue are incremented, and green is decremented. The
> second one works the otherway round. One should start the other as
> soon as one of the values reached the limit of either 0 or 255.
> Both should stop as soon as the set level of depth is reached. The important thing is that last one. "Both should stop as soon as
the set level of depth is reached." Looking at the templates, you
test $depth in both, but in both it's in an xsl:when and there's an
xsl:otherwise which catches the other option. So for example: <xsl:template name="back">
...
<xsl:choose>
<xsl:when test="$current < $depth and ($red > 0)
and ($green < 255) and ($blue > 0)">
<xsl:call-template name="back">
...
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="forth">
...
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template> You need to *not do anything* when $current >= $depth, rather than
just going into xsl:otherwise. So something like: <xsl:template name="back">
...
<xsl:choose>
<xsl:when test="$current >= $depth" />
<xsl:when test="($red > 0) and ($green < 255)
and ($blue > 0)">
<xsl:call-template name="back">
...
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="forth">
...
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
|