Update #[min/max] node macro attributes to #[soft/hard]_[min/max] and make them clamp their input data (#2464)

* Fix min and max macro not enforcing limits when data flows

* Use trait based clamping

* Remove min/max from testing

* cargo fmt

* Resolve into min, and hard_min

* cargo fmt

* fix traits

* cargo fmt

* fix tests

* rename as soft_x

* Add validation code

* Clean up (not compiling because of DVec2 clamping)

* Avoid needing to add trait bounds to node definitions

* Code review

---------

Co-authored-by: Dennis Kobert <dennis@kobert.dev>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
mTvare
2025-05-01 12:22:27 +05:30
committed by GitHub
parent 2fc4896d01
commit 9303953cf8
13 changed files with 259 additions and 46 deletions

View File

@@ -12,6 +12,7 @@ async fn blur(
image_frame: ImageFrameTable<Color>,
/// The radius of the blur kernel.
#[range((0., 100.))]
#[hard_min(0.)]
radius: PixelLength,
/// Use a lower-quality box kernel instead of a circular Gaussian kernel. This is faster but produces boxy artifacts.
box_blur: bool,

View File

@@ -5,8 +5,8 @@ use graphene_core::{Color, Ctx};
async fn image_color_palette(
_: impl Ctx,
image: ImageFrameTable<Color>,
#[min(1.)]
#[max(28.)]
#[hard_min(1.)]
#[soft_max(28.)]
max_size: u32,
) -> Vec<Color> {
const GRID: f32 = 3.;