You've already forked lazarus-ccr
fpvectorial: Fixes the drawing of solids drawn with beziers
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1891 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -18,10 +18,11 @@ unit epsvectorialreader;
|
|||||||
{.$define FPVECTORIALDEBUG_COLORS}
|
{.$define FPVECTORIALDEBUG_COLORS}
|
||||||
{.$define FPVECTORIALDEBUG_ROLL}
|
{.$define FPVECTORIALDEBUG_ROLL}
|
||||||
{.$define FPVECTORIALDEBUG_CODEFLOW}
|
{.$define FPVECTORIALDEBUG_CODEFLOW}
|
||||||
{$define FPVECTORIALDEBUG_INDEX}
|
{.$define FPVECTORIALDEBUG_INDEX}
|
||||||
{.$define FPVECTORIALDEBUG_DICTIONARY}
|
{.$define FPVECTORIALDEBUG_DICTIONARY}
|
||||||
{$define FPVECTORIALDEBUG_CONTROL}
|
{.$define FPVECTORIALDEBUG_CONTROL}
|
||||||
{.$define FPVECTORIALDEBUG_ARITHMETIC}
|
{.$define FPVECTORIALDEBUG_ARITHMETIC}
|
||||||
|
{$define FPVECTORIALDEBUG_CLIP_REGION}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
@ -1720,11 +1721,9 @@ begin
|
|||||||
AData.AddMoveToPath(P1.X, P1.Y);
|
AData.AddMoveToPath(P1.X, P1.Y);
|
||||||
AData.AddBezierToPath(P2.X, P2.Y, P3.X, P3.Y, P4.X, P4.Y);
|
AData.AddBezierToPath(P2.X, P2.Y, P3.X, P3.Y, P4.X, P4.Y);
|
||||||
end;
|
end;
|
||||||
// {$ifdef FPVECTORIALDEBUG}
|
|
||||||
// WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rcurveto %f, %f', [BaseX + PosX, BaseY + PosY]));
|
|
||||||
// {$endif}
|
|
||||||
{$ifdef FPVECTORIALDEBUG_PATHS}
|
{$ifdef FPVECTORIALDEBUG_PATHS}
|
||||||
WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] arc %f, %f', [PosX, PosY]));
|
WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] arc X,Y=%f, %f Resulting X,Y=%f, %f R=%f Angles Start,End=%f,%f',
|
||||||
|
[Param5.FloatValue, Param4.FloatValue, PosX, PosY, Param3.FloatValue, Param2.FloatValue, Param1.FloatValue]));
|
||||||
{$endif}
|
{$endif}
|
||||||
Exit(True);
|
Exit(True);
|
||||||
end;
|
end;
|
||||||
@ -1742,7 +1741,10 @@ begin
|
|||||||
//
|
//
|
||||||
if AToken.StrValue = 'eoclip' then
|
if AToken.StrValue = 'eoclip' then
|
||||||
begin
|
begin
|
||||||
|
{$ifndef FPVECTORIALDEBUG_CLIP_REGION}
|
||||||
|
WriteLn('[TvEPSVectorialReader.ExecutePathConstructionOperator] eoclip');
|
||||||
AData.SetPenStyle(psClear);
|
AData.SetPenStyle(psClear);
|
||||||
|
{$endif}
|
||||||
AData.EndPath();
|
AData.EndPath();
|
||||||
CurrentGraphicState.ClipPath := AData.GetPath(AData.GetPathCount()-1);
|
CurrentGraphicState.ClipPath := AData.GetPath(AData.GetPathCount()-1);
|
||||||
CurrentGraphicState.ClipMode := vcmEvenOddRule;
|
CurrentGraphicState.ClipMode := vcmEvenOddRule;
|
||||||
|
@ -34,7 +34,7 @@ procedure DrawFPVTextToCanvas(ASource: TvVectorialDocument; CurText: TvText;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
{$ifndef Windows}
|
{$ifndef Windows}
|
||||||
{.$define FPVECTORIAL_TOCANVAS_DEBUG}
|
{$define FPVECTORIAL_TOCANVAS_DEBUG}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
|
function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
|
||||||
@ -101,7 +101,6 @@ end;
|
|||||||
|
|
||||||
DrawFPVectorialToCanvas(ASource, ADest, 0, ASource.Height, 1.0, -1.0);
|
DrawFPVectorialToCanvas(ASource, ADest, 0, ASource.Height, 1.0, -1.0);
|
||||||
}
|
}
|
||||||
{$define FPVECTORIAL_TOCANVAS_DEBUG}
|
|
||||||
procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument;
|
procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument;
|
||||||
ADest: TFPCustomCanvas;
|
ADest: TFPCustomCanvas;
|
||||||
ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
|
ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
|
||||||
@ -190,12 +189,15 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
//
|
//
|
||||||
// For solid paths, draw a polygon instead
|
// For solid paths, draw a polygon for the main internal area
|
||||||
//
|
//
|
||||||
|
if CurPath.Brush.Style <> bsClear then
|
||||||
|
begin
|
||||||
CurPath.PrepareForSequentialReading;
|
CurPath.PrepareForSequentialReading;
|
||||||
|
|
||||||
if CurPath.Brush.Style = bsSolid then
|
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||||
begin
|
Write(' Solid Path Internal Area');
|
||||||
|
{$endif}
|
||||||
ADest.Brush.Style := CurPath.Brush.Style;
|
ADest.Brush.Style := CurPath.Brush.Style;
|
||||||
|
|
||||||
SetLength(Points, CurPath.Len);
|
SetLength(Points, CurPath.Len);
|
||||||
@ -210,16 +212,24 @@ begin
|
|||||||
|
|
||||||
Points[j].X := CoordX;
|
Points[j].X := CoordX;
|
||||||
Points[j].Y := CoordY;
|
Points[j].Y := CoordY;
|
||||||
|
|
||||||
|
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||||
|
Write(Format(' P%d,%d', [CoordY, CoordY]));
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ADest.Polygon(Points);
|
ADest.Polygon(Points);
|
||||||
|
|
||||||
Exit;
|
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||||
|
Write(' Now the details ');
|
||||||
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//
|
//
|
||||||
// For other paths, draw more carefully
|
// For other paths, draw more carefully
|
||||||
//
|
//
|
||||||
|
CurPath.PrepareForSequentialReading;
|
||||||
|
|
||||||
for j := 0 to CurPath.Len - 1 do
|
for j := 0 to CurPath.Len - 1 do
|
||||||
begin
|
begin
|
||||||
//WriteLn('j = ', j);
|
//WriteLn('j = ', j);
|
||||||
@ -274,6 +284,12 @@ begin
|
|||||||
Round(sqrt(sqr(Cur2DBSegment.X3 - Cur2DBSegment.X2) + sqr(Cur2DBSegment.Y3 - Cur2DBSegment.Y2))) +
|
Round(sqrt(sqr(Cur2DBSegment.X3 - Cur2DBSegment.X2) + sqr(Cur2DBSegment.Y3 - Cur2DBSegment.Y2))) +
|
||||||
Round(sqrt(sqr(Cur2DBSegment.X - Cur2DBSegment.X3) + sqr(Cur2DBSegment.Y - Cur2DBSegment.Y3)));
|
Round(sqrt(sqr(Cur2DBSegment.X - Cur2DBSegment.X3) + sqr(Cur2DBSegment.Y - Cur2DBSegment.Y3)));
|
||||||
|
|
||||||
|
if (CurPath.Brush.Style <> bsClear) then
|
||||||
|
begin
|
||||||
|
ADest.Brush.Style := CurPath.Brush.Style;
|
||||||
|
SetLength(Points, CurveLength);
|
||||||
|
end;
|
||||||
|
|
||||||
for k := 1 to CurveLength do
|
for k := 1 to CurveLength do
|
||||||
begin
|
begin
|
||||||
t := k / CurveLength;
|
t := k / CurveLength;
|
||||||
@ -282,10 +298,18 @@ begin
|
|||||||
CoordX := CoordToCanvasX(CurX);
|
CoordX := CoordToCanvasX(CurX);
|
||||||
CoordY := CoordToCanvasY(CurY);
|
CoordY := CoordToCanvasY(CurY);
|
||||||
ADest.LineTo(CoordX, CoordY);
|
ADest.LineTo(CoordX, CoordY);
|
||||||
|
|
||||||
|
if (CurPath.Brush.Style = bsSolid) then
|
||||||
|
begin
|
||||||
|
Points[k-1].X := CoordX;
|
||||||
|
Points[k-1].Y := CoordY;
|
||||||
|
end;
|
||||||
// {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
// {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||||
// Write(Format(' CL%d,%d', [CoordX, CoordY]));
|
// Write(Format(' CL%d,%d', [CoordX, CoordY]));
|
||||||
// {$endif}
|
// {$endif}
|
||||||
end;
|
end;
|
||||||
|
if (CurPath.Brush.Style = bsSolid) then ADest.Polygon(Points);
|
||||||
|
|
||||||
PosX := Cur2DSegment.X;
|
PosX := Cur2DSegment.X;
|
||||||
PosY := Cur2DSegment.Y;
|
PosY := Cur2DSegment.Y;
|
||||||
|
|
||||||
@ -411,9 +435,9 @@ begin
|
|||||||
BoundsBottom := IntTmp;
|
BoundsBottom := IntTmp;
|
||||||
end;
|
end;
|
||||||
// Arc(ALeft, ATop, ARight, ABottom, Angle16Deg, Angle16DegLength: Integer);
|
// Arc(ALeft, ATop, ARight, ABottom, Angle16Deg, Angle16DegLength: Integer);
|
||||||
{$ifdef FPVECTORIALDEBUG}
|
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||||
WriteLn(Format('Drawing Arc Center=%f,%f Radius=%f StartAngle=%f AngleLength=%f',
|
// WriteLn(Format('Drawing Arc Center=%f,%f Radius=%f StartAngle=%f AngleLength=%f',
|
||||||
[CurArc.CenterX, CurArc.CenterY, CurArc.Radius, IntStartAngle/16, IntAngleLength/16]));
|
// [CurArc.CenterX, CurArc.CenterY, CurArc.Radius, IntStartAngle/16, IntAngleLength/16]));
|
||||||
{$endif}
|
{$endif}
|
||||||
ADest.Pen.FPColor := CurArc.Pen.Color;
|
ADest.Pen.FPColor := CurArc.Pen.Color;
|
||||||
ALCLDest.Arc(
|
ALCLDest.Arc(
|
||||||
|
Reference in New Issue
Block a user