-
Notifications
You must be signed in to change notification settings - Fork 25
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
add clipRect() function #33
Comments
Is the idea that this method would only allow integer coords, and wouldn't be affected by the context's CTM, like From what I can tell, Skia's and CoreGraphics's versions also are affected by the context's transform and both accept floating point coords for their If there is indeed a very different implementation for "integer pixel axis aligned rects", and assuming it's more performant, shouldn't this be part of an implementation's optimizations rather than a new method on the already "well-stocked" API? Looking a bit on the internets, it seems that function clipRect(ctx, x, y, w, h) {
const path = new Path2D();
path.rect(x, y, w, h);
ctx.clip(path);
} |
The proposed function would have the same semantics as: function clipRect(ctx, x, y, w, h) {
const path = new Path2D();
path.rect(x, y, w, h);
ctx.clip(path);
} The advantage is that it's more performant than the more general JS implementation:
|
Clipping to integer pixel axis aligned rects has a very different implementation than arbitrary geometry. It would be nice to be able to expose
ctx.clipRect()
instead ofctx.rect(); ctx.clip();
Skia and CoreGraphics both expose a
clipRect()
type function so there's definitely precedence for this kind of thing.The text was updated successfully, but these errors were encountered: