Browse Source

fpvectorial: Adds brush support for the svg writer and changes fpvectorial to use TFPColor instead of its own color

git-svn-id: trunk@17761 -
sekelsenmat 14 years ago
parent
commit
3cdbe30c28

+ 28 - 29
packages/fpvectorial/src/dxfvectorialreader.pas

@@ -49,7 +49,7 @@ type
 
 
   TPolylineElement = record
   TPolylineElement = record
     X, Y: Double;
     X, Y: Double;
-    Color: TvColor;
+    Color: TFPColor;
   end;
   end;
 
 
   TSPLineElement = record
   TSPLineElement = record
@@ -104,7 +104,7 @@ type
     procedure ReadENTITIES_POINT(ATokens: TDXFTokens; AData: TvVectorialDocument);
     procedure ReadENTITIES_POINT(ATokens: TDXFTokens; AData: TvVectorialDocument);
     function  GetCoordinateValue(AStr: shortstring): Double;
     function  GetCoordinateValue(AStr: shortstring): Double;
     //
     //
-    function DXFColorIndexToVColor(AColorIndex: Integer): TvColor;
+    function DXFColorIndexToFPColor(AColorIndex: Integer): TFPColor;
   public
   public
     { General reading methods }
     { General reading methods }
     Tokenizer: TDXFTokenizer;
     Tokenizer: TDXFTokenizer;
@@ -146,24 +146,24 @@ const
 
 
   // Obtained from http://www.generalcadd.com/pdf/LivingWithAutoCAD_v4.pdf
   // Obtained from http://www.generalcadd.com/pdf/LivingWithAutoCAD_v4.pdf
   // Valid for DXF up to AutoCad 2004, after that RGB is available
   // Valid for DXF up to AutoCad 2004, after that RGB is available
-  AUTOCAD_COLOR_PALETTE: array[0..15] of TvColor =
+  AUTOCAD_COLOR_PALETTE: array[0..15] of TFPColor =
   (
   (
-    (Red: $00; Green: $00; Blue: $00; Alpha: FPValphaOpaque), // 0 - Black
-    (Red: $00; Green: $00; Blue: $80; Alpha: FPValphaOpaque), // 1 - Dark blue
-    (Red: $00; Green: $80; Blue: $00; Alpha: FPValphaOpaque), // 2 - Dark green
-    (Red: $00; Green: $80; Blue: $80; Alpha: FPValphaOpaque), // 3 - Dark cyan
-    (Red: $80; Green: $00; Blue: $00; Alpha: FPValphaOpaque), // 4 - Dark red
-    (Red: $80; Green: $00; Blue: $80; Alpha: FPValphaOpaque), // 5 - Dark Magenta
-    (Red: $80; Green: $80; Blue: $00; Alpha: FPValphaOpaque), // 6 - Dark
-    (Red: $c0; Green: $c0; Blue: $c0; Alpha: FPValphaOpaque), // 7 - Light Gray
-    (Red: $80; Green: $80; Blue: $80; Alpha: FPValphaOpaque), // 8 - Medium Gray
-    (Red: $00; Green: $00; Blue: $ff; Alpha: FPValphaOpaque), // 9 - Light blue
-    (Red: $00; Green: $ff; Blue: $00; Alpha: FPValphaOpaque), // 10 - Light green
-    (Red: $00; Green: $ff; Blue: $ff; Alpha: FPValphaOpaque), // 11 - Light cyan
-    (Red: $ff; Green: $00; Blue: $00; Alpha: FPValphaOpaque), // 12 - Light red
-    (Red: $ff; Green: $00; Blue: $ff; Alpha: FPValphaOpaque), // 13 - Light Magenta
-    (Red: $ff; Green: $ff; Blue: $00; Alpha: FPValphaOpaque), // 14 - Light Yellow
-    (Red: $ff; Green: $ff; Blue: $ff; Alpha: FPValphaOpaque)  // 15 - White
+    (Red: $0000; Green: $0000; Blue: $0000; Alpha: FPValphaOpaque), // 0 - Black
+    (Red: $0000; Green: $0000; Blue: $8080; Alpha: FPValphaOpaque), // 1 - Dark blue
+    (Red: $0000; Green: $8080; Blue: $0000; Alpha: FPValphaOpaque), // 2 - Dark green
+    (Red: $0000; Green: $8080; Blue: $8080; Alpha: FPValphaOpaque), // 3 - Dark cyan
+    (Red: $8080; Green: $0000; Blue: $0000; Alpha: FPValphaOpaque), // 4 - Dark red
+    (Red: $8080; Green: $0000; Blue: $8080; Alpha: FPValphaOpaque), // 5 - Dark Magenta
+    (Red: $8080; Green: $8080; Blue: $0000; Alpha: FPValphaOpaque), // 6 - Dark
+    (Red: $c0c0; Green: $c0c0; Blue: $c0c0; Alpha: FPValphaOpaque), // 7 - Light Gray
+    (Red: $8080; Green: $8080; Blue: $8080; Alpha: FPValphaOpaque), // 8 - Medium Gray
+    (Red: $0000; Green: $0000; Blue: $ffff; Alpha: FPValphaOpaque), // 9 - Light blue
+    (Red: $0000; Green: $ffff; Blue: $0000; Alpha: FPValphaOpaque), // 10 - Light green
+    (Red: $0000; Green: $ffff; Blue: $ffff; Alpha: FPValphaOpaque), // 11 - Light cyan
+    (Red: $ffff; Green: $0000; Blue: $0000; Alpha: FPValphaOpaque), // 12 - Light red
+    (Red: $ffff; Green: $0000; Blue: $ffff; Alpha: FPValphaOpaque), // 13 - Light Magenta
+    (Red: $ffff; Green: $ffff; Blue: $0000; Alpha: FPValphaOpaque), // 14 - Light Yellow
+    (Red: $ffff; Green: $ffff; Blue: $ffff; Alpha: FPValphaOpaque)  // 15 - White
   );
   );
 
 
 { TDXFToken }
 { TDXFToken }
