コード例 #1
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 public void Update(Location location) {
     SetLastCurveOperationType(location);
     if(location.UseRelativeCoordinates)
         UpdateCore(ref relLocation, location);
     else
         UpdateCore(ref absLocation, location);
 }
コード例 #2
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 void SetLastCurveOperationType(Location location) {
     switch(location.CommandType) {
         case PathCommandType.CurveTo:
         case PathCommandType.SmoothCurveTo: lastCurveOperationType = CurveType.Cubic; break;
         case PathCommandType.QuadraticCurveTo:
         case PathCommandType.SmoothQuadraticCurveTo: lastCurveOperationType = CurveType.Quadratic; break;
         default: lastCurveOperationType = CurveType.None; break;
     }
 }
コード例 #3
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);
 }
コード例 #4
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);
 }
コード例 #5
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 public virtual Location CalcCurveControlPoint(Location curveEndPoint, Location endControlPoint = default(Location)) {
     PointF currentLocation = GetActualLocation(curveEndPoint.UseRelativeCoordinates);
     PointF lastCurveControlPoint = lastCurveLocations.Last();
     PointF[] vectors = new PointF[2];
     PointF[] points = new PointF[2];
     if(lastCurveOperationType == CurveType.Cubic) {
         vectors[0] = new PointF(currentLocation.X - lastCurveControlPoint.X, currentLocation.Y - lastCurveControlPoint.Y);
         points[0] = lastCurveControlPoint;
         vectors[1] = new PointF(endControlPoint.X - currentLocation.X, endControlPoint.Y - currentLocation.Y);
         points[1] = endControlPoint;
     }
     else {
         PointF prevCurveStartLocation = lastCurveLocations[0];
         vectors[0] = new PointF(lastCurveControlPoint.X - prevCurveStartLocation.X, lastCurveControlPoint.Y - prevCurveStartLocation.Y);
         points[0] = curveEndPoint;
         vectors[1] = new PointF(currentLocation.X - lastCurveControlPoint.X, currentLocation.Y - lastCurveControlPoint.Y);
         points[1] = currentLocation;
     }
     PointF result = CalcCurveControlPointCore(vectors, points);
     return new Location(result, curveEndPoint.CommandType, this, curveEndPoint.UseRelativeCoordinates); ;
 }
コード例 #6
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);
 }
コード例 #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);
     }
 }
コード例 #8
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 protected virtual void UpdateCore(ref PointF location, Location assignLocation) {
     if((assignLocation.UnitType & LocationUnitType.X) != 0)
         location.X = assignLocation.X;
     if((assignLocation.UnitType & LocationUnitType.Y) != 0)
         location.Y = assignLocation.Y;
 }
コード例 #9
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 protected override void ParseCore(string[] args, PathLocationInfo pathLocationInfo) {
     radiusCore.Width = Convert.ToSingle(args[0], CultureInfo.InvariantCulture);
     radiusCore.Height = Convert.ToSingle(args[1], CultureInfo.InvariantCulture);
     XAxisRotation = Convert.ToBoolean(Convert.ToInt32(args[2], CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
     LargeArcFlag = Convert.ToBoolean(Convert.ToInt32(args[3], CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
     SweepFlag = Convert.ToBoolean(Convert.ToInt32(args[4], CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
     PointF location = new PointF(Convert.ToSingle(args[5], CultureInfo.InvariantCulture), Convert.ToSingle(args[6], CultureInfo.InvariantCulture));
     locationCore = new Location(location, CommandType, pathLocationInfo, UseRelativeCoordinates);
 }
コード例 #10
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 public PointF GetActualLocation(Location location) {
     Update(location);
     return GetActualLocation(location.UseRelativeCoordinates);
 }
コード例 #11
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 protected override void ParseCore(string[] coordinates, PathLocationInfo pathLocationInfo) {
     foreach(string coordinate in coordinates) {
         PointF point = new PointF(Convert.ToSingle(coordinate, CultureInfo.InvariantCulture), 0);
         Location location = new Location(point, CommandType, pathLocationInfo, UseRelativeCoordinates);
         location.UnitType = LocationUnitType.Y;
         AddLocation(location);
     }
 }
コード例 #12
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 protected override void ParseCore(string[] coordinates, PathLocationInfo pathLocationInfo) {
     for(int i = 0, j = 0; i < coordinates.Length; i += 2, j++) {
         PointF point = new PointF(Convert.ToSingle(coordinates[i], CultureInfo.InvariantCulture), Convert.ToSingle(coordinates[i + 1], CultureInfo.InvariantCulture));
         Location location = new Location(point, CommandType, pathLocationInfo, UseRelativeCoordinates);
         AddLocation(location);
     }
 }
コード例 #13
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 public void AddLocation(Location location) {
     locationsCore.Add(location);
 }
コード例 #14
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 public MoveToCommandArgs(PathCommandType commandType, Location[] locations, PathLocationInfo pathLocationInfo) : base(commandType) {
     locationsCore = locations.ToList();
     PathLocationInfo = pathLocationInfo;
 }
コード例 #15
0
ファイル: Parser.cs プロジェクト: manWhoKnowsHowToFly/SVG.Net
 public MoveToCommandArgs(PathCommandType commandType, Location[] locations) : base(commandType) {
     locationsCore = locations.ToList();
 }