diff --git a/s161/gif_export_wrapper.py b/s161/gif_export_wrapper.py deleted file mode 100644 index ed24d706..00000000 --- a/s161/gif_export_wrapper.py +++ /dev/null @@ -1,44 +0,0 @@ -""" -Alexandre B A Villares http://abav.lugaralgum.com - GPL v3 - -A helper for the Processing gifAnimation library (https://github.com/jordanorelli) -ported to Processing 3 by 01010101 (https://github.com/01010101) -Download the library from https://github.com/01010101/GifAnimation/archive/master.zip -This helper was inspired by an example by Art Simon https://github.com/APCSPrinciples/AnimatedGIF/ - -Put at the start of your sketch: - add_library('gifAnimation') - from gif_exporter import gif_export -and at the end of draw(): - gif_export(GifMaker) -""" - -def gif_export(GifMaker, # gets a reference to the library - filename="exported", # .gif will be added - repeat=0, # 0 makes it an "endless" animation - quality=48, # quality range 0 - 255 - delay=170, # this is quick - frames=0): # 0 will stop on keyPressed or frameCount >= 100000 - global gifExporter - try: - gifExporter - except NameError: - gifExporter = GifMaker(this, filename + ".gif") - gifExporter.setRepeat(repeat) - gifExporter.setQuality(quality) - gifExporter.setDelay(delay) - gif_export._frame = frameCount - print("gif start") - - gifExporter.addFrame() - - if (frames == 0 and keyPressed or frameCount - gif_export._frame >= 100000) \ - or (frames != 0 and frameCount - gif_export._frame >= frames): - gifExporter.finish() - #background(255) - print("gif saved") - del(gifExporter) - noLoop() - return False - else: - return True diff --git a/s161/s161.pde b/s161/s161.pde new file mode 100644 index 00000000..62291bb1 --- /dev/null +++ b/s161/s161.pde @@ -0,0 +1,36 @@ +float x, y; // posição x, posição y +float px, py; // posição x anterior, posição y anterior +float tempoX = 0; // declarando a variável global tempoX e inicializando com 0 +float tempoY = 10; // declarando a variável global tempoY e inicializando com 10 + +void setup() { + size(500, 500); // define o tamanho da tela em pixels. Largura X Altura + x = width * noise(tempoX); // calcula a posição x inicial + y = height * noise(tempoY); // calcula a posição y inicial +} + +void draw() { + background(0); + px = x; // guarda a posição x na variável px + py = y; // guarda a posição y na variável py + x = width * noise(tempoX); // atualiza a posição x sorteando um valor + y = height * noise(tempoY); // atualiza a posição y sorteando um valor + olho(x, y , dist(px, py, x, y)*100); // desenha uma linha entre os pontos (px, py) e (x, y) + // incrementa os tempos a cada frame + tempoX = tempoX + 0.005; + tempoY = tempoY + 0.005; +} + + +void olho(float x, float y, float tamanho) { + noStroke(); + // branco + fill(255); + ellipse(x, y, tamanho, tamanho/2); + // iris + fill(random(256), random(256), random(256)); + ellipse(x, y, tamanho*.40, tamanho*.40); + // pupila + fill(0); + ellipse(x, y, tamanho*.10, tamanho*.10); +} diff --git a/s161/s161.pyde b/s161/s161.pyde deleted file mode 100644 index 83a9a690..00000000 --- a/s161/s161.pyde +++ /dev/null @@ -1,74 +0,0 @@ -# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day -SKETCH_NAME, OUTPUT = "s152", ".gif" # 180601 - -add_library('gifAnimation') -from gif_export_wrapper import * - -GRID_SIZE = 10 - -def setup(): - size(500, 500) - print_text_for_readme(SKETCH_NAME, OUTPUT) - border = 25 - spacing = (width - border * 2) / GRID_SIZE - Ponto.spacing = spacing - for j in range(GRID_SIZE): - for i in range(GRID_SIZE): - Ponto.PONTOS.append(Ponto(border + spacing / 2 + i * spacing, - border + spacing / 2 + j * spacing - )) - -def draw(): - fill(200, 4) - noStroke() - rect(0, 0, width, height) - for p in Ponto.PONTOS: - p.update() - for p in Ponto.PONTOS: - p.plot() - #noLoop() - - if frameCount % 2: - pass - #gif_export(GifMaker, frames=200, filename=SKETCH_NAME) - -class Ponto(): - PONTOS = [] - - def __init__(self, x, y): - self.tx = int(random(100)) - self.ty = int(random(100)) - self.random_speed = 0.01 - self.space = Ponto.spacing * 5 - self.ox = x - self.space*noise(self.tx) - self.oy = y - self.space*noise(self.ty) - - def update(self): - self.tx += self.random_speed - self.x = self.space*noise(self.tx) - self.ty += self.random_speed - self.y = self.space*noise(self.ty) - self.px = self.ox + self.x - self.py = self.oy + self.y - - def plot(self): - fill(0) - noStroke() - for p in Ponto.PONTOS: - if p != self and dist(p.px, p.py, - self.px, self.py) < Ponto.spacing * 1: - if frameCount % 2: # só desenha a linha um frame sim outro não - stroke(100, 0, 200) - line(p.px, p.py, self.px, self.py) - fill(0) - noStroke() - ellipse(self.px, self.py, 3, 3) - -def print_text_for_readme(name, output): - println(""" -![{0}]({0}/{0}{2}) - -{1}: [code](https://github.com/villares/sketch-a-day/tree/master/{0}) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)] - -""".format(name, name[1:], output) - )