villares 2019-05-09 23:39:39 -03:00
rodzic 15937ef6af
commit 3935844b89
2 zmienionych plików z 61 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,50 @@
from pyp5js import *
sliders = []
def setup():
P5 = _P5_INSTANCE
createCanvas(windowWidth, windowHeight)
#createCanvas(600, 600)
for i in range(4):
s = P5.createSlider(0, 64, 0)
s.position(10, i * 30)
s.style("width", "200px")
sliders.append(s)
rectMode('center') # retângulos desenhados pelo centro
colorMode('hsb', 255, 255, 255)
strokeWeight(2) # espessura de linha 2px
noFill() # sem preenchimento
frameRate(30) # deixa um pouco mais lento
def draw():
background(200) # fundo cinza claro
grid_elem = 5 + sliders[0].value()
elem_size = 5 + sliders[1].value()
rand_size = sliders[2].value()
rand_posi = sliders[3].value()
# trava a randomização entre os ciclos de draw
# mas varia com o número de colunas na grade
randomSeed(int(grid_elem / 4))
# calcula o espaçamento entre os quadrandos
spac_size = int(width / (grid_elem + 1))
# para cada coluna um x
for x in range(spac_size / 2, width, spac_size):
# para cada linha um y
for y in range(spac_size / 2, width, spac_size):
# sorteia um tamanho (se o rand_size > 0)
square_size = elem_size + rand_size * random(-1, 1)
stroke(square_size * 3, 255, 128)
rect(x + rand_posi * random(-1, 1), # desenha um quadrado
y + rand_posi * random(-1, 1),
square_size,
square_size)
# def mousePressed():
# global grid_elem
# This is required by pyp5js to work
start_p5(setup, draw)

Wyświetl plik

@ -22,12 +22,23 @@ Get updates from my sort-of-weekly newsletter: [[sketch-mail](https://villares.o
## 2019
---
![sketch_190509a](2019/sketch_190509a/sketch_190509a.gif)
[sketch_190509a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190509a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
Ugly but works :)
---
![sketch_190508a](2019/sketch_190508a/sketch_190508a.gif)
sketch_190508a [[code for Py.Processing](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190508a)]
Back unfolding solids... 2D faces missing.
---
[![sketch_190507a](2019/sketch_190507a/sketch_190507a.png)](https://abav.lugaralgum.com/sketch-a-day/2019/sketch_190507a/index.html)