diff --git a/.gitignore b/.gitignore index bb5d7c19..af81b0d2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .DS_Store *.tga *.class +*.properties diff --git a/s141_s142_s143/gif_exporter.py b/s141_s142_s143/gif_exporter.py new file mode 100644 index 00000000..7b8283f2 --- /dev/null +++ b/s141_s142_s143/gif_exporter.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/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") + noLoop() + del(gifExporter) + return False + else: + return True diff --git a/s141_s142_s143/s140_s141_s142.png b/s141_s142_s143/s140_s141_s142.png new file mode 100644 index 00000000..93333e70 Binary files /dev/null and b/s141_s142_s143/s140_s141_s142.png differ diff --git a/s141_s142_s143/s141_s142_s143.pyde b/s141_s142_s143/s141_s142_s143.pyde new file mode 100644 index 00000000..ad5f7fca --- /dev/null +++ b/s141_s142_s143/s141_s142_s143.pyde @@ -0,0 +1,70 @@ +# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day +SKETCH_NAME = "s140_s141_s142" # 180522 Revisitig ideas from sketch s071 180312 + +# add_library('gifAnimation') +# from gif_exporter import * + + +def setup(): + print_text_for_readme(SKETCH_NAME) + size(1750, 700) + noFill() + +def draw(): + background(200) + grid = 4 + border = 0 + space = (height - border * 2) / grid + for x in range(grid): + for y in range(grid): + px = border + space / 2 + x * space + py = border + space / 2 + y * space + poly_shape(px, py, TWO_PI / (3 + y), rnd=3-x, gen=4, scaling=0) + translate(525,0) + for x in range(1, grid): + for y in range(grid): + px = border + space / 2 + x * space + py = border + space / 2 + y * space + poly_shape(px, py, TWO_PI / (3 + y), rnd=0, gen=4, scaling=x) + translate(525,0) + for x in range(1, grid): + for y in range(grid): + px = border + space / 2 + x * space + py = border + space / 2 + y * space + poly_shape(px, py, TWO_PI / (3 + y), rnd=x, gen=4, scaling=3) + + #gif_export(GifMaker, frames=10, filename=SKETCH_NAME) + saveFrame(SKETCH_NAME+".png") + noLoop() + +def poly_shape(x, y, angle, rnd=0, gen=4, scaling=0): + with pushMatrix(): + translate(x, y) + radius = map(scaling, 0, 3, gen * 8, gen ** 2 * 2.7) #+ random(-rnd, rnd) + ps = createShape() # to create a polygon on a ps PShape object + ps.beginShape() + a = 0 + while a < TWO_PI: + sx = cos(a) * radius + sy = sin(a) * radius + ps.vertex(sx + random(-rnd, rnd), sy + random(-rnd, rnd)) + a += angle + ps.endShape(CLOSE) # end of PShape creation + shape(ps, 0, 0) # Draw the PShape + if gen > 1: # if the recursion 'distance'/'depth' allows... + for i in range(ps.getVertexCount()): + # for each vertex + pv = ps.getVertex(i) # gets vertex as a PVector + # recusively call poly_shape with a smaller D + poly_shape(pv.x, pv.y, angle, rnd, gen - 1, scaling) + +def keyPressed(): + loop() + +def print_text_for_readme(name): + println(""" +![{0}]({0}/{0}.png) + +{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:]) + ) diff --git a/s141_s142_s143/s14X.png b/s141_s142_s143/s14X.png new file mode 100644 index 00000000..c1373dd7 Binary files /dev/null and b/s141_s142_s143/s14X.png differ