Struct plotters::style::TextStyle

source ·
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: BackendColor

The text color

§pos: Pos

The anchor point position

Implementations§

source§

impl<'a> TextStyle<'a>

source

pub fn color<C: Color>(&self, color: &'a C) -> Self

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);
source

pub fn transform(&self, trans: FontTransform) -> Self

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);
source

pub fn pos(&self, pos: Pos) -> Self

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

IntoTextStyle::with_anchor()

Trait Implementations§

source§

impl<'a> BackendTextStyle for TextStyle<'a>

§

type FontError = <FontDataInternal as FontData>::ErrorType

The error type of this text style implementation
source§

fn color(&self) -> BackendColor

source§

fn size(&self) -> f64

source§

fn transform(&self) -> FontTransform

source§

fn style(&self) -> FontStyle

source§

fn layout_box( &self, text: &str ) -> Result<((i32, i32), (i32, i32)), Self::FontError>

source§

fn anchor(&self) -> Pos

source§

fn family(&self) -> FontFamily<'_>

source§

fn draw<E, DrawFunc: FnMut(i32, i32, BackendColor) -> Result<(), E>>( &self, text: &str, pos: BackendCoord, draw: DrawFunc ) -> Result<Result<(), E>, Self::FontError>

source§

impl<'a> Clone for TextStyle<'a>

source§

fn clone(&self) -> TextStyle<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, 'b: 'a> From<&'b TextStyle<'a>> for TextStyle<'a>

Make sure that we are able to automatically copy the TextStyle

source§

fn from(this: &'b TextStyle<'a>) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Into<FontDesc<'a>>> From<T> for TextStyle<'a>

source§

fn from(font: T) -> Self

Converts to this type from the input type.
source§

impl<'a> IntoTextStyle<'a> for TextStyle<'a>

source§

fn into_text_style<P: HasDimension>(self, _: &P) -> TextStyle<'a>

Converts the value into a TextStyle value. Read more
source§

fn with_color<C: Color>(self, color: C) -> TextStyleBuilder<'a, Self>where Self: Sized,

Specifies the color of the text element Read more
source§

fn with_anchor<C: Color>(self, pos: Pos) -> TextStyleBuilder<'a, Self>where Self: Sized,

Specifies the position of the text anchor relative to the text element Read more

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.