mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-06 18:06:01 +02:00
fpvectorial: Advances a lot the new background color support
git-svn-id: trunk@39716 -
This commit is contained in:
parent
7fb826fb84
commit
4dd594eaaf
@ -212,7 +212,6 @@ type
|
||||
public
|
||||
X, Y, Z: Double;
|
||||
Name: string;
|
||||
Page: TvVectorialPage;
|
||||
constructor Create; virtual;
|
||||
procedure Clear; virtual;
|
||||
// in CalculateBoundingBox always remember to treat correctly the case of ADest=nil!!!
|
||||
@ -224,8 +223,9 @@ type
|
||||
procedure Move(ADeltaX, ADeltaY: Double); virtual;
|
||||
procedure MoveSubpart(ADeltaX, ADeltaY: Double; ASubpart: Cardinal); virtual;
|
||||
function GetSubpartCount: Integer; virtual;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); virtual;
|
||||
function AdjustColorToBackground(AColor, ABackgroundColor: TFPColor): TFPColor;
|
||||
function GetNormalizedPos(APage: TvVectorialPage; ANewMin, ANewMax: Double): T3DPoint;
|
||||
function GenerateDebugTree(ADestRoutine: TvDebugAddItemProc; APageItem: Pointer): Pointer; virtual;
|
||||
end;
|
||||
@ -240,8 +240,8 @@ type
|
||||
elements might be able to override this setting. }
|
||||
Pen: TvPen;
|
||||
constructor Create; override;
|
||||
procedure ApplyPenToCanvas(ADest: TFPCustomCanvas);
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure ApplyPenToCanvas(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor);
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -254,7 +254,7 @@ type
|
||||
Brush: TvBrush;
|
||||
constructor Create; override;
|
||||
procedure ApplyBrushToCanvas(ADest: TFPCustomCanvas);
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -287,7 +287,7 @@ type
|
||||
procedure MoveSubpart(ADeltaX, ADeltaY: Double; ASubpart: Cardinal); override;
|
||||
function MoveToSubpart(ASubpart: Cardinal): TPathSegment;
|
||||
function GetSubpartCount: Integer; override;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -308,7 +308,7 @@ type
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
function TryToSelect(APos: TPoint; var ASubpart: Cardinal): TvFindEntityResult; override;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -320,7 +320,7 @@ type
|
||||
TvCircle = class(TvEntityWithPenAndBrush)
|
||||
public
|
||||
Radius: Double;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -334,7 +334,7 @@ type
|
||||
Radius: Double;
|
||||
{@@ The Angle is measured in degrees in relation to the positive X axis }
|
||||
StartAngle, EndAngle: Double;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -351,7 +351,7 @@ type
|
||||
{@@ The Angle is measured in degrees in relation to the positive X axis }
|
||||
Angle: Double;
|
||||
procedure CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); override;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -362,7 +362,7 @@ type
|
||||
// Mandatory fields
|
||||
CX, CY, CZ: Double;
|
||||
procedure CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); override;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -380,7 +380,7 @@ type
|
||||
public
|
||||
// Mandatory fields
|
||||
BaseLeft, BaseRight, DimensionLeft, DimensionRight: T3DPoint;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -395,7 +395,7 @@ type
|
||||
// Mandatory fields
|
||||
IsDiameter: Boolean; // If false, it is a radius, if true, it is a diameter
|
||||
Center, DimensionLeft, DimensionRight: T3DPoint; // Diameter uses both, Radius uses only DImensionLeft
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -447,7 +447,7 @@ type
|
||||
ArrowLength: Double;
|
||||
ArrowBaseLength: Double;
|
||||
procedure CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); override;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -496,7 +496,7 @@ type
|
||||
function CalculateHeight(ADest: TFPCustomCanvas): Double; // in milimeters
|
||||
function CalculateWidth(ADest: TFPCustomCanvas): Double; // in milimeters
|
||||
function AsText: string;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); virtual;
|
||||
procedure GenerateDebugTree(ADestRoutine: TvDebugAddItemProc; APageItem: Pointer); virtual;
|
||||
end;
|
||||
@ -526,7 +526,7 @@ type
|
||||
function CalculateWidth(ADest: TFPCustomCanvas): Double; // in milimeters
|
||||
procedure PositionElements(ADest: TFPCustomCanvas; ABaseX, ABaseY: Double);
|
||||
procedure CalculateBoundingBox(ADest: TFPCustomCanvas; var ALeft, ATop, ARight, ABottom: Double); override;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
function GenerateDebugTree(ADestRoutine: TvDebugAddItemProc; APageItem: Pointer): Pointer; override;
|
||||
end;
|
||||
@ -547,7 +547,7 @@ type
|
||||
function GetNextEntity: TvEntity;
|
||||
procedure AddEntity(AEntity: TvEntity);
|
||||
procedure Clear; override;
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -560,7 +560,7 @@ type
|
||||
|
||||
TvBlock = class(TvEntityWithSubEntities)
|
||||
public
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -573,7 +573,7 @@ type
|
||||
TvInsert = class(TvEntity)
|
||||
public
|
||||
Block: TvBlock; // The block to be inserted
|
||||
procedure Render(ADest: TFPCustomCanvas; ADestX: Integer = 0;
|
||||
procedure Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer = 0;
|
||||
ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0); override;
|
||||
end;
|
||||
|
||||
@ -712,8 +712,8 @@ type
|
||||
function AddPoint(AX, AY, AZ: Double): TvPoint;
|
||||
{ Drawing methods }
|
||||
procedure DrawBackground(ADest: TFPCustomCanvas);
|
||||
function GetInvertedBackgroundColor: TFPColor;
|
||||
function GetContranstingColor: TFPColor;
|
||||
procedure Render(ADest: TFPCustomCanvas;
|
||||
ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
|
||||
{ Debug methods }
|
||||
procedure GenerateDebugTree(ADestRoutine: TvDebugAddItemProc; APageItem: Pointer);
|
||||
//
|
||||
@ -969,12 +969,26 @@ begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
procedure TvEntity.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvEntity.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
function TvEntity.AdjustColorToBackground(AColor, ABackgroundColor: TFPColor
|
||||
): TFPColor;
|
||||
begin
|
||||
Result := AColor;
|
||||
if (Abs(AColor.Red - ABackgroundColor.Red) < $100) and
|
||||
(Abs(AColor.Green - ABackgroundColor.Green) < $100) and
|
||||
(Abs(AColor.Blue - ABackgroundColor.Blue) < $100) then
|
||||
begin
|
||||
if (ABackgroundColor.Red <= $1000) and (ABackgroundColor.Green <= $1000) and (ABackgroundColor.Blue <= $1000) then
|
||||
Result := colWhite
|
||||
else Result := colBlack;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TvEntity.GetNormalizedPos(APage: TvVectorialPage; ANewMin,
|
||||
ANewMax: Double): T3DPoint;
|
||||
begin
|
||||
@ -1002,18 +1016,18 @@ begin
|
||||
Pen.Width := 1;
|
||||
end;
|
||||
|
||||
procedure TvEntityWithPen.ApplyPenToCanvas(ADest: TFPCustomCanvas);
|
||||
procedure TvEntityWithPen.ApplyPenToCanvas(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor);
|
||||
begin
|
||||
ADest.Pen.FPColor := Pen.Color;
|
||||
ADest.Pen.FPColor := AdjustColorToBackground(Pen.Color, ABackgroundColor);
|
||||
ADest.Pen.Width := 1;//Pen.Width;
|
||||
ADest.Pen.Style := Pen.Style;
|
||||
end;
|
||||
|
||||
procedure TvEntityWithPen.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvEntityWithPen.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
begin
|
||||
inherited Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
ApplyPenToCanvas(ADest);
|
||||
inherited Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
ApplyPenToCanvas(ADest, ABackgroundColor);
|
||||
end;
|
||||
|
||||
{ TvEntityWithPenAndBrush }
|
||||
@ -1032,9 +1046,9 @@ begin
|
||||
end;
|
||||
|
||||
procedure TvEntityWithPenAndBrush.Render(ADest: TFPCustomCanvas;
|
||||
ADestX: Integer; ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
ABackgroundColor: TFPColor; ADestX: Integer; ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
begin
|
||||
inherited Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
inherited Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
ApplyBrushToCanvas(ADest);
|
||||
end;
|
||||
|
||||
@ -1259,7 +1273,7 @@ begin
|
||||
Result := Len;
|
||||
end;
|
||||
|
||||
procedure TPath.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TPath.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
|
||||
function CoordToCanvasX(ACoord: Double): Integer;
|
||||
@ -1304,7 +1318,7 @@ begin
|
||||
if ADest.Pen.Width < 1 then ADest.Pen.Width := 1;
|
||||
if (Pen.Width <= 2) and (ADest.Pen.Width > 2) then ADest.Pen.Width := 2;
|
||||
if (Pen.Width <= 5) and (ADest.Pen.Width > 5) then ADest.Pen.Width := 5;
|
||||
ADest.Pen.FPColor := Pen.Color;
|
||||
ADest.Pen.FPColor := AdjustColorToBackground(Pen.Color, ABackgroundColor);
|
||||
ADest.Brush.FPColor := Brush.Color;
|
||||
|
||||
// Prepare the Clipping Region, if any
|
||||
@ -1386,7 +1400,7 @@ begin
|
||||
// This element can override temporarely the Pen
|
||||
st2DLineWithPen:
|
||||
begin
|
||||
ADest.Pen.FPColor := T2DSegmentWithPen(Cur2DSegment).Pen.Color;
|
||||
ADest.Pen.FPColor := AdjustColorToBackground(T2DSegmentWithPen(Cur2DSegment).Pen.Color, ABackgroundColor);
|
||||
|
||||
CoordX := CoordToCanvasX(PosX);
|
||||
CoordY := CoordToCanvasY(PosY);
|
||||
@ -1492,7 +1506,7 @@ begin
|
||||
else Result := vfrNotFound;
|
||||
end;
|
||||
|
||||
procedure TvText.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvText.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
|
||||
function CoordToCanvasX(ACoord: Double): Integer;
|
||||
@ -1513,7 +1527,7 @@ var
|
||||
//
|
||||
LowerDim: T3DPoint;
|
||||
begin
|
||||
inherited Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
inherited Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
|
||||
ADest.Font.Size := Round(AmulX * Font.Size);
|
||||
{ ADest.Pen.Style := psSolid;
|
||||
@ -1541,7 +1555,7 @@ end;
|
||||
|
||||
{ TvCircle }
|
||||
|
||||
procedure TvCircle.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvCircle.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
|
||||
function CoordToCanvasX(ACoord: Double): Integer;
|
||||
@ -1555,7 +1569,7 @@ procedure TvCircle.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
end;
|
||||
|
||||
begin
|
||||
inherited Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
inherited Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
ADest.Ellipse(
|
||||
CoordToCanvasX(X - Radius),
|
||||
CoordToCanvasY(Y - Radius),
|
||||
@ -1566,7 +1580,7 @@ end;
|
||||
|
||||
{ TvCircularArc }
|
||||
|
||||
procedure TvCircularArc.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvCircularArc.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
|
||||
function CoordToCanvasX(ACoord: Double): Integer;
|
||||
@ -1587,6 +1601,7 @@ var
|
||||
ALCLDest: TCanvas absolute ADest;
|
||||
{$endif}
|
||||
begin
|
||||
inherited Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
{$ifdef USE_LCL_CANVAS}
|
||||
// ToDo: Consider a X axis inversion
|
||||
// If the Y axis is inverted, then we need to mirror our angles as well
|
||||
@ -1631,12 +1646,10 @@ begin
|
||||
// WriteLn(Format('Drawing Arc Center=%f,%f Radius=%f StartAngle=%f AngleLength=%f',
|
||||
// [CurArc.CenterX, CurArc.CenterY, CurArc.Radius, IntStartAngle/16, IntAngleLength/16]));
|
||||
{$endif}
|
||||
ADest.Pen.FPColor := Pen.Color;
|
||||
ALCLDest.Arc(
|
||||
BoundsLeft, BoundsTop, BoundsRight, BoundsBottom,
|
||||
IntStartAngle, IntAngleLength
|
||||
);
|
||||
ADest.Pen.FPColor := Page.GetContranstingColor();
|
||||
// Debug info
|
||||
// {$define FPVECTORIALDEBUG}
|
||||
// {$ifdef FPVECTORIALDEBUG}
|
||||
@ -1693,7 +1706,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TvEllipse.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvEllipse.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
|
||||
function CoordToCanvasX(ACoord: Double): Integer;
|
||||
@ -1715,7 +1728,7 @@ var
|
||||
ALCLDest: TCanvas absolute ADest;
|
||||
{$endif}
|
||||
begin
|
||||
inherited Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
inherited Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
|
||||
CalculateBoundingBox(ADest, fx1, fy1, fx2, fy2);
|
||||
x1 := CoordToCanvasX(fx1);
|
||||
@ -1762,7 +1775,7 @@ begin
|
||||
ABottom := Y + CY;
|
||||
end;
|
||||
|
||||
procedure TvRectangle.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvRectangle.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
|
||||
function CoordToCanvasX(ACoord: Double): Integer;
|
||||
@ -1779,7 +1792,7 @@ var
|
||||
x1, x2, y1, y2: Integer;
|
||||
fx1, fy1, fx2, fy2: Double;
|
||||
begin
|
||||
inherited Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
inherited Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
|
||||
CalculateBoundingBox(ADest, fx1, fy1, fx2, fy2);
|
||||
x1 := CoordToCanvasX(fx1);
|
||||
@ -1792,7 +1805,7 @@ end;
|
||||
|
||||
{ TvAlignedDimension }
|
||||
|
||||
procedure TvAlignedDimension.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvAlignedDimension.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
|
||||
function CoordToCanvasX(ACoord: Double): Integer;
|
||||
@ -1812,7 +1825,7 @@ var
|
||||
ALCLDest: TCanvas absolute ADest;
|
||||
{$endif}
|
||||
begin
|
||||
ADest.Pen.FPColor := Page.GetContranstingColor();
|
||||
ADest.Pen.FPColor := AdjustColorToBackground(colBlack, ABackgroundColor);
|
||||
//
|
||||
// Draws this shape:
|
||||
// horizontal vertical
|
||||
@ -1829,7 +1842,7 @@ begin
|
||||
SetLength(Points, 3);
|
||||
if DimensionRight.Y = DimensionLeft.Y then
|
||||
begin
|
||||
ADest.Brush.FPColor := Page.GetContranstingColor();
|
||||
ADest.Brush.FPColor := AdjustColorToBackground(colBlack, ABackgroundColor);
|
||||
ADest.Brush.Style := bsSolid;
|
||||
// Left arrow
|
||||
Points[0] := Point(CoordToCanvasX(DimensionLeft.X), CoordToCanvasY(DimensionLeft.Y));
|
||||
@ -1848,12 +1861,12 @@ begin
|
||||
LowerDim.X := DimensionRight.X-DimensionLeft.X;
|
||||
ADest.Font.Size := 10;
|
||||
ADest.Font.Orientation := 0;
|
||||
ADest.Font.FPColor := Page.GetContranstingColor();
|
||||
ADest.Font.FPColor := AdjustColorToBackground(colBlack, ABackgroundColor);
|
||||
ADest.TextOut(Points[0].X, Points[0].Y-Round(ADest.Font.Size*1.5), Format('%.1f', [LowerDim.X]));
|
||||
end
|
||||
else
|
||||
begin
|
||||
ADest.Brush.FPColor := Page.GetContranstingColor();
|
||||
ADest.Brush.FPColor := AdjustColorToBackground(colBlack, ABackgroundColor);
|
||||
ADest.Brush.Style := bsSolid;
|
||||
// There is no upper/lower preference for DimensionLeft/Right, so we need to check
|
||||
if DimensionLeft.Y > DimensionRight.Y then
|
||||
@ -1884,7 +1897,7 @@ begin
|
||||
if LowerDim.Y < 0 then LowerDim.Y := -1 * LowerDim.Y;
|
||||
ADest.Font.Size := 10;
|
||||
ADest.Font.Orientation := 900;
|
||||
ADest.Font.FPColor := Page.GetContranstingColor();
|
||||
ADest.Font.FPColor := AdjustColorToBackground(colBlack, ABackgroundColor);
|
||||
ADest.TextOut(Points[0].X-Round(ADest.Font.Size*1.5), Points[0].Y, Format('%.1f', [LowerDim.Y]));
|
||||
ADest.Font.Orientation := 0;
|
||||
end;
|
||||
@ -1904,7 +1917,7 @@ end;
|
||||
|
||||
{ TvRadialDimension }
|
||||
|
||||
procedure TvRadialDimension.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvRadialDimension.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
|
||||
function CoordToCanvasX(ACoord: Double): Integer;
|
||||
@ -1924,7 +1937,7 @@ var
|
||||
ALCLDest: TCanvas absolute ADest;
|
||||
{$endif}
|
||||
begin
|
||||
ADest.Pen.FPColor := Page.GetContranstingColor();
|
||||
ADest.Pen.FPColor := AdjustColorToBackground(colBlack, ABackgroundColor);
|
||||
|
||||
// The size of the radius of the circle
|
||||
lRadius := sqrt(sqr(Center.X - DimensionLeft.X) + sqr(Center.Y - DimensionLeft.Y));
|
||||
@ -1933,7 +1946,7 @@ begin
|
||||
|
||||
// Get an arrow in the right part of the circle
|
||||
SetLength(Points, 3);
|
||||
ADest.Brush.FPColor := Page.GetContranstingColor();
|
||||
ADest.Brush.FPColor := AdjustColorToBackground(colBlack, ABackgroundColor);
|
||||
ADest.Brush.Style := bsSolid;
|
||||
Points[0] := Point(CoordToCanvasX(Center.X + lRadius), CoordToCanvasY(Center.Y));
|
||||
Points[1] := Point(CoordToCanvasX(Center.X + lRadius*0.8), CoordToCanvasY(Center.Y - lRadius*0.1));
|
||||
@ -1957,7 +1970,7 @@ begin
|
||||
Points[0].X := CoordToCanvasX(Center.X);
|
||||
Points[0].Y := CoordToCanvasY(Center.Y);
|
||||
ADest.Font.Size := 10;
|
||||
ADest.Font.FPColor := Page.GetContranstingColor();
|
||||
ADest.Font.FPColor := AdjustColorToBackground(colBlack, ABackgroundColor);
|
||||
ADest.TextOut(Points[0].X, Points[0].Y, Format('%.1f', [lRadius]));
|
||||
end
|
||||
else
|
||||
@ -1986,7 +1999,7 @@ begin
|
||||
Points[0].X := CoordToCanvasX(Center.X);
|
||||
Points[0].Y := CoordToCanvasY(Center.Y);
|
||||
ADest.Font.Size := 10;
|
||||
ADest.Font.FPColor := Page.GetContranstingColor();
|
||||
ADest.Font.FPColor := AdjustColorToBackground(colBlack, ABackgroundColor);
|
||||
ADest.TextOut(Points[0].X, Points[0].Y, Format('%.1f', [lRadius * 2]));
|
||||
end;
|
||||
|
||||
@ -2050,7 +2063,7 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TvArrow.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvArrow.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
|
||||
function CoordToCanvasX(ACoord: Double): Integer;
|
||||
@ -2069,7 +2082,7 @@ var
|
||||
lPoints: array[0..2] of TPoint;
|
||||
AlfaAngle: Double;
|
||||
begin
|
||||
ApplyPenToCanvas(ADest);
|
||||
ApplyPenToCanvas(ADest, ABackgroundColor);
|
||||
ApplyBrushToCanvas(ADest);
|
||||
|
||||
lArrow.X := CoordToCanvasX(X);
|
||||
@ -2219,7 +2232,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TvFormulaElement.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvFormulaElement.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
|
||||
function CoordToCanvasX(ACoord: Double): Integer;
|
||||
@ -2258,8 +2271,8 @@ begin
|
||||
fekGreaterOrEqualThan: ADest.TextOut(LeftC, TopC, '≥');
|
||||
fekFraction:
|
||||
begin
|
||||
Formula.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
AdjacentFormula.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
Formula.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
AdjacentFormula.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
|
||||
// Division line
|
||||
lPt[0].X := CoordToCanvasX(Formula.Left);
|
||||
@ -2270,7 +2283,7 @@ begin
|
||||
end;
|
||||
fekRoot:
|
||||
begin
|
||||
Formula.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
Formula.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
|
||||
// Root drawing
|
||||
lPt[0].X := CoordToCanvasX(Left);
|
||||
@ -2289,22 +2302,22 @@ begin
|
||||
end;
|
||||
fekPower:
|
||||
begin
|
||||
Formula.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
Formula.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
// The superscripted power
|
||||
lOldFontSize := ADest.Font.Size;
|
||||
if lOldFontSize = 0 then ADest.Font.Size := 5
|
||||
else ADest.Font.Size := lOldFontSize div 2;
|
||||
AdjacentFormula.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
AdjacentFormula.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
ADest.Font.Size := lOldFontSize;
|
||||
end;
|
||||
fekSubscript:
|
||||
begin
|
||||
Formula.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
Formula.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
// The subscripted item
|
||||
lOldFontSize := ADest.Font.Size;
|
||||
if lOldFontSize = 0 then ADest.Font.Size := 5
|
||||
else ADest.Font.Size := lOldFontSize div 2;
|
||||
AdjacentFormula.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
AdjacentFormula.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
ADest.Font.Size := lOldFontSize;
|
||||
end;
|
||||
fekSummation:
|
||||
@ -2317,10 +2330,10 @@ begin
|
||||
ADest.Font.Size := lOldFontSize;
|
||||
|
||||
// Draw the bottom/main formula
|
||||
Formula.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
Formula.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
|
||||
// Draw the top formula
|
||||
AdjacentFormula.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
AdjacentFormula.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -2560,7 +2573,7 @@ begin
|
||||
ABottom := Y + ABottom;
|
||||
end;
|
||||
|
||||
procedure TvFormula.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvFormula.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
var
|
||||
lElement: TvFormulaElement;
|
||||
@ -2573,7 +2586,7 @@ begin
|
||||
if lElement = nil then Exit;
|
||||
while lElement <> nil do
|
||||
begin
|
||||
lElement.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
lElement.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
|
||||
lElement := GetNextElement();
|
||||
end;
|
||||
@ -2643,12 +2656,12 @@ begin
|
||||
FElements.Clear;
|
||||
end;
|
||||
|
||||
procedure TvEntityWithSubEntities.Render(ADest: TFPCustomCanvas;
|
||||
procedure TvEntityWithSubEntities.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor;
|
||||
ADestX: Integer; ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
var
|
||||
lEntity: TvEntity;
|
||||
begin
|
||||
inherited Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
inherited Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
lEntity := GetFirstEntity();
|
||||
while lEntity <> nil do
|
||||
begin
|
||||
@ -2658,7 +2671,7 @@ begin
|
||||
{$ENDIF}
|
||||
|
||||
// Render
|
||||
lEntity.Render(ADest, ADestX, ADestY, AMulX, AMuly);
|
||||
lEntity.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMuly);
|
||||
|
||||
lEntity := GetNextEntity();
|
||||
end;
|
||||
@ -2666,12 +2679,12 @@ end;
|
||||
|
||||
{ TvInsert }
|
||||
|
||||
procedure TvInsert.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvInsert.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
var
|
||||
lEntity: TvEntity;
|
||||
begin
|
||||
inherited Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
inherited Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
if Block = nil then Exit;
|
||||
lEntity := Block.GetFirstEntity();
|
||||
while lEntity <> nil do
|
||||
@ -2684,7 +2697,7 @@ begin
|
||||
// Alter the position of the elements to consider the positioning of the BLOCK and of the INSERT
|
||||
lEntity.Move(Block.X + X, Block.Y + Y);
|
||||
// Render
|
||||
lEntity.Render(ADest, ADestX, ADestY, AMulX, AMuly);
|
||||
lEntity.Render(ADest, ABackgroundColor, ADestX, ADestY, AMulX, AMuly);
|
||||
// Change them back
|
||||
lEntity.Move(- Block.X - X, - Block.Y - Y);
|
||||
|
||||
@ -2694,7 +2707,7 @@ end;
|
||||
|
||||
{ TvBlock }
|
||||
|
||||
procedure TvBlock.Render(ADest: TFPCustomCanvas; ADestX: Integer;
|
||||
procedure TvBlock.Render(ADest: TFPCustomCanvas; ABackgroundColor: TFPColor; ADestX: Integer;
|
||||
ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
begin
|
||||
// TvBlock.Render must be empty! Because blocks are invisible by themselves
|
||||
@ -2860,8 +2873,6 @@ end;
|
||||
}
|
||||
function TvVectorialPage.AddEntity(AEntity: TvEntity): Integer;
|
||||
begin
|
||||
AEntity.Page := Self;
|
||||
|
||||
if FCurrentLayer = nil then
|
||||
begin
|
||||
Result := FEntities.Count;
|
||||
@ -3247,19 +3258,30 @@ begin
|
||||
ADest.Pen.Style := psSolid;
|
||||
end;
|
||||
|
||||
function TvVectorialPage.GetInvertedBackgroundColor: TFPColor;
|
||||
procedure TvVectorialPage.Render(ADest: TFPCustomCanvas;
|
||||
ADestX: Integer; ADestY: Integer; AMulX: Double; AMulY: Double);
|
||||
var
|
||||
i: Integer;
|
||||
CurEntity: TvEntity;
|
||||
begin
|
||||
Result.Red := $FFFF-BackgroundColor.Red;
|
||||
Result.Green := $FFFF-BackgroundColor.Green;
|
||||
Result.Blue := $FFFF-BackgroundColor.Blue;
|
||||
Result.Alpha := BackgroundColor.Alpha;
|
||||
end;
|
||||
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||
WriteLn(':>DrawFPVectorialToCanvas');
|
||||
{$endif}
|
||||
|
||||
function TvVectorialPage.GetContranstingColor: TFPColor;
|
||||
begin
|
||||
if (BackgroundColor.Red <= $1000) and (BackgroundColor.Green <= $1000) and (BackgroundColor.Blue <= $1000) then
|
||||
Result := colWhite
|
||||
else Result := colBlack;
|
||||
for i := 0 to GetEntitiesCount - 1 do
|
||||
begin
|
||||
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||
Write(Format('[Path] ID=%d', [i]));
|
||||
{$endif}
|
||||
|
||||
CurEntity := GetEntity(i);
|
||||
|
||||
CurEntity.Render(ADest, BackgroundColor, ADestX, ADestY, AMulX, AMulY);
|
||||
end;
|
||||
|
||||
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||
WriteLn(':<DrawFPVectorialToCanvas');
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TvVectorialPage.GenerateDebugTree(ADestRoutine: TvDebugAddItemProc;
|
||||
|
@ -76,26 +76,21 @@ procedure DrawFPVPathToCanvas(ASource: TvVectorialPage; CurPath: TPath;
|
||||
ADest: TFPCustomCanvas;
|
||||
ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
|
||||
begin
|
||||
CurPath.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
CurPath.Render(ADest, colWhite, ADestX, ADestY, AMulX, AMulY);
|
||||
end;
|
||||
|
||||
procedure DrawFPVEntityToCanvas(ASource: TvVectorialPage; CurEntity: TvEntity;
|
||||
ADest: TFPCustomCanvas;
|
||||
ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
|
||||
begin
|
||||
if CurEntity is TvEntityWithPenAndBrush then
|
||||
TvEntityWithPenAndBrush(CurEntity).ApplyBrushToCanvas(ADest);
|
||||
if CurEntity is TvEntityWithPen then
|
||||
TvEntityWithPen(CurEntity).ApplyPenToCanvas(ADest);
|
||||
|
||||
CurEntity.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
CurEntity.Render(ADest, colWhite, ADestX, ADestY, AMulX, AMulY);
|
||||
end;
|
||||
|
||||
procedure DrawFPVTextToCanvas(ASource: TvVectorialPage; CurText: TvText;
|
||||
ADest: TFPCustomCanvas;
|
||||
ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
|
||||
begin
|
||||
CurText.Render(ADest, ADestX, ADestY, AMulX, AMulY);
|
||||
CurText.Render(ADest, colWhite, ADestX, ADestY, AMulX, AMulY);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user