mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Rename the "Table" type to "List" everywhere (#4133)
* Rename the "Table" type to "List" everywhere * Fix a few missed ones * Re-save demo artwork
This commit is contained in:
@@ -12,11 +12,11 @@ impl Adjust<Color> for Color {
|
||||
#[cfg(feature = "std")]
|
||||
mod adjust_std {
|
||||
use super::*;
|
||||
use core_types::table::Table;
|
||||
use core_types::list::List;
|
||||
use raster_types::{CPU, Raster};
|
||||
use vector_types::GradientStops;
|
||||
|
||||
impl Adjust<Color> for Table<Raster<CPU>> {
|
||||
impl Adjust<Color> for List<Raster<CPU>> {
|
||||
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
|
||||
for element in self.iter_element_values_mut() {
|
||||
for color in element.data_mut().data.iter_mut() {
|
||||
@@ -25,14 +25,14 @@ mod adjust_std {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Adjust<Color> for Table<Color> {
|
||||
impl Adjust<Color> for List<Color> {
|
||||
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
|
||||
for element in self.iter_element_values_mut() {
|
||||
*element = map_fn(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Adjust<Color> for Table<GradientStops> {
|
||||
impl Adjust<Color> for List<GradientStops> {
|
||||
fn adjust(&mut self, map_fn: impl Fn(&Color) -> Color) {
|
||||
for element in self.iter_element_values_mut() {
|
||||
element.adjust(&map_fn);
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::adjust::Adjust;
|
||||
use crate::cubic_spline::CubicSplines;
|
||||
use core::fmt::Debug;
|
||||
#[cfg(feature = "std")]
|
||||
use core_types::table::Table;
|
||||
use core_types::list::List;
|
||||
use glam::{Vec3, Vec4};
|
||||
use no_std_types::color::Color;
|
||||
use no_std_types::context::Ctx;
|
||||
@@ -53,9 +53,9 @@ pub enum LuminanceCalculation {
|
||||
fn luminance<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut input: T,
|
||||
@@ -78,9 +78,9 @@ fn luminance<T: Adjust<Color>>(
|
||||
fn gamma_correction<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut input: T,
|
||||
@@ -99,9 +99,9 @@ fn gamma_correction<T: Adjust<Color>>(
|
||||
fn extract_channel<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut input: T,
|
||||
@@ -123,9 +123,9 @@ fn extract_channel<T: Adjust<Color>>(
|
||||
fn make_opaque<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut input: T,
|
||||
@@ -145,9 +145,9 @@ fn make_opaque<T: Adjust<Color>>(
|
||||
fn brightness_contrast_classic<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut input: T,
|
||||
@@ -176,9 +176,9 @@ fn brightness_contrast_classic<T: Adjust<Color>>(
|
||||
fn brightness_contrast<T: Adjust<Color>>(
|
||||
_ctx: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut input: T,
|
||||
@@ -257,9 +257,9 @@ fn brightness_contrast<T: Adjust<Color>>(
|
||||
fn levels<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut image: T,
|
||||
@@ -321,14 +321,14 @@ fn levels<T: Adjust<Color>>(
|
||||
// Algorithm from:
|
||||
// https://stackoverflow.com/a/55233732/775283
|
||||
// Works the same for gamma and linear color
|
||||
// TODO: Currently the un-Table-wrapped `tint` Color is causing a type error. Put this back in the "Raster: Adjustment" category once that's fixed.
|
||||
// TODO: Currently the un-List-wrapped `tint` Color is causing a type error. Put this back in the "Raster: Adjustment" category once that's fixed.
|
||||
#[node_macro::node(name("Black & White"), category(""), properties("black_and_white_properties"), shader_node(PerPixelAdjust))]
|
||||
fn black_and_white<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut image: T,
|
||||
@@ -399,9 +399,9 @@ fn black_and_white<T: Adjust<Color>>(
|
||||
fn hue_saturation<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut input: T,
|
||||
@@ -434,9 +434,9 @@ fn hue_saturation<T: Adjust<Color>>(
|
||||
fn invert<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut input: T,
|
||||
@@ -457,9 +457,9 @@ fn invert<T: Adjust<Color>>(
|
||||
fn threshold<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut image: T,
|
||||
@@ -503,9 +503,9 @@ fn threshold<T: Adjust<Color>>(
|
||||
fn vibrance<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut image: T,
|
||||
@@ -682,9 +682,9 @@ pub enum DomainWarpType {
|
||||
fn channel_mixer<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut image: T,
|
||||
@@ -816,9 +816,9 @@ pub enum SelectiveColorChoice {
|
||||
fn selective_color<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut image: T,
|
||||
@@ -962,9 +962,9 @@ fn selective_color<T: Adjust<Color>>(
|
||||
fn posterize<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut input: T,
|
||||
@@ -996,9 +996,9 @@ fn posterize<T: Adjust<Color>>(
|
||||
fn exposure<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut input: T,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::adjust::Adjust;
|
||||
#[cfg(feature = "std")]
|
||||
use core_types::table::Table;
|
||||
use core_types::list::List;
|
||||
use no_std_types::Ctx;
|
||||
use no_std_types::blending::BlendMode;
|
||||
use no_std_types::color::{Color, Pixel};
|
||||
@@ -23,54 +23,54 @@ impl Blend<Color> for Color {
|
||||
mod blend_std {
|
||||
use super::*;
|
||||
use core::cmp::Ordering;
|
||||
use core_types::table::Table;
|
||||
use core_types::list::List;
|
||||
use raster_types::Image;
|
||||
use raster_types::Raster;
|
||||
|
||||
impl Blend<Color> for Table<Raster<CPU>> {
|
||||
impl Blend<Color> for List<Raster<CPU>> {
|
||||
fn blend(&self, under: &Self, blend_fn: impl Fn(Color, Color) -> Color) -> Self {
|
||||
let mut result_table = self.clone();
|
||||
let pair_count = result_table.len().min(under.len());
|
||||
let mut result_list = self.clone();
|
||||
let pair_count = result_list.len().min(under.len());
|
||||
for index in 0..pair_count {
|
||||
let Some(over) = result_table.element(index) else { break };
|
||||
let Some(over) = result_list.element(index) else { break };
|
||||
let Some(under_element) = under.element(index) else { break };
|
||||
let data = over.data.iter().zip(under_element.data.iter()).map(|(a, b)| blend_fn(*a, *b)).collect();
|
||||
let (width, height) = (over.width, over.height);
|
||||
|
||||
*result_table.element_mut(index).unwrap() = Raster::new_cpu(Image {
|
||||
*result_list.element_mut(index).unwrap() = Raster::new_cpu(Image {
|
||||
data,
|
||||
width,
|
||||
height,
|
||||
base64_string: None,
|
||||
});
|
||||
}
|
||||
result_table
|
||||
result_list
|
||||
}
|
||||
}
|
||||
impl Blend<Color> for Table<Color> {
|
||||
impl Blend<Color> for List<Color> {
|
||||
fn blend(&self, under: &Self, blend_fn: impl Fn(Color, Color) -> Color) -> Self {
|
||||
let mut result_table = self.clone();
|
||||
let pair_count = result_table.len().min(under.len());
|
||||
let mut result_list = self.clone();
|
||||
let pair_count = result_list.len().min(under.len());
|
||||
for index in 0..pair_count {
|
||||
let Some(over) = result_table.element(index) else { break };
|
||||
let Some(over) = result_list.element(index) else { break };
|
||||
let Some(under_element) = under.element(index) else { break };
|
||||
let new_val = blend_fn(*over, *under_element);
|
||||
*result_table.element_mut(index).unwrap() = new_val;
|
||||
*result_list.element_mut(index).unwrap() = new_val;
|
||||
}
|
||||
result_table
|
||||
result_list
|
||||
}
|
||||
}
|
||||
impl Blend<Color> for Table<GradientStops> {
|
||||
impl Blend<Color> for List<GradientStops> {
|
||||
fn blend(&self, under: &Self, blend_fn: impl Fn(Color, Color) -> Color) -> Self {
|
||||
let mut result_table = self.clone();
|
||||
let pair_count = result_table.len().min(under.len());
|
||||
let mut result_list = self.clone();
|
||||
let pair_count = result_list.len().min(under.len());
|
||||
for index in 0..pair_count {
|
||||
let Some(over) = result_table.element(index) else { break };
|
||||
let Some(over) = result_list.element(index) else { break };
|
||||
let Some(under_element) = under.element(index) else { break };
|
||||
let new_val = over.blend(under_element, &blend_fn);
|
||||
*result_table.element_mut(index).unwrap() = new_val;
|
||||
*result_list.element_mut(index).unwrap() = new_val;
|
||||
}
|
||||
result_table
|
||||
result_list
|
||||
}
|
||||
}
|
||||
impl Blend<Color> for GradientStops {
|
||||
@@ -145,17 +145,17 @@ pub fn apply_blend_mode(foreground: Color, background: Color, blend_mode: BlendM
|
||||
fn mix<T: Blend<Color> + Send>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
over: T,
|
||||
#[expose]
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
under: T,
|
||||
@@ -169,9 +169,9 @@ fn mix<T: Blend<Color> + Send>(
|
||||
fn color_overlay<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
#[gpu_image]
|
||||
mut image: T,
|
||||
@@ -197,7 +197,7 @@ fn color_overlay<T: Adjust<Color>>(
|
||||
mod test {
|
||||
use core_types::blending::BlendMode;
|
||||
use core_types::color::Color;
|
||||
use core_types::table::Table;
|
||||
use core_types::list::List;
|
||||
use raster_types::Image;
|
||||
use raster_types::Raster;
|
||||
|
||||
@@ -212,7 +212,7 @@ mod test {
|
||||
// 100% of the output should come from the multiplied value
|
||||
let opacity = 100.;
|
||||
|
||||
let result = super::color_overlay((), Table::new_from_element(Raster::new_cpu(image.clone())), overlay_color, BlendMode::Multiply, opacity);
|
||||
let result = super::color_overlay((), List::new_from_element(Raster::new_cpu(image.clone())), overlay_color, BlendMode::Multiply, opacity);
|
||||
let result = result.element(0).unwrap().clone();
|
||||
|
||||
// The output should just be the original green and alpha channels (as we multiply them by 1 and other channels by 0)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use core_types::context::Ctx;
|
||||
use core_types::list::List;
|
||||
use core_types::registry::types::Percentage;
|
||||
use core_types::table::Table;
|
||||
use image::{DynamicImage, GenericImage, GenericImageView, GrayImage, ImageBuffer, Luma, Rgba, RgbaImage};
|
||||
use ndarray::{Array2, ArrayBase, Dim, OwnedRepr};
|
||||
use raster_types::Image;
|
||||
@@ -8,7 +8,7 @@ use raster_types::{CPU, Raster};
|
||||
use std::cmp::{max, min};
|
||||
|
||||
#[node_macro::node(category("Raster: Filter"))]
|
||||
async fn dehaze(_: impl Ctx, image_frame: Table<Raster<CPU>>, strength: Percentage) -> Table<Raster<CPU>> {
|
||||
async fn dehaze(_: impl Ctx, image_frame: List<Raster<CPU>>, strength: Percentage) -> List<Raster<CPU>> {
|
||||
image_frame
|
||||
.into_iter()
|
||||
.map(|mut row| {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use core_types::color::Color;
|
||||
use core_types::context::Ctx;
|
||||
use core_types::list::List;
|
||||
use core_types::registry::types::PixelLength;
|
||||
use core_types::table::Table;
|
||||
use raster_types::Image;
|
||||
use raster_types::{Bitmap, BitmapMut};
|
||||
use raster_types::{CPU, Raster};
|
||||
@@ -11,7 +11,7 @@ use raster_types::{CPU, Raster};
|
||||
async fn blur(
|
||||
_: impl Ctx,
|
||||
/// The image to be blurred.
|
||||
image_frame: Table<Raster<CPU>>,
|
||||
image_frame: List<Raster<CPU>>,
|
||||
/// The radius of the blur kernel.
|
||||
#[range((0., 100.))]
|
||||
#[hard_min(0.)]
|
||||
@@ -20,7 +20,7 @@ async fn blur(
|
||||
box_blur: bool,
|
||||
/// Opt to incorrectly apply the filter with color calculations in gamma space for compatibility with the results from other software.
|
||||
gamma: bool,
|
||||
) -> Table<Raster<CPU>> {
|
||||
) -> List<Raster<CPU>> {
|
||||
image_frame
|
||||
.into_iter()
|
||||
.map(|mut row| {
|
||||
@@ -47,12 +47,12 @@ async fn blur(
|
||||
async fn median_filter(
|
||||
_: impl Ctx,
|
||||
/// The image to be filtered.
|
||||
image_frame: Table<Raster<CPU>>,
|
||||
image_frame: List<Raster<CPU>>,
|
||||
/// The radius of the filter kernel. Larger values remove more noise but may blur fine details.
|
||||
#[range((0., 50.))]
|
||||
#[hard_min(0.)]
|
||||
radius: PixelLength,
|
||||
) -> Table<Raster<CPU>> {
|
||||
) -> List<Raster<CPU>> {
|
||||
image_frame
|
||||
.into_iter()
|
||||
.map(|mut row| {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Not immediately shader compatible due to needing [`GradientStops`] as a param, which needs [`Vec`]
|
||||
|
||||
use crate::adjust::Adjust;
|
||||
use core_types::table::Table;
|
||||
use core_types::list::List;
|
||||
use core_types::{Color, Ctx};
|
||||
use raster_types::{CPU, Raster};
|
||||
use vector_types::GradientStops;
|
||||
@@ -13,12 +13,12 @@ use vector_types::GradientStops;
|
||||
async fn gradient_map<T: Adjust<Color>>(
|
||||
_: impl Ctx,
|
||||
#[implementations(
|
||||
Table<Raster<CPU>>,
|
||||
Table<Color>,
|
||||
Table<GradientStops>,
|
||||
List<Raster<CPU>>,
|
||||
List<Color>,
|
||||
List<GradientStops>,
|
||||
)]
|
||||
mut image: T,
|
||||
gradient: Table<GradientStops>,
|
||||
gradient: List<GradientStops>,
|
||||
reverse: bool,
|
||||
) -> T {
|
||||
let Some(gradient) = gradient.element(0) else { return image };
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
use core_types::color::Color;
|
||||
use core_types::context::Ctx;
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::list::{Item, List};
|
||||
use raster_types::{CPU, Raster};
|
||||
|
||||
#[node_macro::node(category("Color"))]
|
||||
async fn image_color_palette(
|
||||
_: impl Ctx,
|
||||
image: Table<Raster<CPU>>,
|
||||
image: List<Raster<CPU>>,
|
||||
#[default(4)]
|
||||
#[hard_min(1)]
|
||||
count: u32,
|
||||
) -> Table<Color> {
|
||||
) -> List<Color> {
|
||||
const GRID: f32 = 3.;
|
||||
|
||||
let bins = GRID * GRID * GRID;
|
||||
@@ -71,7 +71,7 @@ mod test {
|
||||
fn test_image_color_palette() {
|
||||
let result = image_color_palette(
|
||||
(),
|
||||
Table::new_from_element(Raster::new_cpu(Image {
|
||||
List::new_from_element(Raster::new_cpu(Image {
|
||||
width: 100,
|
||||
height: 100,
|
||||
data: vec![Color::from_rgbaf32(0., 0., 0., 1.).unwrap(); 10000],
|
||||
@@ -79,6 +79,6 @@ mod test {
|
||||
})),
|
||||
1,
|
||||
);
|
||||
assert_eq!(futures::executor::block_on(result), Table::new_from_element(Color::from_rgbaf32(0., 0., 0., 1.).unwrap()));
|
||||
assert_eq!(futures::executor::block_on(result), List::new_from_element(Color::from_rgbaf32(0., 0., 0., 1.).unwrap()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ use core_types::ATTR_TRANSFORM;
|
||||
use core_types::color::Color;
|
||||
use core_types::color::{Alpha, AlphaMut, Channel, LinearChannel, Luminance, RGBMut};
|
||||
use core_types::context::{Ctx, ExtractFootprint};
|
||||
use core_types::list::{Item, List};
|
||||
use core_types::math::bbox::Bbox;
|
||||
use core_types::table::{Item, Table};
|
||||
use core_types::transform::Transform;
|
||||
use dyn_any::DynAny;
|
||||
use fastnoise_lite;
|
||||
@@ -30,7 +30,7 @@ impl From<std::io::Error> for Error {
|
||||
}
|
||||
|
||||
#[node_macro::node(category("Debug"))]
|
||||
pub fn sample_image(ctx: impl ExtractFootprint + Clone + Send, image_frame: Table<Raster<CPU>>) -> Table<Raster<CPU>> {
|
||||
pub fn sample_image(ctx: impl ExtractFootprint + Clone + Send, image_frame: List<Raster<CPU>>) -> List<Raster<CPU>> {
|
||||
image_frame
|
||||
.into_iter()
|
||||
.filter_map(|row| {
|
||||
@@ -97,11 +97,11 @@ pub fn sample_image(ctx: impl ExtractFootprint + Clone + Send, image_frame: Tabl
|
||||
pub fn combine_channels(
|
||||
_: impl Ctx,
|
||||
_primary: (),
|
||||
#[expose] red: Table<Raster<CPU>>,
|
||||
#[expose] green: Table<Raster<CPU>>,
|
||||
#[expose] blue: Table<Raster<CPU>>,
|
||||
#[expose] alpha: Table<Raster<CPU>>,
|
||||
) -> Table<Raster<CPU>> {
|
||||
#[expose] red: List<Raster<CPU>>,
|
||||
#[expose] green: List<Raster<CPU>>,
|
||||
#[expose] blue: List<Raster<CPU>>,
|
||||
#[expose] alpha: List<Raster<CPU>>,
|
||||
) -> List<Raster<CPU>> {
|
||||
let max_len = red.len().max(green.len()).max(blue.len()).max(alpha.len());
|
||||
let red = red.into_iter().map(Some).chain(std::iter::repeat(None)).take(max_len);
|
||||
let green = green.into_iter().map(Some).chain(std::iter::repeat(None)).take(max_len);
|
||||
@@ -178,11 +178,11 @@ pub fn combine_channels(
|
||||
pub fn mask(
|
||||
_: impl Ctx,
|
||||
/// The image to be masked.
|
||||
image: Table<Raster<CPU>>,
|
||||
image: List<Raster<CPU>>,
|
||||
/// The stencil to be used for masking.
|
||||
#[expose]
|
||||
stencil: Table<Raster<CPU>>,
|
||||
) -> Table<Raster<CPU>> {
|
||||
stencil: List<Raster<CPU>>,
|
||||
) -> List<Raster<CPU>> {
|
||||
// TODO: Figure out what it means to support multiple stencil items?
|
||||
let Some(stencil) = stencil.into_iter().next() else {
|
||||
// No stencil provided so we return the original image
|
||||
@@ -226,7 +226,7 @@ pub fn mask(
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""))]
|
||||
pub fn extend_image_to_bounds(_: impl Ctx, image: Table<Raster<CPU>>, bounds: DAffine2) -> Table<Raster<CPU>> {
|
||||
pub fn extend_image_to_bounds(_: impl Ctx, image: List<Raster<CPU>>, bounds: DAffine2) -> List<Raster<CPU>> {
|
||||
image
|
||||
.into_iter()
|
||||
.map(|mut row| {
|
||||
@@ -240,7 +240,7 @@ pub fn extend_image_to_bounds(_: impl Ctx, image: Table<Raster<CPU>>, bounds: DA
|
||||
let image_data = &row.element().data;
|
||||
let (image_width, image_height) = (row.element().width, row.element().height);
|
||||
if image_width == 0 || image_height == 0 {
|
||||
return empty_image((), bounds, Table::new_from_element(Color::TRANSPARENT)).into_iter().next().unwrap();
|
||||
return empty_image((), bounds, List::new_from_element(Color::TRANSPARENT)).into_iter().next().unwrap();
|
||||
}
|
||||
|
||||
let orig_image_scale = DVec2::new(image_width as f64, image_height as f64);
|
||||
@@ -274,23 +274,23 @@ pub fn extend_image_to_bounds(_: impl Ctx, image: Table<Raster<CPU>>, bounds: DA
|
||||
}
|
||||
|
||||
#[node_macro::node(category("Debug"))]
|
||||
pub fn empty_image(_: impl Ctx, transform: DAffine2, color: Table<Color>) -> Table<Raster<CPU>> {
|
||||
pub fn empty_image(_: impl Ctx, transform: DAffine2, color: List<Color>) -> List<Raster<CPU>> {
|
||||
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 color = color.element(0).copied().unwrap_or(Color::WHITE);
|
||||
let image = Image::new(width, height, color);
|
||||
|
||||
let mut result_table = Table::new_from_element(Raster::new_cpu(image));
|
||||
result_table.set_attribute(ATTR_TRANSFORM, 0, transform);
|
||||
let mut result_list = List::new_from_element(Raster::new_cpu(image));
|
||||
result_list.set_attribute(ATTR_TRANSFORM, 0, transform);
|
||||
|
||||
// Callers of empty_image can safely unwrap on returned `Table`
|
||||
result_table
|
||||
// Callers of empty_image can safely unwrap on returned `List`
|
||||
result_list
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""))]
|
||||
pub fn image(_: impl Ctx, _primary: (), image: Image<Color>) -> Table<Raster<CPU>> {
|
||||
Table::new_from_element(Raster::new_cpu(image))
|
||||
pub fn image(_: impl Ctx, _primary: (), image: Image<Color>) -> List<Raster<CPU>> {
|
||||
List::new_from_element(Raster::new_cpu(image))
|
||||
}
|
||||
|
||||
/// Generates customizable procedural noise patterns.
|
||||
@@ -328,7 +328,7 @@ pub fn noise_pattern(
|
||||
#[widget(ParsedWidgetOverride::Custom = "noise_properties_cellular_jitter")]
|
||||
#[default(1.)]
|
||||
cellular_jitter: f64,
|
||||
) -> Table<Raster<CPU>> {
|
||||
) -> List<Raster<CPU>> {
|
||||
let footprint = ctx.footprint();
|
||||
let viewport_bounds = footprint.viewport_bounds_in_local_space();
|
||||
|
||||
@@ -346,7 +346,7 @@ pub fn noise_pattern(
|
||||
|
||||
// If the image would not be visible, return an empty image
|
||||
if size.x <= 0. || size.y <= 0. {
|
||||
return Table::new();
|
||||
return List::new();
|
||||
}
|
||||
|
||||
let transform = DAffine2::from_translation(offset) * DAffine2::from_scale(size);
|
||||
@@ -392,7 +392,7 @@ pub fn noise_pattern(
|
||||
}
|
||||
}
|
||||
|
||||
return Table::new_from_item(Item::new_from_element(Raster::new_cpu(image)).with_attribute(ATTR_TRANSFORM, transform));
|
||||
return List::new_from_item(Item::new_from_element(Raster::new_cpu(image)).with_attribute(ATTR_TRANSFORM, transform));
|
||||
}
|
||||
};
|
||||
noise.set_noise_type(Some(noise_type));
|
||||
@@ -450,11 +450,11 @@ pub fn noise_pattern(
|
||||
}
|
||||
}
|
||||
|
||||
Table::new_from_item(Item::new_from_element(Raster::new_cpu(image)).with_attribute(ATTR_TRANSFORM, transform))
|
||||
List::new_from_item(Item::new_from_element(Raster::new_cpu(image)).with_attribute(ATTR_TRANSFORM, transform))
|
||||
}
|
||||
|
||||
#[node_macro::node(category("Raster: Pattern"))]
|
||||
pub fn mandelbrot(ctx: impl ExtractFootprint + Send) -> Table<Raster<CPU>> {
|
||||
pub fn mandelbrot(ctx: impl ExtractFootprint + Send) -> List<Raster<CPU>> {
|
||||
let footprint = ctx.footprint();
|
||||
let viewport_bounds = footprint.viewport_bounds_in_local_space();
|
||||
|
||||
@@ -466,7 +466,7 @@ pub fn mandelbrot(ctx: impl ExtractFootprint + Send) -> Table<Raster<CPU>> {
|
||||
|
||||
// If the image would not be visible, return an empty image
|
||||
if size.x <= 0. || size.y <= 0. {
|
||||
return Table::new();
|
||||
return List::new();
|
||||
}
|
||||
|
||||
let scale = footprint.scale();
|
||||
@@ -488,7 +488,7 @@ pub fn mandelbrot(ctx: impl ExtractFootprint + Send) -> Table<Raster<CPU>> {
|
||||
}
|
||||
}
|
||||
|
||||
Table::new_from_item(
|
||||
List::new_from_item(
|
||||
Item::new_from_element(Raster::new_cpu(Image {
|
||||
width,
|
||||
height,
|
||||
|
||||
Reference in New Issue
Block a user