Kitty Graphics Protocol in OCaml
terminal graphics ocaml
1(** Pixel Composition Mode 2 3 Controls how pixels are blended when compositing images or animation frames. 4 5 {2 Protocol Details} 6 7 The composition mode is specified via the [X] key in the control data 8 (for animation frames) or the [C] key (for frame composition operations): 9 - Value 0 or omitted: alpha blending (default) 10 - Value 1: simple overwrite/replacement 11 12 {2 Alpha Blending} 13 14 [{`Alpha_blend}] performs standard alpha compositing using the source 15 pixel's alpha channel. For each pixel: 16 - If source alpha is 255 (opaque), source pixel replaces destination 17 - If source alpha is 0 (transparent), destination pixel is unchanged 18 - Otherwise, colors are blended proportionally 19 20 This mode is essential for: 21 - Transparent PNG images 22 - Overlaying graphics on backgrounds 23 - Anti-aliased edges and text 24 25 {2 Overwrite Mode} 26 27 [{`Overwrite}] simply replaces destination pixels with source pixels, 28 ignoring the alpha channel. This is useful for: 29 - Performance optimization when transparency isn't needed 30 - Replacing rectangular regions entirely 31 - Animation frames that completely replace the previous frame *) 32 33type t = [ `Alpha_blend | `Overwrite ] 34(** Composition modes. 35 36 - [`Alpha_blend] - Full alpha blending (default). Source pixels are 37 composited onto the destination using standard Porter-Duff "over" 38 compositing based on the source alpha channel. 39 - [`Overwrite] - Simple pixel replacement. Source pixels completely 40 replace destination pixels, ignoring alpha values. Faster but no 41 transparency support. *) 42 43val to_int : t -> int 44(** Convert to protocol integer. 45 46 Returns 0 for [`Alpha_blend] or 1 for [`Overwrite]. 47 These values are used in the [X=] or [C=] control data keys. *)