diff --git a/2021/sketch_2021_04_29f/sketch_2021_04_29f.png b/2021/sketch_2021_04_29f/sketch_2021_04_29f.png new file mode 100644 index 00000000..030e707d Binary files /dev/null and b/2021/sketch_2021_04_29f/sketch_2021_04_29f.png differ diff --git a/2021/sketch_2021_04_29f/sketch_2021_04_29f.pyde b/2021/sketch_2021_04_29f/sketch_2021_04_29f.pyde new file mode 100644 index 00000000..102d1ab5 --- /dev/null +++ b/2021/sketch_2021_04_29f/sketch_2021_04_29f.pyde @@ -0,0 +1,51 @@ +from __future__ import division +retangulos = [] + +def setup(): + size(600, 600) + grade(0, 0, 600, 600, 4, 4) + +def draw(): + background(200) + for r in retangulos: + x, y, w, h = r + if mouse_over(x, y, w, h): + fill(0, 0, 200, 100) + else: + fill(128, 100) + rect(x, y, w, h) +def mouse_over(x, y, w, h): + return (x < mouseX < x + w and + y < mouseY < y + h) # True/False + +def mousePressed(): + global arrastando + for i, (x, y, w, h) in enumerate(retangulos): + if mouse_over(x, y, w, h): + arrastando = i + +def mouseReleased(): + global arrastando + arrastando = None + +def mouseDragged(): + if arrastando != None: + dx = mouseX - pmouseX + dy = mouseY - pmouseY + x, y, w, h = retangulos[arrastando] + retangulos[arrastando] = (x + dx, y + dy, w, h) + +def grade(xo, yo, largura_total, altura_total, colunas, filas): + largura_celula = largura_total / colunas + altura_celula = altura_total / filas + for i in range(colunas): + x = xo + largura_celula * i + for j in range(filas): + y = yo + altura_celula * j + # fill(i * 64, j * 64, 128) + if largura_celula > 10 and random(10) > 5: + grade(x, y, largura_celula, altura_celula, 4, 4) + else: + # rect(x, y, largura_celula, altura_celula) + retangulos.append((x, y, largura_celula, altura_celula)) + diff --git a/README.md b/README.md index 4901db0d..a99e45fa 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,12 @@ Here are listed some of the tools I have been using: --- +![sketch_2021_04_29f](2021/sketch_2021_04_29f/sketch_2021_04_29f.png) + +[sketch_2021_04_29f](https://github.com/villares/sketch-a-day/tree/master/2021/sketch_2021_04_29f) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)] + +--- + ![sketch_2021_04_28_FreeCAD](2021/sketch_2021_04_28_FreeCAD/sketch_2021_04_28_FreeCAD.png) [sketch_2021_04_28_FreeCAD](https://github.com/villares/sketch-a-day/tree/master/2021/sketch_2021_04_28_FreeCAD) [[FreeCAD + Python](https://forum.freecadweb.org/viewtopic.php?f=22&t=4887)]