pub struct OPLayer { /* private fields */ }
Expand description
OPLayer is an operation layer, rendered into lines for drawing.
Implementations§
Source§impl OPLayer
impl OPLayer
Sourcepub fn to_lines(&self) -> (MultiLineString<f64>, MultiLineString<f64>)
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 }
Sourcepub fn stroke(&self) -> Option<String>
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 }
pub fn fill(&self) -> Option<String>
pub fn stroke_width(&self) -> f64
Trait Implementations§
Source§impl<'de> Deserialize<'de> for OPLayer
impl<'de> Deserialize<'de> for OPLayer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for OPLayer
impl RefUnwindSafe for OPLayer
impl Send for OPLayer
impl Sync for OPLayer
impl Unpin for OPLayer
impl UnwindSafe for OPLayer
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified
method
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford
method by default
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
Source§fn convert_into(self) -> U
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
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>>
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 moreSource§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.