Skip to content

Commit 4e1cbc0

Browse files
committed
Removed object creation
1 parent cca6cd0 commit 4e1cbc0

1 file changed

Lines changed: 21 additions & 27 deletions

File tree

src/textures/Frame.js

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ var Frame = new Class({
322322
x: 0,
323323
y: 0,
324324
w: 0,
325-
h: 0
325+
h: 0,
326+
r: 0,
327+
b: 0
326328
},
327329
radius: 0,
328330
drawImage: {
@@ -430,6 +432,8 @@ var Frame = new Class({
430432
ss.y = destY;
431433
ss.w = destWidth;
432434
ss.h = destHeight;
435+
ss.r = destX + destWidth;
436+
ss.b = destY + destHeight;
433437

434438
// Adjust properties
435439
this.x = destX;
@@ -508,38 +512,28 @@ var Frame = new Class({
508512
// Need to check for intersection between the cut xywh and ox
509513
// If there is none, we set UV to be empty, otherwise set it to be the intersection rect
510514

511-
// The cut region
512-
var rectA = { x: ss.x, y: ss.y, w: ss.w, h: ss.h, right: ss.x + ss.w, bottom: ss.y + ss.h };
513-
514-
// The crop region
515-
var rectB = { x: x, y: y, w: width, h: height, right: x + width, bottom: y + height };
515+
var cropRight = x + width;
516+
var cropBottom = y + height;
516517

517-
var intersects = !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom);
518-
519-
window.rectA = rectA;
520-
window.rectB = rectB;
518+
var intersects = !(ss.r < x || ss.b < y || ss.x > cropRight || ss.y > cropBottom);
521519

522520
if (intersects)
523521
{
524-
var rx = Math.max(rectA.x, rectB.x);
525-
var ry = Math.max(rectA.y, rectB.y);
526-
var rw = Math.min(rectA.right, rectB.right) - rx;
527-
var rh = Math.min(rectA.bottom, rectB.bottom) - ry;
528-
529-
var rectC = { x: rx, y: ry, w: rw, h: rh, right: rx + rw, bottom: ry + rh };
530-
531-
window.rectC = rectC;
532-
533-
ox = cx + (rx - ss.x);
534-
oy = cy + (ry - ss.y);
535-
ow = rw;
536-
oh = rh;
522+
var ix = Math.max(ss.x, x);
523+
var iy = Math.max(ss.y, y);
524+
var iw = Math.min(ss.r, cropRight) - ix;
525+
var ih = Math.min(ss.b, cropBottom) - iy;
526+
527+
ox = cx + (ix - ss.x);
528+
oy = cy + (iy - ss.y);
529+
ow = iw;
530+
oh = ih;
537531

538-
x = rx;
539-
y = ry;
532+
x = ix;
533+
y = iy;
540534

541-
width = rw;
542-
height = rh;
535+
width = iw;
536+
height = ih;
543537
}
544538
else
545539
{

0 commit comments

Comments
 (0)