Repository: GraphiteEditor/Graphite
File: node-graph/gcore/src/vector/vector_nodes.rs (Rust)

Code before:
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
fn bevel(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length) -> VectorDataTable {
	let source_transform = source.transform();
	let source = source.one_instance_ref().instance;

	let mut result = VectorDataTable::new(bevel_algorithm(source.clone(), source_transform, distance));
	*result.transform_mut() = source_transform;
	result
}

#[node_macro::node(name("Close Path"), category("Vector"), path(graphene_core::vector))]
fn close_path(_: impl Ctx, source: VectorDataTable) -> VectorDataTable {
	let mut new_table = VectorDataTable::empty();
	for mut source_instance in source.instance_iter() {
		source_instance.instance.close_subpaths();
		new_table.push(Instance {
			instance: source_instance.instance,
			transform: source_instance.transform,
			alpha_blending: source_instance.alpha_blending,
			source_node_id: source_instance.source_node_id,
		})
	}
	new_table
}

#[node_macro::node(name("Point Inside Shape"), category("Vector"), path(graphene_core::vector))]
fn point_inside(_: impl Ctx, source: VectorDataTable, point: DVec2) -> bool {
	source.instance_iter().any(|instance| {
		let tranform = instance.transform;
		instance.instance.check_point_inside_shape(tranform, point)
	})
}

#[node_macro::node(name("Merge by Distance"), category("Vector"), path(graphene_core::vector))]
fn merge_by_distance(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length) -> VectorDataTable {
	let source_transform = source.transform();
	let mut source = source.one_instance_ref().instance.clone();

	source.merge_by_distance(distance);

	let mut result = VectorDataTable::new(source);
	*result.transform_mut() = source_transform;

	result
}

#[node_macro::node(category("Vector"), path(graphene_core::vector))]
async fn area(ctx: impl Ctx + CloneVarArgs + ExtractAll, vector_data: impl Node<Context<'static>, Output = VectorDataTable>) -> f64 {
	let new_ctx = OwnedContextImpl::from(ctx).with_footprint(Footprint::default()).into_context();
	let vector_data = vector_data.eval(new_ctx).await;


Review comment (suggestion):
Remove the name, since it must match its function name and we prefer to just call it "Point Inside". The name should be used only for changing the capitalization and whitespace styling if the autogeneration doesn't work.

Code after:
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
fn bevel(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length) -> VectorDataTable {
	let source_transform = source.transform();
	let source = source.one_instance_ref().instance;

	let mut result = VectorDataTable::new(bevel_algorithm(source.clone(), source_transform, distance));
	*result.transform_mut() = source_transform;
	result
}

#[node_macro::node(category("Vector"), path(graphene_core::vector))]
fn close_path(_: impl Ctx, source: VectorDataTable) -> VectorDataTable {
	let mut new_table = VectorDataTable::empty();

	for mut source_instance in source.instance_iter() {
		source_instance.instance.close_subpaths();
		new_table.push(source_instance);
	}

	new_table
}

#[node_macro::node(category("Vector"), path(graphene_core::vector))]
fn point_inside(_: impl Ctx, source: VectorDataTable, point: DVec2) -> bool {
	source.instance_iter().any(|instance| instance.instance.check_point_inside_shape(instance.transform, point))
}

#[node_macro::node(name("Merge by Distance"), category("Vector"), path(graphene_core::vector))]
fn merge_by_distance(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length) -> VectorDataTable {
	let source_transform = source.transform();
	let mut source = source.one_instance_ref().instance.clone();

	source.merge_by_distance(distance);

	let mut result = VectorDataTable::new(source);
	*result.transform_mut() = source_transform;

	result
}

#[node_macro::node(category("Vector"), path(graphene_core::vector))]
async fn area(ctx: impl Ctx + CloneVarArgs + ExtractAll, vector_data: impl Node<Context<'static>, Output = VectorDataTable>) -> f64 {
	let new_ctx = OwnedContextImpl::from(ctx).with_footprint(Footprint::default()).into_context();
	let vector_data = vector_data.eval(new_ctx).await;

	let vector_data_transform = vector_data.transform();
	let vector_data = vector_data.one_instance_ref().instance;

	let mut area = 0.;
	let scale = vector_data_transform.decompose_scale();
	for subpath in vector_data.stroke_bezier_paths() {