kopia lustrzana https://github.com/villares/sketch-a-day
20&21
rodzic
44f52301bd
commit
d93c9e64f4
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 2.1 MiB |
|
@ -1,14 +1,15 @@
|
||||||
# based on https://twitter.com/Hau_kun/status/1163867191252410368?s=20
|
# based on https://twitter.com/Hau_kun/status/1163867191252410368?s=20
|
||||||
|
|
||||||
p,s=[[0]*4 for _ in range(99)],720
|
s,p,r=720,[[360]*4 for _ in range(99)],random
|
||||||
def setup():size(s,s);colorMode(HSB)
|
def setup():size(s,s);colorMode(HSB)
|
||||||
def draw():
|
def draw():
|
||||||
clear()
|
clear()
|
||||||
for f in p:
|
for f in p:
|
||||||
x,y,z,w=f
|
x,y,z,w=f
|
||||||
a,d,r=atan2(w-y,z-x),dist(*f)/100,random
|
a,d=atan2(w-y,z-x),dist(*f)/100
|
||||||
f[2:4]=[r(s)if d<1 else z,r(s)if d<1 else w]
|
f[2:4]=r(s)if d<1 else z,r(s)if d<1 else w
|
||||||
f[0]+=cos(a)*d
|
f[0:2]=x+cos(a)*d,y+sin(a)*d
|
||||||
f[1]+=sin(a)*d
|
|
||||||
fill(d*50,s,s)
|
fill(d*50,s,s)
|
||||||
circle(x,y,10)
|
circle(x,y,10)
|
||||||
|
# if frameCount % 3 == 0:
|
||||||
|
# saveFrame("#####.png")
|
||||||
|
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 131 KiB |
|
@ -0,0 +1,66 @@
|
||||||
|
add_library('pdf')
|
||||||
|
linhas = []
|
||||||
|
divisoes = 5
|
||||||
|
salvar_pdf = False
|
||||||
|
ponto_clique = []
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
size(500, 500)
|
||||||
|
|
||||||
|
def draw():
|
||||||
|
if salvar_pdf:
|
||||||
|
beginRecord(PDF, "####.pdf")
|
||||||
|
|
||||||
|
stroke(255) # traço branco
|
||||||
|
strokeWeight(10) # espessura do traço ("peso")
|
||||||
|
mh, mv = width / 2, height / 2
|
||||||
|
translate(mh, mv)
|
||||||
|
background(0, 128, 32) # verde (mude a sua cor!)
|
||||||
|
|
||||||
|
for num in range(divisoes):
|
||||||
|
rotate(radians(360 / divisoes))
|
||||||
|
for linha in linhas:
|
||||||
|
x1, y1, x2, y2 = linha
|
||||||
|
line(x1 - mh, y1 - mv, x2 - mh, y2 - mv)
|
||||||
|
scale(1, -1)
|
||||||
|
line(x1 - mh, y1 - mv, x2 - mh, y2 - mv)
|
||||||
|
scale(1, -1)
|
||||||
|
|
||||||
|
if salvar_pdf:
|
||||||
|
endRecord()
|
||||||
|
global salvar_pdf
|
||||||
|
salvar_pdf = False
|
||||||
|
|
||||||
|
if ponto_clique:
|
||||||
|
for num in range(divisoes):
|
||||||
|
rotate(radians(360 / divisoes))
|
||||||
|
line(ponto_clique[0] - mh, ponto_clique[1] - mv,
|
||||||
|
mouseX - mh, mouseY - mv)
|
||||||
|
scale(1, -1)
|
||||||
|
line(ponto_clique[0] - mh, ponto_clique[1] - mv,
|
||||||
|
mouseX - mh, mouseY - mv)
|
||||||
|
scale(1, -1)
|
||||||
|
|
||||||
|
def mousePressed(): # def mouseDragged():
|
||||||
|
if ponto_clique:
|
||||||
|
px, py = ponto_clique
|
||||||
|
linhas.append((px, py, mouseX, mouseY))
|
||||||
|
if mouseButton == LEFT:
|
||||||
|
ponto_clique[:] = mouseX, mouseY
|
||||||
|
elif mouseButton == RIGHT:
|
||||||
|
ponto_clique[:] = []
|
||||||
|
|
||||||
|
def keyPressed():
|
||||||
|
if key == "a":
|
||||||
|
linhas[:] = [] # esvazia lista de linhas
|
||||||
|
ponto_clique[:] = []
|
||||||
|
if key == "g":
|
||||||
|
saveFrame("#####.png")
|
||||||
|
print("salvando PNG")
|
||||||
|
if key == "p":
|
||||||
|
global salvar_pdf
|
||||||
|
salvar_pdf = True
|
||||||
|
print("salvando PDF")
|
||||||
|
if keyCode == BACKSPACE and linhas:
|
||||||
|
linhas[:] = linha[:-1]
|
||||||
|
|
Ładowanie…
Reference in New Issue