@@ -7,9 +7,11 @@ use crate::messages::tool::common_functionality::graph_modification_utils::{self
77use crate :: messages:: tool:: common_functionality:: transformation_cage:: BoundingBoxManager ;
88use crate :: messages:: tool:: tool_messages:: tool_prelude:: Key ;
99use crate :: messages:: tool:: utility_types:: * ;
10+ use bezier_rs:: Subpath ;
1011use glam:: { DMat2 , DVec2 } ;
1112use graph_craft:: document:: NodeInput ;
1213use graph_craft:: document:: value:: TaggedValue ;
14+ use graphene_std:: vector:: PointId ;
1315use std:: collections:: VecDeque ;
1416use std:: f64:: consts:: PI ;
1517
@@ -151,36 +153,31 @@ pub fn anchor_overlays(document: &DocumentMessageHandler, overlay_context: &mut
151153 }
152154}
153155
154- pub fn points_on_inner_circle ( document : & DocumentMessageHandler , mouse_position : DVec2 ) -> Option < ( LayerNodeIdentifier , u32 , usize , f64 ) > {
155- for layer in document
156- . network_interface
157- . selected_nodes ( )
158- . selected_visible_and_unlocked_layers ( & document. network_interface )
159- . filter ( |layer| graph_modification_utils:: get_star_id ( * layer, & document. network_interface ) . is_some ( ) )
160- {
161- let Some ( node_inputs) = NodeGraphLayer :: new ( layer, & document. network_interface ) . find_node_inputs ( "Star" ) else {
162- continue ;
163- } ;
156+ pub fn star_outline ( layer : LayerNodeIdentifier , document : & DocumentMessageHandler , overlay_context : & mut OverlayContext ) {
157+ let mut anchors = Vec :: new ( ) ;
164158
165- let viewport = document. network_interface . document_metadata ( ) . transform_to_viewport ( layer) ;
159+ let Some ( node_inputs) = NodeGraphLayer :: new ( layer, & document. network_interface ) . find_node_inputs ( "Star" ) else {
160+ return ;
161+ } ;
166162
167- let ( Some ( & TaggedValue :: U32 ( n) ) , Some ( & TaggedValue :: F64 ( outer ) ) , Some ( & TaggedValue :: F64 ( inner ) ) ) = ( node_inputs[ 1 ] . as_value ( ) , node_inputs[ 2 ] . as_value ( ) , node_inputs[ 3 ] . as_value ( ) ) else {
168- continue ;
169- } ;
163+ let ( Some ( & TaggedValue :: U32 ( n) ) , Some ( & TaggedValue :: F64 ( radius1 ) ) , Some ( & TaggedValue :: F64 ( radius2 ) ) ) = ( node_inputs[ 1 ] . as_value ( ) , node_inputs[ 2 ] . as_value ( ) , node_inputs[ 3 ] . as_value ( ) ) else {
164+ return ;
165+ } ;
170166
171- for i in 0 ..( 2 * n) {
172- let angle = i as f64 * PI / n as f64 ;
173- let ( radius, index) = if i % 2 == 0 { ( outer, 2 ) } else { ( inner, 3 ) } ;
167+ let viewport = document. metadata ( ) . transform_to_viewport ( layer) ;
168+ for i in 0 ..( 2 * n) {
169+ let angle = i as f64 * PI / n as f64 ;
170+ let radius = if i % 2 == 0 { radius1 } else { radius2 } ;
174171
175- let point = viewport . transform_point2 ( DVec2 {
176- x : radius * angle. sin ( ) ,
177- y : -radius * angle. cos ( ) ,
178- } ) ;
172+ let point = DVec2 {
173+ x : radius * angle. sin ( ) ,
174+ y : -radius * angle. cos ( ) ,
175+ } ;
179176
180- if point. distance ( mouse_position) < 5.0 {
181- return Some ( ( layer, i, index, radius) ) ;
182- } ;
183- }
177+ anchors. push ( point) ;
184178 }
185- None
179+
180+ let subpath: Vec < Subpath < PointId > > = vec ! [ Subpath :: from_anchors_linear( anchors, true ) ] ;
181+
182+ overlay_context. outline ( subpath. iter ( ) , viewport, None ) ;
186183}
0 commit comments