Add color weights to Grayscale node and improve luminance handling (#1015)

* Add weighted grayscale node

* Rename nodes, fix grayscale weighting, add luma calc options

* Fix tests

* Add Tint Option

* Improve (but not full fix) tint

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
isiko 2023-02-10 21:55:01 +01:00 committed by Keavon Chambers
parent d456640bb8
commit a709a772d5
7 changed files with 285 additions and 34 deletions

View file

@ -2,6 +2,7 @@ pub use dyn_any::StaticType;
use dyn_any::{DynAny, Upcast};
use dyn_clone::DynClone;
pub use glam::DVec2;
use graphene_core::raster::LuminanceCalculation;
use graphene_core::Node;
use std::hash::Hash;
pub use std::sync::Arc;
@ -26,6 +27,7 @@ pub enum TaggedValue {
Color(graphene_core::raster::color::Color),
Subpath(graphene_core::vector::subpath::Subpath),
RcSubpath(Arc<graphene_core::vector::subpath::Subpath>),
LuminanceCalculation(LuminanceCalculation),
ImaginateSamplingMethod(ImaginateSamplingMethod),
ImaginateMaskStartingFill(ImaginateMaskStartingFill),
ImaginateStatus(ImaginateStatus),
@ -86,20 +88,24 @@ impl Hash for TaggedValue {
13.hash(state);
s.hash(state)
}
Self::ImaginateSamplingMethod(m) => {
Self::LuminanceCalculation(l) => {
14.hash(state);
l.hash(state)
}
Self::ImaginateSamplingMethod(m) => {
15.hash(state);
m.hash(state)
}
Self::ImaginateMaskStartingFill(f) => {
15.hash(state);
16.hash(state);
f.hash(state)
}
Self::ImaginateStatus(s) => {
16.hash(state);
17.hash(state);
s.hash(state)
}
Self::LayerPath(p) => {
17.hash(state);
18.hash(state);
p.hash(state)
}
}
@ -123,6 +129,7 @@ impl<'a> TaggedValue {
TaggedValue::Color(x) => Box::new(x),
TaggedValue::Subpath(x) => Box::new(x),
TaggedValue::RcSubpath(x) => Box::new(x),
TaggedValue::LuminanceCalculation(x) => Box::new(x),
TaggedValue::ImaginateSamplingMethod(x) => Box::new(x),
TaggedValue::ImaginateMaskStartingFill(x) => Box::new(x),
TaggedValue::ImaginateStatus(x) => Box::new(x),