From 3ccb5e6a96065fe1b15bbf10909c72e21d4f2ce0 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Thu, 16 Jun 2011 10:15:51 +0000 Subject: [PATCH] fpvectorial: Adds support for brush color and style in svg outputting git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1683 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../fpvviewer/fpvectorialsrc/fpvutils.pas | 17 +++++++++++++---- .../fpvectorialsrc/svgvectorialwriter.pas | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/applications/fpvviewer/fpvectorialsrc/fpvutils.pas b/applications/fpvviewer/fpvectorialsrc/fpvutils.pas index 26b7fc921..5f96734bb 100644 --- a/applications/fpvviewer/fpvectorialsrc/fpvutils.pas +++ b/applications/fpvviewer/fpvectorialsrc/fpvutils.pas @@ -26,6 +26,7 @@ type // Color Conversion routines function VColorToFPColor(AVColor: TvColor): TFPColor; inline; +function FPColorToVColor(AFPColor: TFPColor): TvColor; function VColorToRGBHexString(AVColor: TvColor): string; function RGBToVColor(AR, AG, AB: Byte): TvColor; inline; function SeparateString(AString: string; ASeparator: Char): T10Strings; @@ -34,10 +35,18 @@ implementation function VColorToFPColor(AVColor: TvColor): TFPColor; inline; begin - Result.Red := AVColor.Red; - Result.Green := AVColor.Green; - Result.Blue := AVColor.Blue; - Result.Alpha := AVColor.Alpha; + Result.Red := AVColor.Red shl 8; + Result.Green := AVColor.Green shl 8; + Result.Blue := AVColor.Blue shl 8; + Result.Alpha := AVColor.Alpha shl 8; +end; + +function FPColorToVColor(AFPColor: TFPColor): TvColor; +begin + Result.Red := AFPColor.Red shr 8; + Result.Green := AFPColor.Green shr 8; + Result.Blue := AFPColor.Blue shr 8; + Result.Alpha := AFPColor.Alpha shr 8; end; function VColorToRGBHexString(AVColor: TvColor): string; diff --git a/applications/fpvviewer/fpvectorialsrc/svgvectorialwriter.pas b/applications/fpvviewer/fpvectorialsrc/svgvectorialwriter.pas index 6fad037e2..3f884c3bb 100644 --- a/applications/fpvviewer/fpvectorialsrc/svgvectorialwriter.pas +++ b/applications/fpvviewer/fpvectorialsrc/svgvectorialwriter.pas @@ -13,7 +13,7 @@ unit svgvectorialwriter; interface uses - Classes, SysUtils, math, fpvectorial, fpvutils; + Classes, SysUtils, math, fpvectorial, fpvutils, fpcanvas; type { TvSVGVectorialWriter } @@ -101,6 +101,8 @@ var // Pen properties lPenWidth: Integer; lPenColor: string; + // Brush properties + lFillColor: string; begin OldPtX := 0; OldPtY := 0; @@ -171,13 +173,19 @@ begin if APath.Pen.Width >= 1 then lPenWidth := APath.Pen.Width 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 := '#' + VColorToRGBHexString(APath.Pen.Color); + // Get the Brush color and style + if APath.Brush.Style = bsClear then lFillColor := 'none' + else lFillColor := '#' + VColorToRGBHexString(APath.Brush.Color); + + // Now effectively write the path AStrings.Add(' '); end;