Reputation: 2593
Currently the VCL has
WITH Canvas DO
BEGIN
CASE PathStyle OF
psLine:
BEGIN
strokeThickness := Max(1, MulDiv( Min(xCellSize,yCellSize), 2, 10));
MoveTo(xOffset + PosX * xCellSize + xCellSize DIV 2,yOffset + PosY * yCellSize + yCellSize DIV 2);
END
But i get error on moveto (undefined).
So how can i convert the moveto to work with FMX?
Upvotes: -1
Views: 1743
Reputation: 612824
The separate MoveTo and LineTo methods do not translate literally. Instead you make a single call to the DrawLine method of TCanvas. This receives two TPointF parameters that specify the beginning and end of the line segment. As well you pass an opacity parameter, 100 for opaque.
Borrowing from the official samples:
var
p1, p2: TPointF;
begin
// sets the ends of the line to be drawn
p1.Create(20, 2);
p2.Create(350, 400);
Image1.Bitmap.Canvas.BeginScene;
// draw the line on the canvas
Image1.Bitmap.Canvas.DrawLine(p1, p2, 100);
Image1.Bitmap.Canvas.EndScene;
// updates the bitmap
Image1.Bitmap.BitmapChanged;
end;
For what it is worth, the TPointF type is one of the worst designed types I've seen in a long while. Its faults are multitudinous:
Upvotes: 3