animated_  pict_  gif
animated_  pict_  write_  animated_  gif
animated_  pict_  frames
frames_  write_  animated_  gif
frame_  bitmap
Disposal
Disposal.any
Disposal.keep
Disposal.restore-bg
Disposal.restore-prev
0.47+9.2

animated_pict_gif🔗ℹ

Alex Knauth

source code: https://github.com/AlexKnauth/animated-pict-gif

 import: animated_pict_gif package: animated-pict-gif

A Rhombus library wrapper around mrlib/gif, to write Rhombus animated picts as animated GIF files.

function

fun animated_pict_write_animated_gif(

  animated_pict :: Pict,

  delay_csec :: Int.in(0 ..= 4294967295),

  filename :: PathString,

  ~loop: loop :: Boolean = delay_csec && #true,

  ~one_at_a_time: one_at_a_time :: Boolean = #false,

  ~last_frame_delay: last_frame_delay :: maybe(Int.in(0 ..= 4294967295)) = #false,

  ~disposal: disposal :: Disposal = Disposal.any,

  ~kind: kind :: draw.Bitmap.Kind = draw.Bitmap.Kind.alpha,

)

Writes the animated_pict to filename as an animated GIF. The delay_csec argument is the amount of time in 1/100ths of a second to wait between frames. If loop is #true, then the GIF is marked as a looping animation.

If last_frame_delay is not #false, a delay of last_frame_delay in 1/100ths of a second is added to the last frame. This extra delay is useful when loop is true.

The kind argument determines whether it includes color pixels and whether it includes an alpha channel to record the opacity of each pixel.

For the meaning of the one_at_a_time argument and the disposal argument, see #{write-animated-gif} from mrlib/gif and #{gif-add-control} from file/gif.

def sq: square(~size: 18, ~fill: "lightblue")

def cr: circle(~size: 12, ~fill: "pink")

def tri: triangle(~width: 16, ~fill: "black")

def pre: beside(sq, cr).scale(1.5)

def post: beside(~sep: 5, cr, tri, sq)

def bg: rectangle(~width: 60, ~height: 30, ~fill: "white")

animated_pict_write_animated_gif(

  overlay(bg, magic_move(pre, post, ~other: #'fade)),

  8,

  magic_move_fade_gif)

function

fun animated_pict_frames(

  animated_pict :: Pict,

  delay_csec :: Int.in(0 ..= 4294967295),

) :: List.of(StaticPict)

Takes snapshots of the animated_pict at intervals of delay_csec in 1/100ths of a second, using the Pict.snapshot method, collecting the results into a List.

function

fun frames_write_animated_gif(

  picts :: List.of(StaticPict),

  delay_csec :: Int.in(0 ..= 4294967295),

  filename :: PathString,

  ~loop: loop :: Boolean = delay_csec && #true,

  ~one_at_a_time: one_at_a_time :: Boolean = #false,

  ~last_frame_delay: last_frame_delay :: maybe(Int.in(0 ..= 4294967295)) = #false,

  ~disposal: disposal :: Disposal = Disposal.any,

  ~kind: kind :: draw.Bitmap.Kind = draw.Bitmap.Kind.alpha,

)

Writes the picts to filename as an animated GIF. The delay_csec argument is the amount of time in 1/100ths of a second to wait between frames. If loop is #true, then the GIF is marked as a looping animation.

If last_frame_delay is not #false, a delay of last_frame_delay in 1/100ths of a second is added to the last frame. This extra delay is useful when loop is true.

The kind argument determines whether it includes color pixels and whether it includes an alpha channel to record the opacity of each pixel.

For the meaning of the one_at_a_time argument and the disposal argument, see #{write-animated-gif} from mrlib/gif and #{gif-add-control} from file/gif.

function

fun frame_bitmap(

  p :: StaticPict,

  ~kind: kind :: draw.Bitmap.Kind = draw.Bitmap.Kind.alpha,

) :: draw.Bitmap

Converts p into a bitmap.

The kind argument determines whether it includes color pixels and whether it includes an alpha channel to record the opacity of each pixel.

Specifies the frame disposal method, which determines how the previous frame is treated when writing a transparent frame. See #{gif-add-control} from file/gif for the meaning of the various disposal options.