Skip to main content

Style

Struct Style 

Source
#[repr(C)]
pub struct Style { pub flags_and_miter_limit: u32, pub line_width: f32, }
Expand description

Data structure encoding stroke or fill style.

Fields§

§flags_and_miter_limit: u32

Encodes the stroke and fill style parameters. This field is split into two 16-bit parts:

  • flags: u16 - encodes fill vs stroke, even-odd vs non-zero fill mode for fills and cap and join style for strokes. See the FLAGS_* constants below for more information.

    flags: |style|fill|join|start cap|end cap|reserved|
     bits:  0     1    2-3  4-5       6-7     8-15
  • miter_limit: u16 - The miter limit for a stroke, encoded in binary16 (half) floating point representation. This field is only meaningful for the Join::Miter join style. It’s ignored for other stroke styles and fills.

§line_width: f32

Encodes the stroke width. This field is ignored for fills.

Implementations§

Source§

impl Style

Source

pub const FLAGS_STYLE_BIT: u32 = 0x8000_0000

0 for a fill, 1 for a stroke

Source

pub const FLAGS_FILL_BIT: u32 = 0x4000_0000

0 for non-zero, 1 for even-odd

Source

pub const FLAGS_JOIN_BITS_BEVEL: u32 = 0

Encodings for join style:

  • 0b00 -> bevel
  • 0b01 -> miter
  • 0b10 -> round
Source

pub const FLAGS_JOIN_BITS_MITER: u32 = 0x1000_0000

Source

pub const FLAGS_JOIN_BITS_ROUND: u32 = 0x2000_0000

Source

pub const FLAGS_JOIN_MASK: u32 = 0x3000_0000

Source

pub const FLAGS_CAP_BITS_BUTT: u32 = 0

Encodings for cap style:

  • 0b00 -> butt
  • 0b01 -> square
  • 0b10 -> round
Source

pub const FLAGS_CAP_BITS_SQUARE: u32 = 0x0100_0000

Source

pub const FLAGS_CAP_BITS_ROUND: u32 = 0x0200_0000

Source

pub const FLAGS_START_CAP_BITS_BUTT: u32

Source

pub const FLAGS_START_CAP_BITS_SQUARE: u32

Source

pub const FLAGS_START_CAP_BITS_ROUND: u32

Source

pub const FLAGS_END_CAP_BITS_BUTT: u32 = Self::FLAGS_CAP_BITS_BUTT

Source

pub const FLAGS_END_CAP_BITS_SQUARE: u32 = Self::FLAGS_CAP_BITS_SQUARE

Source

pub const FLAGS_END_CAP_BITS_ROUND: u32 = Self::FLAGS_CAP_BITS_ROUND

Source

pub const FLAGS_START_CAP_MASK: u32 = 0x0C00_0000

Source

pub const FLAGS_END_CAP_MASK: u32 = 0x0300_0000

Source

pub const MITER_LIMIT_MASK: u32 = 0xFFFF

Source

pub fn from_fill(fill: Fill) -> Self

Source

pub fn from_stroke(stroke: &Stroke) -> Option<Self>

Creates a style from a stroke.

As it isn’t meaningful to encode a zero width stroke, returns None if the width is zero.

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Style

Source§

impl Debug for Style

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Style

Source§

fn default() -> Self

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

impl PartialEq for Style

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Pod for Style

Source§

impl StructuralPartialEq for Style

Source§

impl Zeroable for Style

Source§

fn zeroed() -> Self

Auto Trait Implementations§

§

impl Forget for Style

§

impl Freeze for Style

§

impl Move for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnsafeUnpin for Style

§

impl UnwindSafe for Style

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> AnyBitPattern for T
where T: Pod,

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

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

Source§

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

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

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.