summaryrefslogtreecommitdiff
path: root/packages/fpvectorial/src
diff options
context:
space:
mode:
authorsekelsenmat <sekelsenmat@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-08-13 15:32:03 +0000
committersekelsenmat <sekelsenmat@3ad0048d-3df7-0310-abae-a5850022a9f2>2010-08-13 15:32:03 +0000
commitf10cfe768b8d3354faee0c40e38bf373553a96aa (patch)
treee45e59543223dae46dc51571ae742fec06749ea1 /packages/fpvectorial/src
parentdceb8f4f68d8e19ebd14f5778131ad6a65760644 (diff)
downloadfpc-f10cfe768b8d3354faee0c40e38bf373553a96aa.tar.gz
Now the SVG writer works for lines
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@15801 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fpvectorial/src')
-rw-r--r--packages/fpvectorial/src/fpvectorial.pas6
-rw-r--r--packages/fpvectorial/src/fpvtocanvas.pas14
-rw-r--r--packages/fpvectorial/src/svgvectorialwriter.pas15
3 files changed, 25 insertions, 10 deletions
diff --git a/packages/fpvectorial/src/fpvectorial.pas b/packages/fpvectorial/src/fpvectorial.pas
index d2a50a2a9d..42aa109bb8 100644
--- a/packages/fpvectorial/src/fpvectorial.pas
+++ b/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;
diff --git a/packages/fpvectorial/src/fpvtocanvas.pas b/packages/fpvectorial/src/fpvtocanvas.pas
index a75c7dc8bf..396b6de7c5 100644
--- a/packages/fpvectorial/src/fpvtocanvas.pas
+++ b/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
diff --git a/packages/fpvectorial/src/svgvectorialwriter.pas b/packages/fpvectorial/src/svgvectorialwriter.pas
index 782590afe6..a5bce78de8 100644
--- a/packages/fpvectorial/src/svgvectorialwriter.pas
+++ b/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');