创建 GIF 但看不到文件名 os glob
Creating GIF but cannot see filenames os glob
目标:将此输出导出为 GIF。
这是工作代码,使用 Processing 和 Python。
我无法读取图像文件名来创建 GIF。
我下载了 gif-animation-3.0
并将其放在 libraries
文件夹中。
尝试的解决方案:
import random
import glob
import os
add_library('gif-animation-3.0')
radius = 0
def setup():
global displayWidth, displayHeight, radius, num_frames
size(displayWidth, displayHeight)
background(0)
noFill()
stroke(255, 0, 0, 10)
radius = height / 2
num_frames = 0
global exporter
size(400, 400)
exporter = GifMaker(this, 'Examples/spiral-waves.gif')
exporter.setRepeat(0) # infinite repeat
exporter.setQuality(100) # test values
exporter.setDelay(200) # milliseconds
def draw():
global num_frames
num_frames += 1
print(num_frames)
global radius
center_x = width / 2
center_y = height / 2
beginShape()
for i in range(360):
_noise = noise(i * 0.02, float(frameCount) / 50)
x = center_x + radius * cos(radians(i)) * _noise
y = center_y + radius * sin(radians(i)) * _noise
curveVertex(x, y)
if radius == 0:
stroke(0, 0, 225, 25) # Blue
if radius == 100:
stroke(0, 225, 0, 25) # Green
if radius == 200:
stroke(225, 0, 0, 10) # Red
endShape(CLOSE)
radius -= 1
saveFrame('####.png')
if num_frames == 10:
noLoop()
exporter.addFrame()
exporter.finish()
控制台:
Maybe there's an unclosed paren or quote mark somewhere before this line?
如果还有什么我应该添加到 post 的,请告诉我。
pip install gifmaker
gifmaker -i *.png
目标:将此输出导出为 GIF。
这是工作代码,使用 Processing 和 Python。
我无法读取图像文件名来创建 GIF。
我下载了 gif-animation-3.0
并将其放在 libraries
文件夹中。
尝试的解决方案:
import random
import glob
import os
add_library('gif-animation-3.0')
radius = 0
def setup():
global displayWidth, displayHeight, radius, num_frames
size(displayWidth, displayHeight)
background(0)
noFill()
stroke(255, 0, 0, 10)
radius = height / 2
num_frames = 0
global exporter
size(400, 400)
exporter = GifMaker(this, 'Examples/spiral-waves.gif')
exporter.setRepeat(0) # infinite repeat
exporter.setQuality(100) # test values
exporter.setDelay(200) # milliseconds
def draw():
global num_frames
num_frames += 1
print(num_frames)
global radius
center_x = width / 2
center_y = height / 2
beginShape()
for i in range(360):
_noise = noise(i * 0.02, float(frameCount) / 50)
x = center_x + radius * cos(radians(i)) * _noise
y = center_y + radius * sin(radians(i)) * _noise
curveVertex(x, y)
if radius == 0:
stroke(0, 0, 225, 25) # Blue
if radius == 100:
stroke(0, 225, 0, 25) # Green
if radius == 200:
stroke(225, 0, 0, 10) # Red
endShape(CLOSE)
radius -= 1
saveFrame('####.png')
if num_frames == 10:
noLoop()
exporter.addFrame()
exporter.finish()
控制台:
Maybe there's an unclosed paren or quote mark somewhere before this line?
如果还有什么我应该添加到 post 的,请告诉我。
pip install gifmaker
gifmaker -i *.png