mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 18:38:05 +08:00
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:
@@ -437,6 +437,7 @@ impl IntoGraphicList for List<String> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this
|
||||
impl IntoGraphicList for Item<DAffine2> {
|
||||
fn into_graphic_list(self) -> List<Graphic> {
|
||||
List::new_from_element(Graphic::default())
|
||||
@@ -444,6 +445,7 @@ impl IntoGraphicList for Item<DAffine2> {
|
||||
}
|
||||
|
||||
// DAffine2
|
||||
// TODO: Remove this
|
||||
impl From<Item<DAffine2>> for Graphic {
|
||||
fn from(_: Item<DAffine2>) -> Self {
|
||||
Graphic::default()
|
||||
@@ -453,7 +455,20 @@ impl From<Item<DAffine2>> for Graphic {
|
||||
// DVec2
|
||||
impl From<Item<DVec2>> for Graphic {
|
||||
fn from(position: Item<DVec2>) -> Self {
|
||||
Graphic::VectorList(List::new_from_element(Vector::from_anchor_position(position.into_element())))
|
||||
let (position, attributes) = position.into_parts();
|
||||
|
||||
Graphic::Vector(Box::new(Item::from_parts(Vector::from_anchor_position(position), attributes)))
|
||||
}
|
||||
}
|
||||
impl From<List<DVec2>> for Graphic {
|
||||
fn from(positions: List<DVec2>) -> Self {
|
||||
let anchors = positions.into_iter().map(|position| {
|
||||
let (position, attributes) = position.into_parts();
|
||||
|
||||
Item::from_parts(Vector::from_anchor_position(position), attributes)
|
||||
});
|
||||
|
||||
Graphic::VectorList(anchors.collect())
|
||||
}
|
||||
}
|
||||
// Note: List conversions handled by blanket impl in gcore
|
||||
|
||||
Reference in New Issue
Block a user