Skip to main content

Drawing Style

The drawing style defines the visual appearance of entities created by the user when using the draw tool. It is applied at draw time — only the style properties relevant to the drawn shape are used; extra properties are silently ignored.

setDrawingStyle()

Updates the drawing style. This call does a shallow merge with the existing style, so you only need to pass the properties you want to override.

setDrawingStyle(style: Partial<IDrawingStyleProperties>): void;

The style is persisted in the controller scene and applied whenever the user commits a draw gesture.

var ctrl = Visu.page0.display1.getController();

// Set a red stroke for new rectangles
ctrl.setDrawingStyle({
lineColor: "#FF0000",
lineWidth: 2,
filled: false,
});

// Make newly drawn shapes filled with semi-transparent blue
ctrl.setDrawingStyle({
filled: true,
fillColor: "#0000FF",
fillOpacity: 0.3,
});

IDrawingStyleProperties reference

Stroke

Applies to: Rect2d, Segment2d, Line2d, Path2d, Shape2d, Ellipse2d, Circle2d

PropertyTypeDescription
lineWidthnumberStroke width in pixels
lineColorstringCSS color string (e.g. "#FF0000", "red")
lineOpacitynumberStroke opacity from 0 to 1
lineStyleVe.ELineStyleSolid, dashed, dotted, etc.

Fill

Applies to: Rect2d, Path2d, Shape2d, Ellipse2d, Circle2d

PropertyTypeDescription
filledbooleanWhether the shape has a filled interior
fillColorstringCSS color string
fillOpacitynumberFill opacity from 0 to 1

Point

Applies to: Point2d

PropertyTypeDescription
colorstringCSS color string
opacitynumberOpacity from 0 to 1
markerVe.EMarkerTypeMarker shape (cross, circle, square, etc.)
markerSizenumberMarker size in pixels

Segment caps

Applies to: Segment2d

PropertyTypeDescription
cap1Ve.ECapTypeCap style at the first endpoint
capSize1numberCap size at the first endpoint
cap2Ve.ECapTypeCap style at the second endpoint
capSize2numberCap size at the second endpoint

String entities

Applies to: AnchorString, FrameString

PropertyTypeDescription
colorstringCSS color string
opacitynumberOpacity from 0 to 1
fontSizenumberFont size
hAlignmentTStringHAlignmentHorizontal text alignment
vAlignmentTStringVAlignmentVertical text alignment