public static Rectangle GetBoundingBox(this MoveableObjectData Data, MainForm mainForm) { Rectangle Rect = Data.GetRect(mainForm /*.currentProject*/); //Collect corner points Point TopLeft = Rect.Location; Point TopRight = new Point(Rect.Location.X + Rect.Width, Rect.Location.Y); Point BottomLeft = new Point(Rect.Location.X, Rect.Location.Y + Rect.Height); Point BottomRight = new Point(Rect.Location.X + Rect.Width, Rect.Location.Y + Rect.Height); //Rotate corner points PointF Center = new PointF(Rect.Location.X + Rect.Width / 2f, Rect.Location.Y + Rect.Height / 2f); TopLeft = Point.Round(StaticHelpers.RotatePointAround(TopLeft, Center, Data.rotation)); TopRight = Point.Round(StaticHelpers.RotatePointAround(TopRight, Center, Data.rotation)); BottomLeft = Point.Round(StaticHelpers.RotatePointAround(BottomLeft, Center, Data.rotation)); BottomRight = Point.Round(StaticHelpers.RotatePointAround(BottomRight, Center, Data.rotation)); int minX = Math.Min(TopLeft.X, Math.Min(TopRight.X, Math.Min(BottomLeft.X, BottomRight.X))); int maxX = Math.Max(TopLeft.X, Math.Max(TopRight.X, Math.Max(BottomLeft.X, BottomRight.X))); int minY = Math.Min(TopLeft.Y, Math.Min(TopRight.Y, Math.Min(BottomLeft.Y, BottomRight.Y))); int maxY = Math.Max(TopLeft.Y, Math.Max(TopRight.Y, Math.Max(BottomLeft.Y, BottomRight.Y))); return(new Rectangle(minX, minY, maxX - minX, maxY - minY)); }
public static bool ContainsPoint(this IslandInstanceData Data, Point p, MainForm mainForm) { Rectangle Rect = Data.GetRect(mainForm.currentProject, mainForm.islands); PointF rotatedP = StaticHelpers.RotatePointAround(p, new PointF(Rect.Left + Rect.Width / 2.0f, Rect.Top + Rect.Height / 2.0f), -Data.rotation); p.X = (int)rotatedP.X; p.Y = (int)rotatedP.Y; return(Rect.Contains(p)); }
public static PointF GetPrevControlPoint(this BezierNodeData Data) { PointF controlPoint = new PointF(Data.worldX - Data.controlPointsDistance, Data.worldY); return(StaticHelpers.RotatePointAround(controlPoint, new PointF(Data.worldX, Data.worldY), Data.rotation)); }