kopia lustrzana https://github.com/villares/sketch-a-day
190908
rodzic
164eed165b
commit
b1665ca8c9
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 101 KiB |
|
@ -0,0 +1,25 @@
|
|||
def setup():
|
||||
size(500, 500)
|
||||
fill(200, 0, 0) # red fill
|
||||
stroke(0, 0, 200) # blue stroke
|
||||
strokeWeight(15)
|
||||
star(250, 250, 7, 200, 100) # 7 pointed star
|
||||
|
||||
def star(x, y, np, re, ri):
|
||||
"""
|
||||
draw a star with np tips
|
||||
external radius re, internal radius ri
|
||||
"""
|
||||
pushMatrix()
|
||||
translate(x, y)
|
||||
n = np * 2
|
||||
ang = radians(360. / n)
|
||||
beginShape()
|
||||
for i in range(n):
|
||||
if i % 2 == 0: r = ri
|
||||
else: r = re
|
||||
x = sin(ang * i) * r
|
||||
y = cos(ang * i) * r
|
||||
vertex(x, y)
|
||||
endShape(CLOSE)
|
||||
popMatrix()
|
Ładowanie…
Reference in New Issue