pub struct TextShape {
pub pos: Pos2,
pub galley: Arc<Galley>,
pub underline: Stroke,
pub fallback_color: Color32,
pub override_text_color: Option<Color32>,
pub opacity_factor: f32,
pub angle: f32,
}
Expand description
How to paint some text on screen.
This needs to be recreated if pixels_per_point
(dpi scale) changes.
Fields§
§pos: Pos2
Top left corner of the first character.
galley: Arc<Galley>
The laid out text, from Fonts::layout_job
.
underline: Stroke
Add this underline to the whole text. You can also set an underline when creating the galley.
fallback_color: Color32
Any Color32::PLACEHOLDER
in the galley will be replaced by the given color.
Affects everything: backgrounds, glyphs, strikethough, underline, etc.
override_text_color: Option<Color32>
If set, the text color in the galley will be ignored and replaced with the given color.
This only affects the glyphs and will NOT replace background color nor strikethrough/underline color.
opacity_factor: f32
If set, the text will be rendered with the given opacity in gamma space Affects everything: backgrounds, glyphs, strikethough, underline, etc.
angle: f32
Rotate text by this many radians clockwise.
The pivot is pos
(the upper left corner of the text).
Implementations§
source§impl TextShape
impl TextShape
sourcepub fn new(pos: Pos2, galley: Arc<Galley>, fallback_color: Color32) -> Self
pub fn new(pos: Pos2, galley: Arc<Galley>, fallback_color: Color32) -> Self
The given fallback color will be used for any uncolored part of the galley (using Color32::PLACEHOLDER
).
Any non-placeholder color in the galley takes precedence over this fallback color.
sourcepub fn visual_bounding_rect(&self) -> Rect
pub fn visual_bounding_rect(&self) -> Rect
The visual bounding rectangle
pub fn with_underline(self, underline: Stroke) -> Self
sourcepub fn with_override_text_color(self, override_text_color: Color32) -> Self
pub fn with_override_text_color(self, override_text_color: Color32) -> Self
Use the given color for the text, regardless of what color is already in the galley.
sourcepub fn with_angle(self, angle: f32) -> Self
pub fn with_angle(self, angle: f32) -> Self
Rotate text by this many radians clockwise.
The pivot is pos
(the upper left corner of the text).
sourcepub fn with_opacity_factor(self, opacity_factor: f32) -> Self
pub fn with_opacity_factor(self, opacity_factor: f32) -> Self
Render text with this opacity in gamma space