You've already forked lazarus-ccr
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
This commit is contained in:
@ -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;
|
||||
|
@ -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(' <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"',
|
||||
[lPenColor, lPenWidth]));
|
||||
[lFillColor, lPenColor, lPenWidth]));
|
||||
AStrings.Add(' d="' + PathStr + '"');
|
||||
AStrings.Add(' id="path' + IntToStr(AIndex) + '" />');
|
||||
end;
|
||||
|
Reference in New Issue
Block a user