-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Describe the bug
When a Group is anchored, the bounding box displayed with .debug = true
isn't shifted.
This can be seen here: https://codehs.github.io/chs-js-lib/examples/groups/anchor/
Cause
This is a weird conflict between how Groups are Polygons are anchored. When Thing
s have their bounding box drawn, the canvas translates to 0, 0
then draws the red box around the thing's bounds.
This is complicated by the fact that Groups' x,y is the top left corner of their bounds.
This bug was introduced in this commit: 68d2cca
Solution?
Making Groups' x, y position consider the Groups' anchors might fix this, but that would mean that the anchoring of the Group affects its position, which diverges from the rest of Things.
That could be changed by making a Group do:
get x() {
const bounds = this.getBounds();
return bounds.left + (bounds.right - bounds.left) * this.anchor.horizontal;
}
for example. Then the x, y is still independent of anchor, but bounds (which will be used for drawing the debug and maybe for other checks) will be properly calculated.