@@ -14,6 +14,7 @@ use kurbo::simplify::{SimplifyOptions, simplify_bezpath};
1414use kurbo:: { Affine , BezPath , DEFAULT_ACCURACY , Line , ParamCurve , ParamCurveArclen , PathEl , PathSeg , Shape } ;
1515use rand:: { Rng , SeedableRng } ;
1616use std:: collections:: hash_map:: DefaultHasher ;
17+ use std:: vec;
1718use vector_types:: subpath:: { BezierHandles , ManipulatorGroup } ;
1819use vector_types:: vector:: PointDomain ;
1920use vector_types:: vector:: algorithms:: bezpath_algorithms:: { self , TValue , eval_pathseg_euclidean, evaluate_bezpath, split_bezpath, tangent_on_bezpath} ;
@@ -26,6 +27,7 @@ use vector_types::vector::misc::{
2627} ;
2728use vector_types:: vector:: style:: { Fill , Gradient , GradientStops , PaintOrder , Stroke , StrokeAlign , StrokeCap , StrokeJoin } ;
2829use vector_types:: vector:: { FillId , PointId , RegionId , SegmentDomain , SegmentId , StrokeId , VectorExt } ;
30+ use wasm_bindgen:: UnwrapThrowExt ;
2931
3032/// Implemented for types that can be converted to an iterator of vector rows.
3133/// Used for the fill and stroke node so they can be used on `Table<Graphic>` or `Table<Vector>`.
@@ -107,6 +109,51 @@ where
107109 content
108110}
109111
112+ // #[node_macro::node(category("Vector: Style"), path(graphene_core::vector), properties("fill_properties"))]
113+ // async fn mesh_gradient(
114+ // _: impl Ctx,
115+ // /// The content with vector paths to apply the mesh gradient to.
116+ // mut content: Table<Vector>,
117+ // /// The top-left color of the gradient.
118+ // #[default(Color::BLACK)]
119+ // top_left_color: Table<Color>,
120+ // /// The top-right color of the gradient.
121+ // #[default(Color::BLACK)]
122+ // top_right_color: Table<Color>,
123+ // /// The bottom-left color of the gradient.
124+ // #[default(Color::BLACK)]
125+ // bottom_left_color: Table<Color>,
126+ // /// The bottom-right color of the gradient.
127+ // #[default(Color::BLACK)]
128+ // bottom_right_color: Table<Color>,
129+ // _backup_color: Table<Color>,
130+ // _backup_gradient: Gradient,
131+ // ) -> Table<Vector> {
132+ // for vector in content.vector_iter_mut() {
133+ // let grid_num = 8;
134+ // let grid_stride_uv = 1. / grid_num as f64;
135+
136+ // let segments: Vec<_> = vector.element.segment_iter().collect();
137+ // let points = vector.element.point_domain.positions();
138+ // let top_seg = segments.get(0).unwrap_throw().1;
139+ // let right_seg = segments.get(1).unwrap_throw().1;
140+ // let bottom_seg = segments.get(2).unwrap_throw().1;
141+ // let left_seg = segments.get(3).unwrap_throw().1;
142+
143+ // let bilerp = |u: f64, v: f64| points[0] * (1. - u) * (1. - v) + points[1] * u * (1. - v) + points[2] * (1. - u) * v + points[3] * u * v;
144+
145+ // for i in 0..=grid_num {
146+ // for j in 0..=grid_num {
147+ // let u = i as f64 * grid_stride_uv;
148+ // let v = j as f64 * grid_stride_uv;
149+ // let pos = point_to_dvec2(top_seg.eval(u)) + point_to_dvec2(bottom_seg.eval(1. - u)) - bilerp(u, v);
150+ // }
151+ // }
152+ // }
153+
154+ // content
155+ // }
156+
110157/// Applies a fill style to the vector content, giving an appearance to the area within the interior of the geometry.
111158#[ node_macro:: node( category( "Vector: Style" ) , path( graphene_core:: vector) , properties( "fill_properties" ) ) ]
112159async fn fill < F : Into < Fill > + ' n + Send , V : VectorTableIterMut + ' n + Send > (
0 commit comments