aabb property
AABB
get
aabb
Implementation
AABB get aabb {
final r = texture.rect;
final w = r.width * scale;
final h = r.height * scale;
if (rotation == 0) {
return AABB(
Vec2(position.x - originX * w, position.y - originY * h),
width: w,
height: h,
);
}
final ox = r.width * originX;
final oy = r.height * originY;
final cosR = cos(rotation);
final sinR = sin(rotation);
final l = -ox, rw = r.width - ox;
final t = -oy, b = r.height - oy;
final sx = scale, cx = cosR, sx2 = sinR;
final lc = l * cx, ls = l * sx2;
final rc = rw * cx, rs = rw * sx2;
final tc = t * cx, ts = t * sx2;
final bc = b * cx, bs = b * sx2;
final p1x = position.x + (lc - ts) * sx;
final p1y = position.y + (ls + tc) * sx;
final p2x = position.x + (lc - bs) * sx;
final p2y = position.y + (ls + bc) * sx;
final p3x = position.x + (rc - ts) * sx;
final p3y = position.y + (rs + tc) * sx;
final p4x = position.x + (rc - bs) * sx;
final p4y = position.y + (rs + bc) * sx;
final minX = min(min(p1x, p2x), min(p3x, p4x));
final maxX = max(max(p1x, p2x), max(p3x, p4x));
final minY = min(min(p1y, p2y), min(p3y, p4y));
final maxY = max(max(p1y, p2y), max(p3y, p4y));
return AABB(
Vec2(minX, minY),
width: maxX - minX,
height: maxY - minY,
);
}