mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 04:16:06 +02:00
fpvectorial: Implements support for color channels in percentages
git-svn-id: trunk@43773 -
This commit is contained in:
parent
0ac5918f3d
commit
065d37b166
@ -113,6 +113,7 @@ type
|
||||
const AData: TvVectorialPage;
|
||||
const ASrcX, ASrcY: Double; var ADestX, ADestY: Double);
|
||||
procedure AutoDetectDocSize(var ALeft, ATop, ARight, ABottom: Double; ABaseNode: TDOMNode);
|
||||
function SVGColorValueStrToWord(AStr: string): Word;
|
||||
public
|
||||
{ General reading methods }
|
||||
constructor Create; override;
|
||||
@ -393,12 +394,13 @@ begin
|
||||
try
|
||||
lStr := Copy(lValue, 5, Length(lValue)-5);
|
||||
lStrings.Delimiter := ',';
|
||||
lStrings.StrictDelimiter := True;
|
||||
lStrings.DelimitedText := lStr;
|
||||
if lStrings.Count = 3 then
|
||||
begin
|
||||
Result.Red := StrToInt(lStrings.Strings[0]) * $101;
|
||||
Result.Green := StrToInt(lStrings.Strings[1]) * $101;
|
||||
Result.Blue := StrToInt(lStrings.Strings[2]) * $101;
|
||||
Result.Red := SVGColorValueStrToWord(lStrings.Strings[0]);
|
||||
Result.Green := SVGColorValueStrToWord(lStrings.Strings[1]);
|
||||
Result.Blue := SVGColorValueStrToWord(lStrings.Strings[2]);
|
||||
end
|
||||
else
|
||||
raise Exception.Create(Format('[TvSVGVectorialReader.ReadSVGColor] An unexpected number of channels was found: %d', [lStrings.Count]));
|
||||
@ -2353,6 +2355,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
// From 0..255 to 0..$FFFF
|
||||
// From 0%..100% to 0..$FFFF
|
||||
function TvSVGVectorialReader.SVGColorValueStrToWord(AStr: string): Word;
|
||||
var
|
||||
lStr: string;
|
||||
begin
|
||||
lStr := Trim(AStr);
|
||||
if lStr[Length(lStr)] = '%' then
|
||||
begin
|
||||
lStr := Copy(lStr, 1, Length(lStr)-1);
|
||||
Result := StrToInt(lStr) * $FFFF div 100;
|
||||
end
|
||||
else Result := StrToInt(lStr) * $101;
|
||||
end;
|
||||
|
||||
constructor TvSVGVectorialReader.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
|
Loading…
Reference in New Issue
Block a user