Difference between revisions of "Canvas line"

From Free Pascal wiki
Jump to navigationJump to search
m (Fixed syntax highlighting)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
The '''canvas.line(x1, y1, x2, y2)''' statement will draw a line from point (x1, y1) to (x2, y2).
+
The '''Canvas.Line(x1, y1, x2, y2)''' statement will draw a line from point (x1, y1) to (x2, y2).
  
 
The coordinates of the canvas are:
 
The coordinates of the canvas are:
Line 7: Line 7:
  
 
This code will draw the diagonals in a form:
 
This code will draw the diagonals in a form:
<syntaxhighlight>
+
 
procedure TForm1.Button1Click(Sender: TObject);
+
<syntaxhighlight lang="pascal">
 +
procedure TForm1.Form1Paint(Sender: TObject);
 
begin
 
begin
   canvas.Line(0,0, form1.Width,form1.Height);
+
   Canvas.Line(0, 0, Width-1, Height-1);
   canvas.Line(0,form1.height,form1.width,0);
+
   Canvas.Line(0, Height-1, Width-1 ,0);
 
end;
 
end;
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 02:32, 7 February 2020

The Canvas.Line(x1, y1, x2, y2) statement will draw a line from point (x1, y1) to (x2, y2).

The coordinates of the canvas are:

canvas2.png


This code will draw the diagonals in a form:

procedure TForm1.Form1Paint(Sender: TObject);
begin
  Canvas.Line(0, 0, Width-1, Height-1);
  Canvas.Line(0, Height-1, Width-1 ,0);
end;

See also