Skip to main content

ElementStyle

Struct ElementStyle 

Source
pub struct ElementStyle {
    pub fill_color: Option<String>,
    pub stroke_color: Option<String>,
    pub stroke_width: Option<f64>,
    pub text_color: Option<String>,
    pub text_size: Option<f64>,
    pub opacity: Option<f64>,
    pub class_name: Option<String>,
    pub attributes: HashMap<String, String>,
}
Expand description

Style information for rendering elements

Fields§

§fill_color: Option<String>

Optional override for the fill color.

§stroke_color: Option<String>

Optional override for the stroke color.

§stroke_width: Option<f64>

Optional override for the stroke width.

§text_color: Option<String>

Optional override for the text color.

§text_size: Option<f64>

Optional override for the text size.

§opacity: Option<f64>

Optional override for the element opacity (0.0 to 1.0).

§class_name: Option<String>

Optional CSS class name for the element.

§attributes: HashMap<String, String>

Custom attributes to be added to the SVG element.

Implementations§

Source§

impl ElementStyle

Source

pub fn new() -> Self

Creates a new default element style.

Source

pub fn with_fill(self, color: String) -> Self

Sets the fill color.

Source

pub fn with_stroke(self, color: String, width: f64) -> Self

Sets the stroke color and width.

Source

pub fn with_text(self, color: String, size: f64) -> Self

Sets the text color and size.

Source

pub fn with_opacity(self, opacity: f64) -> Self

Sets the element opacity.

Source

pub fn with_class(self, class_name: String) -> Self

Sets the CSS class name.

Source

pub fn with_attribute(self, key: String, value: String) -> Self

Adds a custom attribute.

Trait Implementations§

Source§

impl Default for ElementStyle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ElementStyle

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ElementStyle

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> 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, 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,