diff --git a/2019/sketch_190326a/sketch_190326a.gif b/2019/sketch_190326a/sketch_190326a.gif index a825727d..d058914b 100644 Binary files a/2019/sketch_190326a/sketch_190326a.gif and b/2019/sketch_190326a/sketch_190326a.gif differ diff --git a/2019/sketch_190330a/gif_exporter.py b/2019/sketch_190330a/gif_exporter.py new file mode 100644 index 00000000..51c431df --- /dev/null +++ b/2019/sketch_190330a/gif_exporter.py @@ -0,0 +1,40 @@ +""" +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/ + +# add at the start of your sketch: + add_library('gifAnimation') + from gif_exporter import gif_export +# add 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=255, # 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) + + gifExporter.addFrame() + + if frames == 0: + if keyPressed and key == "e": + finish = True + + if finish: + gifExporter.finish() + print("gif saved") + exit() diff --git a/2019/sketch_190330a/sketch_190330a.gif b/2019/sketch_190330a/sketch_190330a.gif new file mode 100644 index 00000000..1d4b31be Binary files /dev/null and b/2019/sketch_190330a/sketch_190330a.gif differ diff --git a/2019/sketch_190330a/sketch_190330a.pyde b/2019/sketch_190330a/sketch_190330a.pyde index 76e1c5a3..576afd0b 100644 --- a/2019/sketch_190330a/sketch_190330a.pyde +++ b/2019/sketch_190330a/sketch_190330a.pyde @@ -1,7 +1,14 @@ +# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day from __future__ import division from random import choice from arcs import poly_filleted +add_library('GifAnimation') +from gif_exporter import gif_export +""" +Oh, the difference a grid makes! +""" +SKETCH_NAME, OUTPUT = "sketch_190330a", ".gif" SPACING, MARGIN = 100, 100 X_LIST, Y_LIST = [], [] # listas de posições para elementos rad_list = [10, 20, 30, 40] @@ -44,12 +51,10 @@ def poly_arc_augmented(p_list, r_list): if a1 and a2: start = a1 if a1 < a2 else a1 - TWO_PI arc(p2.x, p2.y, r2 * 2, r2 * 2, start, a2) - elif a1: - println((a1, a2)) - ellipse(p1.x, p1.y, r1 * 2, r1 * 2) else: + # println((a1, a2)) + ellipse(p1.x, p1.y, r1 * 2, r1 * 2) ellipse(p2.x, p2.y, r2 * 2, r2 * 2) - println((a1, a2)) def circ_circ_tangent(p1, p2, r1, r2): @@ -73,10 +78,20 @@ def circ_circ_tangent(p1, p2, r1, r2): return (line_angle + theta) else: line(p1.x, p1.y, p2.x, p2.y) - return line_angle + return None def mouseClicked(): create_list() def keyPressed(): - saveFrame("s####.png") + gif_export(GifMaker, filename=SKETCH_NAME, delay=1200) + +# print text to add to the project's README.md +def settings(): + println( + """ +![{0}](2019/{0}/{0}{1}) + +[{0}](https://github.com/villares/sketch-a-day/tree/master/2019/{0}) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)] +""".format(SKETCH_NAME, OUTPUT) + ) diff --git a/README.md b/README.md index 220b16fa..0d4455ac 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,13 @@ Get updates from my sort-of-weekly newsletter: [[sketch-mail](https://villares.o ## 2019 + +--- + +![sketch_190330a](2019/sketch_190330a/sketch_190330a.gif) + +[sketch_190330a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190330a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)] + --- ![sketch_190329a](2019/sketch_190329a/sketch_190329a.gif) @@ -30,7 +37,6 @@ Get updates from my sort-of-weekly newsletter: [[sketch-mail](https://villares.o [sketch_190329a](https://github.com/villares/sketch-a-day/tree/master/2019/sketch_190329a) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)] - --- ![sketch_190328a](2019/sketch_190328a/sketch_190328a.png)