This module provides functions to manipulate text layers in the Toonboom vector drawings.
Methods
(inner) appendToTextLayers(arg)
This function appends text to a specified text layer. This can be useful if someone wants to write a line of text with different sizes or colors.
Example
var nodeDrawingKey =
{
node : "Top/Drawing",
frame : 1
};
var drawingKey = Drawing.Key(nodeDrawingKey);
DrawingTools.Text.appendToTextLayers({
drawing: drawingKey, art: 2,
layers: [
{ id: 1, // This is the layer id to append to
text: " Appended text!!",
fontSize: 16 } ]});
Parameters:
Name |
Type |
Description |
arg |
Object
|
Properties
Name |
Type |
Description |
drawing |
DrawingKey
|
The drawing key. |
art |
int
|
The art identifier |
layers |
Array.<TextLayer>
|
The text layers. |
|
Returns:
The list of text layers present in the drawing
(inner) createTextLayers(arg)
This function creates new text layers in the specified drawing
Example
var nodeDrawingKey =
{
node : "Top/Drawing",
frame : 1
};
var drawingKey = Drawing.Key(nodeDrawingKey);
// Create chinese text
// We have to fetch a chinese font...
DrawingTools.Text.createTextLayers({
fontSize: 78,
drawing: drawingKey,
art: 2,
layers: [ {
text: "ä½ å¥½",
x: 100, y: 2000,
fontId: Drawing.font.getId("Source Han Sans CN"), // chinese font
colorId : colorId,
fontSize: 100} ]});
DrawingTools.Text.createTextLayers({
drawing: drawingKey, art: 2,
layers: [ {
width: 2000,
underLayer: 1,
colorMatrix : {
xAxis : { x: 3000, y: 100 },
yAxis : { x: 500, y: 1000 },
origin : { x: 500, y: -500 }
},
text: "Hello, here is a text layer that fits on multiple lines.",
alignment: "justify",
x: 0, y: 0, fontId: Drawing.font.getId("Arial"),
colorId : colorId,
fontSize: 48} ]
});
Parameters:
Name |
Type |
Description |
arg |
Object
|
Properties
Name |
Type |
Description |
drawing |
DrawingKey
|
The drawing key. |
art |
int
|
The art identifier |
layers |
Array.<TextLayer>
|
The text layers. |
|
(inner) eraseTextLayers(arg)
This function deletes a list of text layers. Be careful to the order of the text layer ids when removing many layers.
They must be in decreasing order.
Example
var nodeDrawingKey =
{
node : "Top/Drawing",
frame : 1
};
var drawingKey = Drawing.Key(nodeDrawingKey);
var t = Drawing.text.getTextLayers({ drawing: drawingKey, art: 2});
System.println(t.length + " text layers in the drawing");
// Erase the top text layer
if (t.length > 1)
DrawingTools.Text.eraseTextLayers({ drawing: drawingKey, art: 2, layers: [t.length-1]});
Parameters:
Name |
Type |
Description |
arg |
Object
|
Properties
Name |
Type |
Description |
drawing |
DrawingKey
|
The drawing key. |
art |
int
|
The art identifier |
layers |
Array.<int>
|
The text layers ids. |
|