public void LineTo(MoveToCommandArgs args) {
     PointF[] points = new PointF[args.Locations.Length + 1];
     points[0] = LocationInfo.GetActualLocation(args.UseRelativeCoordinates);
     args.Locations.CopyTo(points, 1);
     Path.AddLines(points);
     LocationInfo.UpdateLastCurveControlPoints(PathLocationInfo.CurveType.None);
 }
Пример #2
0
        Action <MoveToCommandArgs> GetCurveRenderMethod(MoveToCommandArgs args, out int nLocations)
        {
            switch (args.CommandType)
            {
            case PathCommandType.CurveTo:
                nLocations = 3;
                return(CubicBezierCurveToCore);

            case PathCommandType.SmoothCurveTo:
                nLocations = 2;
                return(SmoothCubicBezierCurveToCore);

            case PathCommandType.QuadraticCurveTo:
                nLocations = 2;
                return(QuadraticBezierCurveToCore);

            case PathCommandType.SmoothQuadraticCurveTo:
                nLocations = 1;
                return(SmoothQuadraticBezierCurveToCore);

            default:
                nLocations = 0;
                return(x => { });
            }
        }
Пример #3
0
 public void LineTo(MoveToCommandArgs args)
 {
     PointF[] points = new PointF[args.Locations.Length + 1];
     points[0] = LocationInfo.GetActualLocation(args.UseRelativeCoordinates);
     args.Locations.CopyTo(points, 1);
     Path.AddLines(points);
     LocationInfo.UpdateLastCurveControlPoints(PathLocationInfo.CurveType.None);
 }
Пример #4
0
 protected virtual void CubicBezierCurveToCore(MoveToCommandArgs args)
 {
     PointF[] points = new PointF[args.Locations.Length + 1];
     points[0] = LocationInfo.GetActualLocation(args.UseRelativeCoordinates);
     args.Locations.CopyTo(points, 1);
     Path.AddBeziers(points);
     LocationInfo.UpdateLastCurveControlPoints(PathLocationInfo.CurveType.Cubic, points[points.Length - 2]);
 }
 public void MoveTo(MoveToCommandArgs args) {
     LocationInfo.Update(args.Locations[0]);
     if(args.Locations.Length > 1) {
         int length = args.Locations.Length - 1;
         Location[] locations = new Location[length];
         Array.Copy(args.Locations, 1, locations, 0, length);
         LineTo(new MoveToCommandArgs(args.CommandType, locations));
     }
     LocationInfo.UpdateLastCurveControlPoints(PathLocationInfo.CurveType.None);
 }
Пример #6
0
 public void MoveTo(MoveToCommandArgs args)
 {
     LocationInfo.Update(args.Locations[0]);
     if (args.Locations.Length > 1)
     {
         int        length    = args.Locations.Length - 1;
         Location[] locations = new Location[length];
         Array.Copy(args.Locations, 1, locations, 0, length);
         LineTo(new MoveToCommandArgs(args.CommandType, locations));
     }
     LocationInfo.UpdateLastCurveControlPoints(PathLocationInfo.CurveType.None);
 }
Пример #7
0
        public void CurveTo(MoveToCommandArgs args)
        {
            int nLocations;
            Action <MoveToCommandArgs> curveRenderMethod = GetCurveRenderMethod(args, out nLocations);

            for (int i = 0; i < args.Locations.Length / nLocations; i++)
            {
                var locations = new Location[nLocations];
                Array.Copy(args.Locations, i * nLocations, locations, 0, nLocations);
                MoveToCommandArgs newArgs = new MoveToCommandArgs(args.CommandType, locations, args.PathLocationInfo);
                curveRenderMethod(newArgs);
            }
        }
 void SmoothQuadraticBezierCurveToCore(MoveToCommandArgs args) {
     Location curveEndLocation = args.Locations[0];
     Location curveControlLocation;
     if(args.PathLocationInfo.HasSavedLastCurveLocations(PathLocationInfo.CurveType.Quadratic)) {
         curveControlLocation = args.PathLocationInfo.CalcCurveControlPoint(curveEndLocation); 
     }
     else {
         PointF actualLocation = args.PathLocationInfo.GetActualLocation(args.UseRelativeCoordinates);
         curveControlLocation = new Location(actualLocation, args.CommandType, args.PathLocationInfo, args.UseRelativeCoordinates);
     }
     Location[] locations = { curveControlLocation, curveEndLocation };
     MoveToCommandArgs totalArgs = new MoveToCommandArgs(args.CommandType, locations, args.PathLocationInfo);
     QuadraticBezierCurveToCore(totalArgs);
 }
