diff --git a/2019/sketch_191011a/0002.png b/2019/sketch_191011a/0002.png new file mode 100644 index 00000000..b169fae6 Binary files /dev/null and b/2019/sketch_191011a/0002.png differ diff --git a/2019/sketch_191011a/0003.png b/2019/sketch_191011a/0003.png new file mode 100644 index 00000000..8185da31 Binary files /dev/null and b/2019/sketch_191011a/0003.png differ diff --git a/2019/sketch_191011a/0004.png b/2019/sketch_191011a/0004.png new file mode 100644 index 00000000..4de17c5e Binary files /dev/null and b/2019/sketch_191011a/0004.png differ diff --git a/2019/sketch_191011a/elementos.py b/2019/sketch_191011a/elementos.py new file mode 100644 index 00000000..b77238d5 --- /dev/null +++ b/2019/sketch_191011a/elementos.py @@ -0,0 +1,67 @@ +# -*- encoding: utf-8 -*- + +def poly_arrow(x, y, tamanho): + """ Casinha na posição x, y com largura e altura 'tamanho' """ + metade = tamanho / 2 + pushMatrix() # preserva o sistema de coordenadas atual + translate(x, y) # translada a origem do sistema de coordenadas + beginShape() # começa a desenhar a forma, inicia um polígono + vertex(0, -metade) + vertex(-metade, 0) + vertex(-metade, metade) + vertex(0, 0) + vertex(metade, metade) + vertex(metade, 0) + # vertex(0, 0) + endShape(CLOSE) # encerra a forma a fechando no primeiro vértice + popMatrix() # retorna o sistema de coordenadas anterior + + +def casinha(x, y, tamanho): + """ Casinha na posição x, y com largura e altura 'tamanho' """ + metade = tamanho / 2 + pushMatrix() # preserva o sistema de coordenadas atual + translate(x, y) # translada a origem do sistema de coordenadas + beginShape() # começa a desenhar a forma, inicia um polígono + vertex(0, -metade) + vertex(-metade, 0) + vertex(-metade, metade) + vertex(metade, metade) + vertex(metade, 0) + endShape(CLOSE) # encerra a forma a fechando no primeiro vértice + popMatrix() # retorna o sistema de coordenadas anterior + +def estrela(x_centro, y_centro, num_pontas, raio_a, raio_b): + """ + Desenha uma estrela com np pontas + raio a e raio b são os raios internos e das pontas + """ + n = num_pontas * 2 # dobro de pontos que as pontas + inc = radians(360. / n) # ângulo de eincremento entre os pontos + beginShape() # começa a desenhar a forma + ang = 0 # começando com o ângulo 0 + while ang < TWO_PI: + x = x_centro + sin(ang) * raio_a + y = y_centro + cos(ang) * raio_a + vertex(x, y) + ang += inc + x = x_centro + sin(ang) * raio_b + y = y_centro + cos(ang) * raio_b + vertex(x, y) + ang += inc + endShape(CLOSE) # encerra uma forma fechada + + +def olho(x, y, largura, cor=color(100)): + """ Olho na posição x, y com largura e cor """ + pushStyle() # preserva os atributos gráficos atuais + noStroke() + fill(255) + ellipse(x, y, largura, largura * .45) + fill(cor) + circle(x, y, largura * .4) + fill(0) + circle(x, y, largura * .1) + popStyle() # retorna os atributos gráficos anteriores + + diff --git a/2019/sketch_191011a/sketch_191011a.pyde b/2019/sketch_191011a/sketch_191011a.pyde new file mode 100644 index 00000000..cd76cb93 --- /dev/null +++ b/2019/sketch_191011a/sketch_191011a.pyde @@ -0,0 +1,55 @@ +from random import choice +from elementos import casinha, estrela, poly_arrow + +def setup(): + size(768, 768) + noLoop() + colorMode(HSB) + rectMode(CENTER) + strokeJoin(ROUND) + +def draw(): + background(255) + grade(width / 2., width / 2., 4, width) + +def grade(xo, yo, n, tw, e=None): + cw = tw / n + offset = (cw - tw) / 2 + for i in range(n): + x = xo + offset + cw * i + for j in range(n): + y = yo + offset + cw * j + o = 1 + (i + j * 2) % 8 + noFill() + if e is not None: + element(x, y, cw, e) + elif cw > 20 and random(10) < 6: + grade(x, y, 4, cw) + elif cw > 10 and random(10) < 6: + grade(x, y, 2, cw, 0) + else: + element(x, y, cw, o) + + +def element(x, y, w, option): + stroke(0) + noFill() + strokeWeight(1) + p = choice((0, 1, 2)) + pushMatrix() + translate(x, y) + rotate(HALF_PI * p) + if option == 0: + poly_arrow(0, 0, w * 4) + # estrela(x, y, p, choice((w/6, w*.1, w*.2)), w/3) + else: + # casinha(x, y, choice((w/2, w*.9, w*.6))) + # fill(option * 32, 200, 200) + fill(0) + poly_arrow(0, 0, w) + popMatrix() + +def keyPressed(): + if key == 's': + saveFrame("####.png") + redraw()