kopia lustrzana https://github.com/villares/sketch-a-day
main
rodzic
0684b59b30
commit
d60dce7be4
|
@ -30,8 +30,8 @@ def create_arrows():
|
|||
def draw():
|
||||
background(200)
|
||||
# stroke(h, 255, 200, 200)
|
||||
rad = 100 + mouseX
|
||||
m = mouseX / TAU
|
||||
rad = 100 + (mouseX / 10.) ** 2
|
||||
m = PI / 2 + mouseX / 50.
|
||||
start, sweep, thick = -PI - HALF_PI/2 + m/2, PI + HALF_PI - m, 50
|
||||
pushMatrix()
|
||||
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 *
|
||||
|
||||
many_arrows = []
|
||||
|
@ -16,12 +18,6 @@ def setup():
|
|||
for _ in range(3):
|
||||
many_arrows.append(create_arrows())
|
||||
|
||||
# global videoExport
|
||||
# videoExport = VideoExport(this, "video.mp4")
|
||||
# videoExport.setFrameRate(24)
|
||||
# videoExport.startMovie()
|
||||
frameRate(24)
|
||||
|
||||
def create_arrows():
|
||||
arrows = []
|
||||
for _ in range(10):
|
||||
|
@ -39,31 +35,32 @@ def draw():
|
|||
ini_arrows, fin_arrows = many_arrows[i], many_arrows[i - 1]
|
||||
for a, b in zip(ini_arrows, fin_arrows):
|
||||
rad, start, sweep, thick, h = lerp_arrow(b, a, tt)
|
||||
fill(h, 255, 200, 200)
|
||||
fill(h, 255, 200, 150)
|
||||
stroke(0)
|
||||
strokeWeight(2)
|
||||
display_arrow(rad, start, sweep, thick)
|
||||
|
||||
noFill()
|
||||
stroke(255)
|
||||
strokeWeight(5)
|
||||
rad, start, sweep, thick, _ = player_arrow
|
||||
display_arrow(rad, start, sweep, thick)
|
||||
# noFill()
|
||||
# stroke(255)
|
||||
# strokeWeight(5)
|
||||
# rad, start, sweep, thick, _ = player_arrow
|
||||
# display_arrow(rad, start, sweep, thick)
|
||||
|
||||
# videoExport.saveFrame()
|
||||
|
||||
t += (1 + width - t) / 300.
|
||||
t = lerp(t, width, .5)
|
||||
# t += (1 + width - t) / 300.
|
||||
print t
|
||||
if t > width:
|
||||
t += 1
|
||||
if t > 3 * width:
|
||||
if t <= width:
|
||||
t = lerp(t, width + 1, .1)
|
||||
elif t > width:
|
||||
t += 2
|
||||
if t > 1.5 * width:
|
||||
t = 0
|
||||
i = (i + 1) % 3
|
||||
# if i == 0:
|
||||
# videoExport.endMovie()
|
||||
# exit()
|
||||
|
||||
if i == 0:
|
||||
gif_export(GifMaker, finish=True)
|
||||
if frameCount % 2:
|
||||
gif_export(GifMaker, filename="c")
|
||||
|
||||
|
||||
def lerp_arrow(a, b, t):
|
||||
c = []
|
||||
for c_a, c_b in zip(a, b):
|
||||
|
@ -81,7 +78,7 @@ def random_arrow():
|
|||
d = -1 if random(100) >= 50 else 1
|
||||
return (int(random(height * 0.008, height * 0.08)) * 5,
|
||||
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
|
||||
random(255), # hue
|
||||
)
|
||||
|
|
Ładowanie…
Reference in New Issue