Struct TextStyle
pub struct TextStyle<'a> {
pub font: FontDesc<'a>,
pub color: BackendColor,
pub pos: Pos,
}Expand description
Style of a text
Fields§
§font: FontDesc<'a>The font description
color: BackendColorThe text color
pos: PosThe anchor point position
Implementations§
§impl<'a> TextStyle<'a>
impl<'a> TextStyle<'a>
pub fn color<C>(&self, color: &'a C) -> TextStyle<'a>where
C: Color,
pub fn color<C>(&self, color: &'a C) -> TextStyle<'a>where
C: Color,
Sets the color of the style.
color: The required color- returns The up-to-dated text style
use plotters::prelude::*;
let style = TextStyle::from(("sans-serif", 20).into_font()).color(&RED);pub fn transform(&self, trans: FontTransform) -> TextStyle<'a>
pub fn transform(&self, trans: FontTransform) -> TextStyle<'a>
Sets the font transformation of the style.
trans: The required transformation- returns The up-to-dated text style
use plotters::prelude::*;
let style = TextStyle::from(("sans-serif", 20).into_font()).transform(FontTransform::Rotate90);pub fn pos(&self, pos: Pos) -> TextStyle<'a>
pub fn pos(&self, pos: Pos) -> TextStyle<'a>
Sets the anchor position.
pos: The required anchor position- returns The up-to-dated text style
use plotters::prelude::*;
use plotters::style::text_anchor::{Pos, HPos, VPos};
let pos = Pos::new(HPos::Left, VPos::Top);
let style = TextStyle::from(("sans-serif", 20).into_font()).pos(pos);§See also
Trait Implementations§
§impl<'a> BackendTextStyle for TextStyle<'a>
impl<'a> BackendTextStyle for TextStyle<'a>
§type FontError = <FontDataInternal as FontData>::ErrorType
type FontError = <FontDataInternal as FontData>::ErrorType
The error type of this text style implementation
fn color(&self) -> BackendColor
fn size(&self) -> f64
fn transform(&self) -> FontTransform
fn style(&self) -> FontStyle
fn layout_box( &self, text: &str, ) -> Result<((i32, i32), (i32, i32)), <TextStyle<'a> as BackendTextStyle>::FontError>
fn anchor(&self) -> Pos
fn family(&self) -> FontFamily<'_>
fn draw<E, DrawFunc>( &self, text: &str, pos: (i32, i32), draw: DrawFunc, ) -> Result<Result<(), E>, <TextStyle<'a> as BackendTextStyle>::FontError>
§impl<'a, 'b> From<&'b TextStyle<'a>> for TextStyle<'a>where
'b: 'a,
Make sure that we are able to automatically copy the TextStyle
impl<'a, 'b> From<&'b TextStyle<'a>> for TextStyle<'a>where
'b: 'a,
Make sure that we are able to automatically copy the TextStyle
§impl<'a> IntoTextStyle<'a> for TextStyle<'a>
impl<'a> IntoTextStyle<'a> for TextStyle<'a>
§fn into_text_style<P>(self, _: &P) -> TextStyle<'a>where
P: HasDimension,
fn into_text_style<P>(self, _: &P) -> TextStyle<'a>where
P: HasDimension,
Converts the value into a TextStyle value. Read more
§fn with_color<C>(self, color: C) -> TextStyleBuilder<'a, Self>
fn with_color<C>(self, color: C) -> TextStyleBuilder<'a, Self>
Specifies the color of the text element Read more
Auto Trait Implementations§
impl<'a> Freeze for TextStyle<'a>
impl<'a> RefUnwindSafe for TextStyle<'a>
impl<'a> Send for TextStyle<'a>
impl<'a> Sync for TextStyle<'a>
impl<'a> Unpin for TextStyle<'a>
impl<'a> UnwindSafe for TextStyle<'a>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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
Source§impl<T> FromQuery for T
impl<T> FromQuery for T
Source§fn from_query(query: &str) -> T
fn from_query(query: &str) -> T
Create an instance of
Self from a query string.§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>
Converts
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>
Converts
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 more