Brr_canvas.CanvasCanvas element.
The type for HTMLCanvasElement objects.
val create :
?d:Brr.Document.t ->
?at:Brr.At.t list ->
?w:int ->
?h:int ->
Brr.El.t list ->
tcreate ~w ~h [] is a canvas element with a render buffer of wxh pixels (they default to 0).
of_el e is a canvas from element e. This throws a JavaScript error if e is not a canvas element.
val w : t -> intw c is the render buffer width of c in pixels.
val h : t -> inth c is the render buffer height of c in pixels.
val set_w : t -> int -> unitset_w c w sets the render buffer width of c to w pixels.
val set_h : t -> int -> unitset_h c h sets the render buffer height of c to h pixels.
val set_size_to_layout_size : ?hidpi:bool -> t -> unitset_size_to_layout_size t sets the render buffer size to the canvas' element Brr.El.inner_w Brr.El.inner_h and values. If hidpi is true (defaults), these values are multiplied by Brr.Window.device_pixel_ratio.
Context are obtained by the modules that handle them.
C2d.get_context.Gl.get_context.Brr_webgpu.Gpu.Canvas_context.get.val image_encode : ?type':Jstr.t -> ?quality:float -> unit -> image_encodeimage_encode ~type' ~quality () are image encoding parameters type' is the mime type of the image, it defaults to "image/png". quality a number from 0. to 1. if it makes sense for the data format (e.g. JPEG), default is implementation dependent.
val to_data_url :
?encode:image_encode ->
t ->
(Jstr.t, Jv.Error.t) Stdlib.resultto_data_url ~encode t is the canvas's image as a data url.
val to_blob : ?encode:image_encode -> t -> Brr.Blob.t option Fut.or_errorto_blob ~encode t is the canvas's image a blob object. None is returned either if the canvas has no pixels or if an error occurs during image serialisation.
val capture_stream : hz:int option -> t -> Brr_io.Media.Stream.tcapture_stream ~hz is a capture media stream for the canvas at the frequency of hz or manually if unspecified.