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§
§impl TextShape
impl TextShape
pub fn new(pos: Pos2, galley: Arc<Galley>, fallback_color: Color32) -> TextShape
pub fn new(pos: Pos2, galley: Arc<Galley>, fallback_color: Color32) -> TextShape
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.
pub fn visual_bounding_rect(&self) -> Rect
pub fn visual_bounding_rect(&self) -> Rect
The visual bounding rectangle
pub fn with_underline(self, underline: Stroke) -> TextShape
pub fn with_override_text_color(self, override_text_color: Color32) -> TextShape
pub fn with_override_text_color(self, override_text_color: Color32) -> TextShape
Use the given color for the text, regardless of what color is already in the galley.
pub fn with_angle(self, angle: f32) -> TextShape
pub fn with_angle(self, angle: f32) -> TextShape
Rotate text by this many radians clockwise.
The pivot is pos
(the upper left corner of the text).
pub fn with_opacity_factor(self, opacity_factor: f32) -> TextShape
pub fn with_opacity_factor(self, opacity_factor: f32) -> TextShape
Render text with this opacity in gamma space
Trait Implementations§
§impl<'de> Deserialize<'de> for TextShape
impl<'de> Deserialize<'de> for TextShape
§fn deserialize<__D>(
__deserializer: __D
) -> Result<TextShape, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<TextShape, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for TextShape
impl Serialize for TextShape
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for TextShape
Auto Trait Implementations§
impl Freeze for TextShape
impl RefUnwindSafe for TextShape
impl Send for TextShape
impl Sync for TextShape
impl Unpin for TextShape
impl UnwindSafe for TextShape
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request