mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 07:18:04 +08:00
Improve Threshold node, move Gamma into Exposure node
This commit is contained in:
@@ -278,6 +278,18 @@ impl NumberInput {
|
||||
self.mode = NumberInputMode::Range;
|
||||
self
|
||||
}
|
||||
pub fn mode_range(mut self) -> Self {
|
||||
self.mode = NumberInputMode::Range;
|
||||
self
|
||||
}
|
||||
pub fn mode_increment(mut self) -> Self {
|
||||
self.mode = NumberInputMode::Increment;
|
||||
self
|
||||
}
|
||||
pub fn increment_step(mut self, step: f64) -> Self {
|
||||
self.step = step;
|
||||
self
|
||||
}
|
||||
pub fn percentage(self) -> Self {
|
||||
self.min(0.).max(100.).unit("%").display_decimal_places(2)
|
||||
}
|
||||
|
||||
@@ -252,17 +252,6 @@ static STATIC_NODES: &[DocumentNodeType] = &[
|
||||
outputs: &[FrontendGraphDataType::Raster],
|
||||
properties: node_properties::brighten_image_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Gamma",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::GammaNode<_>", &[concrete!("Image"), concrete!("f64")]),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Gamma", TaggedValue::F64(1.), false),
|
||||
],
|
||||
outputs: &[FrontendGraphDataType::Raster],
|
||||
properties: node_properties::adjust_gamma_properties,
|
||||
},
|
||||
DocumentNodeType {
|
||||
name: "Threshold",
|
||||
category: "Image Adjustments",
|
||||
@@ -310,10 +299,15 @@ static STATIC_NODES: &[DocumentNodeType] = &[
|
||||
DocumentNodeType {
|
||||
name: "Exposure",
|
||||
category: "Image Adjustments",
|
||||
identifier: NodeImplementation::proto("graphene_core::raster::ExposureNode<_>", &[concrete!("Image"), concrete!("f64")]),
|
||||
identifier: NodeImplementation::proto(
|
||||
"graphene_core::raster::ExposureNode<_, _, _>",
|
||||
&[concrete!("Image"), concrete!("f64"), concrete!("f64"), concrete!("f64")],
|
||||
),
|
||||
inputs: &[
|
||||
DocumentInputType::new("Image", TaggedValue::Image(Image::empty()), true),
|
||||
DocumentInputType::new("Value", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Exposure", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Offset", TaggedValue::F64(0.), false),
|
||||
DocumentInputType::new("Gamma Correction", TaggedValue::F64(1.), false),
|
||||
],
|
||||
outputs: &[FrontendGraphDataType::Raster],
|
||||
properties: node_properties::exposure_properties,
|
||||
|
||||
@@ -183,12 +183,6 @@ pub fn blur_image_properties(document_node: &DocumentNode, node_id: NodeId, _con
|
||||
vec![LayoutGroup::Row { widgets: radius }, LayoutGroup::Row { widgets: sigma }]
|
||||
}
|
||||
|
||||
pub fn adjust_gamma_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let gamma = number_widget(document_node, node_id, 1, "Gamma", NumberInput::default().min(0.01), true);
|
||||
|
||||
vec![LayoutGroup::Row { widgets: gamma }]
|
||||
}
|
||||
|
||||
pub fn adjust_threshold_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let thereshold = number_widget(document_node, node_id, 1, "Threshold", NumberInput::default().min(0.).max(1.), true);
|
||||
|
||||
@@ -228,9 +222,22 @@ pub fn quantize_properties(document_node: &DocumentNode, node_id: NodeId, _conte
|
||||
vec![LayoutGroup::Row { widgets: value }, LayoutGroup::Row { widgets: index }]
|
||||
}
|
||||
pub fn exposure_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let value = number_widget(document_node, node_id, 1, "Value", NumberInput::default().min(-3.).max(3.), true);
|
||||
let exposure = number_widget(document_node, node_id, 1, "Exposure", NumberInput::default().min(-20.).max(20.), true);
|
||||
let offset = number_widget(document_node, node_id, 2, "Offset", NumberInput::default().min(-0.5).max(0.5), true);
|
||||
let gamma_correction = number_widget(
|
||||
document_node,
|
||||
node_id,
|
||||
3,
|
||||
"Gamma Correction",
|
||||
NumberInput::default().min(0.01).max(9.99).mode_increment().increment_step(0.1),
|
||||
true,
|
||||
);
|
||||
|
||||
vec![LayoutGroup::Row { widgets: value }]
|
||||
vec![
|
||||
LayoutGroup::Row { widgets: exposure },
|
||||
LayoutGroup::Row { widgets: offset },
|
||||
LayoutGroup::Row { widgets: gamma_correction },
|
||||
]
|
||||
}
|
||||
|
||||
pub fn add_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
|
||||
Reference in New Issue
Block a user