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
|
// Color Conversion routines
|
||||||
function VColorToFPColor(AVColor: TvColor): TFPColor; inline;
|
function VColorToFPColor(AVColor: TvColor): TFPColor; inline;
|
||||||
|
function FPColorToVColor(AFPColor: TFPColor): TvColor;
|
||||||
function VColorToRGBHexString(AVColor: TvColor): string;
|
function VColorToRGBHexString(AVColor: TvColor): string;
|
||||||
function RGBToVColor(AR, AG, AB: Byte): TvColor; inline;
|
function RGBToVColor(AR, AG, AB: Byte): TvColor; inline;
|
||||||
function SeparateString(AString: string; ASeparator: Char): T10Strings;
|
function SeparateString(AString: string; ASeparator: Char): T10Strings;
|
||||||
@ -34,10 +35,18 @@ implementation
|
|||||||
|
|
||||||
function VColorToFPColor(AVColor: TvColor): TFPColor; inline;
|
function VColorToFPColor(AVColor: TvColor): TFPColor; inline;
|
||||||
begin
|
begin
|
||||||
Result.Red := AVColor.Red;
|
Result.Red := AVColor.Red shl 8;
|
||||||
Result.Green := AVColor.Green;
|
Result.Green := AVColor.Green shl 8;
|
||||||
Result.Blue := AVColor.Blue;
|
Result.Blue := AVColor.Blue shl 8;
|
||||||
Result.Alpha := AVColor.Alpha;
|
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;
|
end;
|
||||||
|
|
||||||
function VColorToRGBHexString(AVColor: TvColor): string;
|
function VColorToRGBHexString(AVColor: TvColor): string;
|
||||||
|
@ -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
|
// Get the Pen Color and Style
|
||||||
lPenColor := VColorToRGBHexString(APath.Pen.Color);
|
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(' <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;
|
||||||
|
Reference in New Issue
Block a user