Kitty Graphics Protocol in OCaml
terminal graphics ocaml
1(** Animation Playback State 2 3 Controls the playback state of animated images. 4 5 {2 Protocol Details} 6 7 The animation state is specified via the [s] key in the control data 8 when using action [a=a]: 9 - [s=1]: stop animation 10 - [s=2]: run in loading mode 11 - [s=3]: run normally 12 13 {2 Animation Modes} 14 15 The protocol supports two animation approaches: 16 17 {b Terminal-driven animation}: The terminal automatically advances 18 frames based on the gap (delay) specified for each frame. Use 19 [{`Run}] or [{`Loading}] states. 20 21 {b Client-driven animation}: The client manually sets the current 22 frame using [Kgp.Animation.set_current_frame]. Use [{`Stop}] state 23 to prevent automatic advancement. 24 25 {2 Stop State} 26 27 [{`Stop}] halts automatic frame advancement. The animation freezes 28 on the current frame. Use this when: 29 - Implementing client-driven animation 30 - Pausing an animation 31 - Displaying a static frame from an animated image 32 33 {2 Loading State} 34 35 [{`Loading}] runs the animation but waits for new frames when reaching 36 the end instead of looping. Use this when: 37 - Streaming animation frames progressively 38 - Building an animation while displaying it 39 - The animation is not yet complete 40 41 {2 Run State} 42 43 [{`Run}] runs the animation normally, looping back to the first frame 44 after the last. The loop count can be controlled via the [loops] 45 parameter in [Kgp.Animation.set_state]. *) 46 47type t = [ `Stop | `Loading | `Run ] 48(** Animation playback states. 49 50 - [`Stop] - Halt animation playback. The animation freezes on the 51 current frame and does not advance automatically. 52 - [`Loading] - Run animation but wait for new frames at end. When 53 the last frame is reached, the animation pauses until more frames 54 are added, then continues. 55 - [`Run] - Run animation normally and loop. After the last frame, 56 playback returns to the first frame (or stops after the specified 57 number of loops). *) 58 59val to_int : t -> int 60(** Convert to protocol integer. 61 62 Returns 1 for [`Stop], 2 for [`Loading], or 3 for [`Run]. 63 These values are used in the [s=] control data key. *)