kopia lustrzana https://github.com/villares/sketch-a-day
main
rodzic
4b607c86a1
commit
68345b2a46
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 144 KiB |
|
@ -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")
|
||||
del(gifExporter)
|
||||
noLoop()
|
||||
return False
|
||||
else:
|
||||
return True
|
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 3.0 MiB |
|
@ -0,0 +1,58 @@
|
|||
# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day
|
||||
SKETCH_NAME, OUTPUT = "s158", ".gif" # 180607
|
||||
'''
|
||||

|
||||
|
||||
158: [code](https://github.com/villares/sketch-a-day/tree/master/s158) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
|
||||
'''
|
||||
|
||||
add_library('gifAnimation')
|
||||
from gif_export_wrapper import *
|
||||
|
||||
perlinScale = 0.02
|
||||
yo = 0
|
||||
|
||||
def setup():
|
||||
print_text_for_readme(SKETCH_NAME, OUTPUT)
|
||||
size(500, 500, P3D)
|
||||
stroke(200)
|
||||
noFill()
|
||||
strokeWeight(2)
|
||||
|
||||
def draw():
|
||||
#translate(0, 0, 0)
|
||||
rotateX(radians(200))
|
||||
global yo
|
||||
background(0)
|
||||
lines = []
|
||||
for l in range(-40, 10):
|
||||
line_ = []
|
||||
beginShape()
|
||||
y = l * 10
|
||||
for x in range(40, width - 40, 10):
|
||||
n = noise((x + yo / 4) * perlinScale,
|
||||
(l * -4 + yo) * 2 * perlinScale)
|
||||
a = (250 - abs(x - width / 2)) / 2
|
||||
z = height / 2 + map(n, 0, 1, -a, 0)
|
||||
vertex(x, y, z)
|
||||
line_.append((x, y, z))
|
||||
endShape()
|
||||
lines.append(line_)
|
||||
yo += 0.5
|
||||
for line1, line2 in zip(lines, lines[1:]):
|
||||
for i, (x1, y1, z1) in enumerate(line1):
|
||||
x2, y2, z2 = line2[i]
|
||||
line(x1, y1, z1, x2, y2, z2)
|
||||
|
||||
gif_export(GifMaker, frames=200, filename=SKETCH_NAME)
|
||||
# if frameCount <= 50:
|
||||
# saveFrame(OUTPUT)
|
||||
|
||||
def print_text_for_readme(name, output):
|
||||
println("""
|
||||

|
||||
|
||||
{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:], output)
|
||||
)
|
Ładowanie…
Reference in New Issue