fix match zone and point alignments
This commit is contained in:
@@ -86,10 +86,17 @@ class JigsawPiece{
|
|||||||
maxY = point.y;
|
maxY = point.y;
|
||||||
}
|
}
|
||||||
wh = new Vec2(maxX, maxY);
|
wh = new Vec2(maxX, maxY);
|
||||||
// Crop the points so we don't make a bigger source rectangle than needed:
|
// Crop the points so we don't make a bigger source rectangle than needed,
|
||||||
|
// and the origin will align with center of mass better
|
||||||
xy.add(minX, minY);
|
xy.add(minX, minY);
|
||||||
for (point in points.concat([wh])) {
|
wh.subtract(minX, minY);
|
||||||
point.subtract(minX, minY);
|
points = [for (point in points) {
|
||||||
|
point.copy().subtract(minX, minY);
|
||||||
|
}];
|
||||||
|
for (compass => points in bubblePoints) {
|
||||||
|
if (points != null) {
|
||||||
|
bubblePoints[compass] = [for (point in points) point.copy().subtract(minX, minY)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,10 +12,12 @@ class Vec2{
|
|||||||
public function add(dx:Float, dy:Float) {
|
public function add(dx:Float, dy:Float) {
|
||||||
x += dx;
|
x += dx;
|
||||||
y += dy;
|
y += dy;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
public function subtract(dx:Float, dy:Float) {
|
public function subtract(dx:Float, dy:Float) {
|
||||||
x -= dx;
|
x -= dx;
|
||||||
y -= dy;
|
y -= dy;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
public function toString() {
|
public function toString() {
|
||||||
return '(${x}, ${y})';
|
return '(${x}, ${y})';
|
||||||
|
Reference in New Issue
Block a user