mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 07:18:04 +08:00
Add color converter and debug node to use graphic
This commit is contained in:
@@ -80,6 +80,9 @@ pub const ATTR_GRADIENT_TYPE: &str = "gradient_type";
|
||||
/// List<Graphic> data for fill.
|
||||
pub const ATTR_FILL_GRAPHIC: &str = "fill_graphic";
|
||||
|
||||
/// List<Graphic> data for stroke.
|
||||
pub const ATTR_STROKE_PAINT_GRAPHIC: &str = "stroke_paint_graphic";
|
||||
|
||||
// ========================
|
||||
// TRAIT: AnyAttributeValue
|
||||
// ========================
|
||||
|
||||
@@ -171,7 +171,7 @@ fn flatten_graphic_list<T>(content: List<Graphic>, extract_variant: fn(Graphic)
|
||||
}
|
||||
|
||||
/// Converts a `Fill` enum into the `List<Graphic>` representation used as paint storage.
|
||||
/// TODO: Remove once all paint sources flow through `List<Graphic>` directly without going through the `Fill` enum.
|
||||
/// TODO: Remove once all fill paint sources flow through `List<Graphic>` directly without going through the `Fill` enum.
|
||||
pub fn fill_to_graphic_list(fill: &Fill) -> Option<List<Graphic>> {
|
||||
match fill {
|
||||
Fill::None => None,
|
||||
@@ -188,6 +188,12 @@ pub fn fill_to_graphic_list(fill: &Fill) -> Option<List<Graphic>> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts a `Color` into the `List<Graphic>` representation used as paint storage.
|
||||
/// TODO: Remove once all stroke paint sources flow through `List<Graphic>` directly without going through `Stroke.color`.
|
||||
pub fn color_to_graphic_list(color: Option<Color>) -> Option<List<Graphic>> {
|
||||
color.as_ref().map(|color| List::new_from_element((*color).into()))
|
||||
}
|
||||
|
||||
/// Maps from a concrete element type to its corresponding `Graphic` enum variant,
|
||||
/// enabling type-directed casting of typed `List`s from a `Graphic` value.
|
||||
pub trait TryFromGraphic: Clone + Sized {
|
||||
|
||||
Reference in New Issue
Block a user