@@ -478,7 +478,7 @@ var
   // LINE
   // LINE
   LineStartX, LineStartY, LineStartZ: Double;
   LineStartX, LineStartY, LineStartZ: Double;
   LineEndX, LineEndY, LineEndZ: Double;
   LineEndX, LineEndY, LineEndZ: Double;
-  LLineColor: TvColor;
+  LLineColor: TFPColor;
 begin
 begin
   // Initial values
   // Initial values
   LineStartX := 0;
   LineStartX := 0;
@@ -487,7 +487,7 @@ begin
   LineEndX := 0;
   LineEndX := 0;
   LineEndY := 0;
   LineEndY := 0;
   LineEndZ := 0;
   LineEndZ := 0;
-  LLineColor := clvBlack;
+  LLineColor := colBlack;
 
 
   for i := 0 to ATokens.Count - 1 do
   for i := 0 to ATokens.Count - 1 do
   begin
   begin
@@ -507,7 +507,7 @@ begin
       11: LineEndX := CurToken.FloatValue;
       11: LineEndX := CurToken.FloatValue;
       21: LineEndY := CurToken.FloatValue;
       21: LineEndY := CurToken.FloatValue;
       31: LineEndZ := CurToken.FloatValue;
       31: LineEndZ := CurToken.FloatValue;
-      62: LLineColor := DXFColorIndexToVColor(Trunc(CurToken.FloatValue));
+      62: LLineColor := DXFColorIndexToFPColor(Trunc(CurToken.FloatValue));
     end;
     end;
   end;
   end;
 
 
@@ -546,7 +546,7 @@ var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i: Integer;
   i: Integer;
   CenterX, CenterY, CenterZ, Radius, StartAngle, EndAngle: Double;
   CenterX, CenterY, CenterZ, Radius, StartAngle, EndAngle: Double;
-  LColor: TvColor;
+  LColor: TFPColor;
 begin
 begin
   CenterX := 0.0;
   CenterX := 0.0;
   CenterY := 0.0;
   CenterY := 0.0;
