Struct raqote::draw_target::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

source

pub fn new(width: i32, height: i32) -> DrawTarget

source

pub fn from_vec(width: i32, height: i32, vec: Vec<u32>) -> DrawTarget

Use a previously used vector for the bitmap and extend it to the given size(if needed)

source

pub fn into_vec(self) -> Vec<u32>

Take ownership of the buffer backing the DrawTarget

source§

impl<Backing: AsRef<[u32]> + AsMut<[u32]>> DrawTarget<Backing>

source

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).

source

pub fn width(&self) -> i32

source

pub fn height(&self) -> i32

source

pub fn set_transform(&mut self, transform: &Transform)

sets a transform that will be applied to all drawing operations

source

pub fn get_transform(&self) -> &Transform

gets the current transform

source

fn move_to(&mut self, pt: Point)

source

fn line_to(&mut self, pt: Point)

source

fn quad_to(&mut self, cpt: Point, pt: Point)

source

fn add_quad(&mut self, curve: [Point; 3])

source

fn cubic_to(&mut self, cpt1: Point, cpt2: Point, pt: Point)

source

fn close(&mut self)

source

fn apply_path(&mut self, path: &Path)

source

pub fn push_clip_rect(&mut self, rect: IntRect)

source

pub fn pop_clip(&mut self)

source

pub fn push_clip(&mut self, path: &Path)

source

fn clip_bounds(&self) -> IntRect

source

pub fn push_layer(&mut self, opacity: f32)

Pushes a new layer as the drawing target. This is used for implementing group opacity effects.

source

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.

source

pub fn pop_layer(&mut self)

Draws the most recently pushed layer to the drawing target with the pushed opacity applied.

source

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.

source

pub fn draw_image_at( &mut self, x: f32, y: f32, image: &Image<'_>, options: &DrawOptions, )

Draws an image at x, y

source

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

source

pub fn stroke( &mut self, path: &Path, src: &Source<'_>, style: &StrokeStyle, options: &DrawOptions, )

Strokes path with style and fills the result with src

source

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.

source

pub fn fill(&mut self, path: &Path, src: &Source<'_>, options: &DrawOptions)

Fills path with src

source

pub fn clear(&mut self, solid: SolidSource)

Fills the current clip with the solid color solid

source

pub fn draw_text( &mut self, font: &Font, point_size: f32, text: &str, start: Point, src: &Source<'_>, options: &DrawOptions, )

source

pub fn draw_glyphs( &mut self, font: &Font, point_size: f32, ids: &[u32], positions: &[Point], src: &Source<'_>, options: &DrawOptions, )

source§

impl DrawTarget

source

fn choose_blitter<'a, 'b, 'c>( mask: Option<&[u8]>, clip_stack: &'a Vec<Clip>, blitter_storage: &'b mut ShaderBlitterStorage<'a>, shader: &'a dyn Shader, blend: BlendMode, dest: &'a mut [u32], dest_bounds: IntRect, width: i32, ) -> &'b mut dyn Blitter

source§

impl<Backing: AsRef<[u32]> + AsMut<[u32]>> DrawTarget<Backing>

source

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

source

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

source

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).

source

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 dstusing blend mode. The current transform and clip are ignored. src_rect is clamped to (0, 0, src.width, src.height).

source

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).

source

pub fn get_data(&self) -> &[u32]

Returns a reference to the underlying pixel data

source

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

source

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.

source

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.

source

pub fn into_inner(self) -> Backing

Take ownership of the buffer backing the DrawTarget

source

pub fn write_png<P: AsRef<Path>>(&self, path: P) -> Result<(), EncodingError>

Saves the current pixel to a png file at path

Auto Trait Implementations§

§

impl<Backing = Vec<u32>> !Freeze for DrawTarget<Backing>

§

impl<Backing = Vec<u32>> !RefUnwindSafe for DrawTarget<Backing>

§

impl<Backing = Vec<u32>> !Send for DrawTarget<Backing>

§

impl<Backing = Vec<u32>> !Sync for DrawTarget<Backing>

§

impl<Backing> Unpin for DrawTarget<Backing>
where Backing: Unpin,

§

impl<Backing> UnwindSafe for DrawTarget<Backing>
where Backing: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.