Skip to content

Commit

Permalink
added example using text meshing
Browse files Browse the repository at this point in the history
  • Loading branch information
jimy-byerley committed Oct 13, 2023
1 parent 98d5fe2 commit b3c1ce0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from madcad import *

r = 1
h = 0.7
e = 0.1

# generate the shape to write on
shape = cylinder(vec3(0,0,-h), vec3(0,0,h), r)

# generate flat text as a Web (wireframe mesh)
label = text.text("foo bar", fill=False)
# wrap the mesh points around the cylinder
label.points = typedlist(vec3(cos(p.x/r), sin(p.x/r), p.y-0.5)*r
for p in label.points)
# extrude the mesh and give it a cylindric filling
label = intersection(
extrusion(
scale(vec3(1-e-0.1*r, 1-e-0.1*r, 1)),
label.transform(scale(vec3(1+e*1.1, 1+e*1.1, 1))),
),
inflate(shape, e),
)
# merge it onto the cylinder
result = union(shape, label).finish()
print(repr(result))

0 comments on commit b3c1ce0

Please sign in to comment.