You've already forked lazarus-ccr
fpvectorial: Fixes final issues with the brush and relative lines / curves
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1899 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -14,7 +14,7 @@ unit epsvectorialreader;
|
|||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
{$define FPVECTORIALDEBUG_PATHS}
|
{.$define FPVECTORIALDEBUG_PATHS}
|
||||||
{.$define FPVECTORIALDEBUG_COLORS}
|
{.$define FPVECTORIALDEBUG_COLORS}
|
||||||
{.$define FPVECTORIALDEBUG_ROLL}
|
{.$define FPVECTORIALDEBUG_ROLL}
|
||||||
{.$define FPVECTORIALDEBUG_CODEFLOW}
|
{.$define FPVECTORIALDEBUG_CODEFLOW}
|
||||||
@ -159,8 +159,12 @@ begin
|
|||||||
Result.Color := Color;
|
Result.Color := Color;
|
||||||
Result.TranslateX := TranslateX;
|
Result.TranslateX := TranslateX;
|
||||||
Result.TranslateY := TranslateY;
|
Result.TranslateY := TranslateY;
|
||||||
|
Result.ScaleX := ScaleX;
|
||||||
|
Result.ScaleY := ScaleY;
|
||||||
Result.ClipPath := ClipPath;
|
Result.ClipPath := ClipPath;
|
||||||
|
Result.ClipMode := ClipMode;
|
||||||
Result.OverPrint := OverPrint;
|
Result.OverPrint := OverPrint;
|
||||||
|
Result.PenWidth := PenWidth;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TPSToken }
|
{ TPSToken }
|
||||||
@ -1227,6 +1231,12 @@ begin
|
|||||||
{$ifdef FPVECTORIALDEBUG_PATHS}
|
{$ifdef FPVECTORIALDEBUG_PATHS}
|
||||||
WriteLn('[TvEPSVectorialReader.ExecutePaintingOperator] stroke');
|
WriteLn('[TvEPSVectorialReader.ExecutePaintingOperator] stroke');
|
||||||
{$endif}
|
{$endif}
|
||||||
|
AData.SetPenStyle(psSolid);
|
||||||
|
AData.SetBrushStyle(bsClear);
|
||||||
|
AData.SetPenColor(CurrentGraphicState.Color);
|
||||||
|
AData.SetClipPath(CurrentGraphicState.ClipPath, CurrentGraphicState.ClipMode);
|
||||||
|
AData.SetPenWidth(CurrentGraphicState.PenWidth);
|
||||||
|
AData.EndPath();
|
||||||
Exit(True);
|
Exit(True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1236,6 +1246,10 @@ begin
|
|||||||
WriteLn('[TvEPSVectorialReader.ExecutePaintingOperator] eofill');
|
WriteLn('[TvEPSVectorialReader.ExecutePaintingOperator] eofill');
|
||||||
{$endif}
|
{$endif}
|
||||||
AData.SetBrushStyle(bsSolid);
|
AData.SetBrushStyle(bsSolid);
|
||||||
|
AData.SetPenStyle(psSolid);
|
||||||
|
AData.SetClipPath(CurrentGraphicState.ClipPath, CurrentGraphicState.ClipMode);
|
||||||
|
AData.SetPenWidth(CurrentGraphicState.PenWidth);
|
||||||
|
AData.EndPath();
|
||||||
|
|
||||||
Exit(True);
|
Exit(True);
|
||||||
end;
|
end;
|
||||||
@ -1581,13 +1595,17 @@ begin
|
|||||||
{$ifdef FPVECTORIALDEBUG_PATHS}
|
{$ifdef FPVECTORIALDEBUG_PATHS}
|
||||||
WriteLn('[TvEPSVectorialReader.ExecutePathConstructionOperator] newpath');
|
WriteLn('[TvEPSVectorialReader.ExecutePathConstructionOperator] newpath');
|
||||||
{$endif}
|
{$endif}
|
||||||
AData.SetClipPath(CurrentGraphicState.ClipPath, CurrentGraphicState.ClipMode);
|
// AData.SetClipPath(CurrentGraphicState.ClipPath, CurrentGraphicState.ClipMode);
|
||||||
AData.SetPenWidth(CurrentGraphicState.PenWidth);
|
// AData.SetPenWidth(CurrentGraphicState.PenWidth);
|
||||||
|
// AData.SetClipPath(CurrentGraphicState.ClipPath, CurrentGraphicState.ClipMode);
|
||||||
|
AData.SetBrushStyle(bsClear);
|
||||||
|
AData.SetPenStyle(psClear);
|
||||||
AData.EndPath();
|
AData.EndPath();
|
||||||
AData.StartPath();
|
AData.StartPath();
|
||||||
|
|
||||||
AData.SetPenColor(CurrentGraphicState.Color);
|
AData.SetPenColor(CurrentGraphicState.Color);
|
||||||
AData.SetBrushColor(CurrentGraphicState.Color);
|
AData.SetBrushColor(CurrentGraphicState.Color);
|
||||||
|
AData.SetPenStyle(psClear);
|
||||||
|
|
||||||
Exit(True);
|
Exit(True);
|
||||||
end;
|
end;
|
||||||
@ -1629,8 +1647,8 @@ begin
|
|||||||
Param2 := TPSToken(Stack.Pop);
|
Param2 := TPSToken(Stack.Pop);
|
||||||
PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX, PosY);
|
PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX, PosY);
|
||||||
AData.GetCurrentPathPenPos(BaseX, BaseY);
|
AData.GetCurrentPathPenPos(BaseX, BaseY);
|
||||||
PosX2 := PosX + BaseX;//CurrentGraphicState.TranslateX;
|
PosX2 := PosX + BaseX;
|
||||||
PosY2 := PosY + BaseY;//CurrentGraphicState.TranslateY;
|
PosY2 := PosY + BaseY;
|
||||||
{$ifdef FPVECTORIALDEBUG_PATHS}
|
{$ifdef FPVECTORIALDEBUG_PATHS}
|
||||||
WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rlineto %f, %f Base %f, %f Resulting %f, %f',
|
WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rlineto %f, %f Base %f, %f Resulting %f, %f',
|
||||||
[PosX, PosY, BaseX, BaseY, PosX2, PosY2]));
|
[PosX, PosY, BaseX, BaseY, PosX2, PosY2]));
|
||||||
@ -1659,10 +1677,10 @@ begin
|
|||||||
PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX3, PosY3);
|
PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX3, PosY3);
|
||||||
AData.GetCurrentPathPenPos(BaseX, BaseY);
|
AData.GetCurrentPathPenPos(BaseX, BaseY);
|
||||||
// First move to the start of the arc
|
// First move to the start of the arc
|
||||||
BaseX := BaseX + CurrentGraphicState.TranslateX;
|
// BaseX := BaseX + CurrentGraphicState.TranslateX;
|
||||||
BaseY := BaseY + CurrentGraphicState.TranslateY;
|
// BaseY := BaseY + CurrentGraphicState.TranslateY;
|
||||||
{$ifdef FPVECTORIALDEBUG_PATHS}
|
{$ifdef FPVECTORIALDEBUG_PATHS}
|
||||||
WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] translate %f, %f',
|
WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rcurveto translate %f, %f',
|
||||||
[CurrentGraphicState.TranslateX, CurrentGraphicState.TranslateY]));
|
[CurrentGraphicState.TranslateX, CurrentGraphicState.TranslateY]));
|
||||||
WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rcurveto from %f, %f via %f, %f %f, %f to %f, %f',
|
WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rcurveto from %f, %f via %f, %f %f, %f to %f, %f',
|
||||||
[BaseX, BaseY, BaseX + PosX, BaseY + PosY, BaseX + PosX2, BaseY + PosY2, BaseX + PosX3, BaseY + PosY3]));
|
[BaseX, BaseY, BaseX + PosX, BaseY + PosY, BaseX + PosX2, BaseY + PosY2, BaseX + PosX3, BaseY + PosY3]));
|
||||||
@ -1747,6 +1765,7 @@ begin
|
|||||||
{$ifndef FPVECTORIALDEBUG_CLIP_REGION}
|
{$ifndef FPVECTORIALDEBUG_CLIP_REGION}
|
||||||
AData.SetPenStyle(psClear);
|
AData.SetPenStyle(psClear);
|
||||||
{$endif}
|
{$endif}
|
||||||
|
AData.SetBrushStyle(bsClear);
|
||||||
AData.EndPath();
|
AData.EndPath();
|
||||||
CurrentGraphicState.ClipPath := AData.GetPath(AData.GetPathCount()-1);
|
CurrentGraphicState.ClipPath := AData.GetPath(AData.GetPathCount()-1);
|
||||||
CurrentGraphicState.ClipMode := vcmEvenOddRule;
|
CurrentGraphicState.ClipMode := vcmEvenOddRule;
|
||||||
|
@ -9,6 +9,9 @@ interface
|
|||||||
{$define USE_CANVAS_CLIP_REGION}
|
{$define USE_CANVAS_CLIP_REGION}
|
||||||
{.$define DEBUG_CANVAS_CLIP_REGION}
|
{.$define DEBUG_CANVAS_CLIP_REGION}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
{$ifndef Windows}
|
||||||
|
{.$define FPVECTORIAL_TOCANVAS_DEBUG}
|
||||||
|
{$endif}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Math,
|
Classes, SysUtils, Math,
|
||||||
@ -34,10 +37,6 @@ procedure DrawFPVTextToCanvas(ASource: TvVectorialDocument; CurText: TvText;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{$ifndef Windows}
|
|
||||||
{$define FPVECTORIAL_TOCANVAS_DEBUG}
|
|
||||||
{$endif}
|
|
||||||
|
|
||||||
function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
|
function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
|
||||||
var
|
var
|
||||||
sinus, cosinus : Extended;
|
sinus, cosinus : Extended;
|
||||||
@ -259,9 +258,12 @@ begin
|
|||||||
begin
|
begin
|
||||||
ADest.Pen.FPColor := T2DSegmentWithPen(Cur2DSegment).Pen.Color;
|
ADest.Pen.FPColor := T2DSegmentWithPen(Cur2DSegment).Pen.Color;
|
||||||
|
|
||||||
CoordX := CoordToCanvasX(Cur2DSegment.X);
|
CoordX := CoordToCanvasX(PosX);
|
||||||
CoordY := CoordToCanvasY(Cur2DSegment.Y);
|
CoordY := CoordToCanvasY(PosY);
|
||||||
ADest.LineTo(CoordX, CoordY);
|
CoordX2 := CoordToCanvasX(Cur2DSegment.X);
|
||||||
|
CoordY2 := CoordToCanvasY(Cur2DSegment.Y);
|
||||||
|
ADest.Line(CoordX, CoordY, CoordX2, CoordY2);
|
||||||
|
|
||||||
PosX := Cur2DSegment.X;
|
PosX := Cur2DSegment.X;
|
||||||
PosY := Cur2DSegment.Y;
|
PosY := Cur2DSegment.Y;
|
||||||
|
|
||||||
@ -273,9 +275,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
st2DLine, st3DLine:
|
st2DLine, st3DLine:
|
||||||
begin
|
begin
|
||||||
CoordX := CoordToCanvasX(Cur2DSegment.X);
|
CoordX := CoordToCanvasX(PosX);
|
||||||
CoordY := CoordToCanvasY(Cur2DSegment.Y);
|
CoordY := CoordToCanvasY(PosY);
|
||||||
ADest.LineTo(CoordX, CoordY);
|
CoordX2 := CoordToCanvasX(Cur2DSegment.X);
|
||||||
|
CoordY2 := CoordToCanvasY(Cur2DSegment.Y);
|
||||||
|
ADest.Line(CoordX, CoordY, CoordX2, CoordY2);
|
||||||
PosX := Cur2DSegment.X;
|
PosX := Cur2DSegment.X;
|
||||||
PosY := Cur2DSegment.Y;
|
PosY := Cur2DSegment.Y;
|
||||||
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||||
@ -304,6 +308,7 @@ begin
|
|||||||
);
|
);
|
||||||
|
|
||||||
ADest.Brush.Style := CurPath.Brush.Style;
|
ADest.Brush.Style := CurPath.Brush.Style;
|
||||||
|
if Length(Points) >= 3 then
|
||||||
ADest.Polygon(Points);
|
ADest.Polygon(Points);
|
||||||
|
|
||||||
PosX := Cur2DSegment.X;
|
PosX := Cur2DSegment.X;
|
||||||
|
@ -12,6 +12,7 @@ AUTHORS: Felipe Monteiro de Carvalho
|
|||||||
unit fpvutils;
|
unit fpvutils;
|
||||||
|
|
||||||
{$define USE_LCL_CANVAS}
|
{$define USE_LCL_CANVAS}
|
||||||
|
{.$define FPVECTORIAL_BEZIERTOPOINTS_DEBUG}
|
||||||
|
|
||||||
{$ifdef fpc}
|
{$ifdef fpc}
|
||||||
{$mode delphi}
|
{$mode delphi}
|
||||||
@ -196,6 +197,10 @@ var
|
|||||||
CurveLength, k, CurX, CurY, LastPoint: Integer;
|
CurveLength, k, CurX, CurY, LastPoint: Integer;
|
||||||
t: Double;
|
t: Double;
|
||||||
begin
|
begin
|
||||||
|
{$ifdef FPVECTORIAL_BEZIERTOPOINTS_DEBUG}
|
||||||
|
Write(Format('[AddBezierToPoints] P1=%f,%f P2=%f,%f P3=%f,%f P4=%f,%f =>', [P1.X, P1.Y, P2.X, P2.Y, P3.X, P3.Y, P4.X, P4.Y]));
|
||||||
|
{$endif}
|
||||||
|
|
||||||
CurveLength :=
|
CurveLength :=
|
||||||
Round(sqrt(sqr(P2.X - P1.X) + sqr(P2.Y - P1.Y))) +
|
Round(sqrt(sqr(P2.X - P1.X) + sqr(P2.Y - P1.Y))) +
|
||||||
Round(sqrt(sqr(P3.X - P2.X) + sqr(P3.Y - P2.Y))) +
|
Round(sqrt(sqr(P3.X - P2.X) + sqr(P3.Y - P2.Y))) +
|
||||||
@ -210,7 +215,13 @@ begin
|
|||||||
CurY := Round(sqr(1 - t) * (1 - t) * P1.Y + 3 * t * sqr(1 - t) * P2.Y + 3 * t * t * (1 - t) * P3.Y + t * t * t * P4.Y);
|
CurY := Round(sqr(1 - t) * (1 - t) * P1.Y + 3 * t * sqr(1 - t) * P2.Y + 3 * t * t * (1 - t) * P3.Y + t * t * t * P4.Y);
|
||||||
Points[LastPoint+k].X := CurX;
|
Points[LastPoint+k].X := CurX;
|
||||||
Points[LastPoint+k].Y := CurY;
|
Points[LastPoint+k].Y := CurY;
|
||||||
|
{$ifdef FPVECTORIAL_BEZIERTOPOINTS_DEBUG}
|
||||||
|
Write(Format(' P=%d,%d', [CurX, CurY]));
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
{$ifdef FPVECTORIAL_BEZIERTOPOINTS_DEBUG}
|
||||||
|
WriteLn(Format(' CurveLength=%d', [CurveLength]));
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ConvertPathToPoints(APath: TPath; ADestX, ADestY: Integer; AMulX, AMulY: Double; var Points: TPointsArray);
|
procedure ConvertPathToPoints(APath: TPath; ADestX, ADestY: Integer; AMulX, AMulY: Double; var Points: TPointsArray);
|
||||||
|
Reference in New Issue
Block a user