kopia lustrzana https://github.com/villares/sketch-a-day
primeira versão
rodzic
1f874a3356
commit
3296f8b229
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 3.6 MiB |
|
@ -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=255, # quality range 0 - 255
|
||||
delay=170, # 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()
|
|
@ -0,0 +1,19 @@
|
|||
add_library('gifAnimation')
|
||||
from gif_animation_helper import gif_export
|
||||
|
||||
#つぶやきProcessing
|
||||
w,h=500,250
|
||||
def setup():size(w,w);noFill()#;stroke(0,64)
|
||||
def draw():
|
||||
background(h,h,h/2);translate(h,h)
|
||||
a,z=0,sin(frameCount/30.)
|
||||
while a<TWO_PI:
|
||||
x,y=sin(a),cos(a)
|
||||
n=h*noise((abs(x)+x+y),(abs(y)+y+x),z)
|
||||
ellipse(n*x,n*y,n*x/3,n*y/3)
|
||||
a+=.02
|
||||
|
||||
if frameCount/30. < TWO_PI:
|
||||
gif_export(GifMaker, filename="c")
|
||||
else:
|
||||
gif_export(GifMaker, finish=True)
|
Ładowanie…
Reference in New Issue