Skip to main content

addPrimitive

Adds a graphics primitive (a line, rectangle or ellipse) to the pad control list. Primitives are drawn with the current borderColor and fillColor properties.

wizCtl.addPrimitive(type, x1, y1, x2, y2, lineWidth, options)
ParameterDescription
typeA value from the sigSDK.PrimitiveType enum: Line, Rectangle or Ellipse.
x1, y1

For a line, the start position. For a rectangle or ellipse, the top-left corner of the bounding rectangle.
The value is either an absolute position in pixels or one of the following strings:

  • x1: "left", "right", "centre"
  • y1: "top", "middle", "bottom"
x2, y2

For a line, the end position. For a rectangle or ellipse, the bottom-right corner of the bounding rectangle.
The value is an absolute position in pixels, one of the strings listed for x1, y1, or a string such as "+50" for a value relative to x1 or y1.

lineWidthLine width in pixels. (Optional, default 1)
optionsA combination of sigSDK.PrimitiveOptions values. (Optional, default LineSolid and Outline)
Return values
The added object. Throws an exception if an error occurs.

The returned object has a rect property with the displayed area: upperLeftXpixel, upperLeftYpixel, lowerRightXpixel and lowerRightYpixel.

The following example draws a dashed line and a filled rectangle:

wizCtl.setProperty({fillColor: "green", borderColor: "blue"});
wizCtl.addPrimitive(sigSDK.PrimitiveType.Line, 10, 100, 200, 100, 2, sigSDK.PrimitiveOptions.LineDashed.value);
wizCtl.addPrimitive(sigSDK.PrimitiveType.Rectangle, 10, 120, "+80", "+40", 2,
sigSDK.PrimitiveOptions.LineSolid.value | sigSDK.PrimitiveOptions.Fill.value);