diff --git a/Pinta.Tools/Editable/Shapes/EllipseEngine.cs b/Pinta.Tools/Editable/Shapes/EllipseEngine.cs index c17c5ced0..18fe5f191 100644 --- a/Pinta.Tools/Editable/Shapes/EllipseEngine.cs +++ b/Pinta.Tools/Editable/Shapes/EllipseEngine.cs @@ -60,6 +60,20 @@ public override ShapeEngine Clone () return new EllipseEngine (this); } + private static bool IsPerfectRectangle (PointD cp0, PointD cp1, PointD cp2, PointD cp3) + { + if (cp0.X == cp1.X) { + if (cp0.Y == cp3.Y && cp1.Y == cp2.Y && cp2.X == cp3.X) { + return true; + } + } else if (cp0.Y == cp1.Y) { + if (cp0.X == cp3.X && cp1.X == cp2.X && cp2.Y == cp3.Y) { + return true; + } + } + return false; + } + /// /// Generate each point in an elliptic shape and store the result in GeneratedPoints. /// The width of the brush that will be used to draw the shape. @@ -77,17 +91,7 @@ public override void GeneratePoints (int brush_width) //An ellipse also requires that all 4 control points compose a perfect rectangle parallel/perpendicular to the window. //So, confirm that it is indeed a perfect rectangle. - bool perfectRectangle = false; - - if (cp0.X == cp1.X) { - if (cp0.Y == cp3.Y && cp1.Y == cp2.Y && cp2.X == cp3.X) { - perfectRectangle = true; - } - } else if (cp0.Y == cp1.Y) { - if (cp0.X == cp3.X && cp1.X == cp2.X && cp2.Y == cp3.Y) { - perfectRectangle = true; - } - } + bool perfectRectangle = IsPerfectRectangle (cp0, cp1, cp2, cp3); if (perfectRectangle) { //It is expected that the 4 control points always form a perfect rectangle parallel/perpendicular to the window.