fpvmodifytest.pas 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. {
  2. Author: Felipe Monteiro de Carvalho
  3. License: Public Domain
  4. }
  5. program fpvmodifytest;
  6. {$mode objfpc}{$H+}
  7. uses
  8. fpvectorial, svgvectorialwriter, svgvectorialreader, fpvutils;
  9. const
  10. cFormat = vfSVG;
  11. cExtension = '.svg';
  12. var
  13. Vec: TvVectorialDocument;
  14. Path: TPath;
  15. i: Integer;
  16. Segment: TPathSegment;
  17. _2DSegment: T2DSegment;
  18. BezSegment: T2DBezierSegment;
  19. begin
  20. Vec := TvVectorialDocument.Create;
  21. try
  22. // Read the file
  23. Vec.ReadFromFile('bezier_1.svg');
  24. // Now add 10 to the Y coordinate of all elements
  25. for i := 0 to Vec.GetPathCount() - 1 do
  26. begin
  27. Path := Vec.GetPath(i);
  28. Path.PrepareForSequentialReading();
  29. Path.Next();
  30. while Path.CurPoint <> nil do
  31. begin
  32. Segment := Path.CurPoint;
  33. if Segment is T2DBezierSegment then
  34. begin
  35. BezSegment := Segment as T2DBezierSegment;
  36. BezSegment.Y := BezSegment.Y + 10;
  37. BezSegment.Y2 := BezSegment.Y2 + 10;
  38. BezSegment.Y3 := BezSegment.Y3 + 10;
  39. end
  40. else if Segment is T2DSegment then
  41. begin
  42. _2DSegment := Segment as T2DSegment;
  43. _2DSegment.Y := _2DSegment.Y + 10;
  44. end;
  45. Path.Next();
  46. end;
  47. end;
  48. // Write the changed file to disk
  49. Vec.WriteToFile('bezier_1_mod' + cExtension, cFormat);
  50. finally
  51. Vec.Free;
  52. end;
  53. end.