fpvectorial-svg reader: Improves the polyline style reading and fixes a points reading typo in polyline/polygon support

git-svn-id: trunk@39724 -
This commit is contained in:
sekelsenmat 2013-01-02 08:05:43 +00:00
parent c84d05e1d3
commit bf50f1c80c
2 changed files with 44 additions and 15 deletions

View File

@ -2757,7 +2757,9 @@ begin
FEntities := TFPList.Create; FEntities := TFPList.Create;
FTmpPath := TPath.Create; FTmpPath := TPath.Create;
Owner := AOwner; Owner := AOwner;
Clear();
BackgroundColor := colWhite; BackgroundColor := colWhite;
System.FillChar(RenderInfo, SizeOf(RenderInfo), #0);
RenderInfo.BackgroundColor := colWhite; RenderInfo.BackgroundColor := colWhite;
end; end;

View File

@ -292,9 +292,9 @@ begin
lStrings.DelimitedText := lStr; lStrings.DelimitedText := lStr;
if lStrings.Count = 3 then if lStrings.Count = 3 then
begin begin
Result.Red := StrToInt(lStrings.Strings[0]); Result.Red := StrToInt(lStrings.Strings[0]) * $101;
Result.Blue := StrToInt(lStrings.Strings[1]); Result.Blue := StrToInt(lStrings.Strings[1]) * $101;
Result.Green := StrToInt(lStrings.Strings[2]); Result.Green := StrToInt(lStrings.Strings[2]) * $101;
end end
else else
raise Exception.Create(Format('[TvSVGVectorialReader.ReadSVGColor] An unexpected number of channels was found: %d', [lStrings.Count])); raise Exception.Create(Format('[TvSVGVectorialReader.ReadSVGColor] An unexpected number of channels was found: %d', [lStrings.Count]));
@ -509,8 +509,25 @@ darkkhaki #BDB76B
Result.Green := $1515; Result.Green := $1515;
Result.Blue := $8585; Result.Blue := $8585;
end; end;
{indianred #CD5C5C 'indianred':
peru #CD853F chocolate #D2691E begin
Result.Red := $CDCD;
Result.Green := $5C5C;
Result.Blue := $5C5C;
end;
'peru':
begin
Result.Red := $CDCD;
Result.Green := $8585;
Result.Blue := $3F3F;
end;
'chocolate':
begin
Result.Red := $D2D2;
Result.Green := $6969;
Result.Blue := $1E1E;
end;
{
tan #D2B48C tan #D2B48C
lightgray #D3D3D3 lightgrey #D3D3D3 lightgray #D3D3D3 lightgrey #D3D3D3
thistle #D8BFD8 thistle #D8BFD8
@ -569,8 +586,13 @@ lavender #E6E6FA
Result.Green := $FFFF; Result.Green := $FFFF;
Result.Blue := $FFFF; Result.Blue := $FFFF;
end; end;
'sandybrown':
begin
Result.Red := $F4F4;
Result.Green := $A4A4;
Result.Blue := $6060;
end;
{ {
sandybrown #F4A460
wheat #F5DEB3 beige #F5F5DC wheat #F5DEB3 beige #F5F5DC
whitesmoke #F5F5F5 whitesmoke #F5F5F5
mintcream #F5FFFA ghostwhite #F8F8FF mintcream #F5FFFA ghostwhite #F8F8FF
@ -835,6 +857,8 @@ var
vx1, vy1, vx2, vy2: double; vx1, vy1, vx2, vy2: double;
i: Integer; i: Integer;
lNodeName: DOMString; lNodeName: DOMString;
lPath: TPath;
lStyleStr, lStrokeStr, lStrokeWidthStr: DOMString;
begin begin
x1 := 0.0; x1 := 0.0;
y1 := 0.0; y1 := 0.0;
@ -852,14 +876,13 @@ begin
else if lNodeName = 'x2' then else if lNodeName = 'x2' then
x2 := StringWithUnitToFloat(ANode.Attributes.Item[i].NodeValue) x2 := StringWithUnitToFloat(ANode.Attributes.Item[i].NodeValue)
else if lNodeName = 'y2' then else if lNodeName = 'y2' then
y2 := StringWithUnitToFloat(ANode.Attributes.Item[i].NodeValue);{ y2 := StringWithUnitToFloat(ANode.Attributes.Item[i].NodeValue)
else if lNodeName = 'style' then else if lNodeName = 'style' then
ReadSVGStyle(ANode.Attributes.Item[i].NodeValue, lEllipse) lStyleStr := ANode.Attributes.Item[i].NodeValue
else if IsAttributeFromStyle(lNodeName) then else if lNodeName = 'stroke' then
begin lStrokeStr := ANode.Attributes.Item[i].NodeValue
ReadSVGPenStyleWithKeyAndValue(lNodeName, ANode.Attributes.Item[i].NodeValue, lEllipse); else if lNodeName = 'stroke-width' then
ReadSVGBrushStyleWithKeyAndValue(lNodeName, ANode.Attributes.Item[i].NodeValue, lEllipse); lStrokeWidthStr := ANode.Attributes.Item[i].NodeValue;
end;}
end; end;
ConvertSVGCoordinatesToFPVCoordinates( ConvertSVGCoordinatesToFPVCoordinates(
@ -870,7 +893,11 @@ begin
AData.StartPath(); AData.StartPath();
AData.AddMoveToPath(vx1, vy1); AData.AddMoveToPath(vx1, vy1);
AData.AddLineToPath(vx2, vy2); AData.AddLineToPath(vx2, vy2);
AData.EndPath(); lPath := AData.EndPath();
// Add the pen/brush
ReadSVGStyle(lStyleStr, lPath);
ReadSVGStyle(lStrokeStr, lPath);
ReadSVGStyle(lStrokeWidthStr, lPath);
end; end;
procedure TvSVGVectorialReader.ReadPathFromNode(ANode: TDOMNode; procedure TvSVGVectorialReader.ReadPathFromNode(ANode: TDOMNode;
@ -1116,7 +1143,7 @@ begin
while i < FSVGPathTokenizer.Tokens.Count do while i < FSVGPathTokenizer.Tokens.Count do
begin begin
X := FSVGPathTokenizer.Tokens.Items[i].Value; X := FSVGPathTokenizer.Tokens.Items[i].Value;
Y := FSVGPathTokenizer.Tokens.Items[i].Value; Y := FSVGPathTokenizer.Tokens.Items[i+1].Value;
ConvertSVGDeltaToFPVDelta(AData, X, Y, CurX, CurY); ConvertSVGDeltaToFPVDelta(AData, X, Y, CurX, CurY);
AData.AddLineToPath(CurX, CurY); AData.AddLineToPath(CurX, CurY);