mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 13:39:08 +02:00
fpvectorial: Starts moving the font drawing to the top of the curve
git-svn-id: trunk@49010 -
This commit is contained in:
parent
fa18a10e3c
commit
ad069894f5
@ -283,7 +283,7 @@ type
|
|||||||
Next: TPathSegment;
|
Next: TPathSegment;
|
||||||
// mathematical methods
|
// mathematical methods
|
||||||
function GetLength(): Double; virtual;
|
function GetLength(): Double; virtual;
|
||||||
function GetPointAndTangentForDistance(ADistance: Double; out AX, AY, ATangentAngle: Double): Boolean; virtual;
|
function GetPointAndTangentForDistance(ADistance: Double; out AX, AY, ATangentAngle: Double): Boolean; virtual; // ATangentAngle in radians
|
||||||
function GetStartPoint(out APoint: T3DPoint): Boolean;
|
function GetStartPoint(out APoint: T3DPoint): Boolean;
|
||||||
// edition methods
|
// edition methods
|
||||||
procedure Move(ADeltaX, ADeltaY: Double); virtual;
|
procedure Move(ADeltaX, ADeltaY: Double); virtual;
|
||||||
@ -3515,6 +3515,7 @@ end;
|
|||||||
|
|
||||||
// Walk is walking a distance in the path and obtaining the point where we land and the current tangent
|
// Walk is walking a distance in the path and obtaining the point where we land and the current tangent
|
||||||
// Returns true if successful, false otherwise
|
// Returns true if successful, false otherwise
|
||||||
|
// ATangentAngle - In radians
|
||||||
function TPath.NextWalk(ADistance: Double; out AX, AY, ATangentAngle: Double): Boolean;
|
function TPath.NextWalk(ADistance: Double; out AX, AY, ATangentAngle: Double): Boolean;
|
||||||
var
|
var
|
||||||
lCurPoint: TPathSegment;
|
lCurPoint: TPathSegment;
|
||||||
@ -4289,12 +4290,19 @@ procedure TvCurvedText.Render(ADest: TFPCustomCanvas;
|
|||||||
var
|
var
|
||||||
i, lCharLen: Integer;
|
i, lCharLen: Integer;
|
||||||
lText, lUTF8Char: string;
|
lText, lUTF8Char: string;
|
||||||
lX, lY, lTangentAngle: Double;
|
lX, lY, lTangentAngle, lTextHeight: Double;
|
||||||
|
//lLeft, lTop, lWidth, lHeight: Integer;
|
||||||
begin
|
begin
|
||||||
inherited Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMulY, False);
|
inherited Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMulY, False);
|
||||||
|
|
||||||
InitializeRenderInfo(ARenderInfo);
|
InitializeRenderInfo(ARenderInfo);
|
||||||
|
|
||||||
|
if not ADoDraw then
|
||||||
|
begin
|
||||||
|
//Path.CalculateSizeInCanvas(ADest, lLeft, lTop, lWidth, lHeight);
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
// Don't draw anything if we have alpha=zero
|
// Don't draw anything if we have alpha=zero
|
||||||
if Font.Color.Alpha = 0 then Exit;
|
if Font.Color.Alpha = 0 then Exit;
|
||||||
if Path = nil then Exit;
|
if Path = nil then Exit;
|
||||||
@ -4311,6 +4319,13 @@ begin
|
|||||||
for i := 0 to UTF8Length(lText)-1 do
|
for i := 0 to UTF8Length(lText)-1 do
|
||||||
begin
|
begin
|
||||||
lUTF8Char := UTF8Copy(lText, i+1, 1);
|
lUTF8Char := UTF8Copy(lText, i+1, 1);
|
||||||
|
ADest.Font.Orientation := Round(Math.radtodeg(lTangentAngle)*10);
|
||||||
|
|
||||||
|
// Without adjustment the text is down bellow the path, but we want it on top of it
|
||||||
|
lTextHeight := Abs(AMulY) * ADest.TextHeight(lUTF8Char);
|
||||||
|
lX := lX - Sin(Pi / 2 - lTangentAngle) * lTextHeight;
|
||||||
|
lY := lY + Cos(Pi / 2 - lTangentAngle) * lTextHeight;
|
||||||
|
|
||||||
ADest.TextOut(CoordToCanvasX(lX), CoordToCanvasY(lY), lUTF8Char);
|
ADest.TextOut(CoordToCanvasX(lX), CoordToCanvasY(lY), lUTF8Char);
|
||||||
lCharLen := ADest.TextWidth(lUTF8Char);
|
lCharLen := ADest.TextWidth(lUTF8Char);
|
||||||
Path.NextWalk(lCharLen, lX, lY, lTangentAngle);
|
Path.NextWalk(lCharLen, lX, lY, lTangentAngle);
|
||||||
|
@ -231,6 +231,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// (x2,y2)=(x1+L⋅cos(a),y1+L⋅sin(a)).
|
// (x2,y2)=(x1+L⋅cos(a),y1+L⋅sin(a)).
|
||||||
|
// ATangentAngle - in Radians
|
||||||
function LineEquation_GetPointAndTangentForLength(AStart, AEnd: T3DPoint; ADistance: Double; out AX, AY, ATangentAngle: Double): Boolean;
|
function LineEquation_GetPointAndTangentForLength(AStart, AEnd: T3DPoint; ADistance: Double; out AX, AY, ATangentAngle: Double): Boolean;
|
||||||
var
|
var
|
||||||
lLineAngle: Double; // to X axis
|
lLineAngle: Double; // to X axis
|
||||||
|
Loading…
Reference in New Issue
Block a user