pub struct Painter<'a, 'b> { /* private fields */ }Implementations§
Source§impl<'a, 'b> Painter<'a, 'b>
impl<'a, 'b> Painter<'a, 'b>
pub fn new(ctx: &'a mut PaintCtx<'b>) -> Painter<'a, 'b>
pub fn size(&self) -> Size
pub fn rect(&self) -> Rect
pub fn origin_global(&self) -> Point
pub fn ctx(&mut self) -> &mut PaintCtx<'b>
pub fn push_list_transform(&mut self, t: Transform)
pub fn pop_list_transform(&mut self)
pub fn with_transform<R>( &mut self, t: Transform, f: impl FnOnce(&mut Painter<'a, 'b>) -> R, ) -> R
pub fn unproject(&self, p: Point) -> Option<Point>
pub fn to_global_rect(&self, r: Rect) -> Rect
pub fn to_global_point(&self, p: Point) -> Point
pub fn to_local_point(&self, p: Point) -> Point
pub fn fill(&mut self, rect: Rect, fill: Fill) -> Rect
pub fn rounded(&mut self, rect: Rect, radius: f32, fill: Fill) -> Rect
pub fn circle(&mut self, center: Point, radius: f32, fill: Fill) -> Rect
pub fn ring( &mut self, center: Point, radius: f32, width: f32, color: Color, ) -> Rect
pub fn line( &mut self, from: Point, to: Point, stroke: Stroke, color: Color, ) -> Rect
pub fn polyline( &mut self, points: &[Point], stroke: Stroke, color: Color, ) -> Rect
pub fn curve( &mut self, p0: Point, c0: Point, c1: Point, p1: Point, stroke: Stroke, color: Color, ) -> Rect
pub fn rect_outline( &mut self, rect: Rect, radius: f32, stroke: Stroke, color: Color, ) -> Rect
pub fn polygon(&mut self, points: &[Point], color: Color) -> Rect
pub fn ellipse(&mut self, center: Point, rx: f32, ry: f32, color: Color) -> Rect
Sourcepub fn text(&mut self, text: &str, baseline: Point, size: f32, color: Color)
pub fn text(&mut self, text: &str, baseline: Point, size: f32, color: Color)
Draws a single line with baseline as the text baseline.
The font size scales with the active with_transform scale so text
zooms with the canvas instead of staying at a fixed pixel size.
Sourcepub fn text_tl(&mut self, text: &str, top_left: Point, size: f32, color: Color)
pub fn text_tl(&mut self, text: &str, top_left: Point, size: f32, color: Color)
Draws a single line with top_left at the top-left of its line box.
The font size scales with the active with_transform scale.
Sourcepub fn text_metrics(&mut self, size: f32) -> TextMetrics
pub fn text_metrics(&mut self, size: f32) -> TextMetrics
Vertical metrics for the default font at size.
pub fn text_tl_rotated( &mut self, text: &str, top_left: Point, size: f32, color: Color, degrees: f32, pivot: Point, )
pub fn text_styled( &mut self, text: &str, baseline: Point, size: f32, weight: FontWeight, color: Color, )
Sourcepub fn text_width(&mut self, text: &str, size: f32) -> f32
pub fn text_width(&mut self, text: &str, size: f32) -> f32
Measures text in local coordinates, including the transform scale.
pub fn text_width_weighted( &mut self, text: &str, size: f32, weight: FontWeight, ) -> f32
pub fn text_center_x( &mut self, text: &str, center_x: f32, top: f32, size: f32, color: Color, )
pub fn text_center(&mut self, rect: Rect, text: &str, size: f32, color: Color)
pub fn image(&mut self, rect: Rect, uv: [f32; 4], source: ImageSource) -> Rect
pub fn pixels(&mut self, rect: Rect, pixels: &Pixels) -> Rect
pub fn pixels_nearest(&mut self, rect: Rect, pixels: &Pixels) -> Rect
pub fn pixels_region(&mut self, dst: Rect, pixels: &Pixels, src: Rect) -> Rect
pub fn pixel_uv(width: u32, height: u32, src: Rect) -> Option<[f32; 4]>
Sourcepub fn target_uv(group: Size, rect: Rect) -> [f32; 4]
pub fn target_uv(group: Size, rect: Rect) -> [f32; 4]
Maps rect onto an offscreen target that was rendered at group.
A target captures the whole group area, so drawing it into a smaller
rect with [0.0, 0.0, 1.0, 1.0] squeezes the entire target into that
rect. These coordinates sample only the part of the target under
rect, which is what Painter::group users need.
pub fn pixel_at( rect: Rect, width: u32, height: u32, p: Point, ) -> Option<(i32, i32)>
pub fn knob(&mut self, center: Point, radius: f32, fill: Color) -> Rect
pub fn sv_field(&mut self, rect: Rect, hue01: f32) -> Rect
Sourcepub fn current_blend(&self) -> BlendMode
pub fn current_blend(&self) -> BlendMode
Returns the blend mode used by subsequent shader draws and blits.
Sourcepub fn with_blend<R>(
&mut self,
mode: BlendMode,
f: impl FnOnce(&mut Painter<'a, 'b>) -> R,
) -> R
pub fn with_blend<R>( &mut self, mode: BlendMode, f: impl FnOnce(&mut Painter<'a, 'b>) -> R, ) -> R
Runs f with mode as the blend mode for shader draws and blits.
Sourcepub fn group<R>(
&mut self,
size: Size,
blend: BlendMode,
f: impl FnOnce(&mut Painter<'a, 'b>) -> R,
) -> (RenderTargetId, R)
pub fn group<R>( &mut self, size: Size, blend: BlendMode, f: impl FnOnce(&mut Painter<'a, 'b>) -> R, ) -> (RenderTargetId, R)
Renders f into a new offscreen target.
The target is transparent when f starts painting into it. Use the
returned handle as a shader input (sequoia_core::TexInput::Target) or
composite it with Painter::blit.
Sourcepub fn blit(&mut self, target: RenderTargetId, rect: Rect, uv: [f32; 4]) -> Rect
pub fn blit(&mut self, target: RenderTargetId, rect: Rect, uv: [f32; 4]) -> Rect
Copies a finished offscreen target into the current pass.
uv is [u0, v0, u1, v1]; [0.0, 0.0, 1.0, 1.0] copies the whole
target. The current blend mode from Painter::with_blend applies.
Sourcepub fn shader<S>(
&mut self,
shader: S,
rect: Rect,
inputs: &[(&str, TexInput)],
) -> Rectwhere
S: SequoiShader,
pub fn shader<S>(
&mut self,
shader: S,
rect: Rect,
inputs: &[(&str, TexInput)],
) -> Rectwhere
S: SequoiShader,
Pushes a typed shader draw generated by sequoia_shader::shader.
Texture names must match the Sampler2D parameters of the shader.
Inputs may be images or offscreen targets. Missing inputs sample a
transparent white texture. The shader must have been registered under
S::NAME (see App::shader_type).
Sourcepub fn shader_at<S>(
&mut self,
shader: S,
rect: Rect,
uv: [f32; 4],
inputs: &[(&str, TexInput)],
) -> Rectwhere
S: SequoiShader,
pub fn shader_at<S>(
&mut self,
shader: S,
rect: Rect,
uv: [f32; 4],
inputs: &[(&str, TexInput)],
) -> Rectwhere
S: SequoiShader,
Pushes a typed shader draw with explicit texture coordinates.
uv is [u0, v0, u1, v1]. Use Painter::group to produce target
inputs. Returns Rect::ZERO when the shader is not registered.
Sourcepub fn try_shader<S>(
&mut self,
shader: S,
rect: Rect,
inputs: &[(&str, TexInput)],
) -> boolwhere
S: SequoiShader,
pub fn try_shader<S>(
&mut self,
shader: S,
rect: Rect,
inputs: &[(&str, TexInput)],
) -> boolwhere
S: SequoiShader,
Pushes a typed shader draw and reports whether it was recorded.
Unlike Painter::shader, a missing registration is visible to the
caller, which makes optional effect chains and tests explicit.
Sourcepub fn try_shader_at<S>(
&mut self,
shader: S,
rect: Rect,
uv: [f32; 4],
inputs: &[(&str, TexInput)],
) -> boolwhere
S: SequoiShader,
pub fn try_shader_at<S>(
&mut self,
shader: S,
rect: Rect,
uv: [f32; 4],
inputs: &[(&str, TexInput)],
) -> boolwhere
S: SequoiShader,
Records a shader draw with explicit texture coordinates.
Sourcepub fn try_shader_with_blend<S>(
&mut self,
shader: S,
rect: Rect,
textures: &[(&str, TexInput)],
blend: BlendMode,
) -> boolwhere
S: SequoiShader,
pub fn try_shader_with_blend<S>(
&mut self,
shader: S,
rect: Rect,
textures: &[(&str, TexInput)],
blend: BlendMode,
) -> boolwhere
S: SequoiShader,
Records a shader draw with an explicit blend mode.
Sourcepub fn try_shader_at_with_blend<S>(
&mut self,
shader: S,
rect: Rect,
uv: [f32; 4],
textures: &[(&str, TexInput)],
blend: BlendMode,
) -> boolwhere
S: SequoiShader,
pub fn try_shader_at_with_blend<S>(
&mut self,
shader: S,
rect: Rect,
uv: [f32; 4],
textures: &[(&str, TexInput)],
blend: BlendMode,
) -> boolwhere
S: SequoiShader,
Records a shader draw with explicit texture coordinates and blend mode.
Sourcepub fn shader_with_blend<S>(
&mut self,
shader: S,
rect: Rect,
textures: &[(&str, TexInput)],
blend: BlendMode,
) -> Rectwhere
S: SequoiShader,
pub fn shader_with_blend<S>(
&mut self,
shader: S,
rect: Rect,
textures: &[(&str, TexInput)],
blend: BlendMode,
) -> Rectwhere
S: SequoiShader,
Pushes a typed shader draw with an explicit blend mode.