@@ -554,7 +554,7 @@ begin
   Radius := 0.0;
   Radius := 0.0;
   StartAngle := 0.0;
   StartAngle := 0.0;
   EndAngle := 0.0;
   EndAngle := 0.0;
-  LColor := clvBlack;
+  LColor := colBlack;
 
 
   for i := 0 to ATokens.Count - 1 do
   for i := 0 to ATokens.Count - 1 do
   begin
   begin
@@ -574,7 +574,7 @@ begin
       40: Radius := CurToken.FloatValue;
       40: Radius := CurToken.FloatValue;
       50: StartAngle := CurToken.FloatValue;
       50: StartAngle := CurToken.FloatValue;
       51: EndAngle := CurToken.FloatValue;
       51: EndAngle := CurToken.FloatValue;
-      62: LColor := DXFColorIndexToVColor(Trunc(CurToken.FloatValue));
+      62: LColor := DXFColorIndexToFPColor(Trunc(CurToken.FloatValue));
     end;
     end;
   end;
   end;
 
 
@@ -1053,7 +1053,7 @@ begin
   SetLength(Polyline, curPoint+1);
   SetLength(Polyline, curPoint+1);
   Polyline[curPoint].X := 0;
   Polyline[curPoint].X := 0;
   Polyline[curPoint].Y := 0;
   Polyline[curPoint].Y := 0;
-  Polyline[curPoint].Color := clvBlack;
+  Polyline[curPoint].Color := colBlack;
 
 
   for i := 0 to ATokens.Count - 1 do
   for i := 0 to ATokens.Count - 1 do
   begin
   begin
@@ -1071,7 +1071,7 @@ begin
     case CurToken.GroupCode of
     case CurToken.GroupCode of
       10: Polyline[curPoint].X := CurToken.FloatValue - DOC_OFFSET.X;
       10: Polyline[curPoint].X := CurToken.FloatValue - DOC_OFFSET.X;
       20: Polyline[curPoint].Y := CurToken.FloatValue - DOC_OFFSET.Y;
       20: Polyline[curPoint].Y := CurToken.FloatValue - DOC_OFFSET.Y;
-      62: Polyline[curPoint].Color := DXFColorIndexToVColor(Trunc(CurToken.FloatValue));
+      62: Polyline[curPoint].Color := DXFColorIndexToFPColor(Trunc(CurToken.FloatValue));
     end;
     end;
   end;
   end;
 end;
 end;
@@ -1192,8 +1192,7 @@ begin
   Result := StrToFloat(Copy(AStr, 2, Length(AStr) - 1));}
   Result := StrToFloat(Copy(AStr, 2, Length(AStr) - 1));}
 end;
 end;
 
 
-function TvDXFVectorialReader.DXFColorIndexToVColor(AColorIndex: Integer
-  ): TvColor;
+function TvDXFVectorialReader.DXFColorIndexToFPColor(AColorIndex: Integer): TFPColor;
 begin
 begin
   if (AColorIndex >= 0) and (AColorIndex <= 15) then
   if (AColorIndex >= 0) and (AColorIndex <= 15) then
     Result := AUTOCAD_COLOR_PALETTE[AColorIndex]
     Result := AUTOCAD_COLOR_PALETTE[AColorIndex]

+ 16 - 24
packages/fpvectorial/src/fpvectorial.pas

@@ -19,7 +19,7 @@ interface
 
 
 uses
 uses
   Classes, SysUtils, Math,
   Classes, SysUtils, Math,
