home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
600-699
/
ff634.lha
/
APIG
/
apig33.lzh
/
e3_drawing.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1991-09-27
|
6KB
|
213 lines
/* This example simply opens a window and custom screen
for drawing */
/* add library */
x = addlib("apig.library",0,-30,0)
x = addlib("rexxmathlib.library",0,-30,0)
portname = "example3_port" /* this is the name of the port that */
/* intuimessages will be sent to */
p = openport(portname) /* create the port */
call set_apig_globals() /* initialize INTUITION constants */
WaitForPort portname /* this port should be here by now */
wintitle = "This is your Window title"
/* the INTUI-Events you want the window to receive */
winidcmp = CLOSEWINDOW
/* set window flags for system gadgets and type of window you want */
winflags = WINDOWCLOSE+WINDOWDRAG+WINDOWSIZING+WINDOWDEPTH+GIMMEZEROZERO,
+ ACTIVATE
/* open a custom screen */
scr = openscreen(0,0,640,400,3,4,5,LACE+HIRES,CUSTOMSCREEN,scrtitle)
/* open 2 windows, on custom screen, scr NOT = 0 */
win1 = openwindow(portname,0,0,640,199,2,4,winidcmp,winflags,wintitle,scr,0,0,0)
win2 = openwindow(portname,0,201,640,199,2,4,winidcmp,winflags,wintitle,scr,0,0,0)
exitme = 0
/* draw some stuff */
winrasport1 = getwindowrastport(win1) /* to do drawing need windows rastport */
winrasport2 = getwindowrastport(win2)
do i = 1 to 20
x = random(10,639)
y = random(10,198)
p = random(1,15)
if i = 1 then
call move(winrasport1,x,y)
call setapen(winrasport1,p)
call draw(winrasport1,x,y)
x = random(10,600)
y = random(10,180)
r = random(10,100)
p = random(1,15)
call setapen(winrasport2,p)
call drawcircle(winrasport2,x,y,r)
end
call clearscreen(winrasport1,0,0)
call clearscreen(winrasport2,0,0)
do i = 1 to 10
x = random(10,500)
y = random(30,160)
x2 = random(x+10,600)
y2 = random(y+10,180)
p = random(1,15)
call setapen(winrasport1,p)
p = random(1,15)
call setapen(winrasport2,p)
call drawellipse(winrasport1,x,y,x+2,y-20)
call rectfill(winrasport2,x,y,x2,y2)
end
call clearscreen(winrasport1,0,0)
call clearscreen(winrasport2,0,0)
call setapen(winrasport1,9)
call setapen(winrasport2,5)
array = allocmem(650*4,MEMF_CLEAR) /* alloc block of mem. to use as an array */
/* 2 bytes per word, 2 words for X,Y */
array2 = allocmem(650*4,MEMF_CLEAR)
deltarad = (2 * 3.14159) / 640
z = pitext(winrasport1,60,100,"Calculating Array Points ... SIN(X)",1,2,JAM2,0)
z = pitext(winrasport2,60,100,"Calculating Array Points ... COS(X)",1,2,JAM2,0)
npoints = 639
do i = 0 to npoints
y = ((1 - sin(i * deltarad)) * 88)
dx = setx(array,i,i)
dy = sety(array,i,y)
z = pitext(winrasport1,60,125,(" X-Coord = " dx "Y-Coord = " dy " "),3,4,JAM2,0)
y = ((1 - cos(i * deltarad)) * 88)
dx = setx(array2,i,i)
dy = sety(array2,i,y)
z = pitext(winrasport2,60,125,(" X-Coord = " dx "Y-Coord = " dy " "),3,4,JAM2,0)
if i > 500 then
do
z = pitext(winrasport1,90,112," SLOW ! aint it," (npoints - i) "points to go. ",1,2,JAM2,0)
z = pitext(winrasport2,90,112," SLOW ! aint it," (npoints - i) "points to go. ",1,2,JAM2,0)
end
end
call clearscreen(winrasport1,0,0)
call clearscreen(winrasport2,0,0)
z = move(winrasport1,getx(array,0),gety(array,0))
z = move(winrasport2,getx(array2,0),gety(array2,0))
call polydraw(winrasport1,npoints+1,array)
call polydraw(winrasport2,npoints+1,array2)
a = freemem(array,(650*4))
a = freemem(array2,(650*4))
wait 2 secs
linepat = c2d('ffff'x)
planemask = 15
do i = 10 to 199 by 20
z = setapen(winrasport1,((planemask // 7) + 1))
z = setdrpt(winrasport1,linepat)
z = move(winrasport1,10,i)
z = draw(winrasport1,640,i)
if linepat > 512 then
linepat = linepat - 237 /* any number to make linepat different */
if planemask > 10 then
planemask = planemask - 1
else
planemask = 15
z = setapen(winrasport2,((planemask // 7) + 1))
z = setdrpt(winrasport2,linepat)
z = move(winrasport2,10,i)
z = draw(winrasport2,640,i)
if linepat > 1024 then
linepat = linepat - 1024
end
z = pitext(winrasport1,60,120,"DONE... Use the CloseGadget ",3,4,JAM2,0)
z = pitext(winrasport2,60,120,"DONE",5,7,JAM2,0)
do forever /* the main 'wait' loop for message arrival */
x = waitpkt(portname)
do forever /* get all message packets until getpkt() returns null */
msg = getpkt(portname)
if msg = '0000 0000'x then leave
class = getarg(msg,0)
select
when class = CLOSEWINDOW then
do
exitme = exitme + 1
if getarg(msg,7) = win1 then
do
do while msg ~= '0000 0000'x
call reply(msg,0)
msg = getpkt(portname)
end
call closewindow(win1)
end
else
if getarg(msg,7) = win2 then
do
do while msg ~= '0000 0000'x
call reply(msg,0)
msg = getpkt(portname)
end
call closewindow(win2)
end
end
otherwise call reply(msg,0)
end
end
if exitme = 2 then leave
end
a = closescreen(scr)
exit