mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 19:48:11 +08:00
Instance tables refactor part 7: Rename "ImageFrame" -> "RasterData", "ImageFrameTable" -> "RasterDataType", and "RasterFrame" -> "RasterDataType"
This commit is contained in:
Generated
+1
-1
File diff suppressed because one or more lines are too long
@@ -30,7 +30,7 @@ use glam::{DAffine2, DVec2, IVec2};
|
|||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
use graph_craft::document::{NodeId, NodeInput, NodeNetwork, OldNodeNetwork};
|
use graph_craft::document::{NodeId, NodeInput, NodeNetwork, OldNodeNetwork};
|
||||||
use graphene_core::raster::BlendMode;
|
use graphene_core::raster::BlendMode;
|
||||||
use graphene_core::raster::image::ImageFrameTable;
|
use graphene_core::raster::image::RasterDataTable;
|
||||||
use graphene_core::vector::style::ViewMode;
|
use graphene_core::vector::style::ViewMode;
|
||||||
use graphene_std::renderer::{ClickTarget, Quad};
|
use graphene_std::renderer::{ClickTarget, Quad};
|
||||||
use graphene_std::vector::{PointId, path_bool_lib};
|
use graphene_std::vector::{PointId, path_bool_lib};
|
||||||
@@ -864,7 +864,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
|
|||||||
|
|
||||||
responses.add(DocumentMessage::AddTransaction);
|
responses.add(DocumentMessage::AddTransaction);
|
||||||
|
|
||||||
let layer = graph_modification_utils::new_image_layer(ImageFrameTable::new(image), layer_node_id, self.new_layer_parent(true), responses);
|
let layer = graph_modification_utils::new_image_layer(RasterDataTable::new(image), layer_node_id, self.new_layer_parent(true), responses);
|
||||||
|
|
||||||
if let Some(name) = name {
|
if let Some(name) = name {
|
||||||
responses.add(NodeGraphMessage::SetDisplayName {
|
responses.add(NodeGraphMessage::SetDisplayName {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use bezier_rs::Subpath;
|
|||||||
use glam::{DAffine2, DVec2, IVec2};
|
use glam::{DAffine2, DVec2, IVec2};
|
||||||
use graph_craft::document::NodeId;
|
use graph_craft::document::NodeId;
|
||||||
use graphene_core::raster::BlendMode;
|
use graphene_core::raster::BlendMode;
|
||||||
use graphene_core::raster::image::ImageFrameTable;
|
use graphene_core::raster::image::RasterDataTable;
|
||||||
use graphene_core::text::{Font, TypesettingConfig};
|
use graphene_core::text::{Font, TypesettingConfig};
|
||||||
use graphene_core::vector::PointId;
|
use graphene_core::vector::PointId;
|
||||||
use graphene_core::vector::VectorModificationType;
|
use graphene_core::vector::VectorModificationType;
|
||||||
@@ -66,7 +66,7 @@ pub enum GraphOperationMessage {
|
|||||||
},
|
},
|
||||||
NewBitmapLayer {
|
NewBitmapLayer {
|
||||||
id: NodeId,
|
id: NodeId,
|
||||||
image_frame: ImageFrameTable<Color>,
|
image_frame: RasterDataTable<Color>,
|
||||||
parent: LayerNodeIdentifier,
|
parent: LayerNodeIdentifier,
|
||||||
insert_index: usize,
|
insert_index: usize,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use graph_craft::concrete;
|
|||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
use graph_craft::document::{NodeId, NodeInput};
|
use graph_craft::document::{NodeId, NodeInput};
|
||||||
use graphene_core::raster::BlendMode;
|
use graphene_core::raster::BlendMode;
|
||||||
use graphene_core::raster::image::ImageFrameTable;
|
use graphene_core::raster::image::RasterDataTable;
|
||||||
use graphene_core::text::{Font, TypesettingConfig};
|
use graphene_core::text::{Font, TypesettingConfig};
|
||||||
use graphene_core::vector::brush_stroke::BrushStroke;
|
use graphene_core::vector::brush_stroke::BrushStroke;
|
||||||
use graphene_core::vector::style::{Fill, Stroke};
|
use graphene_core::vector::style::{Fill, Stroke};
|
||||||
@@ -209,11 +209,11 @@ impl<'a> ModifyInputsContext<'a> {
|
|||||||
self.network_interface.move_node_to_chain_start(&stroke_id, layer, &[]);
|
self.network_interface.move_node_to_chain_start(&stroke_id, layer, &[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_image_data(&mut self, image_frame: ImageFrameTable<Color>, layer: LayerNodeIdentifier) {
|
pub fn insert_image_data(&mut self, image_frame: RasterDataTable<Color>, layer: LayerNodeIdentifier) {
|
||||||
let transform = resolve_document_node_type("Transform").expect("Transform node does not exist").default_node_template();
|
let transform = resolve_document_node_type("Transform").expect("Transform node does not exist").default_node_template();
|
||||||
let image = resolve_document_node_type("Image")
|
let image = resolve_document_node_type("Image")
|
||||||
.expect("Image node does not exist")
|
.expect("Image node does not exist")
|
||||||
.node_template_input_override([Some(NodeInput::value(TaggedValue::None, false)), Some(NodeInput::value(TaggedValue::ImageFrame(image_frame), false))]);
|
.node_template_input_override([Some(NodeInput::value(TaggedValue::None, false)), Some(NodeInput::value(TaggedValue::RasterData(image_frame), false))]);
|
||||||
|
|
||||||
let image_id = NodeId::new();
|
let image_id = NodeId::new();
|
||||||
self.network_interface.insert_node(image_id, image, &[]);
|
self.network_interface.insert_node(image_id, image, &[]);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use graph_craft::concrete;
|
|||||||
use graph_craft::document::value::*;
|
use graph_craft::document::value::*;
|
||||||
use graph_craft::document::*;
|
use graph_craft::document::*;
|
||||||
use graphene_core::raster::brush_cache::BrushCache;
|
use graphene_core::raster::brush_cache::BrushCache;
|
||||||
use graphene_core::raster::image::ImageFrameTable;
|
use graphene_core::raster::image::RasterDataTable;
|
||||||
use graphene_core::raster::{CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, NoiseType, RedGreenBlueAlpha};
|
use graphene_core::raster::{CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, NoiseType, RedGreenBlueAlpha};
|
||||||
use graphene_core::text::{Font, TypesettingConfig};
|
use graphene_core::text::{Font, TypesettingConfig};
|
||||||
use graphene_core::transform::Footprint;
|
use graphene_core::transform::Footprint;
|
||||||
@@ -608,8 +608,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
exports: vec![NodeInput::node(NodeId(3), 0)],
|
exports: vec![NodeInput::node(NodeId(3), 0)],
|
||||||
nodes: [
|
nodes: [
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
inputs: vec![NodeInput::network(concrete!(ImageFrameTable<Color>), 0)],
|
inputs: vec![NodeInput::network(concrete!(RasterDataTable<Color>), 0)],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::ops::IntoNode<_, ImageFrameTable<SRGBA8>>")),
|
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::ops::IntoNode<_, RasterDataTable<SRGBA8>>")),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
@@ -636,7 +636,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
.collect(),
|
.collect(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
inputs: vec![NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::default()), true)],
|
inputs: vec![NodeInput::value(TaggedValue::RasterData(RasterDataTable::default()), true)],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
persistent_node_metadata: DocumentNodePersistentMetadata {
|
persistent_node_metadata: DocumentNodePersistentMetadata {
|
||||||
@@ -852,7 +852,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
nodes: [
|
nodes: [
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
inputs: vec![
|
inputs: vec![
|
||||||
NodeInput::network(concrete!(ImageFrameTable<Color>), 0),
|
NodeInput::network(concrete!(RasterDataTable<Color>), 0),
|
||||||
NodeInput::value(TaggedValue::RedGreenBlueAlpha(RedGreenBlueAlpha::Red), false),
|
NodeInput::value(TaggedValue::RedGreenBlueAlpha(RedGreenBlueAlpha::Red), false),
|
||||||
],
|
],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::raster::adjustments::ExtractChannelNode")),
|
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::raster::adjustments::ExtractChannelNode")),
|
||||||
@@ -861,7 +861,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
},
|
},
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
inputs: vec![
|
inputs: vec![
|
||||||
NodeInput::network(concrete!(ImageFrameTable<Color>), 0),
|
NodeInput::network(concrete!(RasterDataTable<Color>), 0),
|
||||||
NodeInput::value(TaggedValue::RedGreenBlueAlpha(RedGreenBlueAlpha::Green), false),
|
NodeInput::value(TaggedValue::RedGreenBlueAlpha(RedGreenBlueAlpha::Green), false),
|
||||||
],
|
],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::raster::adjustments::ExtractChannelNode")),
|
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::raster::adjustments::ExtractChannelNode")),
|
||||||
@@ -870,7 +870,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
},
|
},
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
inputs: vec![
|
inputs: vec![
|
||||||
NodeInput::network(concrete!(ImageFrameTable<Color>), 0),
|
NodeInput::network(concrete!(RasterDataTable<Color>), 0),
|
||||||
NodeInput::value(TaggedValue::RedGreenBlueAlpha(RedGreenBlueAlpha::Blue), false),
|
NodeInput::value(TaggedValue::RedGreenBlueAlpha(RedGreenBlueAlpha::Blue), false),
|
||||||
],
|
],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::raster::adjustments::ExtractChannelNode")),
|
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::raster::adjustments::ExtractChannelNode")),
|
||||||
@@ -879,7 +879,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
},
|
},
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
inputs: vec![
|
inputs: vec![
|
||||||
NodeInput::network(concrete!(ImageFrameTable<Color>), 0),
|
NodeInput::network(concrete!(RasterDataTable<Color>), 0),
|
||||||
NodeInput::value(TaggedValue::RedGreenBlueAlpha(RedGreenBlueAlpha::Alpha), false),
|
NodeInput::value(TaggedValue::RedGreenBlueAlpha(RedGreenBlueAlpha::Alpha), false),
|
||||||
],
|
],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::raster::adjustments::ExtractChannelNode")),
|
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::raster::adjustments::ExtractChannelNode")),
|
||||||
@@ -893,7 +893,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
.collect(),
|
.collect(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
inputs: vec![NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::default()), true)],
|
inputs: vec![NodeInput::value(TaggedValue::RasterData(RasterDataTable::default()), true)],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
persistent_node_metadata: DocumentNodePersistentMetadata {
|
persistent_node_metadata: DocumentNodePersistentMetadata {
|
||||||
@@ -959,13 +959,13 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
exports: vec![NodeInput::node(NodeId(0), 0), NodeInput::node(NodeId(1), 0)],
|
exports: vec![NodeInput::node(NodeId(0), 0), NodeInput::node(NodeId(1), 0)],
|
||||||
nodes: [
|
nodes: [
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
inputs: vec![NodeInput::network(concrete!(ImageFrameTable<Color>), 0), NodeInput::value(TaggedValue::XY(XY::X), false)],
|
inputs: vec![NodeInput::network(concrete!(RasterDataTable<Color>), 0), NodeInput::value(TaggedValue::XY(XY::X), false)],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::ops::ExtractXyNode")),
|
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::ops::ExtractXyNode")),
|
||||||
manual_composition: Some(generic!(T)),
|
manual_composition: Some(generic!(T)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
inputs: vec![NodeInput::network(concrete!(ImageFrameTable<Color>), 0), NodeInput::value(TaggedValue::XY(XY::Y), false)],
|
inputs: vec![NodeInput::network(concrete!(RasterDataTable<Color>), 0), NodeInput::value(TaggedValue::XY(XY::Y), false)],
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::ops::ExtractXyNode")),
|
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("graphene_core::ops::ExtractXyNode")),
|
||||||
manual_composition: Some(generic!(T)),
|
manual_composition: Some(generic!(T)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -978,7 +978,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
inputs: vec![NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::default()), true)],
|
inputs: vec![NodeInput::value(TaggedValue::RasterData(RasterDataTable::default()), true)],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
persistent_node_metadata: DocumentNodePersistentMetadata {
|
persistent_node_metadata: DocumentNodePersistentMetadata {
|
||||||
@@ -1029,7 +1029,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
exports: vec![NodeInput::node(NodeId(0), 0)],
|
exports: vec![NodeInput::node(NodeId(0), 0)],
|
||||||
nodes: vec![DocumentNode {
|
nodes: vec![DocumentNode {
|
||||||
inputs: vec![
|
inputs: vec![
|
||||||
NodeInput::network(concrete!(ImageFrameTable<Color>), 0),
|
NodeInput::network(concrete!(RasterDataTable<Color>), 0),
|
||||||
NodeInput::network(concrete!(Vec<graphene_core::vector::brush_stroke::BrushStroke>), 1),
|
NodeInput::network(concrete!(Vec<graphene_core::vector::brush_stroke::BrushStroke>), 1),
|
||||||
NodeInput::network(concrete!(BrushCache), 2),
|
NodeInput::network(concrete!(BrushCache), 2),
|
||||||
],
|
],
|
||||||
@@ -1044,7 +1044,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
inputs: vec![
|
inputs: vec![
|
||||||
NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::default()), true),
|
NodeInput::value(TaggedValue::RasterData(RasterDataTable::default()), true),
|
||||||
NodeInput::value(TaggedValue::BrushStrokes(Vec::new()), false),
|
NodeInput::value(TaggedValue::BrushStrokes(Vec::new()), false),
|
||||||
NodeInput::value(TaggedValue::BrushCache(BrushCache::new_proto()), false),
|
NodeInput::value(TaggedValue::BrushCache(BrushCache::new_proto()), false),
|
||||||
],
|
],
|
||||||
@@ -1083,7 +1083,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
node_template: NodeTemplate {
|
node_template: NodeTemplate {
|
||||||
document_node: DocumentNode {
|
document_node: DocumentNode {
|
||||||
implementation: DocumentNodeImplementation::proto("graphene_core::memo::MemoNode"),
|
implementation: DocumentNodeImplementation::proto("graphene_core::memo::MemoNode"),
|
||||||
inputs: vec![NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::default()), true)],
|
inputs: vec![NodeInput::value(TaggedValue::RasterData(RasterDataTable::default()), true)],
|
||||||
manual_composition: Some(concrete!(Context)),
|
manual_composition: Some(concrete!(Context)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@@ -1102,7 +1102,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
node_template: NodeTemplate {
|
node_template: NodeTemplate {
|
||||||
document_node: DocumentNode {
|
document_node: DocumentNode {
|
||||||
implementation: DocumentNodeImplementation::proto("graphene_core::memo::ImpureMemoNode"),
|
implementation: DocumentNodeImplementation::proto("graphene_core::memo::ImpureMemoNode"),
|
||||||
inputs: vec![NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::default()), true)],
|
inputs: vec![NodeInput::value(TaggedValue::RasterData(RasterDataTable::default()), true)],
|
||||||
manual_composition: Some(concrete!(Context)),
|
manual_composition: Some(concrete!(Context)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@@ -1784,7 +1784,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
inputs: vec![NodeInput::network(concrete!(ImageFrameTable<Color>), 0), NodeInput::node(NodeId(0), 0)],
|
inputs: vec![NodeInput::network(concrete!(RasterDataTable<Color>), 0), NodeInput::node(NodeId(0), 0)],
|
||||||
manual_composition: Some(generic!(T)),
|
manual_composition: Some(generic!(T)),
|
||||||
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("wgpu_executor::UploadTextureNode")),
|
implementation: DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier::new("wgpu_executor::UploadTextureNode")),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
@@ -1802,7 +1802,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
.collect(),
|
.collect(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
inputs: vec![NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::default()), true)],
|
inputs: vec![NodeInput::value(TaggedValue::RasterData(RasterDataTable::default()), true)],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
persistent_node_metadata: DocumentNodePersistentMetadata {
|
persistent_node_metadata: DocumentNodePersistentMetadata {
|
||||||
@@ -1882,7 +1882,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
// document_node: DocumentNode {
|
// document_node: DocumentNode {
|
||||||
// implementation: DocumentNodeImplementation::proto("graphene_core::raster::CurvesNode"),
|
// implementation: DocumentNodeImplementation::proto("graphene_core::raster::CurvesNode"),
|
||||||
// inputs: vec![
|
// inputs: vec![
|
||||||
// NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::default()), true),
|
// NodeInput::value(TaggedValue::RasterData(RasterDataTable::default()), true),
|
||||||
// NodeInput::value(TaggedValue::Curve(Default::default()), false),
|
// NodeInput::value(TaggedValue::Curve(Default::default()), false),
|
||||||
// ],
|
// ],
|
||||||
// ..Default::default()
|
// ..Default::default()
|
||||||
@@ -2646,7 +2646,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
// exports: vec![NodeInput::node(NodeId(1), 0)],
|
// exports: vec![NodeInput::node(NodeId(1), 0)],
|
||||||
// nodes: [
|
// nodes: [
|
||||||
// DocumentNode {
|
// DocumentNode {
|
||||||
// inputs: vec![NodeInput::network(concrete!(ImageFrameTable<Color>), 0)],
|
// inputs: vec![NodeInput::network(concrete!(RasterDataTable<Color>), 0)],
|
||||||
// implementation: DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode"),
|
// implementation: DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode"),
|
||||||
// manual_composition: Some(concrete!(Context)),
|
// manual_composition: Some(concrete!(Context)),
|
||||||
// skip_deduplication: true,
|
// skip_deduplication: true,
|
||||||
@@ -2684,7 +2684,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||||||
// ..Default::default()
|
// ..Default::default()
|
||||||
// }),
|
// }),
|
||||||
// inputs: vec![
|
// inputs: vec![
|
||||||
// NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::default()), true),
|
// NodeInput::value(TaggedValue::RasterData(RasterDataTable::default()), true),
|
||||||
// NodeInput::scope("editor-api"),
|
// NodeInput::scope("editor-api"),
|
||||||
// NodeInput::value(TaggedValue::ImaginateController(Default::default()), false),
|
// NodeInput::value(TaggedValue::ImaginateController(Default::default()), false),
|
||||||
// NodeInput::value(TaggedValue::F64(0.), false), // Remember to keep index used in `ImaginateRandom` updated with this entry's index
|
// NodeInput::value(TaggedValue::F64(0.), false), // Remember to keep index used in `ImaginateRandom` updated with this entry's index
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use graph_craft::Type;
|
|||||||
use graph_craft::document::value::TaggedValue;
|
use graph_craft::document::value::TaggedValue;
|
||||||
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeId, NodeInput};
|
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeId, NodeInput};
|
||||||
use graphene_core::raster::curve::Curve;
|
use graphene_core::raster::curve::Curve;
|
||||||
use graphene_core::raster::image::ImageFrameTable;
|
use graphene_core::raster::image::RasterDataTable;
|
||||||
use graphene_core::raster::{
|
use graphene_core::raster::{
|
||||||
BlendMode, CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, LuminanceCalculation, NoiseType, RedGreenBlue, RedGreenBlueAlpha, RelativeAbsolute,
|
BlendMode, CellularDistanceFunction, CellularReturnType, Color, DomainWarpType, FractalType, LuminanceCalculation, NoiseType, RedGreenBlue, RedGreenBlueAlpha, RelativeAbsolute,
|
||||||
SelectiveColorChoice,
|
SelectiveColorChoice,
|
||||||
@@ -22,14 +22,14 @@ use graphene_core::vector::generator_nodes::grid;
|
|||||||
use graphene_core::vector::misc::CentroidType;
|
use graphene_core::vector::misc::CentroidType;
|
||||||
use graphene_core::vector::style::{GradientType, LineCap, LineJoin};
|
use graphene_core::vector::style::{GradientType, LineCap, LineJoin};
|
||||||
use graphene_std::animation::RealTimeMode;
|
use graphene_std::animation::RealTimeMode;
|
||||||
use graphene_std::application_io::TextureFrameTable;
|
use graphene_std::application_io::TextureDataTable;
|
||||||
use graphene_std::ops::XY;
|
use graphene_std::ops::XY;
|
||||||
use graphene_std::transform::{Footprint, ReferencePoint};
|
use graphene_std::transform::{Footprint, ReferencePoint};
|
||||||
use graphene_std::vector::VectorDataTable;
|
use graphene_std::vector::VectorDataTable;
|
||||||
use graphene_std::vector::misc::ArcType;
|
use graphene_std::vector::misc::ArcType;
|
||||||
use graphene_std::vector::misc::{BooleanOperation, GridType};
|
use graphene_std::vector::misc::{BooleanOperation, GridType};
|
||||||
use graphene_std::vector::style::{Fill, FillChoice, FillType, GradientStops};
|
use graphene_std::vector::style::{Fill, FillChoice, FillType, GradientStops};
|
||||||
use graphene_std::{GraphicGroupTable, NodeInputDecleration, RasterFrame};
|
use graphene_std::{GraphicGroupTable, NodeInputDecleration, RasterDataType};
|
||||||
|
|
||||||
pub(crate) fn string_properties(text: &str) -> Vec<LayoutGroup> {
|
pub(crate) fn string_properties(text: &str) -> Vec<LayoutGroup> {
|
||||||
let widget = TextLabel::new(text).widget_holder();
|
let widget = TextLabel::new(text).widget_holder();
|
||||||
@@ -190,7 +190,7 @@ pub(crate) fn property_from_type(
|
|||||||
// GRAPHICAL DATA TYPES
|
// GRAPHICAL DATA TYPES
|
||||||
// ====================
|
// ====================
|
||||||
Some(x) if x == TypeId::of::<VectorDataTable>() => vector_data_widget(default_info).into(),
|
Some(x) if x == TypeId::of::<VectorDataTable>() => vector_data_widget(default_info).into(),
|
||||||
Some(x) if x == TypeId::of::<RasterFrame>() || x == TypeId::of::<ImageFrameTable<Color>>() || x == TypeId::of::<TextureFrameTable>() => raster_widget(default_info).into(),
|
Some(x) if x == TypeId::of::<RasterDataType>() || x == TypeId::of::<RasterDataTable<Color>>() || x == TypeId::of::<TextureDataTable>() => raster_widget(default_info).into(),
|
||||||
Some(x) if x == TypeId::of::<GraphicGroupTable>() => group_widget(default_info).into(),
|
Some(x) if x == TypeId::of::<GraphicGroupTable>() => group_widget(default_info).into(),
|
||||||
// ============
|
// ============
|
||||||
// STRUCT TYPES
|
// STRUCT TYPES
|
||||||
@@ -198,7 +198,7 @@ pub(crate) fn property_from_type(
|
|||||||
Some(x) if x == TypeId::of::<Color>() => color_widget(default_info, ColorInput::default().allow_none(false)),
|
Some(x) if x == TypeId::of::<Color>() => color_widget(default_info, ColorInput::default().allow_none(false)),
|
||||||
Some(x) if x == TypeId::of::<Option<Color>>() => color_widget(default_info, ColorInput::default().allow_none(true)),
|
Some(x) if x == TypeId::of::<Option<Color>>() => color_widget(default_info, ColorInput::default().allow_none(true)),
|
||||||
Some(x) if x == TypeId::of::<GradientStops>() => color_widget(default_info, ColorInput::default().allow_none(false)),
|
Some(x) if x == TypeId::of::<GradientStops>() => color_widget(default_info, ColorInput::default().allow_none(false)),
|
||||||
Some(x) if x == TypeId::of::<Font>() => font_widget(default_info).into(),
|
Some(x) if x == TypeId::of::<Font>() => font_widget(default_info),
|
||||||
Some(x) if x == TypeId::of::<Curve>() => curve_widget(default_info),
|
Some(x) if x == TypeId::of::<Curve>() => curve_widget(default_info),
|
||||||
Some(x) if x == TypeId::of::<Footprint>() => footprint_widget(default_info, &mut extra_widgets),
|
Some(x) if x == TypeId::of::<Footprint>() => footprint_widget(default_info, &mut extra_widgets),
|
||||||
// ===============================
|
// ===============================
|
||||||
|
|||||||
@@ -263,7 +263,7 @@
|
|||||||
|
|
||||||
// // let transform = context
|
// // let transform = context
|
||||||
// // .executor
|
// // .executor
|
||||||
// // .introspect_node_in_network(context.network, &imaginate_node, |network| network.inputs.first().copied(), |frame: &ImageFrame<Color>| frame.transform)
|
// // .introspect_node_in_network(context.network, &imaginate_node, |network| network.inputs.first().copied(), |frame: &RasterData<Color>| frame.transform)
|
||||||
// // .unwrap_or_default();
|
// // .unwrap_or_default();
|
||||||
// let image_size = context
|
// let image_size = context
|
||||||
// .executor
|
// .executor
|
||||||
@@ -283,7 +283,7 @@
|
|||||||
// .map(|(node_id, _)| node_id)
|
// .map(|(node_id, _)| node_id)
|
||||||
// .copied()
|
// .copied()
|
||||||
// },
|
// },
|
||||||
// |frame: &IORecord<(), ImageFrame<Color>>| (frame.output.image.width, frame.output.image.height),
|
// |frame: &IORecord<(), RasterData<Color>>| (frame.output.image.width, frame.output.image.height),
|
||||||
// )
|
// )
|
||||||
// .unwrap_or_default();
|
// .unwrap_or_default();
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ pub enum FrontendGraphDataType {
|
|||||||
impl FrontendGraphDataType {
|
impl FrontendGraphDataType {
|
||||||
fn with_type(input: &Type) -> Self {
|
fn with_type(input: &Type) -> Self {
|
||||||
match TaggedValue::from_type_or_none(input) {
|
match TaggedValue::from_type_or_none(input) {
|
||||||
TaggedValue::Image(_) | TaggedValue::ImageFrame(_) => Self::Raster,
|
TaggedValue::Image(_) | TaggedValue::RasterData(_) => Self::Raster,
|
||||||
TaggedValue::Subpaths(_) | TaggedValue::VectorData(_) => Self::VectorData,
|
TaggedValue::Subpaths(_) | TaggedValue::VectorData(_) => Self::VectorData,
|
||||||
TaggedValue::U32(_)
|
TaggedValue::U32(_)
|
||||||
| TaggedValue::U64(_)
|
| TaggedValue::U64(_)
|
||||||
|
|||||||
@@ -485,7 +485,6 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
|
|||||||
("graphene_core::raster::GradientMapNode", "graphene_core::raster::adjustments::GradientMapNode"),
|
("graphene_core::raster::GradientMapNode", "graphene_core::raster::adjustments::GradientMapNode"),
|
||||||
("graphene_core::raster::HueSaturationNode", "graphene_core::raster::adjustments::HueSaturationNode"),
|
("graphene_core::raster::HueSaturationNode", "graphene_core::raster::adjustments::HueSaturationNode"),
|
||||||
("graphene_core::raster::InvertNode", "graphene_core::raster::adjustments::InvertNode"),
|
("graphene_core::raster::InvertNode", "graphene_core::raster::adjustments::InvertNode"),
|
||||||
// ("graphene_core::raster::IndexNode", "graphene_core::raster::adjustments::IndexNode"),
|
|
||||||
("graphene_core::raster::InvertRGBNode", "graphene_core::raster::adjustments::InvertNode"),
|
("graphene_core::raster::InvertRGBNode", "graphene_core::raster::adjustments::InvertNode"),
|
||||||
("graphene_core::raster::LevelsNode", "graphene_core::raster::adjustments::LevelsNode"),
|
("graphene_core::raster::LevelsNode", "graphene_core::raster::adjustments::LevelsNode"),
|
||||||
("graphene_core::raster::LuminanceNode", "graphene_core::raster::adjustments::LuminanceNode"),
|
("graphene_core::raster::LuminanceNode", "graphene_core::raster::adjustments::LuminanceNode"),
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ use graphene_core::Context;
|
|||||||
use graphene_core::GraphicGroupTable;
|
use graphene_core::GraphicGroupTable;
|
||||||
use graphene_core::instances::Instances;
|
use graphene_core::instances::Instances;
|
||||||
use graphene_core::memo::IORecord;
|
use graphene_core::memo::IORecord;
|
||||||
|
use graphene_core::raster::Image;
|
||||||
use graphene_core::vector::{VectorData, VectorDataTable};
|
use graphene_core::vector::{VectorData, VectorDataTable};
|
||||||
use graphene_core::{Artboard, ArtboardGroupTable, GraphicElement};
|
use graphene_core::{Artboard, ArtboardGroupTable, GraphicElement};
|
||||||
|
use graphene_std::Color;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@@ -154,7 +156,7 @@ impl InstanceLayout for GraphicElement {
|
|||||||
match self {
|
match self {
|
||||||
Self::GraphicGroup(instances) => instances.identifier(),
|
Self::GraphicGroup(instances) => instances.identifier(),
|
||||||
Self::VectorData(instances) => instances.identifier(),
|
Self::VectorData(instances) => instances.identifier(),
|
||||||
Self::RasterFrame(_) => "RasterFrame".to_string(),
|
Self::RasterDataType(_) => "RasterDataType".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Don't put a breadcrumb for GraphicElement
|
// Don't put a breadcrumb for GraphicElement
|
||||||
@@ -165,7 +167,7 @@ impl InstanceLayout for GraphicElement {
|
|||||||
match self {
|
match self {
|
||||||
Self::GraphicGroup(instances) => instances.layout_with_breadcrumb(data),
|
Self::GraphicGroup(instances) => instances.layout_with_breadcrumb(data),
|
||||||
Self::VectorData(instances) => instances.layout_with_breadcrumb(data),
|
Self::VectorData(instances) => instances.layout_with_breadcrumb(data),
|
||||||
Self::RasterFrame(_) => label("Raster frame not supported"),
|
Self::RasterDataType(_) => label("Raster frame not supported"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,6 +227,19 @@ impl InstanceLayout for VectorData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl InstanceLayout for Image<Color> {
|
||||||
|
fn type_name() -> &'static str {
|
||||||
|
"Image"
|
||||||
|
}
|
||||||
|
fn identifier(&self) -> String {
|
||||||
|
format!("Image (width={}, height={})", self.width, self.height)
|
||||||
|
}
|
||||||
|
fn compute_layout(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||||
|
let rows = vec![vec![TextLabel::new(format!("Image (width={}, height={})", self.width, self.height)).widget_holder()]];
|
||||||
|
vec![LayoutGroup::Table { rows }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl InstanceLayout for Artboard {
|
impl InstanceLayout for Artboard {
|
||||||
fn type_name() -> &'static str {
|
fn type_name() -> &'static str {
|
||||||
"Artboard"
|
"Artboard"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use graph_craft::document::value::TaggedValue;
|
|||||||
use graph_craft::document::{NodeId, NodeInput};
|
use graph_craft::document::{NodeId, NodeInput};
|
||||||
use graphene_core::Color;
|
use graphene_core::Color;
|
||||||
use graphene_core::raster::BlendMode;
|
use graphene_core::raster::BlendMode;
|
||||||
use graphene_core::raster::image::ImageFrameTable;
|
use graphene_core::raster::image::RasterDataTable;
|
||||||
use graphene_core::text::{Font, TypesettingConfig};
|
use graphene_core::text::{Font, TypesettingConfig};
|
||||||
use graphene_core::vector::style::Gradient;
|
use graphene_core::vector::style::Gradient;
|
||||||
use graphene_std::vector::{ManipulatorPointId, PointId, SegmentId, VectorModificationType};
|
use graphene_std::vector::{ManipulatorPointId, PointId, SegmentId, VectorModificationType};
|
||||||
@@ -207,7 +207,7 @@ pub fn new_vector_layer(subpaths: Vec<Subpath<PointId>>, id: NodeId, parent: Lay
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new bitmap layer.
|
/// Create a new bitmap layer.
|
||||||
pub fn new_image_layer(image_frame: ImageFrameTable<Color>, id: NodeId, parent: LayerNodeIdentifier, responses: &mut VecDeque<Message>) -> LayerNodeIdentifier {
|
pub fn new_image_layer(image_frame: RasterDataTable<Color>, id: NodeId, parent: LayerNodeIdentifier, responses: &mut VecDeque<Message>) -> LayerNodeIdentifier {
|
||||||
let insert_index = 0;
|
let insert_index = 0;
|
||||||
responses.add(GraphOperationMessage::NewBitmapLayer {
|
responses.add(GraphOperationMessage::NewBitmapLayer {
|
||||||
id,
|
id,
|
||||||
@@ -424,12 +424,9 @@ impl<'a> NodeGraphLayer<'a> {
|
|||||||
/// Check if a layer is a raster layer
|
/// Check if a layer is a raster layer
|
||||||
pub fn is_raster_layer(layer: LayerNodeIdentifier, network_interface: &mut NodeNetworkInterface) -> bool {
|
pub fn is_raster_layer(layer: LayerNodeIdentifier, network_interface: &mut NodeNetworkInterface) -> bool {
|
||||||
let layer_input_type = network_interface.input_type(&InputConnector::node(layer.to_node(), 1), &[]).0.nested_type().clone();
|
let layer_input_type = network_interface.input_type(&InputConnector::node(layer.to_node(), 1), &[]).0.nested_type().clone();
|
||||||
if layer_input_type == concrete!(graphene_core::raster::image::ImageFrameTable<graphene_core::Color>)
|
|
||||||
|| layer_input_type == concrete!(graphene_core::application_io::TextureFrameTable)
|
layer_input_type == concrete!(graphene_std::RasterDataType)
|
||||||
|| layer_input_type == concrete!(graphene_std::RasterFrame)
|
|| layer_input_type == concrete!(graphene_core::raster::image::RasterDataTable<graphene_core::Color>)
|
||||||
{
|
|| layer_input_type == concrete!(graphene_core::application_io::TextureDataTable)
|
||||||
return true;
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ impl NodeGraphExecutor {
|
|||||||
TaggedValue::OptionalColor(render_object) => Self::debug_render(render_object, transform, responses),
|
TaggedValue::OptionalColor(render_object) => Self::debug_render(render_object, transform, responses),
|
||||||
TaggedValue::VectorData(render_object) => Self::debug_render(render_object, transform, responses),
|
TaggedValue::VectorData(render_object) => Self::debug_render(render_object, transform, responses),
|
||||||
TaggedValue::GraphicGroup(render_object) => Self::debug_render(render_object, transform, responses),
|
TaggedValue::GraphicGroup(render_object) => Self::debug_render(render_object, transform, responses),
|
||||||
TaggedValue::ImageFrame(render_object) => Self::debug_render(render_object, transform, responses),
|
TaggedValue::RasterData(render_object) => Self::debug_render(render_object, transform, responses),
|
||||||
TaggedValue::Palette(render_object) => Self::debug_render(render_object, transform, responses),
|
TaggedValue::Palette(render_object) => Self::debug_render(render_object, transform, responses),
|
||||||
_ => {
|
_ => {
|
||||||
return Err(format!("Invalid node graph output type: {node_graph_output:#?}"));
|
return Err(format!("Invalid node graph output type: {node_graph_output:#?}"));
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ impl Size for web_sys::HtmlCanvasElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Rename to ImageTextureTable
|
pub type TextureDataTable = Instances<ImageTexture>;
|
||||||
pub type TextureFrameTable = Instances<ImageTexture>;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ImageTexture {
|
pub struct ImageTexture {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::application_io::{ImageTexture, TextureFrameTable};
|
use crate::application_io::{ImageTexture, TextureDataTable};
|
||||||
use crate::instances::{Instance, Instances};
|
use crate::instances::{Instance, Instances};
|
||||||
use crate::raster::BlendMode;
|
use crate::raster::BlendMode;
|
||||||
use crate::raster::image::{Image, ImageFrameTable};
|
use crate::raster::image::{Image, RasterDataTable};
|
||||||
use crate::transform::TransformMut;
|
use crate::transform::TransformMut;
|
||||||
use crate::uuid::NodeId;
|
use crate::uuid::NodeId;
|
||||||
use crate::vector::{VectorData, VectorDataTable};
|
use crate::vector::{VectorData, VectorDataTable};
|
||||||
@@ -124,22 +124,22 @@ impl From<VectorDataTable> for GraphicGroupTable {
|
|||||||
}
|
}
|
||||||
impl From<Image<Color>> for GraphicGroupTable {
|
impl From<Image<Color>> for GraphicGroupTable {
|
||||||
fn from(image: Image<Color>) -> Self {
|
fn from(image: Image<Color>) -> Self {
|
||||||
Self::new(GraphicElement::RasterFrame(RasterFrame::ImageFrame(ImageFrameTable::new(image))))
|
Self::new(GraphicElement::RasterDataType(RasterDataType::RasterData(RasterDataTable::new(image))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<ImageFrameTable<Color>> for GraphicGroupTable {
|
impl From<RasterDataTable<Color>> for GraphicGroupTable {
|
||||||
fn from(image_frame: ImageFrameTable<Color>) -> Self {
|
fn from(image_frame: RasterDataTable<Color>) -> Self {
|
||||||
Self::new(GraphicElement::RasterFrame(RasterFrame::ImageFrame(image_frame)))
|
Self::new(GraphicElement::RasterDataType(RasterDataType::RasterData(image_frame)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<ImageTexture> for GraphicGroupTable {
|
impl From<ImageTexture> for GraphicGroupTable {
|
||||||
fn from(image_texture: ImageTexture) -> Self {
|
fn from(image_texture: ImageTexture) -> Self {
|
||||||
Self::new(GraphicElement::RasterFrame(RasterFrame::TextureFrame(TextureFrameTable::new(image_texture))))
|
Self::new(GraphicElement::RasterDataType(RasterDataType::TextureData(TextureDataTable::new(image_texture))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<TextureFrameTable> for GraphicGroupTable {
|
impl From<TextureDataTable> for GraphicGroupTable {
|
||||||
fn from(texture_frame: TextureFrameTable) -> Self {
|
fn from(texture_frame: TextureDataTable) -> Self {
|
||||||
Self::new(GraphicElement::RasterFrame(RasterFrame::TextureFrame(texture_frame)))
|
Self::new(GraphicElement::RasterDataType(RasterDataType::TextureData(texture_frame)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ pub enum GraphicElement {
|
|||||||
GraphicGroup(GraphicGroupTable),
|
GraphicGroup(GraphicGroupTable),
|
||||||
/// A vector shape, equivalent to the SVG <path> tag: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path
|
/// A vector shape, equivalent to the SVG <path> tag: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path
|
||||||
VectorData(VectorDataTable),
|
VectorData(VectorDataTable),
|
||||||
RasterFrame(RasterFrame),
|
RasterDataType(RasterDataType),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for GraphicElement {
|
impl Default for GraphicElement {
|
||||||
@@ -189,16 +189,16 @@ impl GraphicElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_raster(&self) -> Option<&RasterFrame> {
|
pub fn as_raster(&self) -> Option<&RasterDataType> {
|
||||||
match self {
|
match self {
|
||||||
GraphicElement::RasterFrame(raster) => Some(raster),
|
GraphicElement::RasterDataType(raster) => Some(raster),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_raster_mut(&mut self) -> Option<&mut RasterFrame> {
|
pub fn as_raster_mut(&mut self) -> Option<&mut RasterDataType> {
|
||||||
match self {
|
match self {
|
||||||
GraphicElement::RasterFrame(raster) => Some(raster),
|
GraphicElement::RasterDataType(raster) => Some(raster),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,32 +206,32 @@ impl GraphicElement {
|
|||||||
|
|
||||||
// TODO: Rename to Raster
|
// TODO: Rename to Raster
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, DynAny)]
|
#[derive(Clone, Debug, Hash, PartialEq, DynAny)]
|
||||||
pub enum RasterFrame {
|
pub enum RasterDataType {
|
||||||
/// A CPU-based bitmap image with a finite position and extent, equivalent to the SVG <image> tag: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/image
|
/// A CPU-based bitmap image with a finite position and extent, equivalent to the SVG <image> tag: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/image
|
||||||
// TODO: Rename to ImageTable
|
// TODO: Rename to ImageTable
|
||||||
ImageFrame(ImageFrameTable<Color>),
|
RasterData(RasterDataTable<Color>),
|
||||||
/// A GPU texture with a finite position and extent
|
/// A GPU texture with a finite position and extent
|
||||||
// TODO: Rename to ImageTextureTable
|
// TODO: Rename to ImageTextureTable
|
||||||
TextureFrame(TextureFrameTable),
|
TextureData(TextureDataTable),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> serde::Deserialize<'de> for RasterFrame {
|
impl<'de> serde::Deserialize<'de> for RasterDataType {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
Ok(RasterFrame::ImageFrame(ImageFrameTable::new(Image::deserialize(deserializer)?)))
|
Ok(RasterDataType::RasterData(RasterDataTable::new(Image::deserialize(deserializer)?)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl serde::Serialize for RasterFrame {
|
impl serde::Serialize for RasterDataType {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
RasterFrame::ImageFrame(_) => self.serialize(serializer),
|
RasterDataType::RasterData(_) => self.serialize(serializer),
|
||||||
RasterFrame::TextureFrame(_) => todo!(),
|
RasterDataType::TextureData(_) => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -324,8 +324,8 @@ async fn to_element<Data: Into<GraphicElement> + 'n>(
|
|||||||
#[implementations(
|
#[implementations(
|
||||||
GraphicGroupTable,
|
GraphicGroupTable,
|
||||||
VectorDataTable,
|
VectorDataTable,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
TextureFrameTable,
|
TextureDataTable,
|
||||||
)]
|
)]
|
||||||
data: Data,
|
data: Data,
|
||||||
) -> GraphicElement {
|
) -> GraphicElement {
|
||||||
@@ -338,8 +338,8 @@ async fn to_group<Data: Into<GraphicGroupTable> + 'n>(
|
|||||||
#[implementations(
|
#[implementations(
|
||||||
GraphicGroupTable,
|
GraphicGroupTable,
|
||||||
VectorDataTable,
|
VectorDataTable,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
TextureFrameTable,
|
TextureDataTable,
|
||||||
)]
|
)]
|
||||||
element: Data,
|
element: Data,
|
||||||
) -> GraphicGroupTable {
|
) -> GraphicGroupTable {
|
||||||
@@ -391,8 +391,8 @@ async fn to_artboard<Data: Into<GraphicGroupTable> + 'n>(
|
|||||||
#[implementations(
|
#[implementations(
|
||||||
Context -> GraphicGroupTable,
|
Context -> GraphicGroupTable,
|
||||||
Context -> VectorDataTable,
|
Context -> VectorDataTable,
|
||||||
Context -> ImageFrameTable<Color>,
|
Context -> RasterDataTable<Color>,
|
||||||
Context -> TextureFrameTable,
|
Context -> TextureDataTable,
|
||||||
)]
|
)]
|
||||||
contents: impl Node<Context<'static>, Output = Data>,
|
contents: impl Node<Context<'static>, Output = Data>,
|
||||||
label: String,
|
label: String,
|
||||||
@@ -438,23 +438,23 @@ async fn append_artboard(_ctx: impl Ctx, mut artboards: ArtboardGroupTable, artb
|
|||||||
// TODO: Remove this one
|
// TODO: Remove this one
|
||||||
impl From<Image<Color>> for GraphicElement {
|
impl From<Image<Color>> for GraphicElement {
|
||||||
fn from(image_frame: Image<Color>) -> Self {
|
fn from(image_frame: Image<Color>) -> Self {
|
||||||
GraphicElement::RasterFrame(RasterFrame::ImageFrame(ImageFrameTable::new(image_frame)))
|
GraphicElement::RasterDataType(RasterDataType::RasterData(RasterDataTable::new(image_frame)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<ImageFrameTable<Color>> for GraphicElement {
|
impl From<RasterDataTable<Color>> for GraphicElement {
|
||||||
fn from(image_frame: ImageFrameTable<Color>) -> Self {
|
fn from(image_frame: RasterDataTable<Color>) -> Self {
|
||||||
GraphicElement::RasterFrame(RasterFrame::ImageFrame(image_frame))
|
GraphicElement::RasterDataType(RasterDataType::RasterData(image_frame))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Remove this one
|
// TODO: Remove this one
|
||||||
impl From<ImageTexture> for GraphicElement {
|
impl From<ImageTexture> for GraphicElement {
|
||||||
fn from(texture: ImageTexture) -> Self {
|
fn from(image_texture: ImageTexture) -> Self {
|
||||||
GraphicElement::RasterFrame(RasterFrame::TextureFrame(TextureFrameTable::new(texture)))
|
GraphicElement::RasterDataType(RasterDataType::TextureData(TextureDataTable::new(image_texture)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<TextureFrameTable> for GraphicElement {
|
impl From<TextureDataTable> for GraphicElement {
|
||||||
fn from(texture: TextureFrameTable) -> Self {
|
fn from(texture_data: TextureDataTable) -> Self {
|
||||||
GraphicElement::RasterFrame(RasterFrame::TextureFrame(texture))
|
GraphicElement::RasterDataType(RasterDataType::TextureData(texture_data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Remove this one
|
// TODO: Remove this one
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
mod quad;
|
mod quad;
|
||||||
mod rect;
|
mod rect;
|
||||||
|
|
||||||
use crate::raster::image::ImageFrameTable;
|
use crate::raster::image::RasterDataTable;
|
||||||
use crate::raster::{BlendMode, Image};
|
use crate::raster::{BlendMode, Image};
|
||||||
use crate::transform::{Footprint, Transform};
|
use crate::transform::{Footprint, Transform};
|
||||||
use crate::uuid::{NodeId, generate_uuid};
|
use crate::uuid::{NodeId, generate_uuid};
|
||||||
use crate::vector::style::{Fill, Stroke, ViewMode};
|
use crate::vector::style::{Fill, Stroke, ViewMode};
|
||||||
use crate::vector::{PointId, VectorDataTable};
|
use crate::vector::{PointId, VectorDataTable};
|
||||||
use crate::{Artboard, ArtboardGroupTable, Color, GraphicElement, GraphicGroupTable, RasterFrame};
|
use crate::{Artboard, ArtboardGroupTable, Color, GraphicElement, GraphicGroupTable, RasterDataType};
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use bezier_rs::Subpath;
|
use bezier_rs::Subpath;
|
||||||
use dyn_any::DynAny;
|
use dyn_any::DynAny;
|
||||||
@@ -843,7 +843,7 @@ impl GraphicElementRendered for ArtboardGroupTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GraphicElementRendered for ImageFrameTable<Color> {
|
impl GraphicElementRendered for RasterDataTable<Color> {
|
||||||
fn render_svg(&self, render: &mut SvgRender, _render_params: &RenderParams) {
|
fn render_svg(&self, render: &mut SvgRender, _render_params: &RenderParams) {
|
||||||
for instance in self.instance_ref_iter() {
|
for instance in self.instance_ref_iter() {
|
||||||
let transform = *instance.transform * render.transform;
|
let transform = *instance.transform * render.transform;
|
||||||
@@ -923,11 +923,11 @@ impl GraphicElementRendered for ImageFrameTable<Color> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GraphicElementRendered for RasterFrame {
|
impl GraphicElementRendered for RasterDataType {
|
||||||
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
|
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
|
||||||
match self {
|
match self {
|
||||||
RasterFrame::ImageFrame(image) => image.render_svg(render, render_params),
|
RasterDataType::RasterData(image) => image.render_svg(render, render_params),
|
||||||
RasterFrame::TextureFrame(_) => log::warn!("tried to render texture as an svg"),
|
RasterDataType::TextureData(_) => log::warn!("tried to render texture as an svg"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -953,7 +953,7 @@ impl GraphicElementRendered for RasterFrame {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
RasterFrame::ImageFrame(image) => {
|
RasterDataType::RasterData(image) => {
|
||||||
for instance in image.instance_ref_iter() {
|
for instance in image.instance_ref_iter() {
|
||||||
let image = &instance.instance;
|
let image = &instance.instance;
|
||||||
if image.data.is_empty() {
|
if image.data.is_empty() {
|
||||||
@@ -965,7 +965,7 @@ impl GraphicElementRendered for RasterFrame {
|
|||||||
render_stuff(image, *instance.transform, *instance.alpha_blending);
|
render_stuff(image, *instance.transform, *instance.alpha_blending);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RasterFrame::TextureFrame(image_texture) => {
|
RasterDataType::TextureData(image_texture) => {
|
||||||
for instance in image_texture.instance_ref_iter() {
|
for instance in image_texture.instance_ref_iter() {
|
||||||
let image =
|
let image =
|
||||||
vello::peniko::Image::new(vec![].into(), peniko::Format::Rgba8, instance.instance.texture.width(), instance.instance.texture.height()).with_extend(peniko::Extend::Repeat);
|
vello::peniko::Image::new(vec![].into(), peniko::Format::Rgba8, instance.instance.texture.width(), instance.instance.texture.height()).with_extend(peniko::Extend::Repeat);
|
||||||
@@ -986,8 +986,8 @@ impl GraphicElementRendered for RasterFrame {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
RasterFrame::ImageFrame(instances) => instances.instance_ref_iter().flat_map(|instance| calculate_transform(*instance.transform)).reduce(Quad::combine_bounds),
|
RasterDataType::RasterData(instances) => instances.instance_ref_iter().flat_map(|instance| calculate_transform(*instance.transform)).reduce(Quad::combine_bounds),
|
||||||
RasterFrame::TextureFrame(instances) => instances.instance_ref_iter().flat_map(|instance| calculate_transform(*instance.transform)).reduce(Quad::combine_bounds),
|
RasterDataType::TextureData(instances) => instances.instance_ref_iter().flat_map(|instance| calculate_transform(*instance.transform)).reduce(Quad::combine_bounds),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -999,13 +999,13 @@ impl GraphicElementRendered for RasterFrame {
|
|||||||
metadata.upstream_footprints.insert(element_id, footprint);
|
metadata.upstream_footprints.insert(element_id, footprint);
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
RasterFrame::ImageFrame(instances) => {
|
RasterDataType::RasterData(instances) => {
|
||||||
// TODO: Find a way to handle more than one row of the graphical data table
|
// TODO: Find a way to handle more than one row of the graphical data table
|
||||||
if let Some(image) = instances.instance_ref_iter().next() {
|
if let Some(image) = instances.instance_ref_iter().next() {
|
||||||
metadata.local_transforms.insert(element_id, *image.transform);
|
metadata.local_transforms.insert(element_id, *image.transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RasterFrame::TextureFrame(instances) => {
|
RasterDataType::TextureData(instances) => {
|
||||||
// TODO: Find a way to handle more than one row of the graphical data table
|
// TODO: Find a way to handle more than one row of the graphical data table
|
||||||
if let Some(image_texture) = instances.instance_ref_iter().next() {
|
if let Some(image_texture) = instances.instance_ref_iter().next() {
|
||||||
metadata.local_transforms.insert(element_id, *image_texture.transform);
|
metadata.local_transforms.insert(element_id, *image_texture.transform);
|
||||||
@@ -1024,7 +1024,7 @@ impl GraphicElementRendered for GraphicElement {
|
|||||||
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
|
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
|
||||||
match self {
|
match self {
|
||||||
GraphicElement::VectorData(vector_data) => vector_data.render_svg(render, render_params),
|
GraphicElement::VectorData(vector_data) => vector_data.render_svg(render, render_params),
|
||||||
GraphicElement::RasterFrame(raster) => raster.render_svg(render, render_params),
|
GraphicElement::RasterDataType(raster) => raster.render_svg(render, render_params),
|
||||||
GraphicElement::GraphicGroup(graphic_group) => graphic_group.render_svg(render, render_params),
|
GraphicElement::GraphicGroup(graphic_group) => graphic_group.render_svg(render, render_params),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1034,14 +1034,14 @@ impl GraphicElementRendered for GraphicElement {
|
|||||||
match self {
|
match self {
|
||||||
GraphicElement::VectorData(vector_data) => vector_data.render_to_vello(scene, transform, context, render_params),
|
GraphicElement::VectorData(vector_data) => vector_data.render_to_vello(scene, transform, context, render_params),
|
||||||
GraphicElement::GraphicGroup(graphic_group) => graphic_group.render_to_vello(scene, transform, context, render_params),
|
GraphicElement::GraphicGroup(graphic_group) => graphic_group.render_to_vello(scene, transform, context, render_params),
|
||||||
GraphicElement::RasterFrame(raster) => raster.render_to_vello(scene, transform, context, render_params),
|
GraphicElement::RasterDataType(raster) => raster.render_to_vello(scene, transform, context, render_params),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> Option<[DVec2; 2]> {
|
fn bounding_box(&self, transform: DAffine2, include_stroke: bool) -> Option<[DVec2; 2]> {
|
||||||
match self {
|
match self {
|
||||||
GraphicElement::VectorData(vector_data) => vector_data.bounding_box(transform, include_stroke),
|
GraphicElement::VectorData(vector_data) => vector_data.bounding_box(transform, include_stroke),
|
||||||
GraphicElement::RasterFrame(raster) => raster.bounding_box(transform, include_stroke),
|
GraphicElement::RasterDataType(raster) => raster.bounding_box(transform, include_stroke),
|
||||||
GraphicElement::GraphicGroup(graphic_group) => graphic_group.bounding_box(transform, include_stroke),
|
GraphicElement::GraphicGroup(graphic_group) => graphic_group.bounding_box(transform, include_stroke),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1059,16 +1059,16 @@ impl GraphicElementRendered for GraphicElement {
|
|||||||
metadata.local_transforms.insert(element_id, *vector_data.transform);
|
metadata.local_transforms.insert(element_id, *vector_data.transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GraphicElement::RasterFrame(raster_frame) => {
|
GraphicElement::RasterDataType(raster_frame) => {
|
||||||
metadata.upstream_footprints.insert(element_id, footprint);
|
metadata.upstream_footprints.insert(element_id, footprint);
|
||||||
match raster_frame {
|
match raster_frame {
|
||||||
RasterFrame::ImageFrame(instances) => {
|
RasterDataType::RasterData(instances) => {
|
||||||
// TODO: Find a way to handle more than one row of images
|
// TODO: Find a way to handle more than one row of images
|
||||||
if let Some(image) = instances.instance_ref_iter().next() {
|
if let Some(image) = instances.instance_ref_iter().next() {
|
||||||
metadata.local_transforms.insert(element_id, *image.transform);
|
metadata.local_transforms.insert(element_id, *image.transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RasterFrame::TextureFrame(instances) => {
|
RasterDataType::TextureData(instances) => {
|
||||||
// TODO: Find a way to handle more than one row of image textures
|
// TODO: Find a way to handle more than one row of image textures
|
||||||
if let Some(image_texture) = instances.instance_ref_iter().next() {
|
if let Some(image_texture) = instances.instance_ref_iter().next() {
|
||||||
metadata.local_transforms.insert(element_id, *image_texture.transform);
|
metadata.local_transforms.insert(element_id, *image_texture.transform);
|
||||||
@@ -1081,7 +1081,7 @@ impl GraphicElementRendered for GraphicElement {
|
|||||||
|
|
||||||
match self {
|
match self {
|
||||||
GraphicElement::VectorData(vector_data) => vector_data.collect_metadata(metadata, footprint, element_id),
|
GraphicElement::VectorData(vector_data) => vector_data.collect_metadata(metadata, footprint, element_id),
|
||||||
GraphicElement::RasterFrame(raster) => raster.collect_metadata(metadata, footprint, element_id),
|
GraphicElement::RasterDataType(raster) => raster.collect_metadata(metadata, footprint, element_id),
|
||||||
GraphicElement::GraphicGroup(graphic_group) => graphic_group.collect_metadata(metadata, footprint, element_id),
|
GraphicElement::GraphicGroup(graphic_group) => graphic_group.collect_metadata(metadata, footprint, element_id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1089,7 +1089,7 @@ impl GraphicElementRendered for GraphicElement {
|
|||||||
fn add_upstream_click_targets(&self, click_targets: &mut Vec<ClickTarget>) {
|
fn add_upstream_click_targets(&self, click_targets: &mut Vec<ClickTarget>) {
|
||||||
match self {
|
match self {
|
||||||
GraphicElement::VectorData(vector_data) => vector_data.add_upstream_click_targets(click_targets),
|
GraphicElement::VectorData(vector_data) => vector_data.add_upstream_click_targets(click_targets),
|
||||||
GraphicElement::RasterFrame(raster) => raster.add_upstream_click_targets(click_targets),
|
GraphicElement::RasterDataType(raster) => raster.add_upstream_click_targets(click_targets),
|
||||||
GraphicElement::GraphicGroup(graphic_group) => graphic_group.add_upstream_click_targets(click_targets),
|
GraphicElement::GraphicGroup(graphic_group) => graphic_group.add_upstream_click_targets(click_targets),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1098,7 +1098,7 @@ impl GraphicElementRendered for GraphicElement {
|
|||||||
match self {
|
match self {
|
||||||
GraphicElement::VectorData(vector_data) => vector_data.contains_artboard(),
|
GraphicElement::VectorData(vector_data) => vector_data.contains_artboard(),
|
||||||
GraphicElement::GraphicGroup(graphic_group) => graphic_group.contains_artboard(),
|
GraphicElement::GraphicGroup(graphic_group) => graphic_group.contains_artboard(),
|
||||||
GraphicElement::RasterFrame(raster) => raster.contains_artboard(),
|
GraphicElement::RasterDataType(raster) => raster.contains_artboard(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1106,7 +1106,7 @@ impl GraphicElementRendered for GraphicElement {
|
|||||||
match self {
|
match self {
|
||||||
GraphicElement::VectorData(vector_data) => vector_data.new_ids_from_hash(reference),
|
GraphicElement::VectorData(vector_data) => vector_data.new_ids_from_hash(reference),
|
||||||
GraphicElement::GraphicGroup(graphic_group) => graphic_group.new_ids_from_hash(reference),
|
GraphicElement::GraphicGroup(graphic_group) => graphic_group.new_ids_from_hash(reference),
|
||||||
GraphicElement::RasterFrame(_) => (),
|
GraphicElement::RasterDataType(_) => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::Ctx;
|
use crate::Ctx;
|
||||||
use crate::raster::BlendMode;
|
use crate::raster::BlendMode;
|
||||||
use crate::raster::image::ImageFrameTable;
|
use crate::raster::image::RasterDataTable;
|
||||||
use crate::registry::types::{Fraction, Percentage};
|
use crate::registry::types::{Fraction, Percentage};
|
||||||
use crate::vector::style::GradientStops;
|
use crate::vector::style::GradientStops;
|
||||||
use crate::{Color, Node};
|
use crate::{Color, Node};
|
||||||
@@ -453,7 +453,7 @@ fn color_value(_: impl Ctx, _primary: (), #[default(Color::BLACK)] color: Option
|
|||||||
// _: impl Ctx,
|
// _: impl Ctx,
|
||||||
// #[implementations(
|
// #[implementations(
|
||||||
// Color,
|
// Color,
|
||||||
// ImageFrameTable<Color>,
|
// RasterDataTable<Color>,
|
||||||
// GradientStops,
|
// GradientStops,
|
||||||
// )]
|
// )]
|
||||||
// mut image: T,
|
// mut image: T,
|
||||||
@@ -515,7 +515,7 @@ fn unwrap<T: Default>(_: impl Ctx, #[implementations(Option<f64>, Option<f32>, O
|
|||||||
|
|
||||||
/// Meant for debugging purposes, not general use. Clones the input value.
|
/// Meant for debugging purposes, not general use. Clones the input value.
|
||||||
#[node_macro::node(category("Debug"))]
|
#[node_macro::node(category("Debug"))]
|
||||||
fn clone<'i, T: Clone + 'i>(_: impl Ctx, #[implementations(&ImageFrameTable<Color>)] value: &'i T) -> T {
|
fn clone<'i, T: Clone + 'i>(_: impl Ctx, #[implementations(&RasterDataTable<Color>)] value: &'i T) -> T {
|
||||||
value.clone()
|
value.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
pub use self::color::{Color, Luma, SRGBA8};
|
pub use self::color::{Color, Luma, SRGBA8};
|
||||||
use crate::Ctx;
|
use crate::Ctx;
|
||||||
use crate::GraphicGroupTable;
|
use crate::GraphicGroupTable;
|
||||||
use crate::raster::image::ImageFrameTable;
|
use crate::raster::image::RasterDataTable;
|
||||||
use crate::registry::types::Percentage;
|
use crate::registry::types::Percentage;
|
||||||
use crate::vector::VectorDataTable;
|
use crate::vector::VectorDataTable;
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
@@ -310,7 +310,7 @@ impl SetBlendMode for GraphicGroupTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl SetBlendMode for ImageFrameTable<Color> {
|
impl SetBlendMode for RasterDataTable<Color> {
|
||||||
fn set_blend_mode(&mut self, blend_mode: BlendMode) {
|
fn set_blend_mode(&mut self, blend_mode: BlendMode) {
|
||||||
for instance in self.instance_mut_iter() {
|
for instance in self.instance_mut_iter() {
|
||||||
instance.alpha_blending.blend_mode = blend_mode;
|
instance.alpha_blending.blend_mode = blend_mode;
|
||||||
@@ -324,7 +324,7 @@ fn blend_mode<T: SetBlendMode>(
|
|||||||
#[implementations(
|
#[implementations(
|
||||||
GraphicGroupTable,
|
GraphicGroupTable,
|
||||||
VectorDataTable,
|
VectorDataTable,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
)]
|
)]
|
||||||
mut value: T,
|
mut value: T,
|
||||||
blend_mode: BlendMode,
|
blend_mode: BlendMode,
|
||||||
@@ -340,7 +340,7 @@ fn opacity<T: MultiplyAlpha>(
|
|||||||
#[implementations(
|
#[implementations(
|
||||||
GraphicGroupTable,
|
GraphicGroupTable,
|
||||||
VectorDataTable,
|
VectorDataTable,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
)]
|
)]
|
||||||
mut value: T,
|
mut value: T,
|
||||||
#[default(100.)] factor: Percentage,
|
#[default(100.)] factor: Percentage,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use crate::raster::curve::{CubicSplines, CurveManipulatorGroup};
|
|||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
use crate::raster::curve::{Curve, ValueMapperNode};
|
use crate::raster::curve::{Curve, ValueMapperNode};
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
use crate::raster::image::{Image, ImageFrameTable};
|
use crate::raster::image::{Image, RasterDataTable};
|
||||||
use crate::raster::{Channel, Color, Pixel};
|
use crate::raster::{Channel, Color, Pixel};
|
||||||
use crate::registry::types::{Angle, Percentage, SignedPercentage};
|
use crate::registry::types::{Angle, Percentage, SignedPercentage};
|
||||||
use crate::vector::VectorDataTable;
|
use crate::vector::VectorDataTable;
|
||||||
@@ -265,7 +265,7 @@ fn luminance<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut input: T,
|
mut input: T,
|
||||||
@@ -289,7 +289,7 @@ fn extract_channel<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut input: T,
|
mut input: T,
|
||||||
@@ -312,7 +312,7 @@ fn make_opaque<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut input: T,
|
mut input: T,
|
||||||
@@ -337,7 +337,7 @@ fn brightness_contrast<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut input: T,
|
mut input: T,
|
||||||
@@ -426,7 +426,7 @@ fn levels<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut image: T,
|
mut image: T,
|
||||||
@@ -493,7 +493,7 @@ async fn black_and_white<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut image: T,
|
mut image: T,
|
||||||
@@ -565,7 +565,7 @@ async fn hue_saturation<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut input: T,
|
mut input: T,
|
||||||
@@ -599,7 +599,7 @@ async fn invert<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut input: T,
|
mut input: T,
|
||||||
@@ -621,7 +621,7 @@ async fn threshold<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut image: T,
|
mut image: T,
|
||||||
@@ -663,7 +663,7 @@ impl Blend<Color> for Option<Color> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Blend<Color> for ImageFrameTable<Color> {
|
impl Blend<Color> for RasterDataTable<Color> {
|
||||||
fn blend(&self, under: &Self, blend_fn: impl Fn(Color, Color) -> Color) -> Self {
|
fn blend(&self, under: &Self, blend_fn: impl Fn(Color, Color) -> Color) -> Self {
|
||||||
let mut result_table = self.clone();
|
let mut result_table = self.clone();
|
||||||
|
|
||||||
@@ -706,14 +706,14 @@ async fn blend<T: Blend<Color> + Send>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
over: T,
|
over: T,
|
||||||
#[expose]
|
#[expose]
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
under: T,
|
under: T,
|
||||||
@@ -795,7 +795,7 @@ impl Adjust<Color> for GradientStops {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<P: Pixel> Adjust<P> for ImageFrameTable<P>
|
impl<P: Pixel> Adjust<P> for RasterDataTable<P>
|
||||||
where
|
where
|
||||||
GraphicElement: From<Image<P>>,
|
GraphicElement: From<Image<P>>,
|
||||||
{
|
{
|
||||||
@@ -829,7 +829,7 @@ async fn gradient_map<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut image: T,
|
mut image: T,
|
||||||
@@ -865,7 +865,7 @@ async fn vibrance<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut image: T,
|
mut image: T,
|
||||||
@@ -1037,7 +1037,7 @@ async fn channel_mixer<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut image: T,
|
mut image: T,
|
||||||
@@ -1166,7 +1166,7 @@ async fn selective_color<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut image: T,
|
mut image: T,
|
||||||
@@ -1309,7 +1309,7 @@ impl MultiplyAlpha for GraphicGroupTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<P: Pixel> MultiplyAlpha for ImageFrameTable<P>
|
impl<P: Pixel> MultiplyAlpha for RasterDataTable<P>
|
||||||
where
|
where
|
||||||
GraphicElement: From<Image<P>>,
|
GraphicElement: From<Image<P>>,
|
||||||
{
|
{
|
||||||
@@ -1331,7 +1331,7 @@ async fn posterize<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut input: T,
|
mut input: T,
|
||||||
@@ -1364,7 +1364,7 @@ async fn exposure<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut input: T,
|
mut input: T,
|
||||||
@@ -1438,7 +1438,7 @@ fn color_overlay<T: Adjust<Color>>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Color,
|
Color,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GradientStops,
|
GradientStops,
|
||||||
)]
|
)]
|
||||||
mut image: T,
|
mut image: T,
|
||||||
@@ -1488,7 +1488,7 @@ fn color_overlay<T: Adjust<Color>>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::raster::adjustments::BlendMode;
|
use crate::raster::adjustments::BlendMode;
|
||||||
use crate::raster::image::{Image, ImageFrameTable};
|
use crate::raster::image::{Image, RasterDataTable};
|
||||||
use crate::{Color, Node};
|
use crate::{Color, Node};
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
|
||||||
@@ -1514,7 +1514,7 @@ mod test {
|
|||||||
// 100% of the output should come from the multiplied value
|
// 100% of the output should come from the multiplied value
|
||||||
let opacity = 100_f64;
|
let opacity = 100_f64;
|
||||||
|
|
||||||
let result = super::color_overlay((), ImageFrameTable::new(image.clone()), overlay_color, BlendMode::Multiply, opacity);
|
let result = super::color_overlay((), RasterDataTable::new(image.clone()), overlay_color, BlendMode::Multiply, opacity);
|
||||||
let result = result.instance_ref_iter().next().unwrap().instance;
|
let result = result.instance_ref_iter().next().unwrap().instance;
|
||||||
|
|
||||||
// The output should just be the original green and alpha channels (as we multiply them by 1 and other channels by 0)
|
// The output should just be the original green and alpha channels (as we multiply them by 1 and other channels by 0)
|
||||||
|
|||||||
@@ -16,19 +16,13 @@ mod base64_serde {
|
|||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
pub fn as_base64<S, P: Pixel>(key: &[P], serializer: S) -> Result<S::Ok, S::Error>
|
pub fn as_base64<S: Serializer, P: Pixel>(key: &[P], serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
let u8_data = bytemuck::cast_slice(key);
|
let u8_data = bytemuck::cast_slice(key);
|
||||||
let string = base64::engine::general_purpose::STANDARD.encode(u8_data);
|
let string = base64::engine::general_purpose::STANDARD.encode(u8_data);
|
||||||
(key.len() as u64, string).serialize(serializer)
|
(key.len() as u64, string).serialize(serializer)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_base64<'a, D, P: Pixel>(deserializer: D) -> Result<Vec<P>, D::Error>
|
pub fn from_base64<'a, D: Deserializer<'a>, P: Pixel>(deserializer: D) -> Result<Vec<P>, D::Error> {
|
||||||
where
|
|
||||||
D: Deserializer<'a>,
|
|
||||||
{
|
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
<(u64, &[u8])>::deserialize(deserializer)
|
<(u64, &[u8])>::deserialize(deserializer)
|
||||||
.and_then(|(len, str)| {
|
.and_then(|(len, str)| {
|
||||||
@@ -214,7 +208,7 @@ impl<P: Pixel> IntoIterator for Image<P> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Eventually remove this migration document upgrade code
|
// TODO: Eventually remove this migration document upgrade code
|
||||||
pub fn migrate_image_frame<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<ImageFrameTable<Color>, D::Error> {
|
pub fn migrate_image_frame<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<RasterDataTable<Color>, D::Error> {
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Clone, Default, Debug, PartialEq, specta::Type)]
|
#[derive(Clone, Default, Debug, PartialEq, specta::Type)]
|
||||||
@@ -224,13 +218,13 @@ pub fn migrate_image_frame<'de, D: serde::Deserializer<'de>>(deserializer: D) ->
|
|||||||
}
|
}
|
||||||
impl From<ImageFrame<Color>> for GraphicElement {
|
impl From<ImageFrame<Color>> for GraphicElement {
|
||||||
fn from(image_frame: ImageFrame<Color>) -> Self {
|
fn from(image_frame: ImageFrame<Color>) -> Self {
|
||||||
GraphicElement::RasterFrame(crate::RasterFrame::ImageFrame(ImageFrameTable::new(image_frame.image)))
|
GraphicElement::RasterDataType(crate::RasterDataType::RasterData(RasterDataTable::new(image_frame.image)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<GraphicElement> for ImageFrame<Color> {
|
impl From<GraphicElement> for ImageFrame<Color> {
|
||||||
fn from(element: GraphicElement) -> Self {
|
fn from(element: GraphicElement) -> Self {
|
||||||
match element {
|
match element {
|
||||||
GraphicElement::RasterFrame(crate::RasterFrame::ImageFrame(image)) => Self {
|
GraphicElement::RasterDataType(crate::RasterDataType::RasterData(image)) => Self {
|
||||||
image: image.instance_ref_iter().next().unwrap().instance.clone(),
|
image: image.instance_ref_iter().next().unwrap().instance.clone(),
|
||||||
},
|
},
|
||||||
_ => panic!("Expected Image, found {:?}", element),
|
_ => panic!("Expected Image, found {:?}", element),
|
||||||
@@ -261,20 +255,20 @@ pub fn migrate_image_frame<'de, D: serde::Deserializer<'de>>(deserializer: D) ->
|
|||||||
Image(Image<Color>),
|
Image(Image<Color>),
|
||||||
OldImageFrame(OldImageFrame<Color>),
|
OldImageFrame(OldImageFrame<Color>),
|
||||||
ImageFrame(Instances<ImageFrame<Color>>),
|
ImageFrame(Instances<ImageFrame<Color>>),
|
||||||
ImageFrameTable(ImageFrameTable<Color>),
|
RasterDataTable(RasterDataTable<Color>),
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(match FormatVersions::deserialize(deserializer)? {
|
Ok(match FormatVersions::deserialize(deserializer)? {
|
||||||
FormatVersions::Image(image) => ImageFrameTable::new(image),
|
FormatVersions::Image(image) => RasterDataTable::new(image),
|
||||||
FormatVersions::OldImageFrame(image_frame_with_transform_and_blending) => {
|
FormatVersions::OldImageFrame(image_frame_with_transform_and_blending) => {
|
||||||
let OldImageFrame { image, transform, alpha_blending } = image_frame_with_transform_and_blending;
|
let OldImageFrame { image, transform, alpha_blending } = image_frame_with_transform_and_blending;
|
||||||
let mut image_frame_table = ImageFrameTable::new(image);
|
let mut image_frame_table = RasterDataTable::new(image);
|
||||||
*image_frame_table.instance_mut_iter().next().unwrap().transform = transform;
|
*image_frame_table.instance_mut_iter().next().unwrap().transform = transform;
|
||||||
*image_frame_table.instance_mut_iter().next().unwrap().alpha_blending = alpha_blending;
|
*image_frame_table.instance_mut_iter().next().unwrap().alpha_blending = alpha_blending;
|
||||||
image_frame_table
|
image_frame_table
|
||||||
}
|
}
|
||||||
FormatVersions::ImageFrame(image_frame) => ImageFrameTable::new(image_frame.instance_ref_iter().next().unwrap().instance.image.clone()),
|
FormatVersions::ImageFrame(image_frame) => RasterDataTable::new(image_frame.instance_ref_iter().next().unwrap().instance.image.clone()),
|
||||||
FormatVersions::ImageFrameTable(image_frame_table) => image_frame_table,
|
FormatVersions::RasterDataTable(image_frame_table) => image_frame_table,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,13 +283,13 @@ pub fn migrate_image_frame_instance<'de, D: serde::Deserializer<'de>>(deserializ
|
|||||||
}
|
}
|
||||||
impl From<ImageFrame<Color>> for GraphicElement {
|
impl From<ImageFrame<Color>> for GraphicElement {
|
||||||
fn from(image_frame: ImageFrame<Color>) -> Self {
|
fn from(image_frame: ImageFrame<Color>) -> Self {
|
||||||
GraphicElement::RasterFrame(crate::RasterFrame::ImageFrame(ImageFrameTable::new(image_frame.image)))
|
GraphicElement::RasterDataType(crate::RasterDataType::RasterData(RasterDataTable::new(image_frame.image)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<GraphicElement> for ImageFrame<Color> {
|
impl From<GraphicElement> for ImageFrame<Color> {
|
||||||
fn from(element: GraphicElement) -> Self {
|
fn from(element: GraphicElement) -> Self {
|
||||||
match element {
|
match element {
|
||||||
GraphicElement::RasterFrame(crate::RasterFrame::ImageFrame(image)) => Self {
|
GraphicElement::RasterDataType(crate::RasterDataType::RasterData(image)) => Self {
|
||||||
image: image.instance_ref_iter().next().unwrap().instance.clone(),
|
image: image.instance_ref_iter().next().unwrap().instance.clone(),
|
||||||
},
|
},
|
||||||
_ => panic!("Expected Image, found {:?}", element),
|
_ => panic!("Expected Image, found {:?}", element),
|
||||||
@@ -326,7 +320,7 @@ pub fn migrate_image_frame_instance<'de, D: serde::Deserializer<'de>>(deserializ
|
|||||||
Image(Image<Color>),
|
Image(Image<Color>),
|
||||||
OldImageFrame(OldImageFrame<Color>),
|
OldImageFrame(OldImageFrame<Color>),
|
||||||
ImageFrame(Instances<ImageFrame<Color>>),
|
ImageFrame(Instances<ImageFrame<Color>>),
|
||||||
ImageFrameTable(ImageFrameTable<Color>),
|
RasterDataTable(RasterDataTable<Color>),
|
||||||
ImageInstance(Instance<Image<Color>>),
|
ImageInstance(Instance<Image<Color>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,13 +339,13 @@ pub fn migrate_image_frame_instance<'de, D: serde::Deserializer<'de>>(deserializ
|
|||||||
instance: image_frame.instance_ref_iter().next().unwrap().instance.image.clone(),
|
instance: image_frame.instance_ref_iter().next().unwrap().instance.image.clone(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
FormatVersions::ImageFrameTable(image_frame_table) => image_frame_table.instance_iter().next().unwrap_or_default(),
|
FormatVersions::RasterDataTable(image_frame_table) => image_frame_table.instance_iter().next().unwrap_or_default(),
|
||||||
FormatVersions::ImageInstance(image_instance) => image_instance,
|
FormatVersions::ImageInstance(image_instance) => image_instance,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Rename to ImageTable
|
// TODO: Rename to ImageTable
|
||||||
pub type ImageFrameTable<P> = Instances<Image<P>>;
|
pub type RasterDataTable<P> = Instances<Image<P>>;
|
||||||
|
|
||||||
impl<P: Debug + Copy + Pixel> Sample for Image<P> {
|
impl<P: Debug + Copy + Pixel> Sample for Image<P> {
|
||||||
type Pixel = P;
|
type Pixel = P;
|
||||||
@@ -399,9 +393,9 @@ impl From<Image<Color>> for Image<SRGBA8> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ImageFrameTable<Color>> for ImageFrameTable<SRGBA8> {
|
impl From<RasterDataTable<Color>> for RasterDataTable<SRGBA8> {
|
||||||
fn from(image_frame_table: ImageFrameTable<Color>) -> Self {
|
fn from(image_frame_table: RasterDataTable<Color>) -> Self {
|
||||||
let mut result_table = ImageFrameTable::<SRGBA8>::default();
|
let mut result_table = RasterDataTable::<SRGBA8>::default();
|
||||||
|
|
||||||
for image_frame_instance in image_frame_table.instance_iter() {
|
for image_frame_instance in image_frame_table.instance_iter() {
|
||||||
result_table.push(Instance {
|
result_table.push(Instance {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::application_io::TextureFrameTable;
|
use crate::application_io::TextureDataTable;
|
||||||
use crate::instances::Instances;
|
use crate::instances::Instances;
|
||||||
use crate::raster::bbox::AxisAlignedBbox;
|
use crate::raster::bbox::AxisAlignedBbox;
|
||||||
use crate::raster::image::ImageFrameTable;
|
use crate::raster::image::RasterDataTable;
|
||||||
use crate::vector::VectorDataTable;
|
use crate::vector::VectorDataTable;
|
||||||
use crate::{Artboard, CloneVarArgs, Color, Context, Ctx, ExtractAll, GraphicGroupTable, OwnedContextImpl};
|
use crate::{Artboard, CloneVarArgs, Color, Context, Ctx, ExtractAll, GraphicGroupTable, OwnedContextImpl};
|
||||||
use core::f64;
|
use core::f64;
|
||||||
@@ -162,8 +162,8 @@ async fn transform<T: 'n + 'static>(
|
|||||||
#[implementations(
|
#[implementations(
|
||||||
Context -> VectorDataTable,
|
Context -> VectorDataTable,
|
||||||
Context -> GraphicGroupTable,
|
Context -> GraphicGroupTable,
|
||||||
Context -> ImageFrameTable<Color>,
|
Context -> RasterDataTable<Color>,
|
||||||
Context -> TextureFrameTable,
|
Context -> TextureDataTable,
|
||||||
)]
|
)]
|
||||||
transform_target: impl Node<Context<'static>, Output = Instances<T>>,
|
transform_target: impl Node<Context<'static>, Output = Instances<T>>,
|
||||||
translate: DVec2,
|
translate: DVec2,
|
||||||
@@ -194,7 +194,7 @@ async fn transform<T: 'n + 'static>(
|
|||||||
#[node_macro::node(category(""))]
|
#[node_macro::node(category(""))]
|
||||||
fn replace_transform<Data, TransformInput: Transform>(
|
fn replace_transform<Data, TransformInput: Transform>(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(VectorDataTable, ImageFrameTable<Color>, GraphicGroupTable)] mut data: Instances<Data>,
|
#[implementations(VectorDataTable, RasterDataTable<Color>, GraphicGroupTable)] mut data: Instances<Data>,
|
||||||
#[implementations(DAffine2)] transform: TransformInput,
|
#[implementations(DAffine2)] transform: TransformInput,
|
||||||
) -> Instances<Data> {
|
) -> Instances<Data> {
|
||||||
for data_transform in data.instance_mut_iter() {
|
for data_transform in data.instance_mut_iter() {
|
||||||
@@ -209,8 +209,8 @@ async fn boundless_footprint<T: 'n + 'static>(
|
|||||||
#[implementations(
|
#[implementations(
|
||||||
Context -> VectorDataTable,
|
Context -> VectorDataTable,
|
||||||
Context -> GraphicGroupTable,
|
Context -> GraphicGroupTable,
|
||||||
Context -> ImageFrameTable<Color>,
|
Context -> RasterDataTable<Color>,
|
||||||
Context -> TextureFrameTable,
|
Context -> TextureDataTable,
|
||||||
Context -> String,
|
Context -> String,
|
||||||
Context -> f64,
|
Context -> f64,
|
||||||
)]
|
)]
|
||||||
@@ -226,8 +226,8 @@ async fn freeze_real_time<T: 'n + 'static>(
|
|||||||
#[implementations(
|
#[implementations(
|
||||||
Context -> VectorDataTable,
|
Context -> VectorDataTable,
|
||||||
Context -> GraphicGroupTable,
|
Context -> GraphicGroupTable,
|
||||||
Context -> ImageFrameTable<Color>,
|
Context -> RasterDataTable<Color>,
|
||||||
Context -> TextureFrameTable,
|
Context -> TextureDataTable,
|
||||||
Context -> String,
|
Context -> String,
|
||||||
Context -> f64,
|
Context -> f64,
|
||||||
)]
|
)]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::instances::{InstanceRef, Instances};
|
use crate::instances::{InstanceRef, Instances};
|
||||||
use crate::raster::Color;
|
use crate::raster::Color;
|
||||||
use crate::raster::image::ImageFrameTable;
|
use crate::raster::image::RasterDataTable;
|
||||||
use crate::transform::TransformMut;
|
use crate::transform::TransformMut;
|
||||||
use crate::vector::VectorDataTable;
|
use crate::vector::VectorDataTable;
|
||||||
use crate::{CloneVarArgs, Context, Ctx, ExtractAll, ExtractIndex, ExtractVarArgs, GraphicElement, GraphicGroupTable, OwnedContextImpl};
|
use crate::{CloneVarArgs, Context, Ctx, ExtractAll, ExtractIndex, ExtractVarArgs, GraphicElement, GraphicGroupTable, OwnedContextImpl};
|
||||||
@@ -10,7 +10,7 @@ use glam::DVec2;
|
|||||||
async fn instance_on_points<T: Into<GraphicElement> + Default + Clone + 'static>(
|
async fn instance_on_points<T: Into<GraphicElement> + Default + Clone + 'static>(
|
||||||
ctx: impl ExtractAll + CloneVarArgs + Sync + Ctx,
|
ctx: impl ExtractAll + CloneVarArgs + Sync + Ctx,
|
||||||
points: VectorDataTable,
|
points: VectorDataTable,
|
||||||
#[implementations(Context -> GraphicGroupTable, Context -> VectorDataTable, Context -> ImageFrameTable<Color>)] instance: impl Node<'n, Context<'static>, Output = Instances<T>>,
|
#[implementations(Context -> GraphicGroupTable, Context -> VectorDataTable, Context -> RasterDataTable<Color>)] instance: impl Node<'n, Context<'static>, Output = Instances<T>>,
|
||||||
reverse: bool,
|
reverse: bool,
|
||||||
) -> GraphicGroupTable {
|
) -> GraphicGroupTable {
|
||||||
let mut result_table = GraphicGroupTable::default();
|
let mut result_table = GraphicGroupTable::default();
|
||||||
@@ -46,7 +46,7 @@ async fn instance_on_points<T: Into<GraphicElement> + Default + Clone + 'static>
|
|||||||
#[node_macro::node(category("Instancing"), path(graphene_core::vector))]
|
#[node_macro::node(category("Instancing"), path(graphene_core::vector))]
|
||||||
async fn instance_repeat<T: Into<GraphicElement> + Default + Clone + 'static>(
|
async fn instance_repeat<T: Into<GraphicElement> + Default + Clone + 'static>(
|
||||||
ctx: impl ExtractAll + CloneVarArgs + Ctx,
|
ctx: impl ExtractAll + CloneVarArgs + Ctx,
|
||||||
#[implementations(Context -> GraphicGroupTable, Context -> VectorDataTable, Context -> ImageFrameTable<Color>)] instance: impl Node<'n, Context<'static>, Output = Instances<T>>,
|
#[implementations(Context -> GraphicGroupTable, Context -> VectorDataTable, Context -> RasterDataTable<Color>)] instance: impl Node<'n, Context<'static>, Output = Instances<T>>,
|
||||||
#[default(1)] count: u64,
|
#[default(1)] count: u64,
|
||||||
reverse: bool,
|
reverse: bool,
|
||||||
) -> GraphicGroupTable {
|
) -> GraphicGroupTable {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use super::misc::{CentroidType, point_to_dvec2};
|
|||||||
use super::style::{Fill, Gradient, GradientStops, Stroke};
|
use super::style::{Fill, Gradient, GradientStops, Stroke};
|
||||||
use super::{PointId, SegmentDomain, SegmentId, StrokeId, VectorData, VectorDataTable};
|
use super::{PointId, SegmentDomain, SegmentId, StrokeId, VectorData, VectorDataTable};
|
||||||
use crate::instances::{Instance, InstanceMut, Instances};
|
use crate::instances::{Instance, InstanceMut, Instances};
|
||||||
use crate::raster::image::ImageFrameTable;
|
use crate::raster::image::RasterDataTable;
|
||||||
use crate::registry::types::{Angle, Fraction, IntegerCount, Length, Multiplier, Percentage, PixelLength, PixelSize, SeedValue};
|
use crate::registry::types::{Angle, Fraction, IntegerCount, Length, Multiplier, Percentage, PixelLength, PixelSize, SeedValue};
|
||||||
use crate::renderer::GraphicElementRendered;
|
use crate::renderer::GraphicElementRendered;
|
||||||
use crate::transform::{Footprint, ReferencePoint, Transform};
|
use crate::transform::{Footprint, ReferencePoint, Transform};
|
||||||
@@ -204,7 +204,7 @@ where
|
|||||||
async fn repeat<I: 'n + Send>(
|
async fn repeat<I: 'n + Send>(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
// TODO: Implement other GraphicElementRendered types.
|
// TODO: Implement other GraphicElementRendered types.
|
||||||
#[implementations(GraphicGroupTable, VectorDataTable, ImageFrameTable<Color>)] instance: Instances<I>,
|
#[implementations(GraphicGroupTable, VectorDataTable, RasterDataTable<Color>)] instance: Instances<I>,
|
||||||
#[default(100., 100.)]
|
#[default(100., 100.)]
|
||||||
// TODO: When using a custom Properties panel layout in document_node_definitions.rs and this default is set, the widget weirdly doesn't show up in the Properties panel. Investigation is needed.
|
// TODO: When using a custom Properties panel layout in document_node_definitions.rs and this default is set, the widget weirdly doesn't show up in the Properties panel. Investigation is needed.
|
||||||
direction: PixelSize,
|
direction: PixelSize,
|
||||||
@@ -246,7 +246,7 @@ where
|
|||||||
async fn circular_repeat<I: 'n + Send>(
|
async fn circular_repeat<I: 'n + Send>(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
// TODO: Implement other GraphicElementRendered types.
|
// TODO: Implement other GraphicElementRendered types.
|
||||||
#[implementations(GraphicGroupTable, VectorDataTable, ImageFrameTable<Color>)] instance: Instances<I>,
|
#[implementations(GraphicGroupTable, VectorDataTable, RasterDataTable<Color>)] instance: Instances<I>,
|
||||||
angle_offset: Angle,
|
angle_offset: Angle,
|
||||||
#[default(5)] radius: f64,
|
#[default(5)] radius: f64,
|
||||||
#[default(5)] instances: IntegerCount,
|
#[default(5)] instances: IntegerCount,
|
||||||
@@ -286,7 +286,7 @@ async fn copy_to_points<I: 'n + Send>(
|
|||||||
points: VectorDataTable,
|
points: VectorDataTable,
|
||||||
#[expose]
|
#[expose]
|
||||||
/// Artwork to be copied and placed at each point.
|
/// Artwork to be copied and placed at each point.
|
||||||
#[implementations(GraphicGroupTable, VectorDataTable, ImageFrameTable<Color>)]
|
#[implementations(GraphicGroupTable, VectorDataTable, RasterDataTable<Color>)]
|
||||||
instance: Instances<I>,
|
instance: Instances<I>,
|
||||||
/// Minimum range of randomized sizes given to each instance.
|
/// Minimum range of randomized sizes given to each instance.
|
||||||
#[default(1)]
|
#[default(1)]
|
||||||
@@ -370,7 +370,7 @@ where
|
|||||||
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
|
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
|
||||||
async fn mirror<I: 'n + Send>(
|
async fn mirror<I: 'n + Send>(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(GraphicGroupTable, VectorDataTable, ImageFrameTable<Color>)] instance: Instances<I>,
|
#[implementations(GraphicGroupTable, VectorDataTable, RasterDataTable<Color>)] instance: Instances<I>,
|
||||||
#[default(ReferencePoint::Center)] reference_point: ReferencePoint,
|
#[default(ReferencePoint::Center)] reference_point: ReferencePoint,
|
||||||
offset: f64,
|
offset: f64,
|
||||||
#[range((-90., 90.))] angle: Angle,
|
#[range((-90., 90.))] angle: Angle,
|
||||||
|
|||||||
@@ -187,8 +187,8 @@ tagged_value! {
|
|||||||
GraphicElement(graphene_core::GraphicElement),
|
GraphicElement(graphene_core::GraphicElement),
|
||||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::vector::migrate_vector_data"))] // TODO: Eventually remove this migration document upgrade code
|
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::vector::migrate_vector_data"))] // TODO: Eventually remove this migration document upgrade code
|
||||||
VectorData(graphene_core::vector::VectorDataTable),
|
VectorData(graphene_core::vector::VectorDataTable),
|
||||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::raster::image::migrate_image_frame"))] // TODO: Eventually remove this migration document upgrade code
|
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(alias = "ImageFrame", deserialize_with = "graphene_core::raster::image::migrate_image_frame"))] // TODO: Eventually remove this migration document upgrade code
|
||||||
ImageFrame(graphene_core::raster::image::ImageFrameTable<Color>),
|
RasterData(graphene_core::raster::image::RasterDataTable<Color>),
|
||||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::migrate_graphic_group"))] // TODO: Eventually remove this migration document upgrade code
|
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::migrate_graphic_group"))] // TODO: Eventually remove this migration document upgrade code
|
||||||
GraphicGroup(graphene_core::GraphicGroupTable),
|
GraphicGroup(graphene_core::GraphicGroupTable),
|
||||||
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::migrate_artboard_group"))] // TODO: Eventually remove this migration document upgrade code
|
#[cfg_attr(all(feature = "serde", target_arch = "wasm32"), serde(deserialize_with = "graphene_core::migrate_artboard_group"))] // TODO: Eventually remove this migration document upgrade code
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use graphene_core::instances::Instance;
|
|||||||
use graphene_core::raster::adjustments::blend_colors;
|
use graphene_core::raster::adjustments::blend_colors;
|
||||||
use graphene_core::raster::bbox::{AxisAlignedBbox, Bbox};
|
use graphene_core::raster::bbox::{AxisAlignedBbox, Bbox};
|
||||||
use graphene_core::raster::brush_cache::BrushCache;
|
use graphene_core::raster::brush_cache::BrushCache;
|
||||||
use graphene_core::raster::image::{Image, ImageFrameTable};
|
use graphene_core::raster::image::{Image, RasterDataTable};
|
||||||
use graphene_core::raster::{Alpha, BitmapMut, BlendMode, Color, Pixel, Sample};
|
use graphene_core::raster::{Alpha, BitmapMut, BlendMode, Color, Pixel, Sample};
|
||||||
use graphene_core::renderer::GraphicElementRendered;
|
use graphene_core::renderer::GraphicElementRendered;
|
||||||
use graphene_core::transform::Transform;
|
use graphene_core::transform::Transform;
|
||||||
@@ -80,7 +80,7 @@ fn brush_stamp_generator(diameter: f64, color: Color, hardness: f64, flow: f64)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(skip_impl)]
|
#[node_macro::node(skip_impl)]
|
||||||
fn blit<P, BlendFn>(mut target: ImageFrameTable<P>, texture: Image<P>, positions: Vec<DVec2>, blend_mode: BlendFn) -> ImageFrameTable<P>
|
fn blit<P, BlendFn>(mut target: RasterDataTable<P>, texture: Image<P>, positions: Vec<DVec2>, blend_mode: BlendFn) -> RasterDataTable<P>
|
||||||
where
|
where
|
||||||
P: Pixel + Alpha + std::fmt::Debug,
|
P: Pixel + Alpha + std::fmt::Debug,
|
||||||
BlendFn: for<'any_input> Node<'any_input, (P, P), Output = P>,
|
BlendFn: for<'any_input> Node<'any_input, (P, P), Output = P>,
|
||||||
@@ -184,10 +184,10 @@ pub fn blend_with_mode(background: Instance<Image<Color>>, foreground: Instance<
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category("Raster"))]
|
#[node_macro::node(category("Raster"))]
|
||||||
async fn brush(_: impl Ctx, mut image_frame_table: ImageFrameTable<Color>, strokes: Vec<BrushStroke>, cache: BrushCache) -> ImageFrameTable<Color> {
|
async fn brush(_: impl Ctx, mut image_frame_table: RasterDataTable<Color>, strokes: Vec<BrushStroke>, cache: BrushCache) -> RasterDataTable<Color> {
|
||||||
// TODO: Find a way to handle more than one instance
|
// TODO: Find a way to handle more than one instance
|
||||||
let Some(image_frame_instance) = image_frame_table.instance_ref_iter().next() else {
|
let Some(image_frame_instance) = image_frame_table.instance_ref_iter().next() else {
|
||||||
return ImageFrameTable::default();
|
return RasterDataTable::default();
|
||||||
};
|
};
|
||||||
let image_frame_instance = image_frame_instance.to_instance_cloned();
|
let image_frame_instance = image_frame_instance.to_instance_cloned();
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ async fn brush(_: impl Ctx, mut image_frame_table: ImageFrameTable<Color>, strok
|
|||||||
|
|
||||||
// TODO: Find a way to handle more than one instance
|
// TODO: Find a way to handle more than one instance
|
||||||
let Some(mut actual_image) = extend_image_to_bounds((), brush_plan.background.to_table(), background_bounds).instance_iter().next() else {
|
let Some(mut actual_image) = extend_image_to_bounds((), brush_plan.background.to_table(), background_bounds).instance_iter().next() else {
|
||||||
return ImageFrameTable::default();
|
return RasterDataTable::default();
|
||||||
};
|
};
|
||||||
|
|
||||||
let final_stroke_idx = brush_plan.strokes.len().saturating_sub(1);
|
let final_stroke_idx = brush_plan.strokes.len().saturating_sub(1);
|
||||||
@@ -397,7 +397,7 @@ mod test {
|
|||||||
async fn test_brush_output_size() {
|
async fn test_brush_output_size() {
|
||||||
let image = brush(
|
let image = brush(
|
||||||
(),
|
(),
|
||||||
ImageFrameTable::<Color>::new(Image::<Color>::default()),
|
RasterDataTable::<Color>::new(Image::<Color>::default()),
|
||||||
vec![BrushStroke {
|
vec![BrushStroke {
|
||||||
trace: vec![crate::vector::brush_stroke::BrushInputSample { position: DVec2::ZERO }],
|
trace: vec![crate::vector::brush_stroke::BrushInputSample { position: DVec2::ZERO }],
|
||||||
style: BrushStyle {
|
style: BrushStyle {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use graph_craft::proto::types::Percentage;
|
use graph_craft::proto::types::Percentage;
|
||||||
use graphene_core::raster::image::{Image, ImageFrameTable};
|
use graphene_core::raster::image::{Image, RasterDataTable};
|
||||||
use graphene_core::{Color, Ctx};
|
use graphene_core::{Color, Ctx};
|
||||||
use image::{DynamicImage, GenericImage, GenericImageView, GrayImage, ImageBuffer, Luma, Rgba, RgbaImage};
|
use image::{DynamicImage, GenericImage, GenericImageView, GrayImage, ImageBuffer, Luma, Rgba, RgbaImage};
|
||||||
use ndarray::{Array2, ArrayBase, Dim, OwnedRepr};
|
use ndarray::{Array2, ArrayBase, Dim, OwnedRepr};
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
|
||||||
#[node_macro::node(category("Raster"))]
|
#[node_macro::node(category("Raster"))]
|
||||||
async fn dehaze(_: impl Ctx, image_frame: ImageFrameTable<Color>, strength: Percentage) -> ImageFrameTable<Color> {
|
async fn dehaze(_: impl Ctx, image_frame: RasterDataTable<Color>, strength: Percentage) -> RasterDataTable<Color> {
|
||||||
let mut result_table = ImageFrameTable::default();
|
let mut result_table = RasterDataTable::default();
|
||||||
|
|
||||||
for mut image_frame_instance in image_frame.instance_iter() {
|
for mut image_frame_instance in image_frame.instance_iter() {
|
||||||
let image = image_frame_instance.instance;
|
let image = image_frame_instance.instance;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use graph_craft::proto::types::PixelLength;
|
use graph_craft::proto::types::PixelLength;
|
||||||
use graphene_core::raster::image::{Image, ImageFrameTable};
|
use graphene_core::raster::image::{Image, RasterDataTable};
|
||||||
use graphene_core::raster::{Bitmap, BitmapMut};
|
use graphene_core::raster::{Bitmap, BitmapMut};
|
||||||
use graphene_core::{Color, Ctx};
|
use graphene_core::{Color, Ctx};
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ use graphene_core::{Color, Ctx};
|
|||||||
async fn blur(
|
async fn blur(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
/// The image to be blurred.
|
/// The image to be blurred.
|
||||||
image_frame: ImageFrameTable<Color>,
|
image_frame: RasterDataTable<Color>,
|
||||||
/// The radius of the blur kernel.
|
/// The radius of the blur kernel.
|
||||||
#[range((0., 100.))]
|
#[range((0., 100.))]
|
||||||
#[hard_min(0.)]
|
#[hard_min(0.)]
|
||||||
@@ -17,8 +17,8 @@ async fn blur(
|
|||||||
box_blur: bool,
|
box_blur: bool,
|
||||||
/// Opt to incorrectly apply the filter with color calculations in gamma space for compatibility with the results from other software.
|
/// Opt to incorrectly apply the filter with color calculations in gamma space for compatibility with the results from other software.
|
||||||
gamma: bool,
|
gamma: bool,
|
||||||
) -> ImageFrameTable<Color> {
|
) -> RasterDataTable<Color> {
|
||||||
let mut result_table = ImageFrameTable::default();
|
let mut result_table = RasterDataTable::default();
|
||||||
|
|
||||||
for mut image_instance in image_frame.instance_iter() {
|
for mut image_instance in image_frame.instance_iter() {
|
||||||
let image = image_instance.instance.clone();
|
let image = image_instance.instance.clone();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use graph_craft::document::value::TaggedValue;
|
|||||||
use graph_craft::document::*;
|
use graph_craft::document::*;
|
||||||
use graph_craft::proto::*;
|
use graph_craft::proto::*;
|
||||||
use graphene_core::raster::BlendMode;
|
use graphene_core::raster::BlendMode;
|
||||||
use graphene_core::raster::image::{Image, ImageFrameTable};
|
use graphene_core::raster::image::{Image, RasterDataTable};
|
||||||
use graphene_core::*;
|
use graphene_core::*;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wgpu_executor::{Bindgroup, PipelineLayout, Shader, ShaderIO, ShaderInput, WgpuExecutor};
|
use wgpu_executor::{Bindgroup, PipelineLayout, Shader, ShaderIO, ShaderInput, WgpuExecutor};
|
||||||
@@ -34,8 +34,8 @@ async fn compile_gpu<'a: 'n>(_: impl Ctx, node: &'a DocumentNode, typing_context
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category("Debug: GPU"))]
|
#[node_macro::node(category("Debug: GPU"))]
|
||||||
async fn blend_gpu_image(_: impl Ctx, foreground: ImageFrameTable<Color>, background: ImageFrameTable<Color>, blend_mode: BlendMode, opacity: f64) -> ImageFrameTable<Color> {
|
async fn blend_gpu_image(_: impl Ctx, foreground: RasterDataTable<Color>, background: RasterDataTable<Color>, blend_mode: BlendMode, opacity: f64) -> RasterDataTable<Color> {
|
||||||
let mut result_table = ImageFrameTable::default();
|
let mut result_table = RasterDataTable::default();
|
||||||
|
|
||||||
for (foreground_instance, mut background_instance) in foreground.instance_iter().zip(background.instance_iter()) {
|
for (foreground_instance, mut background_instance) in foreground.instance_iter().zip(background.instance_iter()) {
|
||||||
let foreground_transform = foreground_instance.transform;
|
let foreground_transform = foreground_instance.transform;
|
||||||
@@ -95,7 +95,7 @@ async fn blend_gpu_image(_: impl Ctx, foreground: ImageFrameTable<Color>, backgr
|
|||||||
let proto_networks: Result<Vec<_>, _> = compiler.compile(network.clone()).collect();
|
let proto_networks: Result<Vec<_>, _> = compiler.compile(network.clone()).collect();
|
||||||
let Ok(proto_networks_result) = proto_networks else {
|
let Ok(proto_networks_result) = proto_networks else {
|
||||||
log::error!("Error compiling network in 'blend_gpu_image()");
|
log::error!("Error compiling network in 'blend_gpu_image()");
|
||||||
return ImageFrameTable::default();
|
return RasterDataTable::default();
|
||||||
};
|
};
|
||||||
let proto_networks = proto_networks_result;
|
let proto_networks = proto_networks_result;
|
||||||
log::debug!("compiling shader");
|
log::debug!("compiling shader");
|
||||||
@@ -241,7 +241,7 @@ async fn blend_gpu_image(_: impl Ctx, foreground: ImageFrameTable<Color>, backgr
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// #[node_macro::old_node_impl(MapGpuNode)]
|
// #[node_macro::old_node_impl(MapGpuNode)]
|
||||||
// async fn map_gpu<'a: 'input>(image: ImageFrameTable<Color>, node: DocumentNode, editor_api: &'a graphene_core::application_io::EditorApi<WasmApplicationIo>) -> ImageFrameTable<Color> {
|
// async fn map_gpu<'a: 'input>(image: RasterDataTable<Color>, node: DocumentNode, editor_api: &'a graphene_core::application_io::EditorApi<WasmApplicationIo>) -> RasterDataTable<Color> {
|
||||||
// let image_frame_table = ℑ
|
// let image_frame_table = ℑ
|
||||||
// let image = image.instance_ref_iter().next().unwrap().instance;
|
// let image = image.instance_ref_iter().next().unwrap().instance;
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ async fn blend_gpu_image(_: impl Ctx, foreground: ImageFrameTable<Color>, backgr
|
|||||||
// let name = "placeholder".to_string();
|
// let name = "placeholder".to_string();
|
||||||
// let Ok(compute_pass_descriptor) = create_compute_pass_descriptor(node, image_frame_table, executor).await else {
|
// let Ok(compute_pass_descriptor) = create_compute_pass_descriptor(node, image_frame_table, executor).await else {
|
||||||
// log::error!("Error creating compute pass descriptor in 'map_gpu()");
|
// log::error!("Error creating compute pass descriptor in 'map_gpu()");
|
||||||
// return ImageFrameTable::default();
|
// return RasterDataTable::default();
|
||||||
// };
|
// };
|
||||||
// self.cache.lock().as_mut().unwrap().insert(name, compute_pass_descriptor.clone());
|
// self.cache.lock().as_mut().unwrap().insert(name, compute_pass_descriptor.clone());
|
||||||
// log::error!("created compute pass");
|
// log::error!("created compute pass");
|
||||||
@@ -292,7 +292,7 @@ async fn blend_gpu_image(_: impl Ctx, foreground: ImageFrameTable<Color>, backgr
|
|||||||
// height: image.height,
|
// height: image.height,
|
||||||
// ..Default::default()
|
// ..Default::default()
|
||||||
// };
|
// };
|
||||||
// let mut result = ImageFrameTable::new(new_image);
|
// let mut result = RasterDataTable::new(new_image);
|
||||||
// *result.transform_mut() = image_frame_table.transform();
|
// *result.transform_mut() = image_frame_table.transform();
|
||||||
// *result.instance_mut_iter().next().unwrap().alpha_blending = *image_frame_table.instance_ref_iter().next().unwrap().alpha_blending;
|
// *result.instance_mut_iter().next().unwrap().alpha_blending = *image_frame_table.instance_ref_iter().next().unwrap().alpha_blending;
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ async fn blend_gpu_image(_: impl Ctx, foreground: ImageFrameTable<Color>, backgr
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// async fn create_compute_pass_descriptor<T: Clone + Pixel + StaticTypeSized>(node: DocumentNode, image: &ImageFrameTable<T>, executor: &&WgpuExecutor) -> Result<ComputePass, String>
|
// async fn create_compute_pass_descriptor<T: Clone + Pixel + StaticTypeSized>(node: DocumentNode, image: &RasterDataTable<T>, executor: &&WgpuExecutor) -> Result<ComputePass, String>
|
||||||
// where
|
// where
|
||||||
// GraphicElement: From<Image<T>>,
|
// GraphicElement: From<Image<T>>,
|
||||||
// T::Static: Pixel,
|
// T::Static: Pixel,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use graphene_core::raster::image::ImageFrameTable;
|
use graphene_core::raster::image::RasterDataTable;
|
||||||
use graphene_core::{Color, Ctx};
|
use graphene_core::{Color, Ctx};
|
||||||
|
|
||||||
#[node_macro::node(category("Raster"))]
|
#[node_macro::node(category("Raster"))]
|
||||||
async fn image_color_palette(
|
async fn image_color_palette(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
image: ImageFrameTable<Color>,
|
image: RasterDataTable<Color>,
|
||||||
#[hard_min(1.)]
|
#[hard_min(1.)]
|
||||||
#[soft_max(28.)]
|
#[soft_max(28.)]
|
||||||
max_size: u32,
|
max_size: u32,
|
||||||
@@ -64,13 +64,13 @@ async fn image_color_palette(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use graphene_core::raster::image::{Image, ImageFrameTable};
|
use graphene_core::raster::image::{Image, RasterDataTable};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_image_color_palette() {
|
fn test_image_color_palette() {
|
||||||
let result = image_color_palette(
|
let result = image_color_palette(
|
||||||
(),
|
(),
|
||||||
ImageFrameTable::new(Image {
|
RasterDataTable::new(Image {
|
||||||
width: 100,
|
width: 100,
|
||||||
height: 100,
|
height: 100,
|
||||||
data: vec![Color::from_rgbaf32(0., 0., 0., 1.).unwrap(); 10000],
|
data: vec![Color::from_rgbaf32(0., 0., 0., 1.).unwrap(); 10000],
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use fastnoise_lite;
|
|||||||
use glam::{DAffine2, DVec2, Vec2};
|
use glam::{DAffine2, DVec2, Vec2};
|
||||||
use graphene_core::instances::Instance;
|
use graphene_core::instances::Instance;
|
||||||
use graphene_core::raster::bbox::Bbox;
|
use graphene_core::raster::bbox::Bbox;
|
||||||
use graphene_core::raster::image::{Image, ImageFrameTable};
|
use graphene_core::raster::image::{Image, RasterDataTable};
|
||||||
use graphene_core::raster::{Alpha, AlphaMut, Bitmap, BitmapMut, CellularDistanceFunction, CellularReturnType, Channel, DomainWarpType, FractalType, LinearChannel, Luminance, NoiseType, RGBMut};
|
use graphene_core::raster::{Alpha, AlphaMut, Bitmap, BitmapMut, CellularDistanceFunction, CellularReturnType, Channel, DomainWarpType, FractalType, LinearChannel, Luminance, NoiseType, RGBMut};
|
||||||
use graphene_core::transform::Transform;
|
use graphene_core::transform::Transform;
|
||||||
use graphene_core::{AlphaBlending, Color, Ctx, ExtractFootprint};
|
use graphene_core::{AlphaBlending, Color, Ctx, ExtractFootprint};
|
||||||
@@ -25,8 +25,8 @@ impl From<std::io::Error> for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category("Debug: Raster"))]
|
#[node_macro::node(category("Debug: Raster"))]
|
||||||
fn sample_image(ctx: impl ExtractFootprint + Clone + Send, image_frame: ImageFrameTable<Color>) -> ImageFrameTable<Color> {
|
fn sample_image(ctx: impl ExtractFootprint + Clone + Send, image_frame: RasterDataTable<Color>) -> RasterDataTable<Color> {
|
||||||
let mut result_table = ImageFrameTable::default();
|
let mut result_table = RasterDataTable::default();
|
||||||
|
|
||||||
for mut image_frame_instance in image_frame.instance_iter() {
|
for mut image_frame_instance in image_frame.instance_iter() {
|
||||||
let image_frame_transform = image_frame_instance.transform;
|
let image_frame_transform = image_frame_instance.transform;
|
||||||
@@ -95,12 +95,12 @@ fn sample_image(ctx: impl ExtractFootprint + Clone + Send, image_frame: ImageFra
|
|||||||
fn combine_channels(
|
fn combine_channels(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
_primary: (),
|
_primary: (),
|
||||||
#[expose] red: ImageFrameTable<Color>,
|
#[expose] red: RasterDataTable<Color>,
|
||||||
#[expose] green: ImageFrameTable<Color>,
|
#[expose] green: RasterDataTable<Color>,
|
||||||
#[expose] blue: ImageFrameTable<Color>,
|
#[expose] blue: RasterDataTable<Color>,
|
||||||
#[expose] alpha: ImageFrameTable<Color>,
|
#[expose] alpha: RasterDataTable<Color>,
|
||||||
) -> ImageFrameTable<Color> {
|
) -> RasterDataTable<Color> {
|
||||||
let mut result_table = ImageFrameTable::default();
|
let mut result_table = RasterDataTable::default();
|
||||||
|
|
||||||
let max_len = red.len().max(green.len()).max(blue.len()).max(alpha.len());
|
let max_len = red.len().max(green.len()).max(blue.len()).max(alpha.len());
|
||||||
let red = red.instance_iter().map(Some).chain(std::iter::repeat(None)).take(max_len);
|
let red = red.instance_iter().map(Some).chain(std::iter::repeat(None)).take(max_len);
|
||||||
@@ -184,11 +184,11 @@ fn combine_channels(
|
|||||||
fn mask(
|
fn mask(
|
||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
/// The image to be masked.
|
/// The image to be masked.
|
||||||
image: ImageFrameTable<Color>,
|
image: RasterDataTable<Color>,
|
||||||
/// The stencil to be used for masking.
|
/// The stencil to be used for masking.
|
||||||
#[expose]
|
#[expose]
|
||||||
stencil: ImageFrameTable<Color>,
|
stencil: RasterDataTable<Color>,
|
||||||
) -> ImageFrameTable<Color> {
|
) -> RasterDataTable<Color> {
|
||||||
// TODO: Support multiple stencil instances
|
// TODO: Support multiple stencil instances
|
||||||
let Some(stencil_instance) = stencil.instance_iter().next() else {
|
let Some(stencil_instance) = stencil.instance_iter().next() else {
|
||||||
// No stencil provided so we return the original image
|
// No stencil provided so we return the original image
|
||||||
@@ -196,7 +196,7 @@ fn mask(
|
|||||||
};
|
};
|
||||||
let stencil_size = DVec2::new(stencil_instance.instance.width as f64, stencil_instance.instance.height as f64);
|
let stencil_size = DVec2::new(stencil_instance.instance.width as f64, stencil_instance.instance.height as f64);
|
||||||
|
|
||||||
let mut result_table = ImageFrameTable::default();
|
let mut result_table = RasterDataTable::default();
|
||||||
|
|
||||||
for mut image_instance in image.instance_iter() {
|
for mut image_instance in image.instance_iter() {
|
||||||
let image_size = DVec2::new(image_instance.instance.width as f64, image_instance.instance.height as f64);
|
let image_size = DVec2::new(image_instance.instance.width as f64, image_instance.instance.height as f64);
|
||||||
@@ -231,8 +231,8 @@ fn mask(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category(""))]
|
#[node_macro::node(category(""))]
|
||||||
fn extend_image_to_bounds(_: impl Ctx, image: ImageFrameTable<Color>, bounds: DAffine2) -> ImageFrameTable<Color> {
|
fn extend_image_to_bounds(_: impl Ctx, image: RasterDataTable<Color>, bounds: DAffine2) -> RasterDataTable<Color> {
|
||||||
let mut result_table = ImageFrameTable::default();
|
let mut result_table = RasterDataTable::default();
|
||||||
|
|
||||||
for mut image_instance in image.instance_iter() {
|
for mut image_instance in image.instance_iter() {
|
||||||
let image_aabb = Bbox::unit().affine_transform(image_instance.transform).to_axis_aligned_bbox();
|
let image_aabb = Bbox::unit().affine_transform(image_instance.transform).to_axis_aligned_bbox();
|
||||||
@@ -284,13 +284,13 @@ fn extend_image_to_bounds(_: impl Ctx, image: ImageFrameTable<Color>, bounds: DA
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category("Debug: Raster"))]
|
#[node_macro::node(category("Debug: Raster"))]
|
||||||
fn empty_image(_: impl Ctx, transform: DAffine2, color: Color) -> ImageFrameTable<Color> {
|
fn empty_image(_: impl Ctx, transform: DAffine2, color: Color) -> RasterDataTable<Color> {
|
||||||
let width = transform.transform_vector2(DVec2::new(1., 0.)).length() as u32;
|
let width = transform.transform_vector2(DVec2::new(1., 0.)).length() as u32;
|
||||||
let height = transform.transform_vector2(DVec2::new(0., 1.)).length() as u32;
|
let height = transform.transform_vector2(DVec2::new(0., 1.)).length() as u32;
|
||||||
|
|
||||||
let image = Image::new(width, height, color);
|
let image = Image::new(width, height, color);
|
||||||
|
|
||||||
let mut result_table = ImageFrameTable::new(image);
|
let mut result_table = RasterDataTable::new(image);
|
||||||
let image_instance = result_table.get_mut(0).unwrap();
|
let image_instance = result_table.get_mut(0).unwrap();
|
||||||
*image_instance.transform = transform;
|
*image_instance.transform = transform;
|
||||||
*image_instance.alpha_blending = AlphaBlending::default();
|
*image_instance.alpha_blending = AlphaBlending::default();
|
||||||
@@ -301,7 +301,7 @@ fn empty_image(_: impl Ctx, transform: DAffine2, color: Color) -> ImageFrameTabl
|
|||||||
|
|
||||||
/// Constructs a raster image.
|
/// Constructs a raster image.
|
||||||
#[node_macro::node(category(""))]
|
#[node_macro::node(category(""))]
|
||||||
fn image(_: impl Ctx, _primary: (), image: ImageFrameTable<Color>) -> ImageFrameTable<Color> {
|
fn image(_: impl Ctx, _primary: (), image: RasterDataTable<Color>) -> RasterDataTable<Color> {
|
||||||
image
|
image
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,15 +329,15 @@ fn image(_: impl Ctx, _primary: (), image: ImageFrameTable<Color>) -> ImageFrame
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// impl<'i, 'e: 'i, P: Pixel + 'i + Hash + Default + Send, E: 'i, C: 'i, G: 'i, $($t: 'i,)*> Node<'i, ImageFrame<P>> for ImaginateNode<P, E, C, G, $($t,)*>
|
// impl<'i, 'e: 'i, P: Pixel + 'i + Hash + Default + Send, E: 'i, C: 'i, G: 'i, $($t: 'i,)*> Node<'i, RasterData<P>> for ImaginateNode<P, E, C, G, $($t,)*>
|
||||||
// where $($t: for<'any_input> Node<'any_input, (), Output = DynFuture<'any_input, $o>>,)*
|
// where $($t: for<'any_input> Node<'any_input, (), Output = DynFuture<'any_input, $o>>,)*
|
||||||
// E: for<'any_input> Node<'any_input, (), Output = DynFuture<'any_input, &'e WasmEditorApi>>,
|
// E: for<'any_input> Node<'any_input, (), Output = DynFuture<'any_input, &'e WasmEditorApi>>,
|
||||||
// C: for<'any_input> Node<'any_input, (), Output = DynFuture<'any_input, ImaginateController>>,
|
// C: for<'any_input> Node<'any_input, (), Output = DynFuture<'any_input, ImaginateController>>,
|
||||||
// G: for<'any_input> Node<'any_input, (), Output = DynFuture<'any_input, u64>>,
|
// G: for<'any_input> Node<'any_input, (), Output = DynFuture<'any_input, u64>>,
|
||||||
// {
|
// {
|
||||||
// type Output = DynFuture<'i, ImageFrame<P>>;
|
// type Output = DynFuture<'i, RasterData<P>>;
|
||||||
|
|
||||||
// fn eval(&'i self, frame: ImageFrame<P>) -> Self::Output {
|
// fn eval(&'i self, frame: RasterData<P>) -> Self::Output {
|
||||||
// let controller = self.controller.eval(());
|
// let controller = self.controller.eval(());
|
||||||
// $(let $val = self.$val.eval(());)*
|
// $(let $val = self.$val.eval(());)*
|
||||||
|
|
||||||
@@ -369,16 +369,16 @@ fn image(_: impl Ctx, _primary: (), image: ImageFrameTable<Color>) -> ImageFrame
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// fn wrap_image_frame<P: Pixel>(image: Image<P>, transform: DAffine2) -> ImageFrame<P> {
|
// fn wrap_image_frame<P: Pixel>(image: Image<P>, transform: DAffine2) -> RasterData<P> {
|
||||||
// if !transform.decompose_scale().abs_diff_eq(DVec2::ZERO, 0.00001) {
|
// if !transform.decompose_scale().abs_diff_eq(DVec2::ZERO, 0.00001) {
|
||||||
// ImageFrame {
|
// RasterData {
|
||||||
// image,
|
// image,
|
||||||
// transform,
|
// transform,
|
||||||
// alpha_blending: AlphaBlending::default(),
|
// alpha_blending: AlphaBlending::default(),
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
// let resolution = DVec2::new(image.height as f64, image.width as f64);
|
// let resolution = DVec2::new(image.height as f64, image.width as f64);
|
||||||
// ImageFrame {
|
// RasterData {
|
||||||
// image,
|
// image,
|
||||||
// transform: DAffine2::from_scale_angle_translation(resolution, 0., transform.translation),
|
// transform: DAffine2::from_scale_angle_translation(resolution, 0., transform.translation),
|
||||||
// alpha_blending: AlphaBlending::default(),
|
// alpha_blending: AlphaBlending::default(),
|
||||||
@@ -424,7 +424,7 @@ fn noise_pattern(
|
|||||||
cellular_distance_function: CellularDistanceFunction,
|
cellular_distance_function: CellularDistanceFunction,
|
||||||
cellular_return_type: CellularReturnType,
|
cellular_return_type: CellularReturnType,
|
||||||
cellular_jitter: f64,
|
cellular_jitter: f64,
|
||||||
) -> ImageFrameTable<Color> {
|
) -> RasterDataTable<Color> {
|
||||||
let footprint = ctx.footprint();
|
let footprint = ctx.footprint();
|
||||||
let viewport_bounds = footprint.viewport_bounds_in_local_space();
|
let viewport_bounds = footprint.viewport_bounds_in_local_space();
|
||||||
|
|
||||||
@@ -442,7 +442,7 @@ fn noise_pattern(
|
|||||||
|
|
||||||
// If the image would not be visible, return an empty image
|
// If the image would not be visible, return an empty image
|
||||||
if size.x <= 0. || size.y <= 0. {
|
if size.x <= 0. || size.y <= 0. {
|
||||||
return ImageFrameTable::default();
|
return RasterDataTable::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
let footprint_scale = footprint.scale();
|
let footprint_scale = footprint.scale();
|
||||||
@@ -486,7 +486,7 @@ fn noise_pattern(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut result = ImageFrameTable::default();
|
let mut result = RasterDataTable::default();
|
||||||
result.push(Instance {
|
result.push(Instance {
|
||||||
instance: image,
|
instance: image,
|
||||||
transform: DAffine2::from_translation(offset) * DAffine2::from_scale(size),
|
transform: DAffine2::from_translation(offset) * DAffine2::from_scale(size),
|
||||||
@@ -551,7 +551,7 @@ fn noise_pattern(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut result = ImageFrameTable::default();
|
let mut result = RasterDataTable::default();
|
||||||
result.push(Instance {
|
result.push(Instance {
|
||||||
instance: image,
|
instance: image,
|
||||||
transform: DAffine2::from_translation(offset) * DAffine2::from_scale(size),
|
transform: DAffine2::from_translation(offset) * DAffine2::from_scale(size),
|
||||||
@@ -562,7 +562,7 @@ fn noise_pattern(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category("Raster"))]
|
#[node_macro::node(category("Raster"))]
|
||||||
fn mandelbrot(ctx: impl ExtractFootprint + Send) -> ImageFrameTable<Color> {
|
fn mandelbrot(ctx: impl ExtractFootprint + Send) -> RasterDataTable<Color> {
|
||||||
let footprint = ctx.footprint();
|
let footprint = ctx.footprint();
|
||||||
let viewport_bounds = footprint.viewport_bounds_in_local_space();
|
let viewport_bounds = footprint.viewport_bounds_in_local_space();
|
||||||
|
|
||||||
@@ -574,7 +574,7 @@ fn mandelbrot(ctx: impl ExtractFootprint + Send) -> ImageFrameTable<Color> {
|
|||||||
|
|
||||||
// If the image would not be visible, return an empty image
|
// If the image would not be visible, return an empty image
|
||||||
if size.x <= 0. || size.y <= 0. {
|
if size.x <= 0. || size.y <= 0. {
|
||||||
return ImageFrameTable::default();
|
return RasterDataTable::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
let scale = footprint.scale();
|
let scale = footprint.scale();
|
||||||
@@ -602,7 +602,7 @@ fn mandelbrot(ctx: impl ExtractFootprint + Send) -> ImageFrameTable<Color> {
|
|||||||
data,
|
data,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let mut result = ImageFrameTable::default();
|
let mut result = RasterDataTable::default();
|
||||||
result.push(Instance {
|
result.push(Instance {
|
||||||
instance: image,
|
instance: image,
|
||||||
transform: DAffine2::from_translation(offset) * DAffine2::from_scale(size),
|
transform: DAffine2::from_translation(offset) * DAffine2::from_scale(size),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use bezier_rs::{ManipulatorGroup, Subpath};
|
use bezier_rs::{ManipulatorGroup, Subpath};
|
||||||
use glam::{DAffine2, DVec2};
|
use glam::{DAffine2, DVec2};
|
||||||
use graphene_core::RasterFrame;
|
use graphene_core::RasterDataType;
|
||||||
use graphene_core::instances::{Instance, InstanceRef};
|
use graphene_core::instances::{Instance, InstanceRef};
|
||||||
use graphene_core::vector::misc::BooleanOperation;
|
use graphene_core::vector::misc::BooleanOperation;
|
||||||
use graphene_core::vector::style::Fill;
|
use graphene_core::vector::style::Fill;
|
||||||
@@ -203,7 +203,7 @@ fn flatten_vector_data(graphic_group_table: &GraphicGroupTable) -> VectorDataTab
|
|||||||
result_table.push(sub_vector_data);
|
result_table.push(sub_vector_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GraphicElement::RasterFrame(image) => {
|
GraphicElement::RasterDataType(image) => {
|
||||||
let make_instance = |transform| {
|
let make_instance = |transform| {
|
||||||
// Convert the image frame into a rectangular subpath with the image's transform
|
// Convert the image frame into a rectangular subpath with the image's transform
|
||||||
let mut subpath = Subpath::new_rect(DVec2::ZERO, DVec2::ONE);
|
let mut subpath = Subpath::new_rect(DVec2::ZERO, DVec2::ONE);
|
||||||
@@ -218,12 +218,12 @@ fn flatten_vector_data(graphic_group_table: &GraphicGroupTable) -> VectorDataTab
|
|||||||
|
|
||||||
// Apply the parent group's transform to each element of raster data
|
// Apply the parent group's transform to each element of raster data
|
||||||
match image {
|
match image {
|
||||||
RasterFrame::ImageFrame(image) => {
|
RasterDataType::RasterData(image) => {
|
||||||
for instance in image.instance_ref_iter() {
|
for instance in image.instance_ref_iter() {
|
||||||
result_table.push(make_instance(*element.transform * *instance.transform));
|
result_table.push(make_instance(*element.transform * *instance.transform));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RasterFrame::TextureFrame(image) => {
|
RasterDataType::TextureData(image) => {
|
||||||
for instance in image.instance_ref_iter() {
|
for instance in image.instance_ref_iter() {
|
||||||
result_table.push(make_instance(*element.transform * *instance.transform));
|
result_table.push(make_instance(*element.transform * *instance.transform));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use graphene_core::application_io::{ApplicationIo, ExportFormat, RenderConfig};
|
|||||||
use graphene_core::instances::Instances;
|
use graphene_core::instances::Instances;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use graphene_core::raster::bbox::Bbox;
|
use graphene_core::raster::bbox::Bbox;
|
||||||
use graphene_core::raster::image::{Image, ImageFrameTable};
|
use graphene_core::raster::image::{Image, RasterDataTable};
|
||||||
use graphene_core::renderer::RenderMetadata;
|
use graphene_core::renderer::RenderMetadata;
|
||||||
use graphene_core::renderer::{GraphicElementRendered, RenderParams, RenderSvgSegmentList, SvgRender, format_transform_matrix};
|
use graphene_core::renderer::{GraphicElementRendered, RenderParams, RenderSvgSegmentList, SvgRender, format_transform_matrix};
|
||||||
use graphene_core::transform::Footprint;
|
use graphene_core::transform::Footprint;
|
||||||
@@ -39,7 +39,7 @@ async fn create_surface<'a: 'n>(_: impl Ctx, editor: &'a WasmEditorApi) -> Arc<W
|
|||||||
// #[cfg(target_arch = "wasm32")]
|
// #[cfg(target_arch = "wasm32")]
|
||||||
// async fn draw_image_frame(
|
// async fn draw_image_frame(
|
||||||
// _: impl Ctx,
|
// _: impl Ctx,
|
||||||
// image: ImageFrameTable<graphene_core::raster::SRGBA8>,
|
// image: RasterDataTable<graphene_core::raster::SRGBA8>,
|
||||||
// surface_handle: Arc<WasmSurfaceHandle>,
|
// surface_handle: Arc<WasmSurfaceHandle>,
|
||||||
// ) -> graphene_core::application_io::SurfaceHandleFrame<HtmlCanvasElement> {
|
// ) -> graphene_core::application_io::SurfaceHandleFrame<HtmlCanvasElement> {
|
||||||
// let image = image.instance_ref_iter().next().unwrap().instance;
|
// let image = image.instance_ref_iter().next().unwrap().instance;
|
||||||
@@ -49,9 +49,9 @@ async fn create_surface<'a: 'n>(_: impl Ctx, editor: &'a WasmEditorApi) -> Arc<W
|
|||||||
// let canvas = &surface_handle.surface;
|
// let canvas = &surface_handle.surface;
|
||||||
// canvas.set_width(image.image.width);
|
// canvas.set_width(image.image.width);
|
||||||
// canvas.set_height(image.image.height);
|
// canvas.set_height(image.image.height);
|
||||||
// // TODO: replace "2d" with "bitmaprenderer" once we switch to ImageBitmap (lives on gpu) from ImageData (lives on cpu)
|
// // TODO: replace "2d" with "bitmaprenderer" once we switch to ImageBitmap (lives on gpu) from RasterData (lives on cpu)
|
||||||
// let context = canvas.get_context("2d").unwrap().unwrap().dyn_into::<CanvasRenderingContext2d>().unwrap();
|
// let context = canvas.get_context("2d").unwrap().unwrap().dyn_into::<CanvasRenderingContext2d>().unwrap();
|
||||||
// let image_data = web_sys::ImageData::new_with_u8_clamped_array_and_sh(array, image.image.width, image.image.height).expect("Failed to construct ImageData");
|
// let image_data = web_sys::ImageData::new_with_u8_clamped_array_and_sh(array, image.image.width, image.image.height).expect("Failed to construct RasterData");
|
||||||
// context.put_image_data(&image_data, 0., 0.).unwrap();
|
// context.put_image_data(&image_data, 0., 0.).unwrap();
|
||||||
// }
|
// }
|
||||||
// graphene_core::application_io::SurfaceHandleFrame {
|
// graphene_core::application_io::SurfaceHandleFrame {
|
||||||
@@ -76,9 +76,9 @@ async fn load_resource<'a: 'n>(_: impl Ctx, _primary: (), #[scope("editor-api")]
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category("Network"))]
|
#[node_macro::node(category("Network"))]
|
||||||
fn decode_image(_: impl Ctx, data: Arc<[u8]>) -> ImageFrameTable<Color> {
|
fn decode_image(_: impl Ctx, data: Arc<[u8]>) -> RasterDataTable<Color> {
|
||||||
let Some(image) = image::load_from_memory(data.as_ref()).ok() else {
|
let Some(image) = image::load_from_memory(data.as_ref()).ok() else {
|
||||||
return ImageFrameTable::default();
|
return RasterDataTable::default();
|
||||||
};
|
};
|
||||||
let image = image.to_rgba32f();
|
let image = image.to_rgba32f();
|
||||||
let image = Image {
|
let image = Image {
|
||||||
@@ -91,7 +91,7 @@ fn decode_image(_: impl Ctx, data: Arc<[u8]>) -> ImageFrameTable<Color> {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
ImageFrameTable::new(image)
|
RasterDataTable::new(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_svg(data: impl GraphicElementRendered, mut render: SvgRender, render_params: RenderParams, footprint: Footprint) -> RenderOutputType {
|
fn render_svg(data: impl GraphicElementRendered, mut render: SvgRender, render_params: RenderParams, footprint: Footprint) -> RenderOutputType {
|
||||||
@@ -165,13 +165,13 @@ async fn rasterize<T: WasmNotSend + 'n>(
|
|||||||
_: impl Ctx,
|
_: impl Ctx,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
VectorDataTable,
|
VectorDataTable,
|
||||||
ImageFrameTable<Color>,
|
RasterDataTable<Color>,
|
||||||
GraphicGroupTable,
|
GraphicGroupTable,
|
||||||
)]
|
)]
|
||||||
mut data: Instances<T>,
|
mut data: Instances<T>,
|
||||||
footprint: Footprint,
|
footprint: Footprint,
|
||||||
surface_handle: Arc<SurfaceHandle<HtmlCanvasElement>>,
|
surface_handle: Arc<SurfaceHandle<HtmlCanvasElement>>,
|
||||||
) -> ImageFrameTable<Color>
|
) -> RasterDataTable<Color>
|
||||||
where
|
where
|
||||||
Instances<T>: GraphicElementRendered,
|
Instances<T>: GraphicElementRendered,
|
||||||
{
|
{
|
||||||
@@ -179,7 +179,7 @@ where
|
|||||||
|
|
||||||
if footprint.transform.matrix2.determinant() == 0. {
|
if footprint.transform.matrix2.determinant() == 0. {
|
||||||
log::trace!("Invalid footprint received for rasterization");
|
log::trace!("Invalid footprint received for rasterization");
|
||||||
return ImageFrameTable::default();
|
return RasterDataTable::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut render = SvgRender::new();
|
let mut render = SvgRender::new();
|
||||||
@@ -218,7 +218,7 @@ where
|
|||||||
|
|
||||||
let rasterized = context.get_image_data(0., 0., resolution.x as f64, resolution.y as f64).unwrap();
|
let rasterized = context.get_image_data(0., 0., resolution.x as f64, resolution.y as f64).unwrap();
|
||||||
|
|
||||||
let mut result = ImageFrameTable::default();
|
let mut result = RasterDataTable::default();
|
||||||
result.push(Instance {
|
result.push(Instance {
|
||||||
instance: Image::from_image_data(&rasterized.data().0, resolution.x as u32, resolution.y as u32),
|
instance: Image::from_image_data(&rasterized.data().0, resolution.x as u32, resolution.y as u32),
|
||||||
transform: footprint.transform,
|
transform: footprint.transform,
|
||||||
@@ -234,7 +234,7 @@ async fn render<'a: 'n, T: 'n + GraphicElementRendered + WasmNotSend>(
|
|||||||
editor_api: impl Node<Context<'static>, Output = &'a WasmEditorApi>,
|
editor_api: impl Node<Context<'static>, Output = &'a WasmEditorApi>,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
Context -> VectorDataTable,
|
Context -> VectorDataTable,
|
||||||
Context -> ImageFrameTable<Color>,
|
Context -> RasterDataTable<Color>,
|
||||||
Context -> GraphicGroupTable,
|
Context -> GraphicGroupTable,
|
||||||
Context -> graphene_core::Artboard,
|
Context -> graphene_core::Artboard,
|
||||||
Context -> graphene_core::ArtboardGroupTable,
|
Context -> graphene_core::ArtboardGroupTable,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use glam::{DVec2, UVec2};
|
|||||||
use graph_craft::document::value::RenderOutput;
|
use graph_craft::document::value::RenderOutput;
|
||||||
use graph_craft::proto::{NodeConstructor, TypeErasedBox};
|
use graph_craft::proto::{NodeConstructor, TypeErasedBox};
|
||||||
use graphene_core::raster::color::Color;
|
use graphene_core::raster::color::Color;
|
||||||
use graphene_core::raster::image::ImageFrameTable;
|
use graphene_core::raster::image::RasterDataTable;
|
||||||
use graphene_core::raster::*;
|
use graphene_core::raster::*;
|
||||||
use graphene_core::vector::VectorDataTable;
|
use graphene_core::vector::VectorDataTable;
|
||||||
use graphene_core::{Artboard, GraphicGroupTable, concrete, generic};
|
use graphene_core::{Artboard, GraphicGroupTable, concrete, generic};
|
||||||
@@ -13,7 +13,7 @@ use graphene_core::{fn_type_fut, future};
|
|||||||
use graphene_std::Context;
|
use graphene_std::Context;
|
||||||
use graphene_std::GraphicElement;
|
use graphene_std::GraphicElement;
|
||||||
use graphene_std::any::{ComposeTypeErased, DowncastBothNode, DynAnyNode, IntoTypeErasedNode};
|
use graphene_std::any::{ComposeTypeErased, DowncastBothNode, DynAnyNode, IntoTypeErasedNode};
|
||||||
use graphene_std::application_io::{ImageTexture, TextureFrameTable};
|
use graphene_std::application_io::{ImageTexture, TextureDataTable};
|
||||||
use graphene_std::wasm_application_io::*;
|
use graphene_std::wasm_application_io::*;
|
||||||
use node_registry_macros::{async_node, into_node};
|
use node_registry_macros::{async_node, into_node};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
@@ -34,17 +34,17 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
|||||||
into_node!(from: VectorDataTable, to: GraphicGroupTable),
|
into_node!(from: VectorDataTable, to: GraphicGroupTable),
|
||||||
into_node!(from: GraphicGroupTable, to: GraphicGroupTable),
|
into_node!(from: GraphicGroupTable, to: GraphicGroupTable),
|
||||||
into_node!(from: GraphicGroupTable, to: GraphicElement),
|
into_node!(from: GraphicGroupTable, to: GraphicElement),
|
||||||
into_node!(from: ImageFrameTable<Color>, to: ImageFrameTable<Color>),
|
into_node!(from: RasterDataTable<Color>, to: RasterDataTable<Color>),
|
||||||
into_node!(from: ImageFrameTable<Color>, to: ImageFrameTable<SRGBA8>),
|
into_node!(from: RasterDataTable<Color>, to: RasterDataTable<SRGBA8>),
|
||||||
into_node!(from: ImageFrameTable<Color>, to: GraphicElement),
|
into_node!(from: RasterDataTable<Color>, to: GraphicElement),
|
||||||
into_node!(from: ImageFrameTable<Color>, to: GraphicGroupTable),
|
into_node!(from: RasterDataTable<Color>, to: GraphicGroupTable),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => ImageFrameTable<Color>]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => RasterDataTable<Color>]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => ImageTexture]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => ImageTexture]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => VectorDataTable]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => VectorDataTable]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => GraphicGroupTable]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => GraphicGroupTable]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => GraphicElement]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => GraphicElement]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Artboard]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Artboard]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_core::RasterFrame]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_core::RasterDataType]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_core::instances::Instances<Artboard>]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => graphene_core::instances::Instances<Artboard>]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => String]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => String]),
|
||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => glam::IVec2]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => glam::IVec2]),
|
||||||
@@ -70,7 +70,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
|||||||
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Box<graphene_core::vector::VectorModification>]),
|
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => Box<graphene_core::vector::VectorModification>]),
|
||||||
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Image<Color>]),
|
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Image<Color>]),
|
||||||
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => VectorDataTable]),
|
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => VectorDataTable]),
|
||||||
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => ImageFrameTable<Color>]),
|
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => RasterDataTable<Color>]),
|
||||||
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => GraphicGroupTable]),
|
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => GraphicGroupTable]),
|
||||||
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Vec<DVec2>]),
|
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Vec<DVec2>]),
|
||||||
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Arc<WasmSurfaceHandle>]),
|
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => Arc<WasmSurfaceHandle>]),
|
||||||
@@ -112,9 +112,9 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
|||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => ShaderInputFrame]),
|
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => ShaderInputFrame]),
|
||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => TextureFrameTable]),
|
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => TextureDataTable]),
|
||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => TextureFrameTable]),
|
async_node!(graphene_core::memo::MemoNode<_, _>, input: Context, fn_params: [Context => TextureDataTable]),
|
||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
into_node!(from: &WasmEditorApi, to: &WgpuExecutor),
|
into_node!(from: &WasmEditorApi, to: &WgpuExecutor),
|
||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
|
|||||||
@@ -874,7 +874,7 @@ mod tests {
|
|||||||
fn test_node_with_implementations() {
|
fn test_node_with_implementations() {
|
||||||
let attr = quote!(category("Raster: Adjustment"));
|
let attr = quote!(category("Raster: Adjustment"));
|
||||||
let input = quote!(
|
let input = quote!(
|
||||||
fn levels<P: Pixel>(image: ImageFrameTable<P>, #[implementations(f32, f64)] shadows: f64) -> ImageFrameTable<P> {
|
fn levels<P: Pixel>(image: RasterDataTable<P>, #[implementations(f32, f64)] shadows: f64) -> RasterDataTable<P> {
|
||||||
// Implementation details...
|
// Implementation details...
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -895,10 +895,10 @@ mod tests {
|
|||||||
where_clause: None,
|
where_clause: None,
|
||||||
input: Input {
|
input: Input {
|
||||||
pat_ident: pat_ident("image"),
|
pat_ident: pat_ident("image"),
|
||||||
ty: parse_quote!(ImageFrameTable<P>),
|
ty: parse_quote!(RasterDataTable<P>),
|
||||||
implementations: Punctuated::new(),
|
implementations: Punctuated::new(),
|
||||||
},
|
},
|
||||||
output_type: parse_quote!(ImageFrameTable<P>),
|
output_type: parse_quote!(RasterDataTable<P>),
|
||||||
is_async: false,
|
is_async: false,
|
||||||
fields: vec![ParsedField::Regular {
|
fields: vec![ParsedField::Regular {
|
||||||
pat_ident: pat_ident("shadows"),
|
pat_ident: pat_ident("shadows"),
|
||||||
@@ -992,7 +992,7 @@ mod tests {
|
|||||||
fn test_async_node() {
|
fn test_async_node() {
|
||||||
let attr = quote!(category("IO"));
|
let attr = quote!(category("IO"));
|
||||||
let input = quote!(
|
let input = quote!(
|
||||||
async fn load_image(api: &WasmEditorApi, #[expose] path: String) -> ImageFrameTable<Color> {
|
async fn load_image(api: &WasmEditorApi, #[expose] path: String) -> RasterDataTable<Color> {
|
||||||
// Implementation details...
|
// Implementation details...
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -1016,7 +1016,7 @@ mod tests {
|
|||||||
ty: parse_quote!(&WasmEditorApi),
|
ty: parse_quote!(&WasmEditorApi),
|
||||||
implementations: Punctuated::new(),
|
implementations: Punctuated::new(),
|
||||||
},
|
},
|
||||||
output_type: parse_quote!(ImageFrameTable<Color>),
|
output_type: parse_quote!(RasterDataTable<Color>),
|
||||||
is_async: true,
|
is_async: true,
|
||||||
fields: vec![ParsedField::Regular {
|
fields: vec![ParsedField::Regular {
|
||||||
pat_ident: pat_ident("path"),
|
pat_ident: pat_ident("path"),
|
||||||
@@ -1132,7 +1132,7 @@ mod tests {
|
|||||||
fn test_invalid_implementation_syntax() {
|
fn test_invalid_implementation_syntax() {
|
||||||
let attr = quote!(category("Test"));
|
let attr = quote!(category("Test"));
|
||||||
let input = quote!(
|
let input = quote!(
|
||||||
fn test_node(_: (), #[implementations((Footprint, Color), (Footprint, ImageFrameTable<Color>))] input: impl Node<Footprint, Output = T>) -> T {
|
fn test_node(_: (), #[implementations((Footprint, Color), (Footprint, RasterDataTable<Color>))] input: impl Node<Footprint, Output = T>) -> T {
|
||||||
// Implementation details...
|
// Implementation details...
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -1158,10 +1158,10 @@ mod tests {
|
|||||||
#[implementations((), #tuples, Footprint)] footprint: F,
|
#[implementations((), #tuples, Footprint)] footprint: F,
|
||||||
#[implementations(
|
#[implementations(
|
||||||
() -> Color,
|
() -> Color,
|
||||||
() -> ImageFrameTable<Color>,
|
() -> RasterDataTable<Color>,
|
||||||
() -> GradientStops,
|
() -> GradientStops,
|
||||||
Footprint -> Color,
|
Footprint -> Color,
|
||||||
Footprint -> ImageFrameTable<Color>,
|
Footprint -> RasterDataTable<Color>,
|
||||||
Footprint -> GradientStops,
|
Footprint -> GradientStops,
|
||||||
)]
|
)]
|
||||||
image: impl Node<F, Output = T>,
|
image: impl Node<F, Output = T>,
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ pub use executor::GpuExecutor;
|
|||||||
use futures::Future;
|
use futures::Future;
|
||||||
use glam::{DAffine2, UVec2};
|
use glam::{DAffine2, UVec2};
|
||||||
use gpu_executor::{ComputePassDimensions, GPUConstant, StorageBufferOptions, TextureBufferOptions, TextureBufferType, ToStorageBuffer, ToUniformBuffer};
|
use gpu_executor::{ComputePassDimensions, GPUConstant, StorageBufferOptions, TextureBufferOptions, TextureBufferType, ToStorageBuffer, ToUniformBuffer};
|
||||||
use graphene_core::application_io::{ApplicationIo, EditorApi, ImageTexture, SurfaceHandle, TextureFrameTable};
|
use graphene_core::application_io::{ApplicationIo, EditorApi, ImageTexture, SurfaceHandle, TextureDataTable};
|
||||||
use graphene_core::instances::Instance;
|
use graphene_core::instances::Instance;
|
||||||
use graphene_core::raster::image::ImageFrameTable;
|
use graphene_core::raster::image::RasterDataTable;
|
||||||
use graphene_core::raster::{Image, SRGBA8};
|
use graphene_core::raster::{Image, SRGBA8};
|
||||||
use graphene_core::transform::{Footprint, Transform};
|
use graphene_core::transform::{Footprint, Transform};
|
||||||
use graphene_core::{Color, Cow, Ctx, ExtractFootprint, Node, SurfaceFrame, Type};
|
use graphene_core::{Color, Cow, Ctx, ExtractFootprint, Node, SurfaceFrame, Type};
|
||||||
@@ -911,8 +911,8 @@ async fn render_texture<'a: 'n>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[node_macro::node(category(""))]
|
#[node_macro::node(category(""))]
|
||||||
async fn upload_texture<'a: 'n>(_: impl ExtractFootprint + Ctx, input: ImageFrameTable<Color>, executor: &'a WgpuExecutor) -> TextureFrameTable {
|
async fn upload_texture<'a: 'n>(_: impl ExtractFootprint + Ctx, input: RasterDataTable<Color>, executor: &'a WgpuExecutor) -> TextureDataTable {
|
||||||
let mut result_table = TextureFrameTable::default();
|
let mut result_table = TextureDataTable::default();
|
||||||
|
|
||||||
for instance in input.instance_ref_iter() {
|
for instance in input.instance_ref_iter() {
|
||||||
let image = instance.instance;
|
let image = instance.instance;
|
||||||
|
|||||||
Reference in New Issue
Block a user