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]
pub fn context(&self) -> &'a Context
[src]
Get the underlying context this frame was created on.
pub fn get_transform(&self) -> &Transform
[src]
Get current transform which the frame is transformed by.
pub fn transform<F: FnOnce(Frame)>(&self, transform: Transform, handler: F)
[src]
Transform current Frame by 'transform' and call 'handler' with transformed Frame as its only parameter. You can get the passed transform by calling get_transform on Frame instance.
transform
frame gets transformed by this Transform (it takes previous frame transform into account)
handler
the callback where you use the new transformed Frame
pub fn path<F: FnOnce(Path)>(&self, handler: F, options: PathOptions)
[src]
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]
&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]
&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]
&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]
&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]
&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
pub fn text_metrics(&self, font: Font, options: TextOptions) -> TextMetrics
[src]
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]
&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