Class TextDrawingItem
The TextDrawingItem
class extends the functionality of the DrawingItem
class and is specifically tailored to handle text-related drawing operations.
Name | Description |
---|---|
constructor TextDrawingItem() |
Constructor for the class. |
getText() | Retrieves the current text being used for drawing. |
setText() | Sets the text to be used for drawing. |
getTextRect() | Returns the rectangle area within which the text is drawn. |
setTextRect() | Sets the rectangle area within which the text should be drawn. |
TextDrawingItem
Constructor for the class.
constructor(
text: string,
rect: Rect,
drawingStyleId?: number
)
Parameters
text
: the text to be drawn.
rect
: defines the rectangle area within which the text will be drawn.
drawingStyleId
: [Optional] the unique ID of the DrawingStyle
to apply to this DrawingItem
.
Code Snippet
let cameraView = cameraEnhancer.getCameraView();
let drawingLayer = cameraView.createDrawingLayer();
let textItem = new Dynamsoft.DCE.TextDrawingItem(
"Hello World",
{
x: 100,
y: 200,
width: 640,
height: 360,
isMeasuredInPercentage: false
},
3
);
drawingLayer.addDrawingItem(textItem);
See also
getText
Retrieves the current text being used for drawing.
getText(): string;
Parameters
None.
Return Value
The current text being used for drawing.
Code Snippet
textItem.getText();
setText
Sets the text to be used for drawing. This method allows changing the text after the object has been instantiated.
Invoke
renderAll()
for the change to take effect if theDrawingItem
has already been added to aDrawingLayer
.
setText(text: string): void;
Parameters
text
: the text to be drawn.
Return Value
None.
Code Snippet
textItem.setText(/*A-New-Text*/);
getTextRect
Returns the rectangle area within which the text is drawn.
getTextRect(): Rect;
Parameters
None.
Return Value
The rectangle area within which the text is drawn.
Code Snippet
textItem.getTextRect();
setTextRect
Sets the rectangle area within which the text should be drawn. This method allows for the adjustment of position and size of the text.
The change takes effect right away.
setTextRect(rect: Rect): void;
Parameters
rect
: defines the rectangle area within which the text should be drawn.
Return Value
None.
Code Snippet
textItem.setTextRect(
{
height: 100,
width:300,
x: 200,
y :200
}
);
See Also