This module provides a function to extend an image with additional shapes.
Fully supported image formats are:
The errors raised by functions of this module have the namespace http://zorba.io/modules/image/error (associated with prefix ierr).
paint
($image as xs:base64Binary, $shapes as object()*) as xs:base64Binary
Extends the passed image with a sequence of shapes. |
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" : { "start" : [0, 0], "end" : [80, 80] } }
{ "polyLine" : { "points" : [ [10, 10], [30, 10], [30, 30], [10, 30] ] } }
{ "strokedPolyLine" : { "points" : [ [10, 10], [40, 80], [50, 30] ], "strokeLength" : 10, "gapLength" : 2 } }
{ "rectangle" : { "upperLeft" : [ 20, 20 ], "lowerRight" : [ 50, 50 ] } }
{ "roundedRectangle" : { "upperLeft" : [ 20, 20 ], "lowerRight" : [ 50, 50 ], "cornerWidth" : 10, "cornerHeight" : 10 } }
{ "circle" : { "origin" : [ 50, 50 ], "radius" : 5 } }
{ "ellipse" : { "origin" : [ 50, 50 ], "radiusX" : 30, "radiusY" : 20 } }
{ "arc" : { "origin" : [ 50, 50 ], "radiusX" : 10, "radiusY" : 20, "startDegrees" : 180, "endDegrees" : 270 } }
{ "polygon" : { "points" : [ [10, 10], [30, 10], [30, 30] ] } }
{ "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 ] ] } }