kopia lustrzana https://github.com/villares/sketch-a-day
main
rodzic
0684b59b30
commit
d60dce7be4
|
@ -30,8 +30,8 @@ def create_arrows():
|
||||||
def draw():
|
def draw():
|
||||||
background(200)
|
background(200)
|
||||||
# stroke(h, 255, 200, 200)
|
# stroke(h, 255, 200, 200)
|
||||||
rad = 100 + mouseX
|
rad = 100 + (mouseX / 10.) ** 2
|
||||||
m = mouseX / TAU
|
m = PI / 2 + mouseX / 50.
|
||||||
start, sweep, thick = -PI - HALF_PI/2 + m/2, PI + HALF_PI - m, 50
|
start, sweep, thick = -PI - HALF_PI/2 + m/2, PI + HALF_PI - m, 50
|
||||||
pushMatrix()
|
pushMatrix()
|
||||||
translate(width / 2, height / 2 + rad)
|
translate(width / 2, height / 2 + rad)
|
||||||
|
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 3.7 MiB |
File diff suppressed because one or more lines are too long
|
@ -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=100, # 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()
|
|
@ -1,4 +1,6 @@
|
||||||
add_library('VideoExport')
|
add_library('gifAnimation')
|
||||||
|
from gif_animation_helper import gif_export
|
||||||
|
|
||||||
from arcs import *
|
from arcs import *
|
||||||
|
|
||||||
many_arrows = []
|
many_arrows = []
|
||||||
|
@ -16,12 +18,6 @@ def setup():
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
many_arrows.append(create_arrows())
|
many_arrows.append(create_arrows())
|
||||||
|
|
||||||
# global videoExport
|
|
||||||
# videoExport = VideoExport(this, "video.mp4")
|
|
||||||
# videoExport.setFrameRate(24)
|
|
||||||
# videoExport.startMovie()
|
|
||||||
frameRate(24)
|
|
||||||
|
|
||||||
def create_arrows():
|
def create_arrows():
|
||||||
arrows = []
|
arrows = []
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
|
@ -39,31 +35,32 @@ def draw():
|
||||||
ini_arrows, fin_arrows = many_arrows[i], many_arrows[i - 1]
|
ini_arrows, fin_arrows = many_arrows[i], many_arrows[i - 1]
|
||||||
for a, b in zip(ini_arrows, fin_arrows):
|
for a, b in zip(ini_arrows, fin_arrows):
|
||||||
rad, start, sweep, thick, h = lerp_arrow(b, a, tt)
|
rad, start, sweep, thick, h = lerp_arrow(b, a, tt)
|
||||||
fill(h, 255, 200, 200)
|
fill(h, 255, 200, 150)
|
||||||
stroke(0)
|
stroke(0)
|
||||||
strokeWeight(2)
|
strokeWeight(2)
|
||||||
display_arrow(rad, start, sweep, thick)
|
display_arrow(rad, start, sweep, thick)
|
||||||
|
|
||||||
noFill()
|
# noFill()
|
||||||
stroke(255)
|
# stroke(255)
|
||||||
strokeWeight(5)
|
# strokeWeight(5)
|
||||||
rad, start, sweep, thick, _ = player_arrow
|
# rad, start, sweep, thick, _ = player_arrow
|
||||||
display_arrow(rad, start, sweep, thick)
|
# display_arrow(rad, start, sweep, thick)
|
||||||
|
|
||||||
# videoExport.saveFrame()
|
# t += (1 + width - t) / 300.
|
||||||
|
|
||||||
t += (1 + width - t) / 300.
|
|
||||||
t = lerp(t, width, .5)
|
|
||||||
print t
|
print t
|
||||||
if t > width:
|
if t <= width:
|
||||||
t += 1
|
t = lerp(t, width + 1, .1)
|
||||||
if t > 3 * width:
|
elif t > width:
|
||||||
|
t += 2
|
||||||
|
if t > 1.5 * width:
|
||||||
t = 0
|
t = 0
|
||||||
i = (i + 1) % 3
|
i = (i + 1) % 3
|
||||||
# if i == 0:
|
if i == 0:
|
||||||
# videoExport.endMovie()
|
gif_export(GifMaker, finish=True)
|
||||||
# exit()
|
if frameCount % 2:
|
||||||
|
gif_export(GifMaker, filename="c")
|
||||||
|
|
||||||
|
|
||||||
def lerp_arrow(a, b, t):
|
def lerp_arrow(a, b, t):
|
||||||
c = []
|
c = []
|
||||||
for c_a, c_b in zip(a, b):
|
for c_a, c_b in zip(a, b):
|
||||||
|
@ -81,7 +78,7 @@ def random_arrow():
|
||||||
d = -1 if random(100) >= 50 else 1
|
d = -1 if random(100) >= 50 else 1
|
||||||
return (int(random(height * 0.008, height * 0.08)) * 5,
|
return (int(random(height * 0.008, height * 0.08)) * 5,
|
||||||
random(TWO_PI), # start
|
random(TWO_PI), # start
|
||||||
random(TWO_PI), # sweep
|
random(QUARTER_PI / 4, TWO_PI - QUARTER_PI / 4), # sweep
|
||||||
int(random(2, height / 50)) * 5 * d, # thickness
|
int(random(2, height / 50)) * 5 * d, # thickness
|
||||||
random(255), # hue
|
random(255), # hue
|
||||||
)
|
)
|
||||||
|
|
Ładowanie…
Reference in New Issue