Struct raqote::DrawTarget
source · [−]Expand description
The main type used for drawing
Implementations
sourceimpl DrawTarget
impl DrawTarget
sourceimpl<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
pub fn push_clip_rect(&mut self, rect: IntRect)
pub fn pop_clip(&mut self)
pub fn push_clip(&mut self, path: &Path)
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
)
sourceimpl<Backing: AsRef<[u32]> + AsMut<[u32]>> DrawTarget<Backing>
impl<Backing: AsRef<[u32]> + AsMut<[u32]>> DrawTarget<Backing>
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]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
pub fn get_data_u8(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[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]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
pub fn get_data_u8_mut(&mut self) -> &mut [u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[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
Auto Trait Implementations
impl<Backing = Vec<u32, Global>> !RefUnwindSafe for DrawTarget<Backing>
impl<Backing = Vec<u32, Global>> !Send for DrawTarget<Backing>
impl<Backing = Vec<u32, Global>> !Sync for DrawTarget<Backing>
impl<Backing> Unpin for DrawTarget<Backing> where
Backing: Unpin,
impl<Backing> UnwindSafe for DrawTarget<Backing> where
Backing: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more