Skip to content

Commit b9decf1

Browse files
authored
Merge branch 'master' into spline_test1
2 parents 5a5d150 + e60a9c3 commit b9decf1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1933
-935
lines changed

demo-artwork/changing-seasons.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/procedural-string-lights.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editor/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ ron = ["dep:ron"]
3030
# Local dependencies
3131
graphite-proc-macros = { path = "../proc-macros" }
3232
graph-craft = { path = "../node-graph/graph-craft" }
33-
interpreted-executor = { path = "../node-graph/interpreted-executor", features = ["serde"] }
33+
interpreted-executor = { path = "../node-graph/interpreted-executor", features = [
34+
"serde",
35+
] }
3436
graphene-core = { path = "../node-graph/gcore" }
3537
graphene-std = { path = "../node-graph/gstd", features = ["serde"] }
3638

@@ -58,6 +60,9 @@ web-sys = { workspace = true, features = [
5860
"Element",
5961
"HtmlCanvasElement",
6062
"CanvasRenderingContext2d",
63+
"CanvasPattern",
64+
"OffscreenCanvas",
65+
"OffscreenCanvasRenderingContext2d",
6166
"TextMetrics",
6267
] }
6368

editor/src/messages/input_mapper/input_mappings.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ pub fn input_mappings() -> Mapping {
282282
entry!(KeyDown(Enter); action_dispatch=SplineToolMessage::Confirm),
283283
//
284284
// FillToolMessage
285+
entry!(PointerMove; refresh_keys=[Shift], action_dispatch=FillToolMessage::PointerMove),
285286
entry!(KeyDown(MouseLeft); action_dispatch=FillToolMessage::FillPrimaryColor),
286287
entry!(KeyDown(MouseLeft); modifiers=[Shift], action_dispatch=FillToolMessage::FillSecondaryColor),
287288
entry!(KeyUp(MouseLeft); action_dispatch=FillToolMessage::PointerUp),

editor/src/messages/layout/layout_message_handler.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,13 @@ impl LayoutMessageHandler {
276276

277277
responses.add(callback_message);
278278
}
279-
Widget::PivotInput(pivot_input) => {
279+
Widget::ReferencePointInput(reference_point_input) => {
280280
let callback_message = match action {
281-
WidgetValueAction::Commit => (pivot_input.on_commit.callback)(&()),
281+
WidgetValueAction::Commit => (reference_point_input.on_commit.callback)(&()),
282282
WidgetValueAction::Update => {
283-
let update_value = value.as_str().expect("PivotInput update was not of type: u64");
284-
pivot_input.position = update_value.into();
285-
(pivot_input.on_update.callback)(pivot_input)
283+
let update_value = value.as_str().expect("ReferencePointInput update was not of type: u64");
284+
reference_point_input.value = update_value.into();
285+
(reference_point_input.on_update.callback)(reference_point_input)
286286
}
287287
};
288288

editor/src/messages/layout/utility_types/layout_widget.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl LayoutGroup {
373373
Widget::TextInput(x) => &mut x.tooltip,
374374
Widget::TextLabel(x) => &mut x.tooltip,
375375
Widget::BreadcrumbTrailButtons(x) => &mut x.tooltip,
376-
Widget::InvisibleStandinInput(_) | Widget::PivotInput(_) | Widget::RadioInput(_) | Widget::Separator(_) | Widget::WorkingColorsInput(_) | Widget::NodeCatalog(_) => continue,
376+
Widget::InvisibleStandinInput(_) | Widget::ReferencePointInput(_) | Widget::RadioInput(_) | Widget::Separator(_) | Widget::WorkingColorsInput(_) | Widget::NodeCatalog(_) => continue,
377377
};
378378
if val.is_empty() {
379379
val.clone_from(&tooltip);
@@ -546,7 +546,7 @@ pub enum Widget {
546546
NodeCatalog(NodeCatalog),
547547
NumberInput(NumberInput),
548548
ParameterExposeButton(ParameterExposeButton),
549-
PivotInput(PivotInput),
549+
ReferencePointInput(ReferencePointInput),
550550
PopoverButton(PopoverButton),
551551
RadioInput(RadioInput),
552552
Separator(Separator),
@@ -621,7 +621,7 @@ impl DiffUpdate {
621621
| Widget::CurveInput(_)
622622
| Widget::InvisibleStandinInput(_)
623623
| Widget::NodeCatalog(_)
624-
| Widget::PivotInput(_)
624+
| Widget::ReferencePointInput(_)
625625
| Widget::RadioInput(_)
626626
| Widget::Separator(_)
627627
| Widget::TextAreaInput(_)

editor/src/messages/layout/utility_types/widgets/input_widgets.rs

Lines changed: 4 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::messages::input_mapper::utility_types::misc::ActionKeys;
22
use crate::messages::layout::utility_types::widget_prelude::*;
33
use derivative::*;
4-
use glam::DVec2;
54
use graphene_core::Color;
65
use graphene_core::raster::curve::Curve;
6+
use graphene_std::transform::ReferencePoint;
77
use graphite_proc_macros::WidgetBuilder;
88

99
#[derive(Clone, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
@@ -411,100 +411,18 @@ pub struct CurveInput {
411411

412412
#[derive(Clone, Default, Derivative, serde::Serialize, serde::Deserialize, WidgetBuilder, specta::Type)]
413413
#[derivative(Debug, PartialEq)]
414-
pub struct PivotInput {
414+
pub struct ReferencePointInput {
415415
#[widget_builder(constructor)]
416-
pub position: PivotPosition,
416+
pub value: ReferencePoint,
417417

418418
pub disabled: bool,
419419

420420
// Callbacks
421421
#[serde(skip)]
422422
#[derivative(Debug = "ignore", PartialEq = "ignore")]
423-
pub on_update: WidgetCallback<PivotInput>,
423+
pub on_update: WidgetCallback<ReferencePointInput>,
424424

425425
#[serde(skip)]
426426
#[derivative(Debug = "ignore", PartialEq = "ignore")]
427427
pub on_commit: WidgetCallback<()>,
428428
}
429-
430-
#[derive(Clone, Copy, serde::Serialize, serde::Deserialize, Debug, Default, PartialEq, Eq, specta::Type)]
431-
pub enum PivotPosition {
432-
#[default]
433-
None,
434-
TopLeft,
435-
TopCenter,
436-
TopRight,
437-
CenterLeft,
438-
Center,
439-
CenterRight,
440-
BottomLeft,
441-
BottomCenter,
442-
BottomRight,
443-
}
444-
445-
impl From<&str> for PivotPosition {
446-
fn from(input: &str) -> Self {
447-
match input {
448-
"None" => PivotPosition::None,
449-
"TopLeft" => PivotPosition::TopLeft,
450-
"TopCenter" => PivotPosition::TopCenter,
451-
"TopRight" => PivotPosition::TopRight,
452-
"CenterLeft" => PivotPosition::CenterLeft,
453-
"Center" => PivotPosition::Center,
454-
"CenterRight" => PivotPosition::CenterRight,
455-
"BottomLeft" => PivotPosition::BottomLeft,
456-
"BottomCenter" => PivotPosition::BottomCenter,
457-
"BottomRight" => PivotPosition::BottomRight,
458-
_ => panic!("Failed parsing unrecognized PivotPosition enum value '{input}'"),
459-
}
460-
}
461-
}
462-
463-
impl From<PivotPosition> for Option<DVec2> {
464-
fn from(input: PivotPosition) -> Self {
465-
match input {
466-
PivotPosition::None => None,
467-
PivotPosition::TopLeft => Some(DVec2::new(0., 0.)),
468-
PivotPosition::TopCenter => Some(DVec2::new(0.5, 0.)),
469-
PivotPosition::TopRight => Some(DVec2::new(1., 0.)),
470-
PivotPosition::CenterLeft => Some(DVec2::new(0., 0.5)),
471-
PivotPosition::Center => Some(DVec2::new(0.5, 0.5)),
472-
PivotPosition::CenterRight => Some(DVec2::new(1., 0.5)),
473-
PivotPosition::BottomLeft => Some(DVec2::new(0., 1.)),
474-
PivotPosition::BottomCenter => Some(DVec2::new(0.5, 1.)),
475-
PivotPosition::BottomRight => Some(DVec2::new(1., 1.)),
476-
}
477-
}
478-
}
479-
480-
impl From<DVec2> for PivotPosition {
481-
fn from(input: DVec2) -> Self {
482-
const TOLERANCE: f64 = 1e-5_f64;
483-
if input.y.abs() < TOLERANCE {
484-
if input.x.abs() < TOLERANCE {
485-
return PivotPosition::TopLeft;
486-
} else if (input.x - 0.5).abs() < TOLERANCE {
487-
return PivotPosition::TopCenter;
488-
} else if (input.x - 1.).abs() < TOLERANCE {
489-
return PivotPosition::TopRight;
490-
}
491-
} else if (input.y - 0.5).abs() < TOLERANCE {
492-
if input.x.abs() < TOLERANCE {
493-
return PivotPosition::CenterLeft;
494-
} else if (input.x - 0.5).abs() < TOLERANCE {
495-
return PivotPosition::Center;
496-
} else if (input.x - 1.).abs() < TOLERANCE {
497-
return PivotPosition::CenterRight;
498-
}
499-
} else if (input.y - 1.).abs() < TOLERANCE {
500-
if input.x.abs() < TOLERANCE {
501-
return PivotPosition::BottomLeft;
502-
} else if (input.x - 0.5).abs() < TOLERANCE {
503-
return PivotPosition::BottomCenter;
504-
} else if (input.x - 1.).abs() < TOLERANCE {
505-
return PivotPosition::BottomRight;
506-
}
507-
}
508-
PivotPosition::None
509-
}
510-
}

editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs

Lines changed: 164 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use graph_craft::document::value::*;
1515
use graph_craft::document::*;
1616
use graphene_core::raster::brush_cache::BrushCache;
1717
use graphene_core::raster::image::ImageFrameTable;
18-
use graphene_core::raster::{Color, RedGreenBlue, RedGreenBlueAlpha};
18+
use graphene_core::raster::{CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, NoiseType, RedGreenBlue, RedGreenBlueAlpha};
1919
use graphene_core::text::{Font, TypesettingConfig};
2020
use graphene_core::transform::Footprint;
2121
use graphene_core::vector::VectorDataTable;
@@ -128,6 +128,87 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
128128
description: Cow::Borrowed("Passes-through the input value without changing it. This is useful for rerouting wires for organization purposes."),
129129
properties: Some("identity_properties"),
130130
},
131+
DocumentNodeDefinition {
132+
identifier: "Cache",
133+
category: "General",
134+
node_template: NodeTemplate {
135+
document_node: DocumentNode {
136+
implementation: DocumentNodeImplementation::Network(NodeNetwork {
137+
exports: vec![NodeInput::node(NodeId(2), 0)],
138+
nodes: [
139+
DocumentNode {
140+
inputs: vec![NodeInput::network(generic!(T), 0)],
141+
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::memo::MemoNode")),
142+
manual_composition: Some(generic!(T)),
143+
..Default::default()
144+
},
145+
DocumentNode {
146+
inputs: vec![NodeInput::node(NodeId(0), 0)],
147+
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::transform::FreezeRealTimeNode")),
148+
manual_composition: Some(generic!(T)),
149+
..Default::default()
150+
},
151+
DocumentNode {
152+
inputs: vec![NodeInput::node(NodeId(1), 0)],
153+
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::transform::BoundlessFootprintNode")),
154+
manual_composition: Some(generic!(T)),
155+
..Default::default()
156+
},
157+
]
158+
.into_iter()
159+
.enumerate()
160+
.map(|(id, node)| (NodeId(id as u64), node))
161+
.collect(),
162+
..Default::default()
163+
}),
164+
inputs: vec![NodeInput::value(TaggedValue::None, true)],
165+
..Default::default()
166+
},
167+
persistent_node_metadata: DocumentNodePersistentMetadata {
168+
network_metadata: Some(NodeNetworkMetadata {
169+
persistent_metadata: NodeNetworkPersistentMetadata {
170+
node_metadata: [
171+
DocumentNodeMetadata {
172+
persistent_metadata: DocumentNodePersistentMetadata {
173+
display_name: "Memoize".to_string(),
174+
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(0, 0)),
175+
..Default::default()
176+
},
177+
..Default::default()
178+
},
179+
DocumentNodeMetadata {
180+
persistent_metadata: DocumentNodePersistentMetadata {
181+
display_name: "Freeze Real Time".to_string(),
182+
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(7, 0)),
183+
..Default::default()
184+
},
185+
..Default::default()
186+
},
187+
DocumentNodeMetadata {
188+
persistent_metadata: DocumentNodePersistentMetadata {
189+
display_name: "Boundless Footprint".to_string(),
190+
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(14, 0)),
191+
..Default::default()
192+
},
193+
..Default::default()
194+
},
195+
]
196+
.into_iter()
197+
.enumerate()
198+
.map(|(id, node)| (NodeId(id as u64), node))
199+
.collect(),
200+
..Default::default()
201+
},
202+
..Default::default()
203+
}),
204+
input_properties: vec![("Data", "TODO").into()],
205+
output_names: vec!["Data".to_string()],
206+
..Default::default()
207+
},
208+
},
209+
description: Cow::Borrowed("TODO"),
210+
properties: None,
211+
},
131212
// TODO: Auto-generate this from its proto node macro
132213
DocumentNodeDefinition {
133214
identifier: "Monitor",
@@ -716,6 +797,87 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
716797
description: Cow::Borrowed("Rasterizes the given vector data"),
717798
properties: None,
718799
},
800+
DocumentNodeDefinition {
801+
identifier: "Noise Pattern",
802+
category: "Raster",
803+
node_template: NodeTemplate {
804+
document_node: DocumentNode {
805+
manual_composition: Some(concrete!(Context)),
806+
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_std::raster::NoisePatternNode")),
807+
inputs: vec![
808+
NodeInput::value(TaggedValue::None, false),
809+
NodeInput::value(TaggedValue::Bool(true), false),
810+
NodeInput::value(TaggedValue::U32(0), false),
811+
NodeInput::value(TaggedValue::F64(10.), false),
812+
NodeInput::value(TaggedValue::NoiseType(NoiseType::default()), false),
813+
NodeInput::value(TaggedValue::DomainWarpType(DomainWarpType::default()), false),
814+
NodeInput::value(TaggedValue::F64(100.), false),
815+
NodeInput::value(TaggedValue::FractalType(FractalType::default()), false),
816+
NodeInput::value(TaggedValue::U32(3), false),
817+
NodeInput::value(TaggedValue::F64(2.), false),
818+
NodeInput::value(TaggedValue::F64(0.5), false),
819+
NodeInput::value(TaggedValue::F64(0.), false), // 0-1 range
820+
NodeInput::value(TaggedValue::F64(2.), false),
821+
NodeInput::value(TaggedValue::CellularDistanceFunction(CellularDistanceFunction::default()), false),
822+
NodeInput::value(TaggedValue::CellularReturnType(CellularReturnType::default()), false),
823+
NodeInput::value(TaggedValue::F64(1.), false),
824+
],
825+
..Default::default()
826+
},
827+
persistent_node_metadata: DocumentNodePersistentMetadata {
828+
input_properties: vec![
829+
("Spacer", "TODO").into(),
830+
("Clip", "TODO").into(),
831+
("Seed", "TODO").into(),
832+
PropertiesRow::with_override("Scale", "TODO", WidgetOverride::Custom("noise_properties_scale".to_string())),
833+
PropertiesRow::with_override("Noise Type", "TODO", WidgetOverride::Custom("noise_properties_noise_type".to_string())),
834+
PropertiesRow::with_override("Domain Warp Type", "TODO", WidgetOverride::Custom("noise_properties_domain_warp_type".to_string())),
835+
PropertiesRow::with_override("Domain Warp Amplitude", "TODO", WidgetOverride::Custom("noise_properties_domain_warp_amplitude".to_string())),
836+
PropertiesRow::with_override("Fractal Type", "TODO", WidgetOverride::Custom("noise_properties_fractal_type".to_string())),
837+
PropertiesRow::with_override("Fractal Octaves", "TODO", WidgetOverride::Custom("noise_properties_fractal_octaves".to_string())),
838+
PropertiesRow::with_override("Fractal Lacunarity", "TODO", WidgetOverride::Custom("noise_properties_fractal_lacunarity".to_string())),
839+
PropertiesRow::with_override("Fractal Gain", "TODO", WidgetOverride::Custom("noise_properties_fractal_gain".to_string())),
840+
PropertiesRow::with_override("Fractal Weighted Strength", "TODO", WidgetOverride::Custom("noise_properties_fractal_weighted_strength".to_string())),
841+
PropertiesRow::with_override("Fractal Ping Pong Strength", "TODO", WidgetOverride::Custom("noise_properties_ping_pong_strength".to_string())),
842+
PropertiesRow::with_override("Cellular Distance Function", "TODO", WidgetOverride::Custom("noise_properties_cellular_distance_function".to_string())),
843+
PropertiesRow::with_override("Cellular Return Type", "TODO", WidgetOverride::Custom("noise_properties_cellular_return_type".to_string())),
844+
PropertiesRow::with_override("Cellular Jitter", "TODO", WidgetOverride::Custom("noise_properties_cellular_jitter".to_string())),
845+
],
846+
output_names: vec!["Image".to_string()],
847+
network_metadata: Some(NodeNetworkMetadata {
848+
persistent_metadata: NodeNetworkPersistentMetadata {
849+
node_metadata: [
850+
DocumentNodeMetadata {
851+
persistent_metadata: DocumentNodePersistentMetadata {
852+
display_name: "Noise Pattern".to_string(),
853+
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(0, 0)),
854+
..Default::default()
855+
},
856+
..Default::default()
857+
},
858+
DocumentNodeMetadata {
859+
persistent_metadata: DocumentNodePersistentMetadata {
860+
display_name: "Cull".to_string(),
861+
node_type_metadata: NodeTypePersistentMetadata::node(IVec2::new(0, 0)),
862+
..Default::default()
863+
},
864+
..Default::default()
865+
},
866+
]
867+
.into_iter()
868+
.enumerate()
869+
.map(|(id, node)| (NodeId(id as u64), node))
870+
.collect(),
871+
..Default::default()
872+
},
873+
..Default::default()
874+
}),
875+
..Default::default()
876+
},
877+
},
878+
description: Cow::Borrowed("Generates different noise patterns."),
879+
properties: None,
880+
},
719881
// TODO: This needs to work with resolution-aware (raster with footprint, post-Cull node) data.
720882
// TODO: Auto-generate this from its proto node macro
721883
DocumentNodeDefinition {
@@ -3559,7 +3721,7 @@ impl DocumentNodeDefinition {
35593721
};
35603722
nested_node_metadata.persistent_metadata.input_properties.resize_with(input_length, PropertiesRow::default);
35613723

3562-
//Recurse over all sub nodes if the current node is a network implementation
3724+
// Recurse over all sub-nodes if the current node is a network implementation
35633725
let mut current_path = path.clone();
35643726
current_path.push(current_node);
35653727
let DocumentNodeImplementation::Network(template_network) = &node_template.document_node.implementation else {

0 commit comments

Comments
 (0)