plotters::style

Struct 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>

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 112 bytes