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

Code before:
pub struct UnitElipseGenerator<RadiusX, RadiusY> {
	radius_x: RadiusX,
	radius_y: RadiusY,
}

#[node_macro::node_fn(UnitElipseGenerator)]
fn unit_elipse(_input: (), radius_x: f32, radius_y: f32) -> VectorData {
	let radius_x = radius_x.into();
	let radius_y: f64 = radius_y.into();
	let corner1 = DVec2::new(radius_x * -1., radius_y * -1.);
	let corner2: DVec2 = DVec2::new(radius_x, radius_y);
	super::VectorData::from_subpath(Subpath::new_ellipse(corner1, corner2))
}

#[derive(Debug, Clone, Copy)]
pub struct UnitRectangleGenerator<SizeX, SizeY> {
	size_x: SizeX,
	size_y: SizeY,
}

#[node_macro::node_fn(UnitRectangleGenerator)]
fn unit_square(_input: (), size_x: f32, size_y: f32) -> VectorData {
	let size_x = (size_x / 2.).into();
	let size_y = (size_y / 2.).into();
	let corner1 = DVec2::new(size_x * -1., size_y * -1.);
	let corner2 = DVec2::new(size_x, size_y);

	super::VectorData::from_subpaths(vec![Subpath::new_rect(corner1, corner2)])
}

#[derive(Debug, Clone, Copy)]
pub struct UnitPolygonGenerator<Points, Radius> {
	points: Points,
	radius: Radius,
}

#[node_macro::node_fn(UnitPolygonGenerator)]
fn unit_polygon(_input: (), points: u32, radius: f32) -> VectorData {
	let points = points.into();
	let radius = (radius * 2.).into();
	super::VectorData::from_subpath(Subpath::new_regular_polygon(DVec2::splat(radius * -1.), points, radius))
}

#[derive(Debug, Clone, Copy)]
pub struct UnitStarGenerator<Points, Radius, InnerRadius> {
	points: Points,
	radius: Radius,
	inner_radius: InnerRadius,
}

#[node_macro::node_fn(UnitStarGenerator)]

Review comment (suggestion):
The size here is actual half of the side - either rename it or change it to be the actual size:
```rs
let size = DVec2::new(size_x as f64, size_y as f64);
let corner1 = -size / 2.;
let corner2 = size / 2.;
```

Code after:
pub struct EllipseGenerator<RadiusX, RadiusY> {
	radius_x: RadiusX,
	radius_y: RadiusY,
}

#[node_macro::node_fn(EllipseGenerator)]
fn ellipse_generator(_input: (), radius_x: f32, radius_y: f32) -> VectorData {
	let radius = DVec2::new(radius_x as f64, radius_y as f64);
	let corner1 = -radius;
	let corner2 = radius;
	super::VectorData::from_subpath(Subpath::new_ellipse(corner1, corner2))
}

#[derive(Debug, Clone, Copy)]
pub struct RectangleGenerator<SizeX, SizeY> {
	size_x: SizeX,
	size_y: SizeY,
}

#[node_macro::node_fn(RectangleGenerator)]
fn square_generator(_input: (), size_x: f32, size_y: f32) -> VectorData {
	let size = DVec2::new(size_x as f64, size_y as f64);
	let corner1 = -size / 2.;
	let corner2 = size / 2.;

	super::VectorData::from_subpaths(vec![Subpath::new_rect(corner1, corner2)])
}

#[derive(Debug, Clone, Copy)]
pub struct RegularPolygonGenerator<Points, Radius> {
	points: Points,
	radius: Radius,
}

#[node_macro::node_fn(RegularPolygonGenerator)]
fn regular_polygon_generator(_input: (), points: u32, radius: f32) -> VectorData {
	let points = points.into();
	let radius: f64 = (radius * 2.).into();
	super::VectorData::from_subpath(Subpath::new_regular_polygon(DVec2::splat(-radius), points, radius))
}

#[derive(Debug, Clone, Copy)]
pub struct StarGenerator<Points, Radius, InnerRadius> {
	points: Points,
	radius: Radius,
	inner_radius: InnerRadius,
}

#[node_macro::node_fn(StarGenerator)]
fn star_generator(_input: (), points: u32, radius: f32, inner_radius: f32) -> VectorData {
	let points = points.into();