fpvwritetest.pas 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. {
  2. FPVectorial example application for writing vectorial images
  3. generated in code to disk. This program will generate the following
  4. vectorial images:
  5. single_line_1 One line from (0, 20) to (30, 30)
  6. single_line_2 One line from (20, 30) to (30, 20)
  7. polyline_1 One line from (0, 0) to (10, 10) to (20, 30) to (30, 20)
  8. polyline_2 One line from (10, 10) to (20, 30) to (30, 20) to (40, 40)
  9. bezier_1 One path starting in (0, 0) lining to (10, 10) then bezier to (20, 10) and then line to (30, 0)
  10. bezier_2 One curve from (10, 10) to (20, 20)
  11. text_ascii One text written at (10, 10)
  12. text_europen One text testing european languages at (20, 20)
  13. text_asian One text testing asian languages at (30, 30)
  14. Author: Felipe Monteiro de Carvalho
  15. License: Public Domain
  16. }
  17. program fpvwritetest;
  18. {$mode objfpc}{$H+}
  19. uses
  20. fpvectorial, svgvectorialwriter;
  21. const
  22. cFormat = vfSVG;
  23. cExtension = '.svg';
  24. var
  25. Vec: TvVectorialDocument;
  26. {$R *.res}
  27. begin
  28. Vec := TvVectorialDocument.Create;
  29. try
  30. // All documents are 10cm x 10cm
  31. Vec.Width := 100;
  32. Vec.Height := 100;
  33. // single_line_1 One line from (0, 20) to (30, 30)
  34. Vec.StartPath(0, 20);
  35. Vec.AddLineToPath(30, 30);
  36. Vec.EndPath();
  37. Vec.WriteToFile('single_line_1' + cExtension, cFormat);
  38. // single_line_2 One line from (20, 30) to (30, 20)
  39. Vec.Clear;
  40. Vec.StartPath(20, 30);
  41. Vec.AddLineToPath(30, 20);
  42. Vec.EndPath();
  43. Vec.WriteToFile('single_line_2' + cExtension, cFormat);
  44. // single_line_3 One line from (0, 20) to (30, 30) + frame
  45. Vec.Clear;
  46. Vec.StartPath(0, 20);
  47. Vec.AddLineToPath(30, 30);
  48. Vec.EndPath();
  49. Vec.StartPath(0, 0);
  50. Vec.AddLineToPath(100, 0);
  51. Vec.AddLineToPath(100, 100);
  52. Vec.AddLineToPath(0, 100);
  53. Vec.AddLineToPath(0, 0);
  54. Vec.EndPath();
  55. Vec.WriteToFile('single_line_3' + cExtension, cFormat);
  56. // polyline_1 One line from (0, 0) to (10, 10) to (20, 30) to (30, 20)
  57. Vec.Clear;
  58. Vec.StartPath(0, 0);
  59. Vec.AddLineToPath(10, 10);
  60. Vec.AddLineToPath(20, 30);
  61. Vec.AddLineToPath(30, 20);
  62. Vec.EndPath();
  63. Vec.WriteToFile('polyline_1' + cExtension, cFormat);
  64. // polyline_2 One line from (10, 10) to (20, 30) to (30, 20) to (40, 40)
  65. Vec.Clear;
  66. Vec.StartPath(10, 10);
  67. Vec.AddLineToPath(20, 30);
  68. Vec.AddLineToPath(30, 20);
  69. Vec.AddLineToPath(40, 40);
  70. Vec.EndPath();
  71. Vec.WriteToFile('polyline_2' + cExtension, cFormat);
  72. // bezier_1 One path starting in (0, 0) lining to (10, 10) then bezier to (20, 10) and then line to (30, 0)
  73. Vec.Clear;
  74. Vec.StartPath(0, 0);
  75. Vec.AddLineToPath(10, 10);
  76. Vec.AddBezierToPath(10, 20, 20, 20, 20, 10);
  77. Vec.AddLineToPath(30, 0);
  78. Vec.EndPath();
  79. Vec.WriteToFile('bezier_1' + cExtension, cFormat);
  80. // bezier_2 One curve from (10, 10) to (20, 20)
  81. Vec.Clear;
  82. Vec.StartPath(10, 10);
  83. Vec.AddBezierToPath(10, 15, 15, 20, 20, 10);
  84. Vec.EndPath();
  85. Vec.WriteToFile('bezier_2' + cExtension, cFormat);
  86. // text_ascii One text written at (10, 10)
  87. Vec.Clear;
  88. Vec.AddText(10, 10, 0, 'Some text in english.');
  89. Vec.WriteToFile('text_ascii' + cExtension, cFormat);
  90. // text_europen One text testing european languages at (20, 20)
  91. Vec.Clear;
  92. Vec.AddText(20, 20, 0, 'Mówić, cześć, Włosku, Parabéns, Assunção, Correções.');
  93. Vec.WriteToFile('text_europen' + cExtension, cFormat);
  94. // text_asian One text testing asian languages at (30, 30)
  95. Vec.Clear;
  96. Vec.AddText(30, 30, 0, '森林,是一个高密度树木的区域');
  97. Vec.WriteToFile('text_asian' + cExtension, cFormat);
  98. finally
  99. Vec.Free;
  100. end;
  101. end.