class · blotter.ts
Text
A string and the styles to draw it with. One per word or title you want rendered.
extends Emitter<TextEvents>
import { Text } from "blotter.ts"; A Text is measured and rasterised when it is constructed, so the font it names must already be loaded. It is a live object: assigning a new value or new properties notifies every Blotter that draws it, and they rebuild.
Blotter is for short strings: single words, titles, text used as a graphic. A whole paragraph as one Text makes a very large atlas and a canvas nobody can select.
import { Text } from "blotter.ts";
const text = new Text("observation", {
family: "'Castoro', serif",
size: 64,
fill: "#1c1917",
paddingLeft: 20,
paddingRight: 20,
}); Members #
constructor constructor
Takes the string and an optional partial TextProperties. Anything you leave out takes the default.
id property
A unique, read-only identifier for the instance.
value get / set
The string being drawn. Assigning a new one rebuilds every Blotter that draws this text.
properties get / set
The styles, as the full defaulted set when read. Assigning a partial object replaces them: it is merged over the defaults, not over the previous values, and then everything rebuilds. Spread the current properties first when you only want to change one.
text.properties = { ...text.properties, size: 90 }; update method
Notifies observers that this text changed. value and properties writes call it for you; call it yourself after a bulk edit.