Пример #1
0
            public ArcCut( CurveType type, float startAngle, float endAngle,  PointF arcPoint1,  PointF arcPoint2,  PointF centerOfArc,
                 bool UseArcLine = true,  ICurve AttachedCurve = null) : this()
            {
                Option = type;
                Initialized = !arcPoint1.Equals(arcPoint2);
                Center = centerOfArc;

                if (!Initialized)
                {
                    Option = Option.Exclude(CurveType.Arc, CurveType.Pie).Include(CurveType.Full);
                    return;
                }

                if (Option.IsPie())
                    Option = Option.Exclude(CurveType.Arc);
                else
                    Option = Option.Exclude(CurveType.Pie);

                if (Option.IsArc())
                {
                    StartAngle = startAngle;
                    EndAngle = endAngle;
                }
                else
                {
                    StartAngle = arcPoint1.GetAngle(centerOfArc);
                    EndAngle = arcPoint2.GetAngle(centerOfArc);
                }
                if (!UseArcLine)
                {
                    if (EndAngle < StartAngle)
                        Option = Option.Include(CurveType.NegativeMotion);
                    else
                        Option = Option.Exclude(CurveType.NegativeMotion);
                }

                NegativeMotion = Option.NegativeMotion();
                ArcLine = Factory.newLine(arcPoint1, arcPoint2);
                Line1 = Factory.newLine(arcPoint1, centerOfArc);
                Line2 = Factory.newLine(arcPoint2, centerOfArc);
                var l = ArcLine;

                /*If arc line is perfect then cutting ellipse using ArcLine is faster than using Math.Atan2
                * However, it needs to be thoroughly tested as it is knownn to be fragile.*/
                if (UseArcLine)
                    Contains = CheckPixel;
                else
                    Contains = CheckPixel1;

                Extra = GetClosingLines(AttachedCurve);
            }