Improve type handling for ints/floats with the #[hard/soft_min/max(...)] node macro parameter attributes (#4041)

This commit is contained in:
Keavon Chambers
2026-04-23 15:49:30 -07:00
committed by GitHub
parent fcf9396a71
commit f42d12da9e
7 changed files with 114 additions and 19 deletions

View File

@@ -962,7 +962,7 @@ fn posterize<T: Adjust<Color>>(
#[gpu_image]
mut input: T,
#[default(4)]
#[hard_min(2.)]
#[hard_min(2)]
levels: u32,
) -> T {
input.adjust(|color| {

View File

@@ -1,11 +1,16 @@
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>>, #[default(4)] count: IntegerCount) -> Table<Color> {
async fn image_color_palette(
_: impl Ctx,
image: Table<Raster<CPU>>,
#[default(4)]
#[hard_min(1)]
count: u32,
) -> Table<Color> {
const GRID: f32 = 3.;
let bins = GRID * GRID * GRID;