ref: bada775b5e90bff1f76034de4bd05c558ecb0848
parent: 64a242a6031ed1272602e061a29806bfa578131d
author: qwx <qwx@sciops.net>
date: Mon Aug 18 21:06:05 EDT 2025
vcrop: fix clamping of cropped images with panned images selection rect was correctly translated but not shrunk when drawn beyond the left border of the image
--- a/sys/src/cmd/vcrop.c
+++ b/sys/src/cmd/vcrop.c
@@ -64,8 +64,14 @@
o = addpt(n->r.min, o);
o = subpt(o, addpt(n->r.min, pos));
/* clamp rect to image bounds */
- if(o.x < n->r.min.x) o.x = n->r.min.x;
- if(o.y < n->r.min.y) o.y = n->r.min.y;
+ if(o.x < n->r.min.x){
+ r.max.x -= n->r.min.x - o.x;
+ o.x = n->r.min.x;
+ }
+ if(o.y < n->r.min.y){
+ r.max.y -= n->r.min.y - o.y;
+ o.y = n->r.min.y;
+ }
if((o.x + Dx(r)) > n->r.max.x) r.max.x = r.min.x + n->r.max.x - o.x;
if((o.y + Dy(r)) > n->r.max.y) r.max.y = r.min.y + n->r.max.y - o.y;
i = allocimage(display, r, n->chan, 0, DTransparent);
--
⑨