Recent

Author Topic: Using fpVectorial to draw color / fill in SVG files  (Read 1387 times)

Schmitty2005

  • New Member
  • *
  • Posts: 12
Using fpVectorial to draw color / fill in SVG files
« on: December 17, 2024, 03:16:21 am »
I am trying to make a color SVG file using fpVectorial.  Using this link as a start :

https://wiki.lazarus.freepascal.org/fpvectorial

I have looked at fpVectorial.pas located here :

https://github.com/fpc/Lazarus/blob/main/components/fpvectorial/fpvectorial.pas

I want to do simple colors.  I have tried changing the pen and brush, but those do not seem to work.  I am likely doing something wrong.

This is the code I was trying to modify and add some color ( I left out my modifications, they did not work)  :

Code: Pascal  [Select][+][-]
  1. {
  2. Author: Felipe Monteiro de Carvalho
  3.  
  4. License: Public Domain
  5. }
  6. program fpvwritetest;
  7.  
  8. {$mode objfpc}{$H+}
  9.  
  10. uses
  11.   fpvectorial, svgvectorialwriter;
  12.  
  13. const
  14.   cFormat = vfSVG;
  15.   cExtension = '.svg';
  16. var
  17.   VecDoc: TvVectorialDocument;
  18.   Vec: TvVectorialPage;
  19.   s : String;  
  20. begin
  21.   VecDoc := TvVectorialDocument.Create;
  22.   try
  23.     // All documents are 10cm x 10cm
  24.     VecDoc.Width := 100;
  25.     VecDoc.Height := 100;
  26.  
  27.     Vec := VecDoc.AddPage();
  28.     Vec.Width := VecDoc.Width;
  29.     Vec.Height := VecDoc.Height;
  30.  
  31.     // ...
  32.  
  33.     // multi_test_1     Combines various elements
  34.     Vec.Clear;
  35.     Vec.StartPath(0, 20);
  36.     Vec.AddLineToPath(30, 30);
  37.     Vec.EndPath();
  38.     Vec.StartPath(0, 0);
  39.     Vec.AddLineToPath(100, 0);
  40.     Vec.AddLineToPath(100, 100);
  41.     Vec.AddLineToPath(0, 100);
  42.     Vec.AddLineToPath(0, 0);
  43.     Vec.EndPath();
  44.     Vec.StartPath(0, 0);
  45.     Vec.AddLineToPath(10, 10);
  46.     Vec.AddBezierToPath(10, 20, 20, 20, 20, 10);
  47.     Vec.AddLineToPath(30, 0);
  48.     Vec.EndPath();
  49.     Vec.AddText(10, 10, 0, '10,10 Some text in english.');
  50.     s := '20, 20 Mówić, cześć, Włosku, Parabéns.';
  51.     Vec.AddText(20, 20, 0, s);
  52.     s := '30, 30 森林,是一个高密';
  53.     Vec.AddText(30, 30, 0, s);
  54.     VecDoc.WriteToFile('multi_test_1' + cExtension, cFormat);
  55.   finally
  56.     VecDoc.Free;
  57.   end;
  58. end.
  59.  
 

Does anybody have an  example of how to change the pen color in fpVectorial ?

or would I be better off trying out BGRABitmap for programmatically making SVG's  ?
https://bgrabitmap.github.io/

I could find no other documentation on fpVectorial.

Thank you.

dsiders

  • Hero Member
  • *****
  • Posts: 1348
Re: Using fpVectorial to draw color / fill in SVG files
« Reply #1 on: December 17, 2024, 03:57:24 am »
There are several examples of using Pen in the tests directory.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

Schmitty2005

  • New Member
  • *
  • Posts: 12
Re: Using fpVectorial to draw color / fill in SVG files
« Reply #2 on: December 18, 2024, 03:09:52 am »
Yes, it makes sense now.  Thank you!

 

TinyPortal © 2005-2018