http://onionworks.net/2006/imageservice/canvas

drawPolygon (canvas : nodeset, pointNavigator : nodeset, penorfill : nodeset) : void

This method makes it possible to draw a polygon into an existing workspace. The point navigator for the corner points must be created in the following schema.

It can be controlled by indicating a pen or SolidFill whether the area of the polygon is filled or the outer edges are drawn.

The point navigator is an XML file with any number of points. These points are represented by the tag<point/> with the parameters “x” and “y”. In the following example, a triangle with the corner points (300,300), (100,300) and (100,100) are defined.

<xsl:variable name="points">
<point x="300" y="300" />
<point x="100" y="300" />
<point x="100" y="100" />
</xsl:variable>

In the following example, a square filled with colour is drawn into a created workspace.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ise="http://onionworks.net/2006/imageservice/encoders" xmlns:isc="http://onionworks.net/2006/imageservice/commands" xmlns:iscan="http://onionworks.net/2006/imageservice/canvas" xmlns:is="http://onionworks.net/2006/imageservice" xmlns:b="http://onionworks.net/2004/renderengine/binary" xmlns:onion="http://onionworks.net/2004/data" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="no" />
<xsl:template match="/resource">
<xsl:variable name="workspace" select="is:createWorkspace(@src, true())" />
<xsl:variable name="solidFill" select="is:createSolidFill(is:createColor(127,255,255,255))" />
<xsl:variable name="points">
<point x="300" y="300" />
<point x="100" y="300" />
<point x="100" y="100" />
<point x="300" y="100" />
</xsl:variable>
<xsl:variable name="drawPolygon" select="iscan:drawPolygon(iscan:createCanvas($workspace),$points,$solidFill)" />
<xsl:variable name="doWrite" select="is:writeWorkspace($workspace, ise:createJpegEncoder(80))" />
<b:output mimeType="{@onion:src.mimeType}">
<b:webResponse expires="60" />
</b:output>
</xsl:template>
</xsl:stylesheet>
Drawing a square