【发布时间】:2022-02-08 13:21:58
【问题描述】:
目标:将此输出导出为 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?
如果我还有什么需要补充的,请告诉我。
【问题讨论】:
-
这能回答你的问题吗? stackoverflow.com/questions/64215718/…
-
消息是否说明错误在哪里?现在你的代码的最后一部分是一个不会执行的三引号字符串。
-
我刚刚安装了
gifmakerPython 包,它对我来说很好用。用法 - 见https://neuropoly.github.io/gifmaker/usage/ -
@DmitryMesserman 如何制作能够更快浏览图像的 gif?
-
我没有使用
gifmaker包的经验。
标签: python-3.x processing gif glob