Split 'To Graphic' and 'Wrap Graphic' into the 'As Graphic' type assertion and 'Into Group' reducer nodes (#4441)

* Split 'To Graphic' and 'Wrap Graphic' into the 'As Graphic' type assertion and 'Into Group' reducer nodes

* Make 'Into Group' reduce List<DVec2> not Item<DVec2>

* Reset the Merge definition for every legacy alias of its coercion nodes

* Improve test
This commit is contained in:
Keavon Chambers
2026-08-17 02:19:59 -07:00
parent 104b8b71e6
commit d63362718f
14 changed files with 162 additions and 53 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ pub async fn create_artboard<T: IntoGraphicList>(
Context -> List<Raster<GPU>>,
Context -> List<Color>,
Context -> List<Gradient>,
Context -> Item<DAffine2>,
Context -> Item<DAffine2>, // TODO: Remove this
)]
content: impl Node<Context<'static>, Output = T>,
/// Coordinate of the top-left corner of the artboard within the document.
+8 -20
View File
@@ -927,10 +927,10 @@ pub async fn legacy_layer_extend<T: 'n + Send + Clone>(
base
}
/// Nests the input graphical content in a wrapper graphic. This essentially "groups" the input.
/// Nests the input graphical content in a wrapper graphic, collecting it all into a single group.
/// The inverse of this node is 'Flatten Graphic'.
#[node_macro::node(category("General"))]
pub async fn wrap_graphic<T: Into<Graphic> + 'n>(
pub async fn into_group<T: Into<Graphic> + 'n>(
_: impl Ctx,
#[implementations(
List<Graphic>,
@@ -940,31 +940,19 @@ pub async fn wrap_graphic<T: Into<Graphic> + 'n>(
List<Color>,
List<Gradient>,
List<String>,
Item<DAffine2>,
Item<DVec2>,
List<DVec2>,
Item<DAffine2>, // TODO: Remove this
)]
content: T,
) -> Item<Graphic> {
Item::new_from_element(content.into())
}
/// Converts a list of graphical content into a `Graphic[]` by placing it into an element of a new wrapper `Graphic[]`.
/// If it is already a `Graphic[]`, it is not wrapped again. Use the 'Wrap Graphic' node if wrapping is always desired.
/// Type-asserts a value to be graphical content, converting each item of other content types into its matching form.
/// Use the 'Into Group' node instead to collect the content into a single group.
#[node_macro::node(category("General"))]
pub async fn to_graphic<T: IntoGraphicList>(
_: impl Ctx,
#[implementations(
List<Graphic>,
List<Vector>,
List<Raster<CPU>>,
List<Raster<GPU>>,
List<Color>,
List<Gradient>,
List<String>,
)]
content: T,
) -> List<Graphic> {
content.into_graphic_list()
pub async fn as_graphic(_: impl Ctx, value: Item<Graphic>) -> Item<Graphic> {
value
}
/// Removes a level of nesting from a `Graphic[]`, or all nesting if "Fully Flatten" is enabled.