pub struct Canvas { /* private fields */ }Expand description
An imperative painter producing content-stream operators.
Implementations§
Source§impl Canvas
impl Canvas
Sourcepub fn transform(&mut self, m: Matrix)
pub fn transform(&mut self, m: Matrix)
Concatenates m onto the current transformation matrix (cm).
Sourcepub fn set_line_width(&mut self, width: f32)
pub fn set_line_width(&mut self, width: f32)
Sets the stroke line width (w).
Sourcepub fn set_line_cap(&mut self, cap: LineCap)
pub fn set_line_cap(&mut self, cap: LineCap)
Sets the line cap style (J).
Sourcepub fn set_line_join(&mut self, join: LineJoin)
pub fn set_line_join(&mut self, join: LineJoin)
Sets the line join style (j).
Sourcepub fn set_miter_limit(&mut self, limit: f32)
pub fn set_miter_limit(&mut self, limit: f32)
Sets the miter limit (M).
Sourcepub fn set_stroke(&mut self, color: Color)
pub fn set_stroke(&mut self, color: Color)
Sets the stroke color (G/RG/K).
Sourcepub fn curve_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32)
pub fn curve_to(&mut self, x1: f32, y1: f32, x2: f32, y2: f32, x3: f32, y3: f32)
Cubic Bézier with two control points (c).
Sourcepub fn rect(&mut self, x: f32, y: f32, width: f32, height: f32)
pub fn rect(&mut self, x: f32, y: f32, width: f32, height: f32)
Appends a rectangle subpath (re).
Sourcepub fn circle(&mut self, cx: f32, cy: f32, r: f32)
pub fn circle(&mut self, cx: f32, cy: f32, r: f32)
Appends a circle as four Bézier arcs, starting at the rightmost
point (cx + r, cy) and running counter-clockwise.
Sourcepub fn ellipse(&mut self, cx: f32, cy: f32, rx: f32, ry: f32)
pub fn ellipse(&mut self, cx: f32, cy: f32, rx: f32, ry: f32)
Appends an axis-aligned ellipse as four Bézier arcs, starting at the
rightmost point (cx + rx, cy) and running counter-clockwise.
Sourcepub fn polygon(&mut self, points: &[Point])
pub fn polygon(&mut self, points: &[Point])
Appends a closed polygon through points. Fewer than three points
appends nothing.
Sourcepub fn fill_even_odd(&mut self)
pub fn fill_even_odd(&mut self)
Fills the current path, even-odd (f*).
Sourcepub fn close_stroke(&mut self)
pub fn close_stroke(&mut self)
Closes and strokes the current path (s).
Sourcepub fn fill_stroke(&mut self)
pub fn fill_stroke(&mut self)
Fills then strokes the current path (B).
Sourcepub fn clip(&mut self)
pub fn clip(&mut self)
Intersects the clip with the current path, nonzero (W n). The
path is consumed: it is ended without painting and a fresh path
starts afterwards.
Sourcepub fn clip_even_odd(&mut self)
pub fn clip_even_odd(&mut self)
Intersects the clip with the current path, even-odd (W* n). The
path is consumed: it is ended without painting and a fresh path
starts afterwards.
Sourcepub fn text(
&mut self,
text: &str,
x: f32,
y: f32,
font: Standard14,
size: f32,
) -> Result<()>
pub fn text( &mut self, text: &str, x: f32, y: f32, font: Standard14, size: f32, ) -> Result<()>
Shows one line of text with its baseline origin at (x, y)
(BT/Tf/Td/Tj/ET). Errors on unencodable characters
before any operator is pushed, leaving the canvas untouched.
Sourcepub fn add_image(&mut self, image: ImageData) -> ImageHandle
pub fn add_image(&mut self, image: ImageData) -> ImageHandle
Registers an image for use with draw_image.
Sourcepub fn draw_image(
&mut self,
image: ImageHandle,
x: f32,
y: f32,
width: f32,
height: f32,
)
pub fn draw_image( &mut self, image: ImageHandle, x: f32, y: f32, width: f32, height: f32, )
Paints a registered image into the axis-aligned box at (x, y) with
the given size (q cm Do Q).
Sourcepub fn group(&mut self, canvas: Canvas, bbox: [f32; 4]) -> GroupHandle
pub fn group(&mut self, canvas: Canvas, bbox: [f32; 4]) -> GroupHandle
Registers a finished sub-canvas as a form group, with bbox
([llx, lly, urx, ury]) becoming the form’s /BBox. Paint it with
draw_group.
Sourcepub fn draw_group(&mut self, group: GroupHandle, matrix: Matrix)
pub fn draw_group(&mut self, group: GroupHandle, matrix: Matrix)
Paints a registered group under matrix (q cm /GpN Do Q). Two
calls with the same group reference the same form resource.
Sourcepub fn set_fill_alpha(&mut self, alpha: f32)
pub fn set_fill_alpha(&mut self, alpha: f32)
Sets the nonstroking alpha constant (gs referencing /ca).
Sourcepub fn set_stroke_alpha(&mut self, alpha: f32)
pub fn set_stroke_alpha(&mut self, alpha: f32)
Sets the stroking alpha constant (gs referencing /CA).
Sourcepub fn set_blend_mode(&mut self, mode: BlendMode)
pub fn set_blend_mode(&mut self, mode: BlendMode)
Sets the blend mode (gs referencing /BM).