-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathBitBop.pv
More file actions
49 lines (43 loc) · 1.64 KB
/
Copy pathBitBop.pv
File metadata and controls
49 lines (43 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
Using a text path to position other primitives.
In addition to using the text() command to draw type immediately, you
can call textpath() to trace the text's outline into a Bezier path (without
adding it to the canvas). The Bezier can be manipulated or, as demonstrated
# here, queried using its .contains() method.
"""
size(550, 140)
background('#ca0')
fill('#223', .75)
# Set the font and create a text path.
font("Verdana", 100)
align(CENTER)
tp = textpath("PlotDevice", WIDTH/2, 100)
# plot(tp) # Draws the underlying path
# Here are the variables that influence the composition:
resx = 100 # The horizontal resolution
resy = 100 # The vertical resolution
rx = 5.0 # The horizontal randomness each point has
ry = 5.0 # The vertical randomness each point has
dotsize = 3.0 # The maximum size of one dot.
dx = WIDTH / float(resx) # The width each dot covers
dy = HEIGHT / float(resy) # The height each dot covers
# We create a grid of the specified resolution. For each x,y
# coordinate in the space, we first check whether it lies within
# one of the letterforms, then (if so) draw a random square.
for x, y in grid(resx, resy):
sz = random(dotsize)
# Create the point that will be checked
x = x*dx-sz
y = y*dy-sz
# Only do something if the point falls within the path bounds.
# You could add an "else" statement, that draws something in the
# empty positions.
if tp.contains(x, y):
# Change the color for each point -- try it out!
# fill(random(), 0,0, random())
poly(x+random(-rx, rx),
y+random(-ry, ry),
sz)
# else:
# with fill('white',.2):
# arc(x,y,sz)