mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 14:58:05 +08:00
Rename the Coordinate data type to Vec2 (#2959)
This commit is contained in:
@@ -2,9 +2,9 @@ use crate::Ctx;
|
||||
use dyn_any::DynAny;
|
||||
use glam::{DVec2, IVec2, UVec2};
|
||||
|
||||
/// Obtains the X or Y component of a coordinate point.
|
||||
/// Obtains the X or Y component of a vec2.
|
||||
///
|
||||
/// The inverse of this node is "Coordinate Value", which can have either or both its X and Y exposed as graph inputs.
|
||||
/// The inverse of this node is "Vec2 Value", which can have either or both its X and Y parameters exposed as graph inputs.
|
||||
#[node_macro::node(name("Extract XY"), category("Math: Vector"))]
|
||||
fn extract_xy<T: Into<DVec2>>(_: impl Ctx, #[implementations(DVec2, IVec2, UVec2)] vector: T, axis: XY) -> f64 {
|
||||
match axis {
|
||||
@@ -13,7 +13,7 @@ fn extract_xy<T: Into<DVec2>>(_: impl Ctx, #[implementations(DVec2, IVec2, UVec2
|
||||
}
|
||||
}
|
||||
|
||||
/// The X or Y component of a coordinate.
|
||||
/// The X or Y component of a vec2.
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, DynAny, node_macro::ChoiceType, specta::Type, serde::Serialize, serde::Deserialize)]
|
||||
#[widget(Dropdown)]
|
||||
pub enum XY {
|
||||
|
||||
@@ -931,13 +931,13 @@ async fn dimensions(_: impl Ctx, vector_data: VectorDataTable) -> DVec2 {
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Converts a coordinate value into a vector anchor point.
|
||||
/// 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("Coordinate to Point"), path(graphene_core::vector))]
|
||||
async fn position_to_point(_: impl Ctx, coordinate: DVec2) -> VectorDataTable {
|
||||
#[node_macro::node(category("Vector"), name("Vec2 to Point"), path(graphene_core::vector))]
|
||||
async fn vec2_to_point(_: impl Ctx, vec2: DVec2) -> VectorDataTable {
|
||||
let mut point_domain = PointDomain::new();
|
||||
point_domain.push(PointId::generate(), coordinate);
|
||||
point_domain.push(PointId::generate(), vec2);
|
||||
|
||||
VectorDataTable::new_instance(Instance {
|
||||
instance: VectorData { point_domain, ..Default::default() },
|
||||
|
||||
Reference in New Issue
Block a user