mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 17:19:22 +02:00
fpvectorial-svg: Fixes sweep-flag & large-arc for top-left coord system
git-svn-id: trunk@52871 -
This commit is contained in:
parent
867a96e859
commit
64bec544f1
@ -106,7 +106,6 @@ type
|
|||||||
FPathNumber: Integer;
|
FPathNumber: Integer;
|
||||||
// Path support for multiple polygons
|
// Path support for multiple polygons
|
||||||
FPathStart: T2DPoint;
|
FPathStart: T2DPoint;
|
||||||
FIsFirstPathMove: Boolean;
|
|
||||||
// BrushDefs functions
|
// BrushDefs functions
|
||||||
function FindBrushDef_WithName(AName: string): TvEntityWithPenAndBrush;
|
function FindBrushDef_WithName(AName: string): TvEntityWithPenAndBrush;
|
||||||
//
|
//
|
||||||
@ -140,7 +139,7 @@ type
|
|||||||
function ReadLineFromNode(ANode: TDOMNode; AData: TvVectorialPage; ADoc: TvVectorialDocument): TvEntity;
|
function ReadLineFromNode(ANode: TDOMNode; AData: TvVectorialPage; ADoc: TvVectorialDocument): TvEntity;
|
||||||
function ReadPathFromNode(ANode: TDOMNode; AData: TvVectorialPage; ADoc: TvVectorialDocument): TvEntity;
|
function ReadPathFromNode(ANode: TDOMNode; AData: TvVectorialPage; ADoc: TvVectorialDocument): TvEntity;
|
||||||
procedure ReadPathFromString(AStr: string; AData: TvVectorialPage; ADoc: TvVectorialDocument);
|
procedure ReadPathFromString(AStr: string; AData: TvVectorialPage; ADoc: TvVectorialDocument);
|
||||||
procedure ReadNextPathCommand(ACurTokenType: TSVGTokenType; var i: Integer; var CurX, CurY: Double; AData: TvVectorialPage; ADoc: TvVectorialDocument);
|
procedure ReadNextPathCommand(ACurTokenType: TSVGTokenType; var i: Integer; var AIsFirstPathMove: Boolean; var CurX, CurY: Double; AData: TvVectorialPage; ADoc: TvVectorialDocument);
|
||||||
procedure ReadPointsFromString(AStr: string; AData: TvVectorialPage; ADoc: TvVectorialDocument; AClosePath: Boolean);
|
procedure ReadPointsFromString(AStr: string; AData: TvVectorialPage; ADoc: TvVectorialDocument; AClosePath: Boolean);
|
||||||
function ReadPolyFromNode(ANode: TDOMNode; AData: TvVectorialPage; ADoc: TvVectorialDocument): TvEntity;
|
function ReadPolyFromNode(ANode: TDOMNode; AData: TvVectorialPage; ADoc: TvVectorialDocument): TvEntity;
|
||||||
function ReadRectFromNode(ANode: TDOMNode; AData: TvVectorialPage; ADoc: TvVectorialDocument): TvEntity;
|
function ReadRectFromNode(ANode: TDOMNode; AData: TvVectorialPage; ADoc: TvVectorialDocument): TvEntity;
|
||||||
@ -2135,13 +2134,14 @@ var
|
|||||||
lCurTokenType, lLastCommandToken: TSVGTokenType;
|
lCurTokenType, lLastCommandToken: TSVGTokenType;
|
||||||
lDebugStr: String;
|
lDebugStr: String;
|
||||||
lTmpTokenType: TSVGTokenType;
|
lTmpTokenType: TSVGTokenType;
|
||||||
|
lIsFirstPathMove: Boolean;
|
||||||
begin
|
begin
|
||||||
FSVGPathTokenizer.ClearTokens;
|
FSVGPathTokenizer.ClearTokens;
|
||||||
FSVGPathTokenizer.TokenizePathString(AStr);
|
FSVGPathTokenizer.TokenizePathString(AStr);
|
||||||
//lDebugStr := FSVGPathTokenizer.DebugOutTokensAsString();
|
//lDebugStr := FSVGPathTokenizer.DebugOutTokensAsString();
|
||||||
CurX := 0;
|
CurX := 0;
|
||||||
CurY := 0;
|
CurY := 0;
|
||||||
FIsFirstPathMove := true;
|
lIsFirstPathMove := true;
|
||||||
lLastCommandToken := sttFloatValue;
|
lLastCommandToken := sttFloatValue;
|
||||||
|
|
||||||
i := 0;
|
i := 0;
|
||||||
@ -2151,7 +2151,7 @@ begin
|
|||||||
if not (lCurTokenType = sttFloatValue) then
|
if not (lCurTokenType = sttFloatValue) then
|
||||||
begin
|
begin
|
||||||
lLastCommandToken := lCurTokenType;
|
lLastCommandToken := lCurTokenType;
|
||||||
ReadNextPathCommand(lCurTokenType, i, CurX, CurY, AData, ADoc);
|
ReadNextPathCommand(lCurTokenType, i, lIsFirstPathMove, CurX, CurY, AData, ADoc);
|
||||||
end
|
end
|
||||||
// In this case we are getting a command without a starting letter
|
// In this case we are getting a command without a starting letter
|
||||||
// It is a copy of the last one, or something related to it
|
// It is a copy of the last one, or something related to it
|
||||||
@ -2162,13 +2162,13 @@ begin
|
|||||||
if lLastCommandToken = sttRelativeMoveTo then lTmpTokenType := sttRelativeLineTo;
|
if lLastCommandToken = sttRelativeMoveTo then lTmpTokenType := sttRelativeLineTo;
|
||||||
// For bezier I checked that a sttBezierTo upon repetition expects a sttBezierTo
|
// For bezier I checked that a sttBezierTo upon repetition expects a sttBezierTo
|
||||||
Dec(i);// because there is no command token in this command
|
Dec(i);// because there is no command token in this command
|
||||||
ReadNextPathCommand(lTmpTokenType, i, CurX, CurY, AData, ADoc);
|
ReadNextPathCommand(lTmpTokenType, i, lIsFirstPathMove, CurX, CurY, AData, ADoc);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TvSVGVectorialReader.ReadNextPathCommand(ACurTokenType: TSVGTokenType;
|
procedure TvSVGVectorialReader.ReadNextPathCommand(ACurTokenType: TSVGTokenType;
|
||||||
var i: Integer; var CurX, CurY: Double; AData: TvVectorialPage;
|
var i: Integer; var AIsFirstPathMove: Boolean; var CurX, CurY: Double; AData: TvVectorialPage;
|
||||||
ADoc: TvVectorialDocument);
|
ADoc: TvVectorialDocument);
|
||||||
var
|
var
|
||||||
X, Y, X2, Y2, X3, Y3, XQ, YQ, Xnew, Ynew, cx, cy, phi, tmp: Double;
|
X, Y, X2, Y2, X3, Y3, XQ, YQ, Xnew, Ynew, cx, cy, phi, tmp: Double;
|
||||||
@ -2188,12 +2188,6 @@ begin
|
|||||||
// The point at which the polygon starts.
|
// The point at which the polygon starts.
|
||||||
X := FSVGPathTokenizer.Tokens.Items[i+1].Value;
|
X := FSVGPathTokenizer.Tokens.Items[i+1].Value;
|
||||||
Y := FSVGPathTokenizer.Tokens.Items[i+2].Value;
|
Y := FSVGPathTokenizer.Tokens.Items[i+2].Value;
|
||||||
(*
|
|
||||||
if FIsFirstPathMove then begin
|
|
||||||
X := FPathStart.X;
|
|
||||||
Y := FPathStart.Y;
|
|
||||||
FIsFirstPathMove := false;
|
|
||||||
end;*)
|
|
||||||
|
|
||||||
// take care of relative or absolute
|
// take care of relative or absolute
|
||||||
// Idiotism in SVG: If the path starts with a relative move to,
|
// Idiotism in SVG: If the path starts with a relative move to,
|
||||||
@ -2213,10 +2207,11 @@ begin
|
|||||||
AData.AddMoveToPath(CurX, CurY);
|
AData.AddMoveToPath(CurX, CurY);
|
||||||
// Since there may be several subpolygons we must store the start point
|
// Since there may be several subpolygons we must store the start point
|
||||||
// to close the subpolygon correctly later.
|
// to close the subpolygon correctly later.
|
||||||
if FIsFirstPathMove then begin
|
if AIsFirstPathMove then
|
||||||
|
begin
|
||||||
FPathStart.X := CurX;
|
FPathStart.X := CurX;
|
||||||
FPathStart.Y := CurY;
|
FPathStart.Y := CurY;
|
||||||
FIsFirstPathMove := false;
|
AIsFirstPathMove := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Inc(i, 3);
|
Inc(i, 3);
|
||||||
@ -2232,7 +2227,6 @@ begin
|
|||||||
AData.AddLineToPath(CurX, CurY);
|
AData.AddLineToPath(CurX, CurY);
|
||||||
|
|
||||||
Inc(i, 1);
|
Inc(i, 1);
|
||||||
// Inc(i, 3);
|
|
||||||
end
|
end
|
||||||
// --------------
|
// --------------
|
||||||
// Lines
|
// Lines
|
||||||
@ -2488,8 +2482,11 @@ begin
|
|||||||
|
|
||||||
// in svg the y axis increases downward, in fpv upward. Therefore, angles
|
// in svg the y axis increases downward, in fpv upward. Therefore, angles
|
||||||
// change their sign!
|
// change their sign!
|
||||||
|
if not gSVGVecReader_UseTopLeftCoords then
|
||||||
|
begin
|
||||||
phi := -phi;
|
phi := -phi;
|
||||||
SweepFlag := not SweepFlag; // i.e. "clockwise" turns into "counter-clockwise"!
|
SweepFlag := not SweepFlag; // i.e. "clockwise" turns into "counter-clockwise"!
|
||||||
|
end;
|
||||||
|
|
||||||
if CalcEllipseCenter(CurX, CurY, Xnew, Ynew, X2, Y2, phi, LargeArcFlag, SweepFlag, cx, cy, tmp) then
|
if CalcEllipseCenter(CurX, CurY, Xnew, Ynew, X2, Y2, phi, LargeArcFlag, SweepFlag, cx, cy, tmp) then
|
||||||
AData.AddEllipticalArcWithCenterToPath(X2*tmp, Y2*tmp, phi, Xnew, Ynew, cx, cy, SweepFlag)
|
AData.AddEllipticalArcWithCenterToPath(X2*tmp, Y2*tmp, phi, Xnew, Ynew, cx, cy, SweepFlag)
|
||||||
|
Loading…
Reference in New Issue
Block a user