http://zorba.io/modules/image/paint

View as XML or JSON.

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://zorba.io/modules/image/error (associated with prefix ierr).

Function Summary

paint ($image as xs:base64Binary, $shapes as object()*) 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 object()*) 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:
              {
                "line" :
                {
                  "start" : [0, 0],
                  "end" : [80, 80]
                }
              }
              
  • polyline:
               {
                 "polyLine" :
                 {
                   "points" : [ [10, 10], [30, 10], [30, 30], [10, 30] ]
                 }
               }
             
  • stroked polyline:
               {
                 "strokedPolyLine" :
                 {
                   "points" : [ [10, 10], [40, 80], [50, 30] ],
                   "strokeLength" : 10,
                   "gapLength" : 2
                 }
               }
             
  • rectangle:
               {
                 "rectangle" :
                 {
                   "upperLeft" : [ 20, 20 ],
                   "lowerRight" : [ 50, 50 ]
                 }
               }
             
  • rounded rectangle:
               { "roundedRectangle" :
                 {
                   "upperLeft" : [ 20, 20 ],
                   "lowerRight" : [ 50, 50 ],
                   "cornerWidth" : 10,
                   "cornerHeight" : 10
                 }
               }
             
  • circle:
               {
                 "circle" :
                 {
                   "origin" : [ 50, 50 ],
                   "radius" : 5
                 }
               }
             
  • ellipse:
               {
                 "ellipse" :
                 {
                   "origin" : [ 50, 50 ],
                   "radiusX" : 30,
                   "radiusY" : 20
                 }
               }
             
  • arc:
               {
                 "arc" :
                 {
                   "origin" : [ 50, 50 ],
                   "radiusX" : 10,
                   "radiusY" : 20,
                   "startDegrees" : 180,
                   "endDegrees" : 270
                 }
               }
             
  • polygon:
               {
                 "polygon" :
                 {
                   "points" : [ [10, 10], [30, 10], [30, 30] ]
                 }
               }
             
  • text:
               {
                 "text" :
                 {
                   "origin" : [ 50, 50 ],
                   "text" : "Hello World!",
                   "font" : "Arial",
                   "font-size" : 12
                 }
               }
             

Optionally, each of the shape elements can contain elements to define the stroke with, stroke color, fill color, and anti-aliasing.

E.g.:

     {
       "polygon" :
       {
         "strokeWidth" : 3,
         "strokeColor" : "#FF0000",
         "fillColor" : "#00FF00",
         "antiAliasing" : fn:true(),
         "points" : [ [ 10, 10 ], [ 40, 80 ], [ 50, 30 ] ]
       }
     }
   

Parameters

image as xs:base64Binary
the passed image
shapes as object()
the shapes

Returns

xs:base64Binary
image with additional shapes