pub struct Canvas<'a> {
pub w: i32,
pub h: i32,
/* private fields */
}Fields§
§w: i32§h: i32Implementations§
Source§impl<'a> Canvas<'a>
impl<'a> Canvas<'a>
Sourcepub fn new(px: &'a mut [u32], w: i32, h: i32) -> Self
pub fn new(px: &'a mut [u32], w: i32, h: i32) -> Self
Wrap a pixel buffer. px.len() must equal w * h.
pub fn fill_rect(&mut self, rect: Rect, color: Color)
Sourcepub fn dim_rect(&mut self, rect: Rect, strength: u32)
pub fn dim_rect(&mut self, rect: Rect, strength: u32)
Darken already-drawn pixels inside rect to strength/256 of
their brightness — a backdrop panel without an alpha channel. 0
blacks out, 256 leaves the pixels untouched.
pub fn draw_rect_outline(&mut self, rect: Rect, color: Color, thickness: i32)
pub fn fill_circle(&mut self, cx: i32, cy: i32, r: i32, color: Color)
pub fn draw_circle_outline( &mut self, cx: i32, cy: i32, r: i32, color: Color, thickness: i32, )
Sourcepub fn draw_text(
&mut self,
x: i32,
y: i32,
text: &str,
color: Color,
scale: i32,
)
pub fn draw_text( &mut self, x: i32, y: i32, text: &str, color: Color, scale: i32, )
Draw text with the embedded font, top-left of the line box at
(x, y). scale multiplies the base text size — pass the
monitor’s DPI scale so text is the same visual size on any display.
Sourcepub fn draw_shape_rotated(
&mut self,
shape: &Shape,
deg: i32,
color: Color,
thickness: i32,
fill: bool,
)
pub fn draw_shape_rotated( &mut self, shape: &Shape, deg: i32, color: Color, thickness: i32, fill: bool, )
Draw a shape rotated deg about its bbox center. Unrotated shapes
and circles take the fast paths; triangles rotate their vertices and
reuse the triangle raster; rotated rects raster by inverse-rotating
each candidate pixel into the rect’s local space.
Sourcepub fn draw_shape(
&mut self,
shape: &Shape,
color: Color,
thickness: i32,
fill: bool,
)
pub fn draw_shape( &mut self, shape: &Shape, color: Color, thickness: i32, fill: bool, )
Draw a selection shape as outline or fill.
Sourcepub fn draw_segment(&mut self, line: Line, color: Color, thickness: i32)
pub fn draw_segment(&mut self, line: Line, color: Color, thickness: i32)
A bare segment, no end decoration — for lines nobody grabs, like a snap guide. Caps on a short guide read as a box rather than a line, which is the opposite of pointing at something.