Browse Source

Now the SVG writer works for lines

git-svn-id: trunk@15801 -
sekelsenmat 15 years ago
parent
commit
3708922b62

+ 3 - 3
packages/fpvectorial/src/fpvectorial.pas

@@ -38,10 +38,10 @@ type
     st2DLine, st2DBezier,
     st3DLine, st3DBezier);
 
-  {@
+  {@@
     The coordinates in fpvectorial are given in millimiters and
-    the starting point is in the top-left corner of the document
-    and it grows to the bottom and to the right.
+    the starting point is in the bottom-left corner of the document.
+    The X grows to the right and the Y grows to the top.
   }
   TPathSegment = record
     SegmentType: TSegmentType;

+ 14 - 0
packages/fpvectorial/src/fpvtocanvas.pas

@@ -14,6 +14,20 @@ procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument; ADest: TFPCustom
 
 implementation
 
+{@@
+  This function draws a FPVectorial vectorial image to a TFPCustomCanvas
+  descendent, such as TCanvas from the LCL.
+
+  Be careful that by default this routine does not execute coordinate transformations,
+  and that FPVectorial works with a start point in the bottom-left corner, with
+  the X growing to the right and the Y growing to the top. This will result in
+  an image in TFPCustomCanvas mirrored in the Y axis in relation with the document
+  as seen in a PDF viewer, for example. This can be easily changed with the
+  provided parameters. To have the standard view of an image viewer one could
+  use this function like this:
+
+  DrawFPVectorialToCanvas(ASource, ADest, 0, ASource.Height, 1.0, -1.0);
+}
 procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument; ADest: TFPCustomCanvas;
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
 var

+ 8 - 7
packages/fpvectorial/src/svgvectorialwriter.pas

@@ -36,8 +36,8 @@ implementation
 
 procedure TvSVGVectorialWriter.WriteDocumentSize(AStrings: TStrings; AData: TvVectorialDocument);
 begin
-  AStrings.Add('  width="744.09448819"');
-  AStrings.Add('  height="1052.3622047"');
+  AStrings.Add('  width="' + FloatToStr(AData.Width, FPointSeparator) + 'mm"');
+  AStrings.Add('  height="' + FloatToStr(AData.Height, FPointSeparator) + 'mm"');
 end;
 
 procedure TvSVGVectorialWriter.WriteDocumentName(AStrings: TStrings; AData: TvVectorialDocument);
@@ -46,9 +46,11 @@ begin
 end;
 
 {@@
-  SVG Coordinate system measures things in millimiters.
+  SVG Coordinate system measures things in whatever unit we pass to it, so we
+  choose to pass in millimiters (mm), like FPVectorial uses.
+
   The initial point is in the bottom-left corner of the document and it grows
-  to the top and to the right.
+  to the top and to the right, just like in FPVectorial.
 
   SVG uses commas "," to separate the X,Y coordinates, so it always uses points
   "." as decimal separators and uses no thousand separators
@@ -70,9 +72,8 @@ begin
 
       PtX := lPath.Points[j].X;
       PtY := lPath.Points[j].Y;
-      PtY := AData.Height - PtY;
-      PathStr := PathStr + FloatToStr(PtX, FPointSeparator) + ','
-        + FloatToStr(PtY, FPointSeparator) + ' ';
+      PathStr := PathStr + FloatToStr(PtX, FPointSeparator) + 'mm,'
+        + FloatToStr(PtY, FPointSeparator) + 'mm ';
     end;
 
     AStrings.Add('  <path');