mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 14:18:04 +08:00
Replace the 'Vec2 to Point' node with automatic conversion machinery (#4236)
* Replace the 'Vec2 to Point' node with an 'As Vector' node and automatic conversion * Accept a Vec2 as content for the Wrap Graphic node * Rename the type-assertion nodes from 'To' to 'As' * Fix the Transform node reversing a Vec2 input's direction * Fix text migration bug
This commit is contained in:
@@ -1074,16 +1074,10 @@ async fn dimensions(_: impl Ctx, content: List<Vector>) -> DVec2 {
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
// TODO: Replace this node with an automatic type conversion implementation of the `Convert` trait
|
||||
/// Converts a vec2 value into a vector path composed of a single anchor point.
|
||||
///
|
||||
/// This is useful in conjunction with nodes that repeat it, followed by the "Points to Polyline" node to string together a path of the points.
|
||||
#[node_macro::node(category("Vector"), name("Vec2 to Point"), path(core_types::vector))]
|
||||
async fn vec2_to_point(_: impl Ctx, vec2: DVec2) -> List<Vector> {
|
||||
let mut point_domain = PointDomain::new();
|
||||
point_domain.push(PointId::generate(), vec2);
|
||||
|
||||
List::new_from_item(Item::new_from_element(Vector { point_domain, ..Default::default() }))
|
||||
/// Type-asserts a value to be vector data.
|
||||
#[node_macro::node(category("Vector"), name("As Vector"), path(core_types::vector))]
|
||||
fn as_vector(_: impl Ctx, value: List<Vector>) -> List<Vector> {
|
||||
value
|
||||
}
|
||||
|
||||
/// Creates a polyline from a series of vector points, replacing any existing segments and regions that may already exist.
|
||||
|
||||
Reference in New Issue
Block a user