pub struct PixmapMut<'a> { /* private fields */ }image or svg or canvas only.Expand description
A container that references mutable premultiplied RGBA pixels.
Can be created from Pixmap or from a user provided data.
The data is not aligned, therefore width == stride.
Implementations§
Source§impl<'a> PixmapMut<'a>
impl<'a> PixmapMut<'a>
Sourcepub fn from_bytes(
data: &'a mut [u8],
width: u32,
height: u32,
) -> Option<PixmapMut<'a>>
pub fn from_bytes( data: &'a mut [u8], width: u32, height: u32, ) -> Option<PixmapMut<'a>>
Creates a new PixmapMut from bytes.
The size must be at least size.width() * size.height() * BYTES_PER_PIXEL.
Zero size in an error. Width is limited by i32::MAX/4.
The data is assumed to have premultiplied RGBA pixels (byteorder: RGBA).
Sourcepub fn to_owned(&self) -> Pixmap
pub fn to_owned(&self) -> Pixmap
Creates a new Pixmap from the current data.
Clones the underlying data.
Sourcepub fn pixels_mut(&mut self) -> &mut [PremultipliedColorU8]
pub fn pixels_mut(&mut self) -> &mut [PremultipliedColorU8]
Returns a mutable slice of pixels.
Source§impl PixmapMut<'_>
impl PixmapMut<'_>
Sourcepub fn fill_rect(
&mut self,
rect: Rect,
paint: &Paint<'_>,
transform: Transform,
mask: Option<&Mask>,
)
pub fn fill_rect( &mut self, rect: Rect, paint: &Paint<'_>, transform: Transform, mask: Option<&Mask>, )
Draws a filled rectangle onto the pixmap.
This function is usually slower than filling a rectangular path, but it produces better results. Mainly it doesn’t suffer from weird clipping of horizontal/vertical edges.
Used mainly to render a pixmap onto a pixmap.
Returns None when there is nothing to fill or in case of a numeric overflow.
Sourcepub fn fill_path(
&mut self,
path: &Path,
paint: &Paint<'_>,
fill_rule: FillRule,
transform: Transform,
mask: Option<&Mask>,
)
pub fn fill_path( &mut self, path: &Path, paint: &Paint<'_>, fill_rule: FillRule, transform: Transform, mask: Option<&Mask>, )
Draws a filled path onto the pixmap.
Sourcepub fn stroke_path(
&mut self,
path: &Path,
paint: &Paint<'_>,
stroke: &Stroke,
transform: Transform,
mask: Option<&Mask>,
)
pub fn stroke_path( &mut self, path: &Path, paint: &Paint<'_>, stroke: &Stroke, transform: Transform, mask: Option<&Mask>, )
Strokes a path.
Stroking is implemented using two separate algorithms:
- If a stroke width is wider than 1px (after applying the transformation),
a path will be converted into a stroked path and then filled using
fill_path. Which means that we have to allocate a separatePath, that can be 2-3x larger then the original path. - If a stroke width is thinner than 1px (after applying the transformation), we will use hairline stroking, which doesn’t involve a separate path allocation.
Also, if a stroke has a dash array, then path will be converted into
a dashed path first and then stroked. Which means a yet another allocation.
Sourcepub fn draw_pixmap(
&mut self,
x: i32,
y: i32,
pixmap: PixmapRef<'_>,
paint: &PixmapPaint,
transform: Transform,
mask: Option<&Mask>,
)
pub fn draw_pixmap( &mut self, x: i32, y: i32, pixmap: PixmapRef<'_>, paint: &PixmapPaint, transform: Transform, mask: Option<&Mask>, )
Draws a Pixmap on top of the current Pixmap.
The same as filling a rectangle with a pixmap pattern.
Sourcepub fn apply_mask(&mut self, mask: &Mask)
pub fn apply_mask(&mut self, mask: &Mask)
Applies a masks.
When a Mask is passed to drawing methods, it will be used to mask-out
content we’re about to draw.
This method masks-out an already drawn content.
It’s not as fast, but can be useful when a mask is not available during drawing.
This method is similar to filling the whole pixmap with an another,
mask-like pixmap using the DestinationOut blend mode.
Mask must have the same size as Pixmap. No transform or offset are allowed.
Trait Implementations§
impl<'a> StructuralPartialEq for PixmapMut<'a>
Auto Trait Implementations§
impl<'a> Freeze for PixmapMut<'a>
impl<'a> RefUnwindSafe for PixmapMut<'a>
impl<'a> Send for PixmapMut<'a>
impl<'a> Sync for PixmapMut<'a>
impl<'a> Unpin for PixmapMut<'a>
impl<'a> !UnwindSafe for PixmapMut<'a>
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
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more