Alexandre B A Villares 2019-09-08 16:03:54 -03:00
rodzic 164eed165b
commit b1665ca8c9
2 zmienionych plików z 25 dodań i 0 usunięć

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 101 KiB

Wyświetl plik

@ -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()