Struct nanovg::Frame [−][src]
pub struct Frame<'a> { /* fields omitted */ }
A frame which can draw paths. All NanoVG path drawing operations are done on a frame.
Methods
impl<'a> Frame<'a>
[src]
impl<'a> Frame<'a>
pub fn context(&self) -> &'a Context
[src]
pub fn context(&self) -> &'a Context
Get the underlying context this frame was created on.
pub fn transform(&self) -> &Transform
[src]
pub fn transform(&self) -> &Transform
Get current transform which the frame is transformed by.
pub fn transformed<'b, F: FnOnce(Frame<'b>)>(
&'b mut self,
transform: Transform,
handler: F
)
[src]
pub fn transformed<'b, F: FnOnce(Frame<'b>)>(
&'b mut self,
transform: Transform,
handler: F
)
Create a new frame where all drawing operations are transformed by transform
.
self
is passed as &mut because only one transformation at a time can be applied to a single frame.
Transforming a sub-frame however, is valid.
The resulting transformation can be retrieved with Frame::transform.
pub fn path<F: FnOnce(Path)>(&self, handler: F, options: PathOptions)
[src]
pub fn path<F: FnOnce(Path)>(&self, handler: F, options: PathOptions)
Draw a new path.
handler
is the callback in which you operate the path.
options
control how the path is rendered.
pub fn text<S: AsRef<str>>(
&self,
font: Font,
(x, y): (f32, f32),
text: S,
options: TextOptions
)
[src]
pub fn text<S: AsRef<str>>(
&self,
font: Font,
(x, y): (f32, f32),
text: S,
options: TextOptions
)
Draw a single line on the screen. Newline characters are ignored.
font
the font face to use.
(x, y)
the origin / position to draw the text at. The origin is relative to the alignment of options
.
text
the string to draw.
options
optional (Default::default
) options that control the visual appearance of the text.
pub fn text_box<S: AsRef<str>>(
&self,
font: Font,
(x, y): (f32, f32),
text: S,
options: TextOptions
)
[src]
pub fn text_box<S: AsRef<str>>(
&self,
font: Font,
(x, y): (f32, f32),
text: S,
options: TextOptions
)
Draw multiline text on the screen.
font
the font face to use.
(x, y)
the origin / position to draw the text at. The origin is relative to the alignment of options
.
text
the string to draw.
options
optional (Default::default
) options that control the visual appearance of the text.
pub fn text_bounds<S: AsRef<str>>(
&self,
font: Font,
(x, y): (f32, f32),
text: S,
options: TextOptions
) -> (f32, TextBounds)
[src]
pub fn text_bounds<S: AsRef<str>>(
&self,
font: Font,
(x, y): (f32, f32),
text: S,
options: TextOptions
) -> (f32, TextBounds)
Measures specified text string.
Returns tuple (f32, TextBounds) where the first element specifies horizontal advance of measured text
and the second element specifies the bounding box of measured text.
font
the font face to use.
(x, y)
the origin / position to measure the text from.
text
the string to measure.
options
optional (Default::default
) options that controls how the text is measured.
pub fn text_box_bounds<S: AsRef<str>>(
&self,
font: Font,
(x, y): (f32, f32),
text: S,
options: TextOptions
) -> TextBounds
[src]
pub fn text_box_bounds<S: AsRef<str>>(
&self,
font: Font,
(x, y): (f32, f32),
text: S,
options: TextOptions
) -> TextBounds
Measures specified multi-text string.
Returns bounding box of measured multi-text.
font
the font face to use.
(x, y)
the origin / position to measure the text from.
text
the string to measure.
options
optional (Default::default
) options that controls how the text is measured.
ⓘImportant traits for TextGlyphPositions<'a>pub fn text_glyph_positions<S: AsRef<str>>(
&self,
(x, y): (f32, f32),
text: S
) -> TextGlyphPositions
[src]
pub fn text_glyph_positions<S: AsRef<str>>(
&self,
(x, y): (f32, f32),
text: S
) -> TextGlyphPositions
Calculates and breaks text into series of glyph positions.
Returns iterator over all glyph positions in text.
(x, y)
the coordinate space from which to offset coordinates in GlyphPosition
text
the text to break into glyph positions
If you want to get current glyph and the next one, use .peekable() on this iterator.
pub fn text_metrics(&self, font: Font, options: TextOptions) -> TextMetrics
[src]
pub fn text_metrics(&self, font: Font, options: TextOptions) -> TextMetrics
Returns vertical text metrics based on given font and text options
Measured values are stored in TextMetrics struct in local coordinate space.
options
the options specify how metrics should be calculated.
font
the font for which to calculate metrics.
ⓘImportant traits for TextBreakLines<'a>pub fn text_break_lines<S: AsRef<str>>(
&self,
text: S,
break_row_width: f32
) -> TextBreakLines
[src]
pub fn text_break_lines<S: AsRef<str>>(
&self,
text: S,
break_row_width: f32
) -> TextBreakLines
Breaks text into lines.
Text is split at word boundaries, new-line character or when row width exceeds break_row_width.
Returns iterator over text lines.
text
the text to break into lines
break_row_width
maximum width of row