[−][src]Struct tiny_skia::Canvas
Provides a high-level rendering API.
Unlike the most of other types, Canvas
provides an unchecked API.
Which means that a drawing command will simply be ignored in case of an error
and a caller has no way of checking it.
Implementations
impl<'a> Canvas<'a>
[src]
pub fn pixmap(&mut self) -> &mut PixmapMut<'a>
[src]
Returns an underlying pixmap.
pub fn translate(&mut self, tx: f32, ty: f32)
[src]
Translates the canvas.
pub fn scale(&mut self, sx: f32, sy: f32)
[src]
Scales the canvas.
pub fn transform(
&mut self,
sx: f32,
ky: f32,
kx: f32,
sy: f32,
tx: f32,
ty: f32
)
[src]
&mut self,
sx: f32,
ky: f32,
kx: f32,
sy: f32,
tx: f32,
ty: f32
)
Applies an affine transformation to the canvas.
pub fn apply_transform(&mut self, ts: &Transform)
[src]
Applies an affine transformation to the canvas.
pub fn get_transform(&mut self) -> Transform
[src]
Gets the current canvas transform.
pub fn set_transform(&mut self, ts: Transform)
[src]
Sets the canvas transform.
pub fn reset_transform(&mut self)
[src]
Resets the canvas transform to identity.
pub fn set_clip_rect(&mut self, rect: Rect, anti_alias: bool)
[src]
Sets a clip rectangle.
Consecutive calls will replace the previous value.
Clipping is affected by the current transform.
pub fn set_clip_path(
&mut self,
path: &Path,
fill_type: FillRule,
anti_alias: bool
)
[src]
&mut self,
path: &Path,
fill_type: FillRule,
anti_alias: bool
)
Sets a clip path.
Consecutive calls will replace the previous value.
Clipping is affected by the current transform.
pub fn set_clip_mask(&mut self, clip: ClipMask)
[src]
Sets the current clip mask.
This is a low-level alternative to set_clip_rect
and set_clip_path
.
pub fn get_clip_mask(&self) -> &ClipMask
[src]
Returns a reference to the current clip mask.
pub fn take_clip_mask(&mut self) -> ClipMask
[src]
Takes the current clip mask.
pub fn reset_clip(&mut self)
[src]
Resets the current clip.
pub fn fill_path(&mut self, path: &Path, paint: &Paint<'_>, fill_type: FillRule)
[src]
Fills a path.
pub fn stroke_path(&mut self, path: &Path, paint: &Paint<'_>, stroke: &Stroke)
[src]
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
Canvas::fill_path
. Which means that we have to allocate a separatePath
, that can be 2-3x larger then the original path.Canvas
will reuse this allocation during subsequent strokes. - 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.
pub fn draw_pixmap(
&mut self,
x: i32,
y: i32,
pixmap: PixmapRef<'_>,
paint: &PixmapPaint
)
[src]
&mut self,
x: i32,
y: i32,
pixmap: PixmapRef<'_>,
paint: &PixmapPaint
)
Draws a Pixmap
on top of the current Pixmap
.
We basically filling a rectangle with a pixmap
pattern.
pub fn fill_rect(&mut self, rect: Rect, paint: &Paint<'_>)
[src]
Fills a rectangle.
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.
Fallbacks to Canvas::fill_path
when Canvas
has a transform.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Canvas<'a>
[src]
impl<'a> Send for Canvas<'a>
[src]
impl<'a> Sync for Canvas<'a>
[src]
impl<'a> Unpin for Canvas<'a>
[src]
impl<'a> !UnwindSafe for Canvas<'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,