public virtual JabRectangle GetRectangle() { JabRectangle rec; if (DrawIn == DrawSpace.SCREENSPACE) { rec = new JabRectangle((float)TopLeftPosition().X, (float)TopLeftPosition().Y, (float)(Width * ScaleX), (float)(Height * ScaleY)); } else { Vector2 topleftpos = TopLeftPosition(); rec = new JabRectangle(topleftpos.X, topleftpos.Y, (float)(Width * ScaleX * Camera.Get.WorldScale.X), (float)(Height * ScaleY * Camera.Get.WorldScale.Y)); } Vector2 topleft = Vector2.Zero; topleft.X = rec.Left; topleft.Y = rec.Top; Vector2 bottomRight = Vector2.Zero; bottomRight.X = rec.Right; bottomRight.Y = rec.Bottom; Vector2 topright = Vector2.Zero; topright.X = rec.Right; topright.Y = rec.Top; Vector2 bottomleft = Vector2.Zero; bottomleft.X = rec.Left; bottomleft.Y = rec.Bottom; topleft = JabMath.RotateVectorAround(HandleAdjustedPosition(), topleft, Rot); bottomRight = JabMath.RotateVectorAround(HandleAdjustedPosition(), bottomRight, Rot); bottomleft = JabMath.RotateVectorAround(HandleAdjustedPosition(), bottomleft, Rot); topright = JabMath.RotateVectorAround(HandleAdjustedPosition(), topright, Rot); Vector2 newTopLeft = Vector2.Zero; Vector2 newBottomRight = Vector2.Zero; if (DrawIn == DrawSpace.WORLDSPACE) { newTopLeft = new Vector2(Math.Min(Math.Min(topleft.X, bottomRight.X), Math.Min(bottomleft.X, topright.X)), Math.Min(Math.Min(topleft.Y, bottomRight.Y), Math.Min(bottomleft.Y, topright.Y))); newBottomRight = new Vector2( Math.Max(Math.Max(topleft.X, bottomRight.X), Math.Max(bottomleft.X, topright.X)), Math.Max(Math.Max(topleft.Y, bottomRight.Y), Math.Max(bottomleft.Y, topright.Y))); } else { newTopLeft = new Vector2(Math.Min(Math.Min(topleft.X, bottomRight.X), Math.Min(bottomleft.X, topright.X)), Math.Min(Math.Min(topleft.Y, bottomRight.Y), Math.Min(bottomleft.Y, topright.Y))); newBottomRight = new Vector2( Math.Max(Math.Max(topleft.X, bottomRight.X), Math.Max(bottomleft.X, topright.X)), Math.Max(Math.Max(topleft.Y, bottomRight.Y), Math.Max(bottomleft.Y, topright.Y))); } float rectangleWidth = (float)Math.Abs((float)newTopLeft.X - newBottomRight.X); float rectangleHeight = (float)Math.Abs((float)newTopLeft.Y - newBottomRight.Y); Vector2 pos = bottomRight - (new Vector2(rectangleWidth, rectangleHeight)); if (DrawIn == DrawSpace.SCREENSPACE) { rec = new JabRectangle(newTopLeft.X, newTopLeft.Y, rectangleWidth, rectangleHeight); } else { newTopLeft /= BaseGame.Get.BackBufferDimensions; rec = new JabRectangle(newTopLeft.X, newTopLeft.Y, rectangleWidth / BaseGame.Get.BackBufferWidth, rectangleHeight / BaseGame.Get.BackBufferHeight); } return(rec); }