In this example:
Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; Procedure formcreate (Sender: tobject); Procedure formmouseup (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} const {defines the color of the rings as a constant array} colors: array [0 .. 4] of tcolor = (clblue, clblack, clred, clyellow, clgreen); var CI: integer; {used as the color serial number} procedure tform1.formcreate (Sender: tobject); begin button1.caption: = 'repainted '; self. color: = clwhite; canvas. pen. width: = 5; end; Procedure tform1.formmouseup (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); const r = 30; {circle radius} var radian: Double; {record radians; parameters required for sin and cos functions; radians = angle * PI/180} I, A, B: integer; begin canvas. moveTo (X, Y-R); canvas. pen. color: = colors [CI]; for I: = 1 to 360 do begin radian: = I * (PI/180); {get radian}: = x + round (sin (radian) * R); {use the sin function to obtain the abscissa} B: = Y-round (COS (radian) * R ); {retrieve ordinate using cos function} canvas. lineto (a, B); {draw} application. processmessages; {do not affect other operations} Sleep (3); {wait 3 ms} end; Inc (CI); If Ci = 5 then CI: = 0; end; procedure tform1.button1click (Sender: tobject); begin CI: = 0; repaint; end.
Public Function directory under System Unit