text
Creates a text box in a diagram or scene.
Syntax
-
text(a, s)
-
x
is a two-dimensional real vector -
s
is a string
-
-
text(a, s[, d[, α]])
-
a
is a three-dimensional real vector -
s
is a string -
d
is a three-dimensional real vector -
α
is a real number
-
Description
In a diagram
text(a, s)
creates a text box with its top-left corner at a
and with text s
.
The text box is shown in the current diagram and a reference to the object is returned.
The visual properties of the object can be changed using the AdjustVisual
function.
In a scene
text(a, s, d, α)
creates a text box with its top-left corner at a
and with text s
. The normal direction of the text box is given by d
and the text is rotated by an amount α
about d
and its top-left corner.
If omitted, d
defaults to ❨0, 0, 1❩
and α
to 0
.
The object is shown in the current scene and a reference to the object is returned.
The AdjustVisual
function can be used to adjust the appearance of the text box. See Visual settings for a list of applicable settings.
Examples
d ≔ diagram("trig"); AdjustVisual(d.view, "xmin": −2⋅π, "xmax": 2⋅π, "ymin": −1.5, "ymax": 1.5); s ≔ LinePlot(graph(sin, −2⋅π, 2⋅π)); c ≔ LinePlot(graph(cos, −2⋅π, 2⋅π)); AdjustVisual(s, "line color": "blue"); AdjustVisual(c, "line color": "red"); st ≔ text(❨5, sin(5)❩, "sin"); ct ≔ text(❨5, cos(5)❩, "cos"); AdjustVisual(st, "text color": "blue"); AdjustVisual(ct, "text color": "red");
scene("text"); words ≔ first(SortBy(frequencies(words(ExampleData("Alice in Wonderland"))), (x ↦ −x[2])), 75); ForEach(words, w, ( t ≔ text(10⋅RandomSignedVector(3), w[1], ❨1, 0, 0❩); AdjustVisual(t, "font name": "Georgia", "font size": round(200 ⋅ √(w[2]/words[1][2])), "color": RandomColor(), "opacity": .7); ) );