mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Add some Improvements to Mask Node (#1233)
These Improvements were proposed by nat-rix for PR #1153 but also apply to the Mask Node
This commit is contained in:
@@ -206,13 +206,14 @@ fn mask_image<
|
||||
|
||||
// Transforms a point from the background image to the forground image
|
||||
let bg_to_fg = image.transform() * DAffine2::from_scale(1. / image_size);
|
||||
let stencil_transform_inverse = stencil.transform().inverse();
|
||||
|
||||
let area = bg_to_fg.transform_point2(DVec2::new(1., 1.)) - bg_to_fg.transform_point2(DVec2::ZERO);
|
||||
let area = bg_to_fg.transform_vector2(DVec2::ONE);
|
||||
for y in 0..image.height() {
|
||||
for x in 0..image.width() {
|
||||
let image_point = DVec2::new(x as f64, y as f64);
|
||||
let mut mask_point = bg_to_fg.transform_point2(image_point);
|
||||
let local_mask_point = stencil.transform().inverse().transform_point2(mask_point);
|
||||
let local_mask_point = stencil_transform_inverse.transform_point2(mask_point);
|
||||
mask_point = stencil.transform().transform_point2(local_mask_point.clamp(DVec2::ZERO, DVec2::ONE));
|
||||
|
||||
let image_pixel = image.get_pixel_mut(x, y).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user