Skip to content

Commit

Permalink
Partial progress (the stuff that's not compiling and I'm not sure about)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keavon committed Jan 29, 2025
1 parent be23316 commit 3a5707b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 58 deletions.
17 changes: 3 additions & 14 deletions node-graph/gcore/src/vector/vector_data/modification.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::*;
use crate::uuid::generate_uuid;
use crate::Ctx;

use bezier_rs::BezierHandles;
use dyn_any::DynAny;
Expand Down Expand Up @@ -423,20 +424,8 @@ impl core::hash::Hash for VectorModification {

/// A node that applies a procedural modification to some [`VectorData`].
#[node_macro::node(category(""))]
async fn path_modify<F: 'n + Send + Sync + Clone>(
#[implementations(
(),
Footprint,
)]
input: F,
#[implementations(
() -> VectorData,
Footprint -> VectorData,
)]
vector_data: impl Node<F, Output = VectorData>,
modification: Box<VectorModification>,
) -> VectorData {
let mut vector_data = vector_data.eval(input).await;
async fn path_modify(_ctx: impl Ctx, vector_data: VectorData, modification: Box<VectorModification>) -> VectorData {
let mut vector_data = vector_data;
modification.apply(&mut vector_data);
vector_data
}
Expand Down
2 changes: 1 addition & 1 deletion node-graph/gcore/src/vector/vector_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ async fn circular_repeat<I: 'n + GraphicElementRendered + Transform + TransformM
}

#[node_macro::node(category("Vector"), path(graphene_core::vector))]
async fn copy_to_points<I: GraphicElementRendered + ConcatElement + TransformMut + Send + 'n>(
async fn copy_to_points<I: GraphicElementRendered + TransformMut + Send + 'n>(
_: impl Ctx,
points: VectorData,
#[expose]
Expand Down
18 changes: 2 additions & 16 deletions node-graph/gstd/src/dehaze.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
use graph_craft::proto::types::Percentage;
use graphene_core::raster::{Image, ImageFrame};
use graphene_core::transform::Footprint;
use graphene_core::Color;
use graphene_core::{Color, Ctx};

use image::{DynamicImage, GenericImage, GenericImageView, GrayImage, ImageBuffer, Luma, Rgba, RgbaImage};
use ndarray::{Array2, ArrayBase, Dim, OwnedRepr};
use std::cmp::{max, min};

#[node_macro::node(category("Raster: Filter"))]
async fn dehaze<F: 'n + Send + Sync>(
#[implementations(
(),
Footprint,
)]
footprint: F,
#[implementations(
() -> ImageFrame<Color>,
Footprint -> ImageFrame<Color>,
)]
image_frame: impl Node<F, Output = ImageFrame<Color>>,
strength: Percentage,
) -> ImageFrame<Color> {
let image_frame = image_frame.eval(footprint).await;

async fn dehaze(_: impl Ctx, image_frame: ImageFrame<Color>, strength: Percentage) -> ImageFrame<Color> {
// Prepare the image data for processing
let image = image_frame.image;
let image_data = bytemuck::cast_vec(image.data);
Expand Down
15 changes: 3 additions & 12 deletions node-graph/gstd/src/image_color_palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@ use graphene_core::transform::Footprint;
use graphene_core::{Color, Ctx};

#[node_macro::node(category("Raster"))]
async fn image_color_palette<F: 'n + Send>(
#[implementations(
(),
Footprint,
)]
footprint: F,
#[implementations(
() -> ImageFrame<Color>,
Footprint -> ImageFrame<Color>,
)]
image: impl Node<F, Output = ImageFrame<Color>>,
async fn image_color_palette(
_: impl Ctx,
image: ImageFrame<Color>,
#[min(1.)]
#[max(28.)]
max_size: u32,
Expand All @@ -25,7 +17,6 @@ async fn image_color_palette<F: 'n + Send>(
let mut histogram: Vec<usize> = vec![0; (bins + 1.) as usize];
let mut colors: Vec<Vec<Color>> = vec![vec![]; (bins + 1.) as usize];

let image = image.eval(footprint).await;
for pixel in image.image.data.iter() {
let r = pixel.r() * GRID;
let g = pixel.g() * GRID;
Expand Down
16 changes: 1 addition & 15 deletions node-graph/gstd/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,7 @@ use glam::{DAffine2, DVec2};
use std::ops::Mul;

#[node_macro::node(category(""))]
async fn boolean_operation<F: 'n + Send>(
#[implementations(
(),
Footprint,
)]
footprint: F,
#[implementations(
() -> GraphicGroup,
Footprint -> GraphicGroup,
)]
group_of_paths: impl Node<F, Output = GraphicGroup>,
operation: BooleanOperation,
) -> VectorData {
let group_of_paths = group_of_paths.eval(footprint).await;

async fn boolean_operation(_: impl Ctx, group_of_paths: GraphicGroup, operation: BooleanOperation) -> VectorData {
fn vector_from_image<T: Transform>(image_frame: T) -> VectorData {
let corner1 = DVec2::ZERO;
let corner2 = DVec2::new(1., 1.);
Expand Down

0 comments on commit 3a5707b

Please sign in to comment.