Skip to content

Commit 54eff07

Browse files
docs: Add documentation for text
1 parent 5bb0c2c commit 54eff07

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

docs/primitives/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ The current list of primitives supported:
5353
- [point](point)
5454
- [polygon](polygon)
5555
- [sphere](sphere)
56+
- [text](text)
5657
- [tube](tube)
5758
- [uniformPolyhedron](uniformPolyhedron)

docs/primitives/text.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Properties:
2+
- `color` (type: [color](/mathics-threejs-backend/types/color)) — default: black
3+
- `coords` (type: [coord[]](/mathics-threejs-backend/types/coord)) — this **NEED** to be a relative coordinate. The z value will change the zIndex of the text
4+
- `texts` (type: string[]) — a list with the same size as `coords` containing the texts
5+
- `textSize = 20` (type: number) — the size in pixels of the text font. Default: `20`
6+
7+
Add 2d text captions to the scene.
8+
9+
## Examples
10+
- ```json
11+
{
12+
"type": "text",
13+
"color": [1, 0, 0],
14+
"coords": [
15+
[null, [0, 0, 0]],
16+
[null, [1, 1, 1]]
17+
],
18+
"texts": [
19+
"Bottom left",
20+
"Top right"
21+
]
22+
}
23+
```
24+
<div class='center' id='graphics-container-1'></div>
25+
<script>
26+
drawGraphics3d(
27+
document.getElementById('graphics-container-1'),
28+
{
29+
elements: [
30+
{
31+
type: 'text',
32+
color: [1, 0, 0],
33+
coords: [
34+
[null, [0, 0, 0]],
35+
[null, [1, 1, 1]]
36+
],
37+
texts: [
38+
"Bottom left",
39+
"Top right"
40+
]
41+
}
42+
],
43+
viewpoint: [2, -4, 4]
44+
}
45+
);
46+
</script>

0 commit comments

Comments
 (0)