mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 06:38:12 +08:00
Generalize the 'Map Vector' node as 'Map' with support for all graphical types (#3793)
* Rename Map Vector to Map
* Fix compilation errors
* Move to the Graphic module and add Read {Graphic, Raster, Color} nodes
---------
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
bd1c54907d
commit
ba177c4c5d
@@ -1,10 +1,18 @@
|
||||
use core_types::ExtractVarArgs;
|
||||
use core_types::table::Table;
|
||||
use core_types::{Color, ExtractVarArgs};
|
||||
use core_types::{Ctx, ExtractIndex, ExtractPosition};
|
||||
use glam::DVec2;
|
||||
use graphic_types::Vector;
|
||||
use graphic_types::{Graphic, Vector};
|
||||
use raster_types::{CPU, Raster};
|
||||
|
||||
#[node_macro::node(category("Context"), path(graphene_core::vector))]
|
||||
fn read_graphic(ctx: impl Ctx + ExtractVarArgs) -> Table<Graphic> {
|
||||
let Ok(var_arg) = ctx.vararg(0) else { return Default::default() };
|
||||
let var_arg = var_arg as &dyn std::any::Any;
|
||||
|
||||
var_arg.downcast_ref().cloned().unwrap_or_default()
|
||||
}
|
||||
|
||||
// TODO: Call this "Read Context" once it's fully generic
|
||||
#[node_macro::node(category("Context"), path(graphene_core::vector))]
|
||||
fn read_vector(ctx: impl Ctx + ExtractVarArgs) -> Table<Vector> {
|
||||
let Ok(var_arg) = ctx.vararg(0) else { return Default::default() };
|
||||
@@ -13,6 +21,22 @@ fn read_vector(ctx: impl Ctx + ExtractVarArgs) -> Table<Vector> {
|
||||
var_arg.downcast_ref().cloned().unwrap_or_default()
|
||||
}
|
||||
|
||||
#[node_macro::node(category("Context"), path(graphene_core::vector))]
|
||||
fn read_raster(ctx: impl Ctx + ExtractVarArgs) -> Table<Raster<CPU>> {
|
||||
let Ok(var_arg) = ctx.vararg(0) else { return Default::default() };
|
||||
let var_arg = var_arg as &dyn std::any::Any;
|
||||
|
||||
var_arg.downcast_ref().cloned().unwrap_or_default()
|
||||
}
|
||||
|
||||
#[node_macro::node(category("Context"), path(graphene_core::vector))]
|
||||
fn read_color(ctx: impl Ctx + ExtractVarArgs) -> Table<Color> {
|
||||
let Ok(var_arg) = ctx.vararg(0) else { return Default::default() };
|
||||
let var_arg = var_arg as &dyn std::any::Any;
|
||||
|
||||
var_arg.downcast_ref().cloned().unwrap_or_default()
|
||||
}
|
||||
|
||||
#[node_macro::node(category("Context"), path(core_types::vector))]
|
||||
async fn read_position(
|
||||
ctx: impl Ctx + ExtractPosition,
|
||||
|
||||
Reference in New Issue
Block a user