diff --git a/2020/sketch_2020_5_08a/gif_animation_helper.py b/2020/sketch_2020_5_08a/gif_animation_helper.py new file mode 100644 index 00000000..15d96d4c --- /dev/null +++ b/2020/sketch_2020_5_08a/gif_animation_helper.py @@ -0,0 +1,44 @@ +""" +Alexandre B A Villares http://abav.lugaralgum.com - GPL v3 + +A helper for the Processing gifAnimation library https://github.com/extrapixel/gif-animation/tree/3.0 +Download from https://github.com/villares/processing-play/blob/master/export_GIF/unzip_and_move_to_libraries_GifAnimation.zip +This helper was inspired by an example by Art Simon https://github.com/APCSPrinciples/AnimatedGIF/ + +v2019_09_23 + +# add at the start of your sketch: + add_library('gifAnimation') + from gif_animation_helper import gif_export +# add at the end of draw(): + gif_export(GifMaker, "filename") +""" + +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=32, # quality range 0 - 255 + delay=200, # this is quick + frames=0, # 0 will stop on keyPressed or frameCount >= 100000 + finish=False): # force stop + global gifExporter + try: + gifExporter + except NameError: + gifExporter = GifMaker(this, filename + ".gif") + gifExporter.setRepeat(repeat) + gifExporter.setQuality(quality) + gifExporter.setDelay(delay) + print("gif recording started") + + + gifExporter.addFrame() + + if (frames == 0 and keyPressed and key == "e" or + frames != 0 and frameCount >= frames): + finish = True + + if finish: + gifExporter.finish() + print("gif saved, exit") + exit() diff --git a/2020/sketch_2020_5_08a/sketch_2020_5_08a.gif b/2020/sketch_2020_5_08a/sketch_2020_5_08a.gif new file mode 100644 index 00000000..c2887ae9 Binary files /dev/null and b/2020/sketch_2020_5_08a/sketch_2020_5_08a.gif differ diff --git a/2020/sketch_2020_5_08a/sketch_2020_5_08a.pyde b/2020/sketch_2020_5_08a/sketch_2020_5_08a.pyde new file mode 100644 index 00000000..3f218fc6 --- /dev/null +++ b/2020/sketch_2020_5_08a/sketch_2020_5_08a.pyde @@ -0,0 +1,79 @@ +""" +Yet another noise fielf +""" + +add_library('GifAnimation') +from gif_animation_helper import gif_export +sketch_name = 'sketch_2020_05_7a' + +escala = 0.002 +xo = yo = zo = 0 +s_len = 30 +def setup(): + size(500, 500) + strokeWeight(2) + +def draw(): + background(240) + for x in range(-10, width + 10, 10): + for y in range(-10, height + 10, 10): + n = noise(x * escala, + y * escala, + zo * escala) + pushMatrix() + translate(x, y) + rotate(TWO_PI * n) + s = s_len * n + stroke(0, 200, 0) + line(-s, 0, s, 0) + popMatrix() + n = noise(x * escala, + y * escala, + (zo + yo)* escala) + pushMatrix() + translate(x, y) + rotate(TWO_PI * n) + s = s_len * n + stroke(0, 0, 200) + line(-s, 0, s, 0) + popMatrix() + n = noise(x * escala, + y * escala, + (zo + xo)* escala) + pushMatrix() + translate(x, y) + rotate(TWO_PI * n) + s = s_len * n + stroke(0) + line(-s, 0, s, 0) + popMatrix() + + +def keyPressed(): + gif_export(GifMaker, "animation", quality=10, delay=120) + + global xo, yo, zo, s_len, escala + if key == 'd': + escala += 0.001 + if key == 'c': + escala -= 0.001 + if key == 's': + s_len +=1 + if key == 'x': + s_len -=1 + if key == 'a': + zo +=10 + if key == 'z': + zo -=10 + if keyCode == UP: + yo -=10 + if keyCode == DOWN: + yo +=10 + if keyCode == RIGHT: + xo +=10 + if keyCode == LEFT: + xo -=10 + + if key == 'q': + gif_export(GifMaker, "animation", finish=True) + diff --git a/README.md b/README.md index b477f02c..5964c181 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ You may also support my artistic work, open educational resources and research u ## 2020 +--- + +![sketch_2020_05_08a](2020/sketch_2020_05_08a/sketch_2020_05_08a.gif) + +[sketch_2020_05_08a](https://github.com/villares/sketch-a-day/tree/master/2020/sketch_2020_05_08a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)] + + --- ![sketch_2020_05_07a](2020/sketch_2020_05_07a/sketch_2020_05_07a.gif)