Mosaic_mlx.CanvasSourceMutable cell-level drawing surface.
A canvas is passed to the ~on_draw callback of the canvas element. Use the drawing functions to render content into the canvas grid.
type t = Mosaic_ui.Canvas.tThe type for canvases.
val width : t -> intwidth t is the grid width of t in cells.
val height : t -> intheight t is the grid height of t in cells.
val draw_text :
?style:Ansi.Style.t ->
?tab_width:int ->
t ->
x:int ->
y:int ->
text:string ->
unitdraw_text t ~x ~y ~text draws text as a single line at column x, row y.
style defaults to Ansi.Style.default. tab_width defaults to 8.
val fill_rect :
t ->
x:int ->
y:int ->
width:int ->
height:int ->
color:Ansi.Color.t ->
unitfill_rect t ~x ~y ~width ~height ~color fills the rectangle with the given background color.
val draw_box :
t ->
x:int ->
y:int ->
width:int ->
height:int ->
?border:Border.t ->
?sides:Border.side list ->
?style:Ansi.Style.t ->
?fill:Ansi.Color.t ->
?title:string ->
?title_alignment:[ `Left | `Center | `Right ] ->
?title_style:Ansi.Style.t ->
unit ->
unitdraw_box t ~x ~y ~width ~height () draws a Unicode box at column x, row y.
border defaults to Border.rounded.sides defaults to all four sides.style defaults to Ansi.Style.default.fill defaults to no fill.title defaults to no title.title_alignment defaults to `Left.title_style defaults to Ansi.Style.default.val draw_line :
t ->
x1:int ->
y1:int ->
x2:int ->
y2:int ->
?style:Ansi.Style.t ->
?glyphs:Matrix.Grid.line_glyphs ->
?kind:[ `Line | `Braille ] ->
unit ->
unitdraw_line t ~x1 ~y1 ~x2 ~y2 () draws a line from (x1, y1) to (x2, y2).
style defaults to Ansi.Style.default.glyphs defaults to standard box-drawing characters.kind defaults to `Line. Use `Braille for Braille dot patterns.val set_cell :
t ->
x:int ->
y:int ->
glyph:Matrix.Glyph.t ->
fg:Ansi.Color.t ->
bg:Ansi.Color.t ->
attrs:Ansi.Attr.t ->
?link:string ->
?blend:bool ->
unit ->
unitset_cell t ~x ~y ~glyph ~fg ~bg ~attrs () writes a single cell.
link defaults to no hyperlink. blend defaults to the canvas respect_alpha setting.
val clear : ?color:Ansi.Color.t -> t -> unitclear t clears the canvas grid and schedules a re-render.
color defaults to the terminal default background.
val grid : t -> Matrix.Grid.tgrid t is the underlying grid for t. Use this for operations not covered by the canvas drawing functions.
set_on_draw t cb registers cb as the render-time drawing callback for t. cb fires each render pass after the grid has been auto-resized; ~delta is the elapsed time in seconds since the last frame. Pass None to clear the callback.
set_on_resize t cb registers cb as the resize callback for t. cb fires when the canvas grid dimensions change. Pass None to clear the callback.
val request_render : t -> unitrequest_render t schedules a re-render of t. Call this after drawing outside of a draw callback.
val set_respect_alpha : t -> bool -> unitset_respect_alpha t v enables or disables alpha blending within the canvas grid.
val respect_alpha : t -> boolrespect_alpha t is true iff alpha blending is enabled.