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