OPLayer

Struct OPLayer 

Source
pub struct OPLayer { /* private fields */ }
Expand description

OPLayer is an operation layer, rendered into lines for drawing.

Implementations§

Source§

impl OPLayer

Source

pub fn to_lines(&self) -> (MultiLineString<f64>, MultiLineString<f64>)

Examples found in repository?
examples/carlson_smith_gallery_nannou.rs (line 112)
100    fn on_change(&self) -> Layers {
101        let ctx = self.generate();
102        println!("Flattening...");
103        let layers = if self.settings.draft {
104            ctx.flatten().to_layers()
105        } else {
106            ctx.to_layers()
107        };
108        println!("Done flattening");
109
110        let mut out = Layers::new();
111        for layer in &layers {
112            let (strokes, fills) = layer.to_lines();
113            if self.settings.draft {
114                if out.contains_key(&layer.stroke().unwrap()) {
115                    let (mut orig_stroke, _orig_fill) =
116                        out.get_mut(&layer.stroke().unwrap()).unwrap().clone();
117                    orig_stroke.0.append(&mut strokes.0.clone());
118                    out.insert(
119                        layer.stroke().unwrap().clone(),
120                        (orig_stroke.clone(), MultiLineString::new(vec![])),
121                    );
122                } else {
123                    out.insert(
124                        layer.stroke().unwrap().clone(),
125                        (strokes.clone(), MultiLineString::new(vec![])),
126                    );
127                }
128            } else {
129                if out.contains_key(&layer.stroke().unwrap()) {
130                    let (mut orig_stroke, mut orig_fill) =
131                        out.get_mut(&layer.stroke().unwrap()).unwrap().clone();
132                    orig_stroke.0.append(&mut strokes.0.clone());
133                    orig_fill.0.append(&mut fills.0.clone());
134                    out.insert(
135                        layer.stroke().unwrap(),
136                        (orig_stroke.clone(), orig_fill.clone()),
137                    );
138                } else {
139                    out.insert(layer.stroke().unwrap(), (strokes.clone(), fills.clone()));
140                }
141            }
142        }
143        out
144    }
Source

pub fn stroke(&self) -> Option<String>

Examples found in repository?
examples/carlson_smith_gallery_nannou.rs (line 114)
100    fn on_change(&self) -> Layers {
101        let ctx = self.generate();
102        println!("Flattening...");
103        let layers = if self.settings.draft {
104            ctx.flatten().to_layers()
105        } else {
106            ctx.to_layers()
107        };
108        println!("Done flattening");
109
110        let mut out = Layers::new();
111        for layer in &layers {
112            let (strokes, fills) = layer.to_lines();
113            if self.settings.draft {
114                if out.contains_key(&layer.stroke().unwrap()) {
115                    let (mut orig_stroke, _orig_fill) =
116                        out.get_mut(&layer.stroke().unwrap()).unwrap().clone();
117                    orig_stroke.0.append(&mut strokes.0.clone());
118                    out.insert(
119                        layer.stroke().unwrap().clone(),
120                        (orig_stroke.clone(), MultiLineString::new(vec![])),
121                    );
122                } else {
123                    out.insert(
124                        layer.stroke().unwrap().clone(),
125                        (strokes.clone(), MultiLineString::new(vec![])),
126                    );
127                }
128            } else {
129                if out.contains_key(&layer.stroke().unwrap()) {
130                    let (mut orig_stroke, mut orig_fill) =
131                        out.get_mut(&layer.stroke().unwrap()).unwrap().clone();
132                    orig_stroke.0.append(&mut strokes.0.clone());
133                    orig_fill.0.append(&mut fills.0.clone());
134                    out.insert(
135                        layer.stroke().unwrap(),
136                        (orig_stroke.clone(), orig_fill.clone()),
137                    );
138                } else {
139                    out.insert(layer.stroke().unwrap(), (strokes.clone(), fills.clone()));
140                }
141            }
142        }
143        out
144    }
Source

pub fn fill(&self) -> Option<String>

Source

pub fn stroke_width(&self) -> f64

Trait Implementations§

Source§

impl Clone for OPLayer

Source§

fn clone(&self) -> OPLayer

Returns a duplicate 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 Debug for OPLayer

Source§

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

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

impl<'de> Deserialize<'de> for OPLayer

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 OPLayer

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<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Component + Float, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
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, U> ConvertInto<U> for T
where U: ConvertFrom<T>,

Source§

fn convert_into(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

fn convert_unclamped_into(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

fn try_convert_into(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,