http://onionworks.net/2006/imageservice

createPen () : nodeset

This method enables the creation of a pen as a drawing element. The method enables the transfer of the parameters “color”, “width”, “lineStyle”, “endCap”, “cornerJoin” and “alignment” with which the drawing behaviour of the pen can be controlled. If these values are not transferred, then the default values are used – you will find these in the following list.

  • width = 1
  • lineStyle = Solid
  • endCap = Flat
  • cornerJoin  = Miter
  • alignment = Center

The syntax of the method is illustrated in the following example.

<xsl:variable name="pen" select="is:createPen(is:createColor(255,0,0),5,'Solid','Square','Round','Center')" />

In the following example, it is shown how to use the method.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ise="http://onionworks.net/2006/imageservice/encoders" 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="pen" select="is:createPen(is:createColor(255,0,0),5,'Solid','Square','Round','Center')" />
<xsl:variable name="drawLine" select="iscan:drawLine(iscan:createCanvas($workspace), is:createPoint(100,100),is:createPoint(200,200),$pen)" />
<xsl:variable name="doWrite" select="is:writeWorkspace($workspace, ise:createJpegEncoder(60))" />
<b:output mimeType="{@onion:src.mimeType}">
<b:webResponse expires="60" />
</b:output>
</xsl:template>
</xsl:stylesheet>
Drawing a red line

This example draws a line into an existing picture. To start with, a workspace is produced with an existing picture, and then a pen is created with the colour red. Using the pen as a drawing element, a line is now written into the workspace, which will be written into the output stream in the following.