Module Gtk_cairo.Gtk_cairo

module Gtk_cairo: sig .. end

An implementation of Renderer using GTK+ and cairo2 as the backend. This is the main renderer that supports all p5ml features.


type buffer = {
   window : GWindow.window;
   draw : GMisc.drawing_area;
   shape : Shape.t Stdlib.ref;
   surface : Cairo.Surface.t Stdlib.ref;
   context : Cairo.context Stdlib.ref;
   events : Renderer.event Stdlib.Queue.t;
   mutex : Mutex.t;
}
val width : buffer -> int
val height : buffer -> int
val apply_color : Color.color -> Cairo.context -> unit
val draw_path_sep : Paint.paint -> Paint.paint -> Cairo.context -> unit
val draw_path : Paint.paint -> Cairo.context -> unit
val handle_apply_vertex : 'a -> Cairo.context -> Shape.vertex -> unit
val handle_apply_shape : Paint.paint -> Cairo.context -> Shape.t -> unit
val queue_event : buffer -> Renderer.event -> unit
val expose : buffer ->
< misc : < window : [> `drawable ] Gobject.obj; .. >; .. > -> 'a -> bool
val redraw_trigger : buffer -> unit -> bool
val event_notifiers : [> `BUTTON_MOTION
| `BUTTON_PRESS
| `BUTTON_RELEASE
| `ENTER_NOTIFY
| `KEY_PRESS
| `KEY_RELEASE
| `LEAVE_NOTIFY
| `POINTER_MOTION
| `SCROLL ]
list
val handle_mouse_moved : buffer -> GdkEvent.Motion.t -> bool
val build_mouse_coords : GdkEvent.Button.t -> Renderer.mouse_coords
val get_mouse_button : GdkEvent.Button.t -> [> `Center | `Left | `Right ]
val handle_mouse_pressed : buffer -> GdkEvent.Button.t -> bool
val handle_mouse_released : buffer -> GdkEvent.Button.t -> bool
val get_key : GdkEvent.Key.t -> Stdlib.Uchar.t
val handle_key_pressed : buffer -> GdkEvent.Key.t -> bool
val handle_key_released : buffer -> GdkEvent.Key.t -> bool
val handle_window_enter : 'a -> 'b -> bool
val handle_window_leave : 'a -> 'b -> bool
val handle_mouse_scroll : buffer -> GdkEvent.Scroll.t -> bool
val handle_window_resized : buffer -> GdkEvent.Configure.t -> bool
val handle_window_delete : buffer -> 'a -> bool
val create_buffer : float -> [< `FullScreen | `Size of int * int ] -> buffer
val begin_draw : 'a -> unit
val end_draw : 'a -> unit
val clear : 'a -> unit

clear buffer does not modify the buffer. This is because the Cairo surface gets cleared every frame automatically.

val event_queue : buffer -> Renderer.event list
val render : buffer -> Shape.t -> unit