The following program illustrates how to use the various graphics functions.
MODULE 'intuition/intuition'
PROC main()
DEF wptr, i
wptr:=OpenW(20,50,200,100,IDCMP_CLOSEWINDOW,
WFLG_CLOSEGADGET OR WFLG_ACTIVATE,
'Graphics demo window',NIL,1,NIL)
IF wptr /* Check to see we opened a window */
Colour(1,3)
TextF(20,30,'Hello World')
SetTopaz(11)
TextF(20,60,'Hello World')
FOR i:=10 TO 150 STEP 8 /* Plot a few points */
Plot(i,40,2)
ENDFOR
Line(160,40,160,70,3)
Line(160,70,170,40,2)
Box(10,75,160,85,1)
WHILE WaitIMessage(wptr)<>IDCMP_CLOSEWINDOW
ENDWHILE
CloseW(wptr)
ELSE
WriteF('Error -- could not open window!\n')
ENDIF
ENDPROC
First of all a small window is opened with a close gadget and activated (so it is the selected window). Clicks on the close gadget will be reported via IDCMP, and this is the only way to quit the program. The graphics functions are used as follows:
Colour is used to set the foreground colour to pen one and the background colour to pen three.
This will make the text nicely highlighted.
FOR loop plots a dotted line in pen two.
Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.