http://www.zorba-xquery.com/modules/image/paint

Description

Before using any of the functions below please remember to import the module namespace:

import module namespace paint = "http://www.zorba-xquery.com/modules/image/paint";
This module provides a function to extend an image with additional shapes. Fully supported image formats are:
  • GIF
  • JPEG
  • PNG
  • TIFF
  • BMP

The errors raised by functions of this module have the namespace http://www.zorba-xquery.com/modules/image/error (associated with prefix ierr).

Imported Schemas

Please note that the schemas are not automatically imported in the modules that import this module.

In order to import and use the schemas, please add:

import schema namespace img =  "http://www.zorba-xquery.com/modules/image/image";

Author

Daniel Thomas

XQuery version and encoding

xquery version "3.0" encoding "utf-8";

Namespaces

errhttp://www.w3.org/2005/xqt-errors
ierrhttp://www.zorba-xquery.com/modules/image/error
imghttp://www.zorba-xquery.com/modules/image/image
painthttp://www.zorba-xquery.com/modules/image/paint
verhttp://www.zorba-xquery.com/options/versioning

Function Summary

paint($image as xs:base64Binary, $shapes as element(*)*) as xs:base64Binary

Extends the passed image with a sequence of shapes.

Functions

paint#2

declare function paint:paint(
    $image as xs:base64Binary,
    $shapes as element(*)*
) as xs:base64Binary

Extends the passed image with a sequence of shapes. The shapes are passed as a sequence of elements. The possibilities for shape elements are:

  • line:
              <img:line>
                <img:start><img:x>-20</img:x><img:y>-20</img:y></img:start>
                <img:end><img:x>80</img:x><img:y>80</img:y></img:end>
              </img:line>
  • polyline:
               <img:polyLine>
                 <img:point><img:x>10</img:x><img:y>10</img:y></img:point>
                 <img:point><img:x>40</img:x><img:y>80</img:y></point>
                 <img:point><img:x>50</img:x><img:y>30</img:y></point>
                 <img:point><img:x>200</img:x><img:y>200</img:y></point>
               </img:polyLine>
             
  • stroked polyline:
               <img:strokedPolyLine>
                 <img:point><img:x>10</img:x><img:y>10</img:y></img:point>
                 <img:point><img:x>40</img:x><img:y>80</img:y></img:point>
                 <img:point><img:x>50</img:x><img:y>30</img:y></img:point>
                 <img:strokeLength>5</img:strokeLength><img:gapLength>2</img:gapLength>
               </img:strokedPolyLine>
             
  • rectangle:
               <img:rectangle>
                 <img:upperLeft><img:x>20</img:x><img:y>20</img:y></img:upperLeft>
                 <img:lowerRight><img:x>50</img:x><img:y>50</img:y></img:lowerRight>
               </img:rectangle>
             
  • rounded rectangle:
               <img:roundedRectangle>
                 <img:upperLeft><img:x>20</img:x><img:y>20</img:y></img:upperLeft>
                 <img:lowerRight><img:x>50</img:x><img:y>50</img:y></img:lowerRight>
                 <img:cornerWidth>10</img:cornerWidth><img:cornerHeight>10</img:cornerHeight>
               </img:roundedRectangle>
             
  • circle:
               <img:circle>
                 <img:origin><img:x>20</img:x><img:y>20</img:y></img:origin>
                 <img:perimeter>5</img:perimeter>
               </img:circle>
             
  • ellipse:
               <img:ellipse>
                 <img:origin><img:x>50</img:x><img:y>50</img:y></img:origin>
                 <img:perimeterX>30</img:perimeterX><img:perimeterY>20</img:perimeterY>
               </img:ellipse>
             
  • arc:
               <img:arc>
                 <img:origin><img:x>50</img:x><img:y>50</img:y></img:origin>
                 <img:perimeterX>10</img:perimeterX><img:perimeterY>20</img:perimeterY>
                 <img:startDegrees>180</img:startDegrees><img:endDegrees>270</img:endDegrees>
               </img:arc>
             
  • polygon:
               <img:polygon>
                 <img:point><img:x>10</img:x><img:y>10</img:y></img:point>
                 <img:point><img:x>40</img:x><img:y>80</img:y></img:point>
                 <img:point><img:x>50</img:x><img:y>30</img:y></img:point>
               </img:polygon>
             
  • text:
               <img:text>
                 <img:origin><img:x>20</img:x><img:y>20</img:y></img:origin>
                 <img:text>Hello Zorba</img:text><img:font></img:font><img:font-size>12</img:font-size>
               </img:text>
             
Optionally, each of the shape elements can contain elements to define the stroke with, stroke color, fill color, and anti-aliasing. E.g.:

     <img:rectangle>
       <img:strokeWidth>5</img:strokeWidth>
       <img:strokeColor>#00AF00</img:strokeColor>
       <img:fillColor>#A10000</img:fillColor>
       <img:antiAliasing>true</img:antiAliasing>
       <img:upperLeft><img:x>20</img:x><img:y>20</img:y></img:upperLeft>
       <img:lowerRight><img:x>50</img:x><img:y>50</img:y></img:lowerRight>
     </img:rectangle>
   

Parameters

  • $image as xs:base64Binary
    the passed image
  • $shapes as element(*)
    the shapes

Returns

  • xs:base64Binary

    image with additional shapes

Errors

  • ierr:IM001 the passed image is invalid.
  • err:FORG0001 one of the passed shape elements is invalid.

Examples

blog comments powered by Disqus