///|
/// An owned reference to a Cairo drawing context.
type Context
///|
#borrow(surface)
/// Creates a drawing context for `surface`.
pub extern "c" fn Context::create(surface : Surface) -> Context = "moonbit_cairo_context_create"
///|
#borrow(context)
extern "c" fn cairo_status(context : Context) -> Int = "moonbit_cairo_context_status"
///|
/// Returns this context's current status.
pub fn Context::status(self : Context) -> Status {
Status(cairo_status(self))
}
///|
#borrow(self)
/// Returns an independently owned reference to this context's target surface.
pub extern "c" fn Context::get_target(self : Context) -> Surface = "moonbit_cairo_context_get_target"
///|
#borrow(self)
/// Saves the current graphics state on this context's state stack.
pub extern "c" fn Context::save(self : Context) = "moonbit_cairo_context_save"
///|
#borrow(self)
/// Restores the most recently saved graphics state.
pub extern "c" fn Context::restore(self : Context) = "moonbit_cairo_context_restore"
///|
#borrow(self)
/// Starts a new sub-path at `(x, y)`.
pub extern "c" fn Context::move_to(self : Context, x : Double, y : Double) = "moonbit_cairo_context_move_to"
///|
#borrow(self)
/// Adds a line from the current point to `(x, y)`.
pub extern "c" fn Context::line_to(self : Context, x : Double, y : Double) = "moonbit_cairo_context_line_to"
///|
#borrow(self)
/// Adds a cubic Bézier segment ending at `(x3, y3)`.
pub extern "c" fn Context::curve_to(
self : Context,
x1 : Double,
y1 : Double,
x2 : Double,
y2 : Double,
x3 : Double,
y3 : Double,
) = "moonbit_cairo_context_curve_to"
///|
#borrow(self)
/// Closes the current sub-path with a line to its starting point.
pub extern "c" fn Context::close_path(self : Context) = "moonbit_cairo_context_close_path"
///|
#borrow(self)
/// Clears the current path and unsets its current point.
pub extern "c" fn Context::new_path(self : Context) = "moonbit_cairo_context_new_path"
///|
#borrow(self)
/// Adds a closed rectangular sub-path.
pub extern "c" fn Context::rectangle(
self : Context,
x : Double,
y : Double,
width : Double,
height : Double,
) = "moonbit_cairo_context_rectangle"
///|
#borrow(self)
/// Adds a circular arc in the direction of increasing angles.
pub extern "c" fn Context::arc(
self : Context,
center_x : Double,
center_y : Double,
radius : Double,
angle_1 : Double,
angle_2 : Double,
) = "moonbit_cairo_context_arc"
///|
#borrow(self)
/// Sets an opaque RGB source color.
pub extern "c" fn Context::set_source_rgb(
self : Context,
red : Double,
green : Double,
blue : Double,
) = "moonbit_cairo_context_set_source_rgb"
///|
#borrow(self)
/// Sets an RGBA source color.
pub extern "c" fn Context::set_source_rgba(
self : Context,
red : Double,
green : Double,
blue : Double,
alpha : Double,
) = "moonbit_cairo_context_set_source_rgba"
///|
#borrow(self, surface)
/// Uses `surface` as the source, with its origin at user-space `(x, y)`.
///
/// The context retains the native source surface until another source replaces
/// it or the context is destroyed. Both coordinates default to `0.0`.
pub extern "c" fn Context::set_source_surface(
self : Context,
surface : Surface,
x? : Double = 0.0,
y? : Double = 0.0,
) = "moonbit_cairo_context_set_source_surface"
///|
#borrow(self)
/// Sets the current line width.
pub extern "c" fn Context::set_line_width(self : Context, width : Double) = "moonbit_cairo_context_set_line_width"
///|
#borrow(self)
/// Paints the current source everywhere within the current clip.
pub extern "c" fn Context::paint(self : Context) = "moonbit_cairo_context_paint"
///|
#borrow(self)
/// Fills the current path and then clears it.
pub extern "c" fn Context::fill(self : Context) = "moonbit_cairo_context_fill"
///|
#borrow(self)
/// Strokes the current path and then clears it.
pub extern "c" fn Context::stroke(self : Context) = "moonbit_cairo_context_stroke"
///|
#borrow(self)
/// Translates the current transformation matrix.
pub extern "c" fn Context::translate(self : Context, tx : Double, ty : Double) = "moonbit_cairo_context_translate"
///|
#borrow(self)
/// Scales the current transformation matrix.
pub extern "c" fn Context::scale(self : Context, sx : Double, sy : Double) = "moonbit_cairo_context_scale"
///|
#borrow(self)
/// Rotates the current transformation matrix by `radians`.
pub extern "c" fn Context::rotate(self : Context, radians : Double) = "moonbit_cairo_context_rotate"
///|
#borrow(context, x, y)
extern "c" fn cairo_get_current_point(
context : Context,
x : Ref[Double],
y : Ref[Double],
) = "moonbit_cairo_context_get_current_point"
///|
/// Returns the current path point through Cairo's output-parameter API.
pub fn Context::get_current_point(self : Context) -> (Double, Double) {
let x = Ref(0.0)
let y = Ref(0.0)
cairo_get_current_point(self, x, y)
(x.val, y.val)
}
///|
#borrow(self)
/// Copies the current path into an independently owned snapshot.
pub extern "c" fn Context::copy_path(self : Context) -> Path = "moonbit_cairo_context_copy_path"
///|
#borrow(self)
/// Copies the current path with curves flattened into line segments.
pub extern "c" fn Context::copy_path_flat(self : Context) -> Path = "moonbit_cairo_context_copy_path_flat"
///|
#borrow(self, path)
/// Appends an owned path snapshot without consuming it.
pub extern "c" fn Context::append_path(self : Context, path : Path) = "moonbit_cairo_context_append_path"