@@ -3,7 +3,9 @@ use crate::messages::portfolio::document::node_graph::document_node_definitions:
33use crate :: messages:: portfolio:: document:: utility_types:: document_metadata:: LayerNodeIdentifier ;
44use crate :: messages:: portfolio:: document:: utility_types:: network_interface:: { self , FlowType , InputConnector , NodeNetworkInterface , OutputConnector } ;
55use crate :: messages:: prelude:: * ;
6- use crate :: messages:: tool:: common_functionality:: graph_modification_utils:: { get_fill_input_node_id, get_upstream_gradient_value_node_id, gradient_chain_target_input} ;
6+ use crate :: messages:: tool:: common_functionality:: graph_modification_utils:: {
7+ get_fill_input_node_id, get_fill_node_id_with_direct_fill_input, get_upstream_gradient_value_node_id, get_upstream_mesh_gradient_value_node_id, gradient_chain_target_input,
8+ } ;
79use glam:: { DAffine2 , DVec2 , IVec2 } ;
810use graph_craft:: application_io:: resource:: ResourceId ;
911use graph_craft:: document:: value:: TaggedValue ;
@@ -16,7 +18,7 @@ use graphene_std::raster_types::Image;
1618use graphene_std:: subpath:: Subpath ;
1719use graphene_std:: text:: { Font , TypesettingConfig } ;
1820use graphene_std:: vector:: style:: { GradientSpreadMethod , GradientType , Stroke } ;
19- use graphene_std:: vector:: { Gradient , PointId , Vector , VectorModification , VectorModificationType } ;
21+ use graphene_std:: vector:: { Gradient , MeshGradient , PointId , Vector , VectorModification , VectorModificationType } ;
2022use graphene_std:: { Artboard , Color , Graphic , NodeInputDecleration } ;
2123
2224#[ derive( PartialEq , Clone , Copy , Debug , serde:: Serialize , serde:: Deserialize ) ]
@@ -571,6 +573,36 @@ impl<'a> ModifyInputsContext<'a> {
571573 ) ;
572574 }
573575
576+ /// Write the mesh gradient to the Fill node's direct value.
577+ pub fn fill_mesh_gradient_set ( & mut self , mesh_gradient : MeshGradient ) {
578+ let Some ( fill_node_id) = self
579+ . get_output_layer ( )
580+ . and_then ( |output_layer| get_fill_node_id_with_direct_fill_input ( output_layer, self . network_interface ) )
581+ else {
582+ return ;
583+ } ;
584+ self . set_input_with_refresh (
585+ InputConnector :: node ( fill_node_id, graphene_std:: vector:: fill:: BackupMeshGradientInput :: INDEX ) ,
586+ NodeInput :: value ( TaggedValue :: MeshGradient ( mesh_gradient. clone ( ) ) , false ) ,
587+ true ,
588+ ) ;
589+ self . set_input_with_refresh (
590+ InputConnector :: node ( fill_node_id, graphene_std:: vector:: fill:: FillInput :: < List < Graphic > > :: INDEX ) ,
591+ NodeInput :: value ( TaggedValue :: MeshGradient ( mesh_gradient) , false ) ,
592+ false ,
593+ ) ;
594+ }
595+
596+ /// Write the mesh gradient to the Mesh Gradient Value node feeding the layer.
597+ pub fn mesh_gradient_set ( & mut self , mesh_gradient : MeshGradient ) {
598+ let Some ( output_layer) = self . get_output_layer ( ) else { return } ;
599+ let Some ( mesh_gradient_value_id) = get_upstream_mesh_gradient_value_node_id ( output_layer, self . network_interface ) else {
600+ return ;
601+ } ;
602+ let input_connector = InputConnector :: node ( mesh_gradient_value_id, graphene_std:: math_nodes:: mesh_gradient_value:: MeshGradientInput :: INDEX ) ;
603+ self . set_input_with_refresh ( input_connector, NodeInput :: value ( TaggedValue :: MeshGradient ( mesh_gradient) , false ) , false ) ;
604+ }
605+
574606 /// Write the gradient stops to the 'Gradient Value' node feeding the layer.
575607 pub fn gradient_stops_set ( & mut self , stops : Gradient ) {
576608 let Some ( output_layer) = self . get_output_layer ( ) else { return } ;
0 commit comments