Skip to content

Commit 94b0703

Browse files
committed
Code review
1 parent 2464b13 commit 94b0703

File tree

7 files changed

+12
-2
lines changed

7 files changed

+12
-2
lines changed

node-graph/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Instead of manually implementing the `Node` trait with complex generics, one can
102102

103103
```rs
104104
#[node_macro::node(category("Raster: Adjustments"))]
105-
fn opacity(_input: (), #[default(424242)] color: Color,#[soft_min(0.1)] opacity_multiplier: f64) -> Color {
105+
fn opacity(_input: (), #[default(424242)] color: Color, #[soft_min(0.1)] opacity_multiplier: f64) -> Color {
106106
let opacity_multiplier = opacity_multiplier as f32 / 100.;
107107
Color::from_rgbaf32_unchecked(color.r(), color.g(), color.b(), color.a() * opacity_multiplier)
108108
}

node-graph/gcore/src/misc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TODO(TrueDoctor): Replace this with the more idiomatic approach instead of using `trait Clampable`.
2+
13
/// A trait for types that can be clamped within a min/max range defined by f64.
24
pub trait Clampable: Sized {
35
/// Clamps the value to be no less than `min`.

node-graph/gcore/src/raster/adjustments.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,7 @@ async fn exposure<T: Adjust<Color>>(
14351435
offset: f64,
14361436
#[default(1.)]
14371437
#[range((0.01, 10.))]
1438+
#[hard_min(0.0001)]
14381439
gamma_correction: f64,
14391440
) -> T {
14401441
input.adjust(|color| {

node-graph/gcore/src/raster/color.rs

+2
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,8 @@ impl Color {
930930

931931
#[inline(always)]
932932
pub fn gamma(&self, gamma: f32) -> Color {
933+
let gamma = gamma.max(0.0001);
934+
933935
// From https://www.dfstudios.co.uk/articles/programming/image-programming-algorithms/image-processing-algorithms-part-6-gamma-correction/
934936
let inverse_gamma = 1. / gamma;
935937
self.map_rgb(|c: f32| c.powf(inverse_gamma))

node-graph/gcore/src/vector/vector_nodes.rs

+4
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,14 @@ async fn round_corners(
433433
#[default(10.)]
434434
radius: PixelLength,
435435
#[range((0., 1.))]
436+
#[hard_min(0.)]
437+
#[hard_max(1.)]
436438
#[default(0.5)]
437439
roundness: f64,
438440
#[default(100.)] edge_length_limit: Percentage,
439441
#[range((0., 180.))]
442+
#[hard_min(0.)]
443+
#[hard_max(180.)]
440444
#[default(5.)]
441445
min_angle_threshold: Angle,
442446
) -> VectorDataTable {

node-graph/gstd/src/filter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ async fn blur(
1212
image_frame: ImageFrameTable<Color>,
1313
/// The radius of the blur kernel.
1414
#[range((0., 100.))]
15+
#[hard_min(0.)]
1516
radius: PixelLength,
1617
/// Use a lower-quality box kernel instead of a circular Gaussian kernel. This is faster but produces boxy artifacts.
1718
box_blur: bool,

node-graph/gstd/src/image_color_palette.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ async fn image_color_palette(
66
_: impl Ctx,
77
image: ImageFrameTable<Color>,
88
#[hard_min(1.)]
9-
#[hard_max(28.)]
9+
#[soft_max(28.)]
1010
max_size: u32,
1111
) -> Vec<Color> {
1212
const GRID: f32 = 3.;

0 commit comments

Comments
 (0)