Struct pdf_canvas::Canvas
source · [−]pub struct Canvas<'a> { /* private fields */ }
Expand description
A visual area where content can be drawn (a page).
Provides methods for defining and stroking or filling paths, as well as placing text objects.
TODO Everything here that takes a BuiltinFont
should take any
FontSource
instead.
Implementations
sourceimpl<'a> Canvas<'a>
impl<'a> Canvas<'a>
sourcepub fn rectangle(
&mut self,
x: f32,
y: f32,
width: f32,
height: f32
) -> Result<()>
pub fn rectangle(
&mut self,
x: f32,
y: f32,
width: f32,
height: f32
) -> Result<()>
Append a closed rectangle with a corner at (x, y) and extending width × height to the to the current path.
sourcepub fn set_line_join_style(&mut self, style: JoinStyle) -> Result<()>
pub fn set_line_join_style(&mut self, style: JoinStyle) -> Result<()>
Set the line join style in the graphics state.
sourcepub fn set_line_cap_style(&mut self, style: CapStyle) -> Result<()>
pub fn set_line_cap_style(&mut self, style: CapStyle) -> Result<()>
Set the line join style in the graphics state.
sourcepub fn set_line_width(&mut self, w: f32) -> Result<()>
pub fn set_line_width(&mut self, w: f32) -> Result<()>
Set the line width in the graphics state.
sourcepub fn set_stroke_color(&mut self, color: Color) -> Result<()>
pub fn set_stroke_color(&mut self, color: Color) -> Result<()>
Set color for stroking operations.
sourcepub fn set_fill_color(&mut self, color: Color) -> Result<()>
pub fn set_fill_color(&mut self, color: Color) -> Result<()>
Set color for non-stroking operations.
sourcepub fn concat(&mut self, m: Matrix) -> Result<()>
pub fn concat(&mut self, m: Matrix) -> Result<()>
Modify the current transformation matrix for coordinates by concatenating the specified matrix.
sourcepub fn line(&mut self, x1: f32, y1: f32, x2: f32, y2: f32) -> Result<()>
pub fn line(&mut self, x1: f32, y1: f32, x2: f32, y2: f32) -> Result<()>
Append a straight line from (x1, y1) to (x2, y2) to the current path.
sourcepub fn move_to(&mut self, x: f32, y: f32) -> Result<()>
pub fn move_to(&mut self, x: f32, y: f32) -> Result<()>
Begin a new subpath at the point (x, y).
sourcepub fn line_to(&mut self, x: f32, y: f32) -> Result<()>
pub fn line_to(&mut self, x: f32, y: f32) -> Result<()>
Add a straight line from the current point to (x, y) to the current path.
sourcepub fn curve_to(
&mut self,
x1: f32,
y1: f32,
x2: f32,
y2: f32,
x3: f32,
y3: f32
) -> Result<()>
pub fn curve_to(
&mut self,
x1: f32,
y1: f32,
x2: f32,
y2: f32,
x3: f32,
y3: f32
) -> Result<()>
Add a Bézier curve from the current point to (x3, y3) with (x1, y1) and (x2, y2) as Bézier controll points.
sourcepub fn circle(&mut self, x: f32, y: f32, r: f32) -> Result<()>
pub fn circle(&mut self, x: f32, y: f32, r: f32) -> Result<()>
Add a circle approximated by four cubic Bézier curves to the current path. Based on http://spencermortensen.com/articles/bezier-circle/
sourcepub fn close_and_stroke(&mut self) -> Result<()>
pub fn close_and_stroke(&mut self) -> Result<()>
Close and stroke the current path.
sourcepub fn get_font(&mut self, font: BuiltinFont) -> FontRef
pub fn get_font(&mut self, font: BuiltinFont) -> FontRef
Get a FontRef for a specific font.
sourcepub fn text<F, T>(&mut self, render_text: F) -> Result<T> where
F: FnOnce(&mut TextObject<'_>) -> Result<T>,
pub fn text<F, T>(&mut self, render_text: F) -> Result<T> where
F: FnOnce(&mut TextObject<'_>) -> Result<T>,
Create a text object.
The contents of the text object is defined by the function render_text, by applying methods to the TextObject it gets as an argument. On success, return the value returned by render_text.
sourcepub fn left_text(
&mut self,
x: f32,
y: f32,
font: BuiltinFont,
size: f32,
text: &str
) -> Result<()>
pub fn left_text(
&mut self,
x: f32,
y: f32,
font: BuiltinFont,
size: f32,
text: &str
) -> Result<()>
Utility method for placing a string of text.
sourcepub fn right_text(
&mut self,
x: f32,
y: f32,
font: BuiltinFont,
size: f32,
text: &str
) -> Result<()>
pub fn right_text(
&mut self,
x: f32,
y: f32,
font: BuiltinFont,
size: f32,
text: &str
) -> Result<()>
Utility method for placing a string of text.
sourcepub fn center_text(
&mut self,
x: f32,
y: f32,
font: BuiltinFont,
size: f32,
text: &str
) -> Result<()>
pub fn center_text(
&mut self,
x: f32,
y: f32,
font: BuiltinFont,
size: f32,
text: &str
) -> Result<()>
Utility method for placing a string of text.
sourcepub fn add_outline(&mut self, title: &str)
pub fn add_outline(&mut self, title: &str)
Add an item for this page in the document outline.
An outline item associates a name (contained in an ordered tree) with a location in the document. The PDF standard supports several ways to specify an exact location on a page, but this implementation currently only supports linking to a specific page (the page that this Canvas is for).
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Canvas<'a>
impl<'a> !Send for Canvas<'a>
impl<'a> !Sync for Canvas<'a>
impl<'a> Unpin for Canvas<'a>
impl<'a> !UnwindSafe for Canvas<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more