Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transforms appear to have no effect on clipping #187

Open
J-Cake opened this issue Nov 28, 2022 · 1 comment
Open

Transforms appear to have no effect on clipping #187

J-Cake opened this issue Nov 28, 2022 · 1 comment

Comments

@J-Cake
Copy link

J-Cake commented Nov 28, 2022

I seem to have run into an issue where the transform I set (translation only at this point) has no effect on clips.

Take the example below

ctx.clear(SolidSource::from_unpremultiplied_argb(0xff, 0xff, 0xff, 0xff));

ctx.set_transform(&Transform::translation(50., 50.));
ctx.push_clip_rect(IntRect {
    min: IntPoint::zero(),
    max: IntPoint::new(100, 100)
});
let fill = Source::Solid(SolidSource::from_unpremultiplied_argb(0xff, 0xff, 0, 0));
ctx.fill_rect(0., 0., 200., 200., &fill, &DrawOptions::default());

The result I get is the following:
Screenshot_20221128_182231

If the transform were working, it would begin at (50, 50) and extend to (150, 150), however, reaches from (0, 0) to (100, 100). You can tell because the red rectangle is only 50x50 and offset to (50, 50).

If this is expected, what would the best approach be for computing the absolute transform, such that I can offset the clip accordingly?

@J-Cake
Copy link
Author

J-Cake commented Nov 28, 2022

This can also be confirmed by applying an incremental rotation to the transform, and observing where the clipping occurs.

@J-Cake J-Cake changed the title Transforms appears to have no effect on clipping Transforms appear to have no effect on clipping Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant