kopia lustrzana https://github.com/villares/sketch-a-day
Update sketch_2020_06_10a.pyde
rodzic
eaf265dbc7
commit
ca213f4052
|
@ -3,21 +3,21 @@ def setup():
|
|||
noStroke()
|
||||
|
||||
def draw():
|
||||
tc = poly_points(250, 250, 100, n=6)
|
||||
background(0)
|
||||
noStroke()
|
||||
tc = poly_points(250, 250, 100, n=12)
|
||||
for i, p in enumerate(tc):
|
||||
t(p[0], p[1], 100,
|
||||
5 * i * radians(60))
|
||||
t(p[0], p[1], 100, 5 * i * radians(210))
|
||||
|
||||
def t(x, y, s, rot=0):
|
||||
pp = poly_points(x, y, s, ,3, rot + PI)
|
||||
def t(x, y, s, rot=0, d=35):
|
||||
pp = poly_points(x, y, s, 3, rot + PI)
|
||||
fill(255)
|
||||
beginShape()
|
||||
for p in pp:
|
||||
vertex(*p)
|
||||
endShape(CLOSE)
|
||||
e0 = div_points(pp[0], pp[1])
|
||||
e1 = div_points(pp[1], pp[2])[::-1]
|
||||
stroke(0)
|
||||
e0 = div_points(pp[0], pp[1], d)
|
||||
e1 = div_points(pp[1], pp[2], d)[::-1]
|
||||
fill(0)
|
||||
lines = zip(e0, e1)
|
||||
for la, lb in zip(lines[:-1:2], lines[1::2]):
|
||||
|
@ -27,7 +27,7 @@ def t(x, y, s, rot=0):
|
|||
x2, y2, x3, y3)
|
||||
|
||||
def poly_points(x, y, r, n, rot=0):
|
||||
a = TWO_PI / n
|
||||
a = TWO_PI / n
|
||||
points = []
|
||||
for i in range(n):
|
||||
px = x + r * cos(a * i + rot)
|
||||
|
@ -35,7 +35,7 @@ def poly_points(x, y, r, n, rot=0):
|
|||
points.append((px, py))
|
||||
return points
|
||||
|
||||
def div_points(a, b, n=10):
|
||||
return [(lerp(a[0], b[0], float(i) / n),
|
||||
lerp(a[1], b[1], float(i) / n))
|
||||
for i in range(1, n)]
|
||||
def div_points(a, b, d=10):
|
||||
return [(lerp(a[0], b[0], float(i) / d),
|
||||
lerp(a[1], b[1], float(i) / d))
|
||||
for i in range(1, d)]
|
||||
|
|
Ładowanie…
Reference in New Issue