1240d25011
- Add `selection/state.rs` to manage selection masks, including combining masks and calculating bounds. - Introduce `vector_edit.rs` for vector shape manipulation, handling drag sessions, and hit testing for handles. - Create `feature_scorecard.rs` to ensure stable feature identifiers and regression gates for GUI components. - Implement raster behavior tests in `raster_test.rs` to validate gradient application against masks.
45 lines
967 B
Rust
45 lines
967 B
Rust
//! Pure Cycle 3 raster behavior tests.
|
|
|
|
use hcie_iced_gui::raster::apply_gradient;
|
|
|
|
#[test]
|
|
fn linear_gradient_interpolates_and_respects_mask() {
|
|
let mut pixels = vec![0; 3 * 4];
|
|
let mask = [255, 255, 0];
|
|
apply_gradient(
|
|
&mut pixels,
|
|
3,
|
|
1,
|
|
(0.5, 0.5),
|
|
(2.5, 0.5),
|
|
false,
|
|
[0, 0, 0, 255],
|
|
[200, 100, 50, 255],
|
|
1.0,
|
|
Some(&mask),
|
|
);
|
|
assert_eq!(&pixels[0..4], &[0, 0, 0, 255]);
|
|
assert_eq!(&pixels[4..8], &[100, 50, 25, 255]);
|
|
assert_eq!(&pixels[8..12], &[0, 0, 0, 0]);
|
|
}
|
|
|
|
#[test]
|
|
fn radial_gradient_uses_distance_from_origin() {
|
|
let mut pixels = vec![0; 3 * 4];
|
|
apply_gradient(
|
|
&mut pixels,
|
|
3,
|
|
1,
|
|
(0.5, 0.5),
|
|
(2.5, 0.5),
|
|
true,
|
|
[0, 0, 0, 255],
|
|
[200, 0, 0, 255],
|
|
1.0,
|
|
None,
|
|
);
|
|
assert_eq!(pixels[0], 0);
|
|
assert_eq!(pixels[4], 100);
|
|
assert_eq!(pixels[8], 200);
|
|
}
|