mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 11:28:30 +08:00
Instance tables refactor part 2: move the transform and alpha_blending fields up a level (#2249)
* Fix domain data structure field plural naming * Rename method one_item to one_instance Rename method one_item to one_instance * Move the Instance<T> methods over to providing an Instance<T>/InstanceMut<T> Move the Instance<T> methods over to providing an Instance<T>/InstanceMut<T> * Add transform and alpha_blending fields to Instances<T> * Finish the refactor (Brush tool is broken though) * Add test for brush node * Fix brush node * Fix default empty images being 1x1 instead of 0x0 as they should be * Fix tests * Fix path transform * Add correct upgrading to move the transform/blending up a level --------- Co-authored-by: hypercube <0hypercube@gmail.com>
This commit is contained in:
co-authored by
hypercube
parent
4ff2bdb04f
commit
f1160e1ca6
@@ -1,6 +1,7 @@
|
||||
use graph_craft::proto::types::Percentage;
|
||||
use graphene_core::raster::image::{ImageFrame, ImageFrameTable};
|
||||
use graphene_core::raster::Image;
|
||||
use graphene_core::transform::{Transform, TransformMut};
|
||||
use graphene_core::{Color, Ctx};
|
||||
|
||||
use image::{DynamicImage, GenericImage, GenericImageView, GrayImage, ImageBuffer, Luma, Rgba, RgbaImage};
|
||||
@@ -9,7 +10,10 @@ use std::cmp::{max, min};
|
||||
|
||||
#[node_macro::node(category("Raster"))]
|
||||
async fn dehaze(_: impl Ctx, image_frame: ImageFrameTable<Color>, strength: Percentage) -> ImageFrameTable<Color> {
|
||||
let image_frame = image_frame.one_item();
|
||||
let image_frame_transform = image_frame.transform();
|
||||
let image_frame_alpha_blending = image_frame.one_instance().alpha_blending;
|
||||
|
||||
let image_frame = image_frame.one_instance().instance;
|
||||
|
||||
// Prepare the image data for processing
|
||||
let image = &image_frame.image;
|
||||
@@ -30,13 +34,11 @@ async fn dehaze(_: impl Ctx, image_frame: ImageFrameTable<Color>, strength: Perc
|
||||
base64_string: None,
|
||||
};
|
||||
|
||||
let result = ImageFrame {
|
||||
image: dehazed_image,
|
||||
transform: image_frame.transform,
|
||||
alpha_blending: image_frame.alpha_blending,
|
||||
};
|
||||
let mut result = ImageFrameTable::new(ImageFrame { image: dehazed_image });
|
||||
*result.transform_mut() = image_frame_transform;
|
||||
*result.one_instance_mut().alpha_blending = *image_frame_alpha_blending;
|
||||
|
||||
ImageFrameTable::new(result)
|
||||
result
|
||||
}
|
||||
|
||||
// There is no real point in modifying these values because they do not change the final result all that much.
|
||||
|
||||
Reference in New Issue
Block a user