New nodes: RGBA to Color, HSVA to Color, Hex to Color, and Read Gradient (#3838)

* New nodes: RGBA to Color, HSVA to Color, Hex to Color, and Read Gradient

* Simplify
This commit is contained in:
Keavon Chambers
2026-02-26 18:22:04 -08:00
committed by GitHub
parent f1cbc4b396
commit 9ecbfb7110
12 changed files with 154 additions and 43 deletions

View File

@@ -1,16 +1,11 @@
use core_types::color::Color;
use core_types::context::Ctx;
use core_types::registry::types::IntegerCount;
use core_types::table::{Table, TableRow};
use raster_types::{CPU, Raster};
#[node_macro::node(category("Color"))]
async fn image_color_palette(
_: impl Ctx,
image: Table<Raster<CPU>>,
#[hard_min(1.)]
#[soft_max(28.)]
max_size: u32,
) -> Table<Color> {
async fn image_color_palette(_: impl Ctx, image: Table<Raster<CPU>>, #[default(4)] count: IntegerCount) -> Table<Color> {
const GRID: f32 = 3.;
let bins = GRID * GRID * GRID;
@@ -35,7 +30,7 @@ async fn image_color_palette(
shorted
.iter()
.take(max_size as usize)
.take(count as usize)
.flat_map(|&i| {
let list = &color_bins[i];