TextBuilder
A builder for the Text item.
Extends GenericItemBuilder
Example
import OBR, { buildText } from "@owlbear-rodeo/sdk";
const item = buildText()
.richText([
{
type: "paragraph",
children: [{ text: "Owlbear Rodeo" }],
},
])
.build();
OBR.scene.items.addItems([item]);
Reference
Methods
text
text(text);
Set the texts text content.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| text | TextContent | The content of the text |
Returns the current builder.
width
width(width);
Set the texts width.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| width | TextSize | The text width |
Returns the current builder.
height
height(height);
Set the texts height.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| height | TextSize | The text height |
Returns the current builder.
richText
richText(richText);
Set the texts richText.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| richText | RichText | The rich text |
Returns the current builder.
plainText
plainText(plainText);
Set the texts plainText.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| plainText | string | The plain text |
Returns the current builder.
textType
textType(textType);
Set the texts textType.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| textType | "PLAIN" | "RICH" | The text type |
Returns the current builder.
padding
padding(padding);
Set the text styles padding.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| padding | number | The text padding |
Returns the current builder.
fontFamily
fontFamily(fontFamily);
Set the text styles fontFamily.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fontFamily | string | The text font family |
Returns the current builder.
fontSize
fontSize(fontSize);
Set the text styles fontSize.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fontSize | number | The text font size |
Returns the current builder.
fontWeight
fontWeight(fontWeight);
Set the text styles fontWeight.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fontWeight | number | The text font weight |
Returns the current builder.
textAlign
textAlign(textAlign);
Set the text styles textAlign.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| textAlign | "LEFT" | "CENTER" | "RIGHT" | The text horizontal alignment |
Returns the current builder.
textAlignVertical
textAlignVertical(textAlignVertical);
Set the text styles textAlignVertical.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| textAlignVertical | "BOTTOM" | "MIDDLE" | "TOP" | The text vertical alignment |
Returns the current builder.
fillColor
fillColor(fillColor);
Set the text styles fillColor.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fillColor | string | The texts fill color |
Returns the current builder.
fillOpacity
fillOpacity(fillOpacity);
Set the text styles fillOpacity.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fillOpacity | number | The texts fill opacity |
Returns the current builder.
strokeColor
strokeColor(strokeColor);
Set the text styles strokeColor.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| strokeColor | string | The texts stroke color |
Returns the current builder.
strokeOpacity
strokeOpacity(strokeOpacity);
Set the text styles strokeOpacity.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| strokeOpacity | number | The texts stroke opacity |
Returns the current builder.
strokeWidth
strokeWidth(strokeWidth);
Set the text styles strokeWidth.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| strokeWidth | number | The texts stroke width |
Returns the current builder.
lineHeight
lineHeight(lineHeight);
Set the text styles lineHeight.
Parameters
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| lineHeight | number | The texts line height |
Returns the current builder.
build
build();
Returns the final Text item.