Skip to content

Commit b3c1ce0

Browse files
committed
added example using text meshing
1 parent 98d5fe2 commit b3c1ce0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/text.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from madcad import *
2+
3+
r = 1
4+
h = 0.7
5+
e = 0.1
6+
7+
# generate the shape to write on
8+
shape = cylinder(vec3(0,0,-h), vec3(0,0,h), r)
9+
10+
# generate flat text as a Web (wireframe mesh)
11+
label = text.text("foo bar", fill=False)
12+
# wrap the mesh points around the cylinder
13+
label.points = typedlist(vec3(cos(p.x/r), sin(p.x/r), p.y-0.5)*r
14+
for p in label.points)
15+
# extrude the mesh and give it a cylindric filling
16+
label = intersection(
17+
extrusion(
18+
scale(vec3(1-e-0.1*r, 1-e-0.1*r, 1)),
19+
label.transform(scale(vec3(1+e*1.1, 1+e*1.1, 1))),
20+
),
21+
inflate(shape, e),
22+
)
23+
# merge it onto the cylinder
24+
result = union(shape, label).finish()
25+
print(repr(result))

0 commit comments

Comments
 (0)