-  fpcanvas;
+  fpcanvas, fpimage;
 
 
 type
 type
   TvVectorialFormat = (
   TvVectorialFormat = (
@@ -44,19 +44,14 @@ const
   STR_ENCAPSULATEDPOSTSCRIPT_EXTENSION = '.eps';
   STR_ENCAPSULATEDPOSTSCRIPT_EXTENSION = '.eps';
 
 
 type
 type
-  {@@ We need our own format because TFPColor is too big for our needs and TColor has no Alpha }
-  TvColor = packed record
-    Red, Green, Blue, Alpha: Byte;
-  end;
-
   TvPen = record
   TvPen = record
-    Color: TvColor;
+    Color: TFPColor;
     Style: TFPPenStyle;
     Style: TFPPenStyle;
     Width: Integer;
     Width: Integer;
   end;
   end;
 
 
   TvBrush = record
   TvBrush = record
-    Color: TvColor;
+    Color: TFPColor;
     Style: TFPBrushStyle;
     Style: TFPBrushStyle;
   end;
   end;
 
 
@@ -64,9 +59,6 @@ const
   FPValphaTransparent = $00;
   FPValphaTransparent = $00;
   FPValphaOpaque = $FF;
   FPValphaOpaque = $FF;
 
 
-  clvBlack: TvColor = (Red: $00; Green: $00; Blue: $00; Alpha: FPValphaOpaque);
-  clvBlue: TvColor = (Red: $00; Green: $00; Blue: $FF; Alpha: FPValphaOpaque);
-
 type
 type
   T3DPoint = record
   T3DPoint = record
     X, Y, Z: Double;
     X, Y, Z: Double;
@@ -154,7 +146,7 @@ type
   end;
   end;
 
 
   TvFont = record
   TvFont = record
-    Color: TvColor;
+    Color: TFPColor;
     Size: integer;
     Size: integer;
     Name: utf8string;
     Name: utf8string;
     {@@
     {@@
@@ -290,21 +282,21 @@ type
     procedure StartPath(); overload;
     procedure StartPath(); overload;
     procedure AddMoveToPath(AX, AY: Double);
     procedure AddMoveToPath(AX, AY: Double);
     procedure AddLineToPath(AX, AY: Double); overload;
     procedure AddLineToPath(AX, AY: Double); overload;
-    procedure AddLineToPath(AX, AY: Double; AColor: TvColor); overload;
+    procedure AddLineToPath(AX, AY: Double; AColor: TFPColor); overload;
     procedure AddLineToPath(AX, AY, AZ: Double); overload;
     procedure AddLineToPath(AX, AY, AZ: Double); overload;
     procedure GetCurrenPathPenPos(var AX, AY: Double);
     procedure GetCurrenPathPenPos(var AX, AY: Double);
     procedure AddBezierToPath(AX1, AY1, AX2, AY2, AX3, AY3: Double); overload;
     procedure AddBezierToPath(AX1, AY1, AX2, AY2, AX3, AY3: Double); overload;
     procedure AddBezierToPath(AX1, AY1, AZ1, AX2, AY2, AZ2, AX3, AY3, AZ3: Double); overload;
     procedure AddBezierToPath(AX1, AY1, AZ1, AX2, AY2, AZ2, AX3, AY3, AZ3: Double); overload;
-    procedure SetBrushColor(AColor: TvColor);
+    procedure SetBrushColor(AColor: TFPColor);
     procedure SetBrushStyle(AStyle: TFPBrushStyle);
     procedure SetBrushStyle(AStyle: TFPBrushStyle);
-    procedure SetPenColor(AColor: TvColor);
+    procedure SetPenColor(AColor: TFPColor);
     procedure SetPenStyle(AStyle: TFPPenStyle);
     procedure SetPenStyle(AStyle: TFPPenStyle);
     procedure SetPenWidth(AWidth: Integer);
     procedure SetPenWidth(AWidth: Integer);
     procedure EndPath();
     procedure EndPath();
     procedure AddText(AX, AY, AZ: Double; FontName: string; FontSize: integer; AText: utf8string); overload;
     procedure AddText(AX, AY, AZ: Double; FontName: string; FontSize: integer; AText: utf8string); overload;
     procedure AddText(AX, AY, AZ: Double; AStr: utf8string); overload;
     procedure AddText(AX, AY, AZ: Double; AStr: utf8string); overload;
     procedure AddCircle(ACenterX, ACenterY, ACenterZ, ARadius: Double);
     procedure AddCircle(ACenterX, ACenterY, ACenterZ, ARadius: Double);
-    procedure AddCircularArc(ACenterX, ACenterY, ACenterZ, ARadius, AStartAngle, AEndAngle: Double; AColor: TvColor);
+    procedure AddCircularArc(ACenterX, ACenterY, ACenterZ, ARadius, AStartAngle, AEndAngle: Double; AColor: TFPColor);
     procedure AddEllipse(CenterX, CenterY, CenterZ, MajorHalfAxis, MinorHalfAxis, Angle: Double);
     procedure AddEllipse(CenterX, CenterY, CenterZ, MajorHalfAxis, MinorHalfAxis, Angle: Double);
     // Dimensions
     // Dimensions
     procedure AddAlignedDimension(BaseLeft, BaseRight, DimLeft, DimRight: T3DPoint);
     procedure AddAlignedDimension(BaseLeft, BaseRight, DimLeft, DimRight: T3DPoint);
@@ -467,9 +459,9 @@ end;
 constructor TvEntity.Create;
 constructor TvEntity.Create;
 begin
 begin
   Pen.Style := psSolid;
   Pen.Style := psSolid;
-  Pen.Color := clvBlack;
+  Pen.Color := colBlack;
   Brush.Style := bsClear;
   Brush.Style := bsClear;
-  Brush.Color := clvBlue;
+  Brush.Color := colBlue;
 end;
 end;
 
 
 { TvEllipse }
 { TvEllipse }
@@ -636,7 +628,7 @@ begin
   AppendSegmentToTmpPath(segment);
   AppendSegmentToTmpPath(segment);
 end;
 end;
 
 
-procedure TvVectorialDocument.AddLineToPath(AX, AY: Double; AColor: TvColor);
+procedure TvVectorialDocument.AddLineToPath(AX, AY: Double; AColor: TFPColor);
 var
 var
   segment: T2DSegmentWithPen;
   segment: T2DSegmentWithPen;
 begin
 begin
@@ -716,7 +708,7 @@ begin
   AppendSegmentToTmpPath(segment);
   AppendSegmentToTmpPath(segment);
 end;
 end;
 
 
-procedure TvVectorialDocument.SetBrushColor(AColor: TvColor);
+procedure TvVectorialDocument.SetBrushColor(AColor: TFPColor);
 begin
 begin
   FTmPPath.Brush.Color := AColor;
   FTmPPath.Brush.Color := AColor;
 end;
 end;
@@ -726,7 +718,7 @@ begin
   FTmPPath.Brush.Style := AStyle;
   FTmPPath.Brush.Style := AStyle;
 end;
 end;
 
 
-procedure TvVectorialDocument.SetPenColor(AColor: TvColor);
+procedure TvVectorialDocument.SetPenColor(AColor: TFPColor);
 begin
 begin
   FTmPPath.Pen.Color := AColor;
   FTmPPath.Pen.Color := AColor;
 end;
 end;
@@ -790,7 +782,7 @@ begin
 end;
 end;
 
 
 procedure TvVectorialDocument.AddCircularArc(ACenterX, ACenterY, ACenterZ,
 procedure TvVectorialDocument.AddCircularArc(ACenterX, ACenterY, ACenterZ,
-  ARadius, AStartAngle, AEndAngle: Double; AColor: TvColor);
+  ARadius, AStartAngle, AEndAngle: Double; AColor: TFPColor);
 var
 var
   lCircularArc: TvCircularArc;
   lCircularArc: TvCircularArc;
 begin
 begin
@@ -893,9 +885,9 @@ begin
   FTmpPath.Points := nil;
   FTmpPath.Points := nil;
   FTmpPath.PointsEnd := nil;
   FTmpPath.PointsEnd := nil;
   FTmpPath.Len := 0;
   FTmpPath.Len := 0;
-  FTmpPath.Brush.Color := clvBlue;
+  FTmpPath.Brush.Color := colBlue;
   FTmpPath.Brush.Style := bsClear;
   FTmpPath.Brush.Style := bsClear;
-  FTmpPath.Pen.Color := clvBlack;
+  FTmpPath.Pen.Color := colBlack;
   FTmpPath.Pen.Style := psSolid;
   FTmpPath.Pen.Style := psSolid;
   FTmpPath.Pen.Width := 1;
   FTmpPath.Pen.Width := 1;
 end;
 end;

+ 8 - 33
packages/fpvectorial/src/fpvtocanvas.pas

@@ -35,18 +35,6 @@ implementation
 {$define FPVECTORIALDEBUG}
 {$define FPVECTORIALDEBUG}
 {$endif}
 {$endif}
 
 
-{$ifdef USE_LCL_CANVAS}
-function VColorToTColor(AVColor: TvColor): TColor; inline;
-begin
-  Result := RGBToColor(AVColor.Red, AVColor.Green, AVColor.Blue);
-end;
-{$endif}
-
-function VColorToFPColor(AVColor: TvColor): TFPColor; inline;
-begin
-  Result := FPColor(AVColor.Red*$100, AVColor.Green*$100, AVColor.Blue*$100);
-end;
-
 function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
 function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
 var
 var
   sinus, cosinus : Extended;
   sinus, cosinus : Extended;
@@ -173,13 +161,8 @@ begin
     ADest.Pen.Style := CurPath.Pen.Style;
     ADest.Pen.Style := CurPath.Pen.Style;
     ADest.Pen.Width := CurPath.Pen.Width;
     ADest.Pen.Width := CurPath.Pen.Width;
     ADest.Brush.Style := CurPath.Brush.Style;
     ADest.Brush.Style := CurPath.Brush.Style;
-    {$ifdef USE_LCL_CANVAS}
-    ADest.Pen.Color := VColorToTColor(CurPath.Pen.Color);
-    ADest.Brush.Color := VColorToTColor(CurPath.Brush.Color);
-    {$else}
-    ADest.Pen.FPColor := VColorToFPColor(CurPath.Pen.Color);
-    ADest.Brush.FPColor := VColorToFPColor(CurPath.Brush.Color);
-    {$endif}
+    ADest.Pen.FPColor := CurPath.Pen.Color;
+    ADest.Brush.FPColor := CurPath.Brush.Color;
 
 
     {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
     {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
     Write(Format('[Path] ID=%d', [i]));
     Write(Format('[Path] ID=%d', [i]));
@@ -201,15 +184,12 @@ begin
       // This element can override temporarely the Pen
       // This element can override temporarely the Pen
       st2DLineWithPen:
       st2DLineWithPen:
       begin
       begin
-        {$ifdef USE_LCL_CANVAS}
-          ADest.Pen.Color := VColorToTColor(T2DSegmentWithPen(Cur2DSegment).Pen.Color);
-        {$endif}
+        ADest.Pen.FPColor := T2DSegmentWithPen(Cur2DSegment).Pen.Color;
 
 
         ADest.LineTo(CoordToCanvasX(Cur2DSegment.X), CoordToCanvasY(Cur2DSegment.Y));
         ADest.LineTo(CoordToCanvasX(Cur2DSegment.X), CoordToCanvasY(Cur2DSegment.Y));
 
 
-        {$ifdef USE_LCL_CANVAS}
-          ADest.Pen.Color := VColorToTColor(CurPath.Pen.Color);
-        {$endif}
+        ADest.Pen.FPColor := CurPath.Pen.Color;
+
         {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
         {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
         Write(Format(' L%d,%d', [CoordToCanvasX(Cur2DSegment.X), CoordToCanvasY(Cur2DSegment.Y)]));
         Write(Format(' L%d,%d', [CoordToCanvasX(Cur2DSegment.X), CoordToCanvasY(Cur2DSegment.Y)]));
         {$endif}
         {$endif}
@@ -285,13 +265,8 @@ begin
 
 
     ADest.Brush.Style := CurEntity.Brush.Style;
     ADest.Brush.Style := CurEntity.Brush.Style;
     ADest.Pen.Style := CurEntity.Pen.Style;
     ADest.Pen.Style := CurEntity.Pen.Style;
-    {$ifdef USE_LCL_CANVAS}
-    ADest.Pen.Color := VColorToTColor(CurEntity.Pen.Color);
-    ADest.Brush.Color := VColorToTColor(CurEntity.Brush.Color);
-    {$else}
-    ADest.Pen.FPColor := VColorToFPColor(CurEntity.Pen.Color);
-    ADest.Brush.FPColor := VColorToFPColor(CurEntity.Brush.Color);
-    {$endif}
+    ADest.Pen.FPColor := CurEntity.Pen.Color;
+    ADest.Brush.FPColor := CurEntity.Brush.Color;
 
 
     if CurEntity is TvCircle then
     if CurEntity is TvCircle then
     begin
     begin
@@ -355,7 +330,7 @@ begin
       WriteLn(Format('Drawing Arc Center=%f,%f Radius=%f StartAngle=%f AngleLength=%f',
       WriteLn(Format('Drawing Arc Center=%f,%f Radius=%f StartAngle=%f AngleLength=%f',
         [CurArc.CenterX, CurArc.CenterY, CurArc.Radius, IntStartAngle/16, IntAngleLength/16]));
         [CurArc.CenterX, CurArc.CenterY, CurArc.Radius, IntStartAngle/16, IntAngleLength/16]));
       {$endif}
       {$endif}
-      ADest.Pen.Color := {$ifdef USE_LCL_CANVAS}VColorToTColor(CurArc.Pen.Color);{$else}VColorToFPColor(CurArc.Pen.Color);{$endif}
+      ADest.Pen.FPColor := CurArc.Pen.Color;
       ADest.Arc(
       ADest.Arc(
         BoundsLeft, BoundsTop, BoundsRight, BoundsBottom,
         BoundsLeft, BoundsTop, BoundsRight, BoundsBottom,
         IntStartAngle, IntAngleLength
         IntStartAngle, IntAngleLength

+ 21 - 22
packages/fpvectorial/src/fpvutils.pas

@@ -25,32 +25,29 @@ type
   T10Strings = array[0..9] of shortstring;
   T10Strings = array[0..9] of shortstring;
 
 
 // Color Conversion routines
 // Color Conversion routines
-function VColorToFPColor(AVColor: TvColor): TFPColor; inline;
-function VColorToRGBHexString(AVColor: TvColor): string;
-function RGBToVColor(AR, AG, AB: Byte): TvColor; inline;
-function  SeparateString(AString: string; ASeparator: Char): T10Strings;
+function FPColorToRGBHexString(AColor: TFPColor): string;
+function RGBToFPColor(AR, AG, AB: byte): TFPColor; inline;
+function SeparateString(AString: string; ASeparator: char): T10Strings;
 
 
 implementation
 implementation
 
 
-function VColorToFPColor(AVColor: TvColor): TFPColor; inline;
+function FPColorToRGBHexString(AColor: TFPColor): string;
 begin
 begin
-  Result.Red := AVColor.Red;
-  Result.Green := AVColor.Green;
-  Result.Blue := AVColor.Blue;
-  Result.Alpha := AVColor.Alpha;
+  Result := Format('%.2x%.2x%.2x', [AColor.Red shr 8, AColor.Green shr 8, AColor.Blue shr 8]);
 end;
 end;
 
 
-function VColorToRGBHexString(AVColor: TvColor): string;
+function RGBToFPColor(AR, AG, AB: byte): TFPColor; inline;
 begin
 begin
-  Result := Format('%.2x%.2x%.2x', [AVColor.Red, AVColor.Green, AVColor.Blue]);
-end;
+  if AR > $100 then Result.Red := (AR shl 8) + $FF
+  else Result.Red := AR shl 8;
 
 
-function RGBToVColor(AR, AG, AB: Byte): TvColor; inline;
-begin
-  Result.Red := AR;
-  Result.Green := AG;
-  Result.Blue := AB;
-  Result.Alpha := 255;
+  if AR > $100 then Result.Green := (AG shl 8) + $FF
+  else Result.Green := AG shl 8;
+
+  if AR > $100 then Result.Blue := (AB shl 8) + $FF
+  else Result.Blue := AB shl 8;
+
+  Result.Alpha := $FFFF;
 end;
 end;
 
 
 {@@
 {@@
@@ -62,14 +59,15 @@ end;
   Number of substrings: 10 (indexed 0 to 9)
   Number of substrings: 10 (indexed 0 to 9)
   Length of each substring: 255 (they are shortstrings)
   Length of each substring: 255 (they are shortstrings)
 }
 }
-function SeparateString(AString: string; ASeparator: Char): T10Strings;
+function SeparateString(AString: string; ASeparator: char): T10Strings;
 var
 var
-  i, CurrentPart: Integer;
+  i, CurrentPart: integer;
 begin
 begin
   CurrentPart := 0;
   CurrentPart := 0;
 
 
   { Clears the result }
   { Clears the result }
-  for i := 0 to 9 do Result[i] := '';
+  for i := 0 to 9 do
+    Result[i] := '';
 
 
   { Iterates througth the string, filling strings }
   { Iterates througth the string, filling strings }
   for i := 1 to Length(AString) do
   for i := 1 to Length(AString) do
@@ -79,7 +77,8 @@ begin
       Inc(CurrentPart);
       Inc(CurrentPart);
 
 
       { Verifies if the string capacity wasn't exceeded }
       { Verifies if the string capacity wasn't exceeded }
-      if CurrentPart > 9 then Exit;
+      if CurrentPart > 9 then
+        Exit;
     end
     end
     else
     else
       Result[CurrentPart] := Result[CurrentPart] + Copy(AString, i, 1);
       Result[CurrentPart] := Result[CurrentPart] + Copy(AString, i, 1);

+ 13 - 5
packages/fpvectorial/src/svgvectorialwriter.pas

@@ -13,7 +13,7 @@ unit svgvectorialwriter;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, math, fpvectorial, fpvutils;
+  Classes, SysUtils, math, fpvectorial, fpvutils, fpcanvas;
 
 
 type
 type
   { TvSVGVectorialWriter }
   { TvSVGVectorialWriter }
@@ -101,6 +101,8 @@ var
   // Pen properties
   // Pen properties
   lPenWidth: Integer;
   lPenWidth: Integer;
   lPenColor: string;
   lPenColor: string;
+  // Brush properties
+  lFillColor: string;
 begin
 begin
   OldPtX := 0;
   OldPtX := 0;
   OldPtY := 0;
   OldPtY := 0;
@@ -171,13 +173,19 @@ begin
   if APath.Pen.Width >= 1 then lPenWidth := APath.Pen.Width
   if APath.Pen.Width >= 1 then lPenWidth := APath.Pen.Width
   else lPenWidth := 1;
   else lPenWidth := 1;
 
 
-  // Get the Pen Color
-  lPenColor := VColorToRGBHexString(APath.Pen.Color);
+  // Get the Pen Color and Style
+  if APath.Pen.Style = psClear then lPenColor := 'none'
+  else lPenColor := '#' + FPColorToRGBHexString(APath.Pen.Color);
 
 
+  // Get the Brush color and style
+  if APath.Brush.Style = bsClear then lFillColor := 'none'
+  else lFillColor := '#' + FPColorToRGBHexString(APath.Brush.Color);
+
+  // Now effectively write the path
   AStrings.Add('  <path');
   AStrings.Add('  <path');
-  AStrings.Add(Format('    style="fill:none;stroke:#%s;stroke-width:%dpx;'
+  AStrings.Add(Format('    style="fill:%s;stroke:%s;stroke-width:%dpx;'
    + 'stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"',
    + 'stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"',
-   [lPenColor, lPenWidth]));
+   [lFillColor, lPenColor, lPenWidth]));
   AStrings.Add('    d="' + PathStr + '"');
   AStrings.Add('    d="' + PathStr + '"');
   AStrings.Add('  id="path' + IntToStr(AIndex) + '" />');
   AStrings.Add('  id="path' + IntToStr(AIndex) + '" />');
 end;
 end;