Пример #9
0
        void SmoothQuadraticBezierCurveToCore(MoveToCommandArgs args)
        {
            Location curveEndLocation = args.Locations[0];
            Location curveControlLocation;

            if (args.PathLocationInfo.HasSavedLastCurveLocations(PathLocationInfo.CurveType.Quadratic))
            {
                curveControlLocation = args.PathLocationInfo.CalcCurveControlPoint(curveEndLocation);
            }
            else
            {
                PointF actualLocation = args.PathLocationInfo.GetActualLocation(args.UseRelativeCoordinates);
                curveControlLocation = new Location(actualLocation, args.CommandType, args.PathLocationInfo, args.UseRelativeCoordinates);
            }
            Location[]        locations = { curveControlLocation, curveEndLocation };
            MoveToCommandArgs totalArgs = new MoveToCommandArgs(args.CommandType, locations, args.PathLocationInfo);

            QuadraticBezierCurveToCore(totalArgs);
        }
Пример #10
0
        void SmoothCubicBezierCurveToCore(MoveToCommandArgs args)
        {
            Location firstCurveControlLocation;
            Location secondCurveControlLocation = args.Locations[args.Locations.Length - 2];
            Location endCurveLocation           = args.Locations[args.Locations.Length - 1];

            if (args.PathLocationInfo.HasSavedLastCurveLocations(PathLocationInfo.CurveType.Cubic))
            {
                firstCurveControlLocation = args.PathLocationInfo.CalcCurveControlPoint(endCurveLocation, secondCurveControlLocation);
            }
            else
            {
                PointF actualLocation = args.PathLocationInfo.GetActualLocation(args.UseRelativeCoordinates);
                firstCurveControlLocation = new Location(actualLocation, args.CommandType, args.PathLocationInfo, args.UseRelativeCoordinates);
            }
            Location[]        locations = { firstCurveControlLocation, secondCurveControlLocation, endCurveLocation };
            MoveToCommandArgs newArgs   = new MoveToCommandArgs(args.CommandType, locations);

            CubicBezierCurveToCore(newArgs);
        }
Пример #11
0
 void SmoothCubicBezierCurveToCore(MoveToCommandArgs args) {
     Location firstCurveControlLocation;
     Location secondCurveControlLocation = args.Locations[args.Locations.Length - 2];
     Location endCurveLocation = args.Locations[args.Locations.Length - 1];
     if(args.PathLocationInfo.HasSavedLastCurveLocations(PathLocationInfo.CurveType.Cubic)) {
         firstCurveControlLocation = args.PathLocationInfo.CalcCurveControlPoint(endCurveLocation, secondCurveControlLocation);
     }
     else {
         PointF actualLocation = args.PathLocationInfo.GetActualLocation(args.UseRelativeCoordinates);
         firstCurveControlLocation = new Location(actualLocation, args.CommandType, args.PathLocationInfo, args.UseRelativeCoordinates);
     }
     Location[] locations = { firstCurveControlLocation, secondCurveControlLocation, endCurveLocation };
     MoveToCommandArgs newArgs = new MoveToCommandArgs(args.CommandType, locations);
     CubicBezierCurveToCore(newArgs);
 }
Пример #12
0
 Action<MoveToCommandArgs> GetCurveRenderMethod(MoveToCommandArgs args, out int nLocations) {
     switch(args.CommandType) {
         case PathCommandType.CurveTo:
             nLocations = 3;
             return CubicBezierCurveToCore;
         case PathCommandType.SmoothCurveTo:
             nLocations = 2;
             return SmoothCubicBezierCurveToCore;
         case PathCommandType.QuadraticCurveTo:
             nLocations = 2;
             return QuadraticBezierCurveToCore;
         case PathCommandType.SmoothQuadraticCurveTo:
             nLocations = 1;
             return SmoothQuadraticBezierCurveToCore;
         default:
             nLocations = 0;
             return x => { };
     }
 }
Пример #13
0
 public void CurveTo(MoveToCommandArgs args) {
     int nLocations;
     Action<MoveToCommandArgs> curveRenderMethod = GetCurveRenderMethod(args, out nLocations);
     for(int i = 0; i < args.Locations.Length / nLocations; i++) {
         var locations = new Location[nLocations];
         Array.Copy(args.Locations, i * nLocations, locations, 0, nLocations);
         MoveToCommandArgs newArgs = new MoveToCommandArgs(args.CommandType, locations, args.PathLocationInfo);
         curveRenderMethod(newArgs);
     }
 }
Пример #14
0
 protected virtual void QuadraticBezierCurveToCore(MoveToCommandArgs args) {
     PointF[] points = new PointF[args.Locations.Length + 2];
     points[0] = LocationInfo.GetActualLocation(args.UseRelativeCoordinates);
     args.Locations.CopyTo(points, 1);
     points[points.Length - 1] = points[points.Length - 2];
     Path.AddBeziers(points);
     LocationInfo.UpdateLastCurveControlPoints(PathLocationInfo.CurveType.Quadratic, points[0], points[1]);
 }