fpvwritetest.pas 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. begin
  27. Vec := TvVectorialDocument.Create;
  28. try
  29. // single_line_1 One line from (0, 20) to (30, 30)
  30. Vec.StartPath(0, 20);
  31. Vec.AddLineToPath(30, 30);
  32. Vec.EndPath();
  33. Vec.WriteToFile('single_line_1' + cExtension, cFormat);
  34. // single_line_2 One line from (20, 30) to (30, 20)
  35. Vec.Clear;
  36. Vec.StartPath(20, 30);
  37. Vec.AddLineToPath(30, 20);
  38. Vec.EndPath();
  39. Vec.WriteToFile('single_line_2' + cExtension, cFormat);
  40. // polyline_1 One line from (0, 0) to (10, 10) to (20, 30) to (30, 20)
  41. Vec.Clear;
  42. Vec.StartPath(0, 0);
  43. Vec.AddLineToPath(10, 10);
  44. Vec.AddLineToPath(20, 30);
  45. Vec.AddLineToPath(30, 20);
  46. Vec.EndPath();
  47. Vec.WriteToFile('polyline_1' + cExtension, cFormat);
  48. // polyline_2 One line from (10, 10) to (20, 30) to (30, 20) to (40, 40)
  49. Vec.Clear;
  50. Vec.StartPath(10, 10);
  51. Vec.AddLineToPath(20, 30);
  52. Vec.AddLineToPath(30, 20);
  53. Vec.AddLineToPath(40, 40);
  54. Vec.EndPath();
  55. Vec.WriteToFile('polyline_2' + cExtension, cFormat);
  56. // bezier_1 One path starting in (0, 0) lining to (10, 10) then bezier to (20, 10) and then line to (30, 0)
  57. Vec.Clear;
  58. Vec.StartPath(0, 0);
  59. Vec.AddLineToPath(10, 10);
  60. Vec.AddBezierToPath(10, 20, 20, 20, 20, 10);
  61. Vec.AddLineToPath(30, 0);
  62. Vec.EndPath();
  63. Vec.WriteToFile('bezier_1' + cExtension, cFormat);
  64. // bezier_2 One curve from (10, 10) to (20, 20)
  65. Vec.Clear;
  66. Vec.StartPath(10, 10);
  67. Vec.AddBezierToPath(10, 15, 15, 20, 20, 10);
  68. Vec.EndPath();
  69. Vec.WriteToFile('bezier_2' + cExtension, cFormat);
  70. // text_ascii One text written at (10, 10)
  71. Vec.Clear;
  72. Vec.AddText('Some text in english.');
  73. Vec.WriteToFile('text_ascii' + cExtension, cFormat);
  74. // text_europen One text testing european languages at (20, 20)
  75. Vec.Clear;
  76. Vec.AddText('Mówić, cześć, Włosku, Parabéns, Assunção, Correções.');
  77. Vec.WriteToFile('text_europen' + cExtension, cFormat);
  78. // text_asian One text testing asian languages at (30, 30)
  79. Vec.Clear;
  80. Vec.AddText('森林,是一个高密度树木的区域');
  81. Vec.WriteToFile('text_asian' + cExtension, cFormat);
  82. finally
  83. Vec.Free;
  84. end;
  85. end.