gif.add_frame(image, delay: 50)
Adds a frame to the animated GIF.
add_frame takes a rendered GD::Image and appends it
as a frame in the animated GIF.
Frames are played back in the order they are added.
image (GD::Image)The image to use as a frame.
img = GD::Image.new(200, 200)
gif.add_frame(img)
delay (Integer, optional)The duration each frame is displayed.
50 (0.5 seconds)gif.add_frame(img, delay: 10)
close is calledgif = GD::Gif.new("animation.gif")
10.times do |i|
img = GD::Image.new(200, 200)
img.filled_circle(
100,
100,
20 + i * 5,
GD::Color.rgb(255, 0, 0)
)
gif.add_frame(img, delay: 5)
end
gif.close