pub struct CGContext { /* private fields */ }Available on crate feature
cg only.Expand description
Reference-counted CGContextRef backed by a bitmap.
Implementations§
Source§impl CGContext
impl CGContext
Sourcepub fn bytes_per_row(&self) -> usize
pub fn bytes_per_row(&self) -> usize
Bytes per row.
Sourcepub fn bits_per_component(&self) -> usize
pub fn bits_per_component(&self) -> usize
Bits per component.
Sourcepub fn bits_per_pixel(&self) -> usize
pub fn bits_per_pixel(&self) -> usize
Bits per pixel.
Sourcepub fn color_space(&self) -> Option<CGColorSpace>
pub fn color_space(&self) -> Option<CGColorSpace>
The context color space, if one is set.
Sourcepub fn alpha_info(&self) -> u32
pub fn alpha_info(&self) -> u32
The raw CGImageAlphaInfo value for the bitmap context.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
The bitmap storage as mutable bytes.
Sourcepub fn set_rgb_fill_color(&self, r: f64, g: f64, b: f64, a: f64)
pub fn set_rgb_fill_color(&self, r: f64, g: f64, b: f64, a: f64)
Set the current fill color in DeviceRGB.
Sourcepub fn set_rgb_stroke_color(&self, r: f64, g: f64, b: f64, a: f64)
pub fn set_rgb_stroke_color(&self, r: f64, g: f64, b: f64, a: f64)
Set the current stroke color in DeviceRGB.
Sourcepub fn set_line_width(&self, w: f64)
pub fn set_line_width(&self, w: f64)
Set the stroke line width.
Sourcepub fn clear_rect(&self, x: f64, y: f64, w: f64, h: f64)
pub fn clear_rect(&self, x: f64, y: f64, w: f64, h: f64)
Clear a rectangle to transparent black.
Sourcepub fn begin_path(&self)
pub fn begin_path(&self)
Begin a new path.
Sourcepub fn close_path(&self)
pub fn close_path(&self)
Close the current path.
Sourcepub fn add_line_to(&self, x: f64, y: f64)
pub fn add_line_to(&self, x: f64, y: f64)
Add a line segment to the current path.
Sourcepub fn add_ellipse_in_rect(&self, x: f64, y: f64, w: f64, h: f64)
pub fn add_ellipse_in_rect(&self, x: f64, y: f64, w: f64, h: f64)
Add an ellipse inscribed in the rectangle.
Sourcepub fn stroke_path(&self)
pub fn stroke_path(&self)
Stroke the current path.
Sourcepub fn draw_image(&self, x: f64, y: f64, w: f64, h: f64, image: &CGImage)
pub fn draw_image(&self, x: f64, y: f64, w: f64, h: f64, image: &CGImage)
Draw an image into the target rectangle.
Sourcepub fn save_g_state(&self)
pub fn save_g_state(&self)
Save the current graphics state.
Sourcepub fn restore_g_state(&self)
pub fn restore_g_state(&self)
Restore the most recently saved graphics state.
Sourcepub fn snapshot_to_image(&self) -> Option<CGImage>
pub fn snapshot_to_image(&self) -> Option<CGImage>
Snapshot the current bitmap contents to a CGImage.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CGContext
impl RefUnwindSafe for CGContext
impl !Send for CGContext
impl !Sync for CGContext
impl Unpin for CGContext
impl UnsafeUnpin for CGContext
impl UnwindSafe for CGContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more