Don't Be a Square

By Al Williams

Dr. Dobb's Sourcebook January/February 1997

(a)	Canvas.MoveTo(0,0);
	Canvas.LineTo(100,100);
(b)	with Form1.Canvas do
	    begin
	  .
	  .
	  .
	    Pen.Width:=22;
	    Pen.Color:=clRed;
	    angle:=((hour+min/60)*30-90)*0.0175; 
	    x:=Round(2*(radius/3)*
	       cos(angle))+pt.x;
	    y:=Round(2*(radius/3)*
	       sin(angle))+pt.y;
	    MoveTo(pt.x,pt.y);
	    LineTo(x,y);
	  .
	  .
	  .

(c)	SetBKMode(Canvas.Handle,TRANSPARENT);
	SetBKColor(Canvas.Handle,RGB(0,0,0);

Example 2: (a) Drawing a 45 degree line; (b) drawing the hour hand of a clock; (c) using the canvas' Handle property to call the Windows API.

Back to Article