///|
/// An owned reference to a Cairo surface.
type Surface
///|
/// Creates an image surface with the requested pixel format and dimensions.
pub extern "c" fn Surface::create_image(
format : Format,
width : Int,
height : Int,
) -> Surface = "moonbit_cairo_surface_create_image"
///|
extern "c" fn cairo_surface_create_recording(
content : Content,
has_extents : Bool,
x : Double,
y : Double,
width : Double,
height : Double,
) -> Surface = "moonbit_cairo_surface_create_recording"
///|
/// Creates a surface that records drawing operations for later replay.
///
/// Omitting `extents` creates an unbounded recording surface. A supplied
/// rectangle limits recording in the surface's device-space coordinates.
/// Transformations later applied to a drawing context, such as scaling or
/// translation, do not transform these bounds. Cairo copies the rectangle
/// during this call.
pub fn Surface::create_recording(
content : Content,
extents? : Rectangle,
) -> Surface {
match extents {
Some(rectangle) => {
let (x, y, width, height) = rectangle.components()
cairo_surface_create_recording(content, true, x, y, width, height)
}
None => cairo_surface_create_recording(content, false, 0.0, 0.0, 0.0, 0.0)
}
}
///|
#borrow(surface)
extern "c" fn cairo_surface_status(surface : Surface) -> Int = "moonbit_cairo_surface_status"
///|
/// Returns this surface's current status.
pub fn Surface::status(self : Surface) -> Status {
Status(cairo_surface_status(self))
}
///|
#borrow(self)
/// Returns the width of an image surface in pixels.
pub extern "c" fn Surface::width(self : Surface) -> Int = "moonbit_cairo_surface_width"
///|
#borrow(self)
/// Returns the height of an image surface in pixels.
pub extern "c" fn Surface::height(self : Surface) -> Int = "moonbit_cairo_surface_height"
///|
#borrow(self)
/// Returns the number of bytes between rows of an image surface.
pub extern "c" fn Surface::stride(self : Surface) -> Int = "moonbit_cairo_surface_stride"
///|
#borrow(surface, path)
extern "c" fn cairo_surface_write_to_png(
surface : Surface,
path : Bytes,
) -> Int = "moonbit_cairo_surface_write_to_png"
///|
/// Writes this surface to a PNG file and returns Cairo's operation status.
pub fn Surface::write_to_png(self : Surface, path : String) -> Status {
Status(cairo_surface_write_to_png(self, @encoding/utf8.encode(path)))
}