Struct raqote::DrawTarget
source · pub struct DrawTarget<Backing = Vec<u32>> {
width: i32,
height: i32,
rasterizer: Rasterizer,
current_point: Option<Point>,
first_point: Option<Point>,
buf: Backing,
clip_stack: Vec<Clip>,
layer_stack: Vec<Layer>,
transform: Transform,
}
Expand description
The main type used for drawing
Fields§
§width: i32
§height: i32
§rasterizer: Rasterizer
§current_point: Option<Point>
§first_point: Option<Point>
§buf: Backing
§clip_stack: Vec<Clip>
§layer_stack: Vec<Layer>
§transform: Transform
Implementations§
source§impl DrawTarget
impl DrawTarget
source§impl<Backing: AsRef<[u32]> + AsMut<[u32]>> DrawTarget<Backing>
impl<Backing: AsRef<[u32]> + AsMut<[u32]>> DrawTarget<Backing>
sourcepub fn from_backing(width: i32, height: i32, buf: Backing) -> Self
pub fn from_backing(width: i32, height: i32, buf: Backing) -> Self
Use an existing backing storage for the bitmap
The backing store must be the correct size (width*height elements).
pub fn width(&self) -> i32
pub fn height(&self) -> i32
sourcepub fn set_transform(&mut self, transform: &Transform)
pub fn set_transform(&mut self, transform: &Transform)
sets a transform that will be applied to all drawing operations
sourcepub fn get_transform(&self) -> &Transform
pub fn get_transform(&self) -> &Transform
gets the current transform
fn move_to(&mut self, pt: Point)
fn line_to(&mut self, pt: Point)
fn quad_to(&mut self, cpt: Point, pt: Point)
fn add_quad(&mut self, curve: [Point; 3])
fn cubic_to(&mut self, cpt1: Point, cpt2: Point, pt: Point)
fn close(&mut self)
fn apply_path(&mut self, path: &Path)
pub fn push_clip_rect(&mut self, rect: IntRect)
pub fn pop_clip(&mut self)
pub fn push_clip(&mut self, path: &Path)
fn clip_bounds(&self) -> IntRect
sourcepub fn push_layer(&mut self, opacity: f32)
pub fn push_layer(&mut self, opacity: f32)
Pushes a new layer as the drawing target. This is used for implementing group opacity effects.
sourcepub fn push_layer_with_blend(&mut self, opacity: f32, blend: BlendMode)
pub fn push_layer_with_blend(&mut self, opacity: f32, blend: BlendMode)
Pushes a new layer as the drawing target. This is used for implementing group opacity or blend effects.
sourcepub fn pop_layer(&mut self)
pub fn pop_layer(&mut self)
Draws the most recently pushed layer to the drawing target with the pushed opacity applied.
sourcepub fn draw_image_with_size_at(
&mut self,
width: f32,
height: f32,
x: f32,
y: f32,
image: &Image<'_>,
options: &DrawOptions,
)
pub fn draw_image_with_size_at( &mut self, width: f32, height: f32, x: f32, y: f32, image: &Image<'_>, options: &DrawOptions, )
Draws an image at (x, y) with the size (width, height). This will rescale the image to the destination size.
sourcepub fn draw_image_at(
&mut self,
x: f32,
y: f32,
image: &Image<'_>,
options: &DrawOptions,
)
pub fn draw_image_at( &mut self, x: f32, y: f32, image: &Image<'_>, options: &DrawOptions, )
Draws an image at x, y
sourcepub fn mask(&mut self, src: &Source<'_>, x: i32, y: i32, mask: &Mask)
pub fn mask(&mut self, src: &Source<'_>, x: i32, y: i32, mask: &Mask)
Draws src
through an untransformed mask
positioned at x
, y
in device space
sourcepub fn stroke(
&mut self,
path: &Path,
src: &Source<'_>,
style: &StrokeStyle,
options: &DrawOptions,
)
pub fn stroke( &mut self, path: &Path, src: &Source<'_>, style: &StrokeStyle, options: &DrawOptions, )
Strokes path
with style
and fills the result with src
sourcepub fn fill_rect(
&mut self,
x: f32,
y: f32,
width: f32,
height: f32,
src: &Source<'_>,
options: &DrawOptions,
)
pub fn fill_rect( &mut self, x: f32, y: f32, width: f32, height: f32, src: &Source<'_>, options: &DrawOptions, )
Fills the rect x
, y,
, width
, height
with src
. If the result is an
integer aligned rectangle performance will be faster than filling a rectangular path.
sourcepub fn fill(&mut self, path: &Path, src: &Source<'_>, options: &DrawOptions)
pub fn fill(&mut self, path: &Path, src: &Source<'_>, options: &DrawOptions)
Fills path
with src
sourcepub fn clear(&mut self, solid: SolidSource)
pub fn clear(&mut self, solid: SolidSource)
Fills the current clip with the solid color solid
pub fn draw_text( &mut self, font: &Font, point_size: f32, text: &str, start: Point, src: &Source<'_>, options: &DrawOptions, )
pub fn draw_glyphs( &mut self, font: &Font, point_size: f32, ids: &[u32], positions: &[Point], src: &Source<'_>, options: &DrawOptions, )
source§impl DrawTarget
impl DrawTarget
source§impl<Backing: AsRef<[u32]> + AsMut<[u32]>> DrawTarget<Backing>
impl<Backing: AsRef<[u32]> + AsMut<[u32]>> DrawTarget<Backing>
sourcefn composite(
&mut self,
src: &Source<'_>,
mask: Option<&[u8]>,
mask_rect: IntRect,
rect: IntRect,
blend: BlendMode,
alpha: f32,
)
fn composite( &mut self, src: &Source<'_>, mask: Option<&[u8]>, mask_rect: IntRect, rect: IntRect, blend: BlendMode, alpha: f32, )
mask_rect
is in DrawTarget space. i.e size is the size of the mask and origin is the position.
you can not render a part of the mask
sourcepub fn composite_surface<F: Fn(&[u32], &mut [u32]), SrcBacking: AsRef<[u32]>>(
&mut self,
src: &DrawTarget<SrcBacking>,
src_rect: IntRect,
dst: IntPoint,
f: F,
)
pub fn composite_surface<F: Fn(&[u32], &mut [u32]), SrcBacking: AsRef<[u32]>>( &mut self, src: &DrawTarget<SrcBacking>, src_rect: IntRect, dst: IntPoint, f: F, )
Draws src_rect
of src
at dst
. The current transform and clip are ignored
sourcepub fn copy_surface<SrcBacking: AsRef<[u32]>>(
&mut self,
src: &DrawTarget<SrcBacking>,
src_rect: IntRect,
dst: IntPoint,
)
pub fn copy_surface<SrcBacking: AsRef<[u32]>>( &mut self, src: &DrawTarget<SrcBacking>, src_rect: IntRect, dst: IntPoint, )
Draws src_rect
of src
at dst
. The current transform and clip are ignored.
src_rect
is clamped to (0, 0, src.width, src.height).
sourcepub fn blend_surface<SrcBacking: AsRef<[u32]>>(
&mut self,
src: &DrawTarget<SrcBacking>,
src_rect: IntRect,
dst: IntPoint,
blend: BlendMode,
)
pub fn blend_surface<SrcBacking: AsRef<[u32]>>( &mut self, src: &DrawTarget<SrcBacking>, src_rect: IntRect, dst: IntPoint, blend: BlendMode, )
Blends src_rect
of src
at dst
using blend
mode.
The current transform and clip are ignored.
src_rect
is clamped to (0, 0, src.width
, src.height
).
sourcepub fn blend_surface_with_alpha<SrcBacking: AsRef<[u32]>>(
&mut self,
src: &DrawTarget<SrcBacking>,
src_rect: IntRect,
dst: IntPoint,
alpha: f32,
)
pub fn blend_surface_with_alpha<SrcBacking: AsRef<[u32]>>( &mut self, src: &DrawTarget<SrcBacking>, src_rect: IntRect, dst: IntPoint, alpha: f32, )
Blends src_rect
of src
at dst
using alpha
. The current transform and clip are ignored.
src_rect
is clamped to (0, 0, src.width
, src.height
).
sourcepub fn get_data_mut(&mut self) -> &mut [u32]
pub fn get_data_mut(&mut self) -> &mut [u32]
Returns a mut reference to the underlying pixel data as ARGB with a representation like: (A << 24) | (R << 16) | (G << 8) | B
sourcepub fn get_data_u8(&self) -> &[u8] ⓘ
pub fn get_data_u8(&self) -> &[u8] ⓘ
Returns a reference to the underlying pixel data as individual bytes with the order BGRA on little endian.
sourcepub fn get_data_u8_mut(&mut self) -> &mut [u8] ⓘ
pub fn get_data_u8_mut(&mut self) -> &mut [u8] ⓘ
Returns a mut reference to the underlying pixel data as individual bytes with the order BGRA on little endian.
sourcepub fn into_inner(self) -> Backing
pub fn into_inner(self) -> Backing
Take ownership of the buffer backing the DrawTarget