Skip to main content

Style

Struct Style 

Source
#[non_exhaustive]
pub struct Style {
Show 15 fields pub color: u32, pub width: f32, pub unit: Unit, pub cap: Cap, pub join: Join, pub miter_limit: f32, pub dash: [f32; 8], pub dashes: u32, pub dash_unit: Unit, pub dash_phase: f32, pub hatch: [HatchLine; 4], pub hatches: u32, pub hatch_width: f32, pub transparency: Transparency, pub by_block: u32,
}
Expand description

a stroke’s look. Made with new and changed field by field (it may grow)

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§color: u32

0xAARRGGBB: sRGB codes as the target shows them, straight alpha

§width: f32

in units; 0 (or anything thinner than a pixel): a hairline, 1 px wide

§unit: Unit§cap: Cap§join: Join§miter_limit: f32

the longest miter over the width (lib/gfx’s and SVG’s ratio); at least 1

§dash: [f32; 8]

a dash pattern: lengths on and off in turn, starting with on, the first dashes entries (0: solid). An odd count runs twice (on, off, on, then off, on, off), as in SVG; every dash ends in cap, joins only where a dash runs through a vertex. The pattern runs along each entity from its start (a closed polyline’s first point, an arc’s start, a circle’s angle 0), across the joins of a polyline

§dashes: u32§dash_unit: Unit

the unit of the pattern’s lengths and of its phase

§dash_phase: f32

how far into the pattern an entity starts (in dash_units)

§hatch: [HatchLine; 4]

a fill’s hatch: the first hatches line families (0: the fill is solid), drawn in color over nothing, the lines hatch_width px wide (0, or thinner than a pixel: 1 px); strokes ignore it

§hatches: u32§hatch_width: f32§transparency: Transparency

AutoCAD’s transparency of what the style draws: its layer’s (the default), its block insert’s, or its own; the colour’s alpha times 1 - percent / 100 (G6b2)

§by_block: u32

inside a block, what an entity of this style takes from its insert’s style instead of its own (BY_BLOCK_COLOR, BY_BLOCK_WIDTH, BY_BLOCK_DASH; DXF’s ByBlock); outside a block the style’s own (G6b2)

Implementations§

Source§

impl Style

Source

pub const fn new(color: u32) -> Style

a hairline of a colour: width 0, butt caps, miter joins with the limit 4, solid

Source

pub fn hatched(self, families: &[HatchLine], width: f32) -> Style

the same with a hatch (at most HATCH_MAX families; none: a solid fill) of lines width px wide

Source

pub fn dashed(self, pattern: &[f32], unit: Unit, phase: f32) -> Style

the same with a dash pattern (at most DASH_MAX entries; an empty one: solid), its unit and phase

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 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 StructuralPartialEq for Style

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> 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, 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> ErasedDestructor for T
where T: 'static,

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

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.