[−][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.
Fields
pixmap: Pixmap
A pixmap owned by the canvas.
Implementations
impl Canvas
[src]
pub fn new(width: u32, height: u32) -> Option<Self>
[src]
Creates a new canvas.
A canvas is filled with transparent black by default, aka (0, 0, 0, 0).
Allocates a new pixmap. Use Canvas::from(pixmap)
to reuse an existing one.
Zero size in an error.
Pixmap's width is limited by i32::MAX/4.
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 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
Painter::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: &Pixmap,
paint: &PixmapPaint
)
[src]
&mut self,
x: i32,
y: i32,
pixmap: &Pixmap,
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.
If there is no transform - uses Painter::fill_rect
.
Otherwise, it is just a Canvas::fill_path
with a rectangular path.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Canvas
impl Send for Canvas
impl Sync for Canvas
impl Unpin for Canvas
impl UnwindSafe for Canvas
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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>,