protected override Rectangle CalculateBoundingRectangle(bool tight) { if (tight) { CalcShapeRectangles(out smallRectBuffer, out largeRectBuffer); largeRectBuffer.Offset(X, Y); smallRectBuffer.Offset(X, Y); float angle = Geometry.TenthsOfDegreeToDegrees(Angle); Point tl = Geometry.RotatePoint(X, Y, angle, largeRectBuffer.Left, largeRectBuffer.Top); Point tr = Geometry.RotatePoint(X, Y, angle, largeRectBuffer.Right, largeRectBuffer.Top); Point bl1 = Geometry.RotatePoint(X, Y, angle, largeRectBuffer.Left, largeRectBuffer.Bottom); Point br1 = Geometry.RotatePoint(X, Y, angle, largeRectBuffer.Right, largeRectBuffer.Bottom); Point bl2 = Geometry.RotatePoint(X, Y, angle, smallRectBuffer.Left, smallRectBuffer.Bottom); Point br2 = Geometry.RotatePoint(X, Y, angle, smallRectBuffer.Right, smallRectBuffer.Bottom); Rectangle result = Rectangle.Empty; Geometry.CalcBoundingRectangle(tl, tr, bl1, br1, out result); result = Geometry.UniteWithRectangle(bl2, result); result = Geometry.UniteWithRectangle(br2, result); ShapeUtils.InflateBoundingRectangle(ref result, LineStyle); return(result); } else { return(base.CalculateBoundingRectangle(tight)); } }
protected override Rectangle CalculateBoundingRectangle(bool tight) { if (tight) { CalcRingBounds(out upperRingBounds, out lowerRingBounds); float angle = Geometry.TenthsOfDegreeToDegrees(Angle); float ringRadius = upperRingBounds.Width / 2f; PointF upperCenter = PointF.Empty; upperCenter.X = X + (upperRingBounds.Left + upperRingBounds.Width / 2f); upperCenter.Y = Y + (upperRingBounds.Top + upperRingBounds.Height / 2f); PointF lowerCenter = PointF.Empty; lowerCenter.X = X + (lowerRingBounds.Left + lowerRingBounds.Width / 2f); lowerCenter.Y = Y + (lowerRingBounds.Top + lowerRingBounds.Height / 2f); upperCenter = Geometry.RotatePoint(X, Y, angle, upperCenter); lowerCenter = Geometry.RotatePoint(X, Y, angle, lowerCenter); Rectangle result = Rectangle.Empty; result.X = (int)Math.Round(Math.Min(upperCenter.X - ringRadius, lowerCenter.X - ringRadius)); result.Y = (int)Math.Round(Math.Min(upperCenter.Y - ringRadius, lowerCenter.Y - ringRadius)); result.Width = (int)Math.Round(Math.Max(upperCenter.X + ringRadius, lowerCenter.X + ringRadius)) - result.X; result.Height = (int)Math.Round(Math.Max(upperCenter.Y + ringRadius, lowerCenter.Y + ringRadius)) - result.Y; result = Geometry.UniteWithRectangle(Geometry.RotatePoint(X, Y, angle, X, Y - (Height / 2)), result); result = Geometry.UniteWithRectangle(Geometry.RotatePoint(X, Y, angle, X, Y - (Height / 2) + Height), result); ShapeUtils.InflateBoundingRectangle(ref result, LineStyle); return(result); } else { return(base.CalculateBoundingRectangle(tight)); } }
/// <override></override> protected override Rectangle CalculateBoundingRectangle(bool tight) { // tight and loose fitting bounding rectangles are equal if (Angle == 0 || Angle == 900 || Angle == 1800 || Angle == 2700) { return(base.CalculateBoundingRectangle(tight)); } else { // Calculate tight fitting bounding rectangle Rectangle result = Geometry.InvalidRectangle; float angleDeg = Geometry.TenthsOfDegreeToDegrees(Angle); int x1, y1, x2, y2, x3, y3; int left = (int)Math.Round(X - (Width / 2f)); int top = Y - (int)Math.Round(Height * CenterPosFactorY); int right = left + Width; int bottom = top + Height; x1 = left; y1 = top; x2 = right; y2 = top; x3 = X; y3 = bottom; Geometry.RotatePoint(X, Y, angleDeg, ref x1, ref y1); Geometry.RotatePoint(X, Y, angleDeg, ref x2, ref y2); Geometry.RotatePoint(X, Y, angleDeg, ref x3, ref y3); result.X = Math.Min(Math.Min(x1, x2), Math.Min(x1, x3)); result.Y = Math.Min(Math.Min(y1, y2), Math.Min(y1, y3)); result.Width = Math.Max(Math.Max(x1, x2), Math.Max(x1, x3)) - result.X; result.Height = Math.Max(Math.Max(y1, y2), Math.Max(y1, y3)) - result.Y; ShapeUtils.InflateBoundingRectangle(ref result, LineStyle); return(result); } }
/// <override></override> protected override Rectangle CalculateBoundingRectangle(bool tight) { if (tight) { Rectangle result = Rectangle.Empty; result.X = X - (int)Math.Round(Diameter / 2f); result.Y = Y - (int)Math.Round(Diameter / 2f); result.Width = result.Height = Diameter; // Rotate top line if (Angle != 0) { float angleDeg = Geometry.TenthsOfDegreeToDegrees(Angle); Point tl = Point.Empty; tl.Offset(result.Left, result.Top); tl = Geometry.RotatePoint(X, Y, angleDeg, tl); Point tr = Point.Empty; tr.Offset(result.Right, result.Top); tr = Geometry.RotatePoint(X, Y, angleDeg, tr); Geometry.UniteRectangles(tl.X, tl.Y, tr.X, tr.Y, result); ShapeUtils.InflateBoundingRectangle(ref result, LineStyle); } return(result); } return(base.CalculateBoundingRectangle(tight)); }
/// <override></override> protected override Rectangle CalculateBoundingRectangle(bool tight) { if (tight) { if (Angle % 900 == 0) return base.CalculateBoundingRectangle(tight); else { Rectangle result = Geometry.InvalidRectangle; // Calculate the minimum bounding box int cornerRadius = CalcCornerRadius(); int w = (int)Math.Round(Width / 2f) - cornerRadius; int h = (int)Math.Round(Height / 2f) - cornerRadius; Rectangle rect = Rectangle.Empty; rect.Offset(X - w, Y - h); rect.Width = Width - cornerRadius - cornerRadius; rect.Height = Height - cornerRadius - cornerRadius; Point topLeft, topRight, bottomLeft, bottomRight; Geometry.RotateRectangle(rect, Center, Geometry.TenthsOfDegreeToDegrees(Angle), out topLeft, out topRight, out bottomRight, out bottomLeft); result.X = Math.Min(Math.Min(topLeft.X, topRight.X), Math.Min(bottomLeft.X, bottomRight.X)); result.Y = Math.Min(Math.Min(topLeft.Y, topRight.Y), Math.Min(bottomLeft.Y, bottomRight.Y)); result.Width = Math.Max(Math.Max(topLeft.X, topRight.X), Math.Max(bottomLeft.X, bottomRight.X)) - result.X; result.Height = Math.Max(Math.Max(topLeft.Y, topRight.Y), Math.Max(bottomLeft.Y, bottomRight.Y)) - result.Y; result.Inflate(cornerRadius, cornerRadius); ShapeUtils.InflateBoundingRectangle(ref result, LineStyle); return result; } } else return base.CalculateBoundingRectangle(tight); }
/// <override></override> protected override Rectangle CalculateBoundingRectangle(bool tight) { Rectangle result; CalculalteTranslatedShapePoints(); Geometry.CalcBoundingRectangle(pointBuffer, out result); ShapeUtils.InflateBoundingRectangle(ref result, LineStyle); return(result); }
protected override Rectangle CalculateBoundingRectangle(bool tight) { // Tight and loose bounding rectangles are equal Rectangle result = Geometry.InvalidRectangle; if (Width >= 0 && Height >= 0) { int left = (int)Math.Round(-Width / 2f); int top = (int)Math.Round(-Height * CenterPosFactorY); int right = left + Width; int bottom = (int)Math.Round(Height - (Height * CenterPosFactorY)); if (Angle == 0 || Angle == 1800) { result.X = X + left; result.Y = (Angle == 0) ? Y + top : Y - bottom; result.Width = right - left; result.Height = bottom - top; } else if (Angle == 900 || Angle == 2700) { result.X = (Angle == 900) ? X - bottom : result.X = X + top; result.Y = Y + left; result.Width = bottom - top; result.Height = right - left; } else { float angleDeg = Geometry.TenthsOfDegreeToDegrees(Angle); int x1, y1, x2, y2, x3, y3, x4, y4; x1 = X + left; y1 = Y + top; x2 = X + right; y2 = Y + top; x3 = X + right; y3 = Y + bottom; x4 = X + left; y4 = Y + bottom; Geometry.RotatePoint(X, Y, angleDeg, ref x1, ref y1); Geometry.RotatePoint(X, Y, angleDeg, ref x2, ref y2); Geometry.RotatePoint(X, Y, angleDeg, ref x3, ref y3); Geometry.RotatePoint(X, Y, angleDeg, ref x4, ref y4); result.X = Math.Min(Math.Min(x1, x2), Math.Min(x3, x4)); result.Y = Math.Min(Math.Min(y1, y2), Math.Min(y3, y4)); result.Width = Math.Max(Math.Max(x1, x2), Math.Max(x3, x4)) - result.X; result.Height = Math.Max(Math.Max(y1, y2), Math.Max(y3, y4)) - result.Y; } ShapeUtils.InflateBoundingRectangle(ref result, LineStyle); } return(result); }
/// <override></override> protected override Rectangle CalculateBoundingRectangle(bool tight) { if (tight) { Rectangle result = base.CalculateBoundingRectangle(tight); Rectangle r = Rectangle.Empty; r.Location = Point.Round(Geometry.RotatePoint(X, Y, Geometry.TenthsOfDegreeToDegrees(Angle), X + (DiameterInternal / 2f), Y + (DiameterInternal / 2f))); ShapeUtils.InflateBoundingRectangle(ref r, LineStyle); return(Geometry.UniteRectangles(r, result)); } else { return(base.CalculateBoundingRectangle(tight)); } }
/// <override></override> protected override Rectangle CalculateBoundingRectangle(bool tight) { Rectangle result = Geometry.InvalidRectangle; if (Width >= 0 && Height >= 0) { CalcShapePoints(); Geometry.CalcBoundingRectangle(shapePoints, 0, 0, Geometry.TenthsOfDegreeToDegrees(Angle), out result); if (Geometry.IsValid(result)) { result.Offset(X, Y); ShapeUtils.InflateBoundingRectangle(ref result, LineStyle); } } return(result); }
protected override Rectangle CalculateBoundingRectangle(bool tight) { if (tight) { CalcShapePoints(ref shapeBuffer); Matrix.Reset(); Matrix.Translate(X, Y); Matrix.RotateAt(Geometry.TenthsOfDegreeToDegrees(Angle), Center, System.Drawing.Drawing2D.MatrixOrder.Append); Matrix.TransformPoints(shapeBuffer); Rectangle result; Geometry.CalcBoundingRectangle(shapeBuffer, out result); ShapeUtils.InflateBoundingRectangle(ref result, LineStyle); return(result); } else { return(base.CalculateBoundingRectangle(tight)); } }