home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 1
/
CDPD_Vol1.bin
/
pd
/
026-050
/
049
/
polygon
/
polygon2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-06-23
|
6KB
|
223 lines
/* polygon drawing routine based on Polygon Constructor by John Jainschigg
taken from Family Computing June 1986 */
/* Polygon is based on an original program by Terry W. Gintz
for the Apple Macintosh -- that used Quickdraw for the polygon drawing */
void IMsg();
/* Include the definitions and functions we need */
#include "polygon2.h"
#include "polyg3.c"
#include "palette.c"
#include "save.c"
struct IntuiText Menu0IText [] = {
{
0,3,JAM2, /* Front Pen, Back Pen, Draw Mode */
0,0, /* Left Edge, Top Edge */
&TestFont, /* pointer to Text Font */
" new pict ", /* text of Menu Item */
NULL /* pointer to next IText */
},
{0,3,JAM2,0,0,&TestFont,"modify color",NULL },
{0,3,JAM2,0,0,&TestFont,"cycle colors",NULL },
{0,3,JAM2,0,0,&TestFont,"stop drawing",NULL },
{0,3,JAM2,0,0,&TestFont,"save picture",NULL },
{0,3,JAM2,0,0,&TestFont," quit ",NULL },
};
struct MenuItem Menu0Item[6] = {
{
&Menu0Item[1], /* pointer to next Item */
0,0,120,9, /* Left, Top, Width, Height */
ITEMTEXT | ITEMENABLED | HIGHCOMP, /* Flags */
0, /* no mutual exclude */
(APTR)&Menu0IText[0], /* Render info */
NULL,NULL,NULL, /*Alt Image, Command (amiga) char, subitem*/
MENUNULL /* next select */
},
{&Menu0Item[2],0,9,120,9,ITEMTEXT | ITEMENABLED | HIGHCOMP,
0,(APTR)&Menu0IText[1],NULL,NULL,NULL,MENUNULL},
{&Menu0Item[3],0,18,120,9,ITEMTEXT | ITEMENABLED | HIGHCOMP,
0,(APTR)&Menu0IText[2],NULL,NULL,NULL,MENUNULL},
{&Menu0Item[4],0,27,120,9,ITEMTEXT | ITEMENABLED | HIGHCOMP,
0,(APTR)&Menu0IText[3],NULL,NULL,NULL,MENUNULL},
{&Menu0Item[5],0,36,120,9,ITEMTEXT | ITEMENABLED | HIGHCOMP,
0,(APTR)&Menu0IText[4],NULL,NULL,NULL,MENUNULL},
{NULL,0,45,120,9,ITEMTEXT | ITEMENABLED | HIGHCOMP,
0,(APTR)&Menu0IText[5],NULL,NULL,NULL,MENUNULL}
};
struct Menu BdMenu [1] = {
NULL, /* ptr to next Menu */
10,0,120,0, /* left,top,width,height--top and height ignored */
MENUENABLED, /* Flags */
" Polygons ", /* menu title */
&Menu0Item[0] /* First Item in list */
};
int nf,cycle,delay,sav;
UWORD color18, color19;
main()
{
USHORT drawing;
cycle=0;
nf=0;
delay=9000;
initwind();
init_colors();
init_scr();
drawing=1;
poly();
while(drawing)
{
IMsg();
}
} /* end of main */
void IMsg()
{
struct IntuiMessage *BdMsg; /* Intuition message structure */
ULONG Mclass; /* Message class */
USHORT Mcode; /* Message code */
if (cycle==1)
cyclecolors();
if (nf==1)
poly();
while (BdMsg = (struct IntuiMessage *)GetMsg(w->UserPort)){
Mclass = BdMsg->Class;
Mcode = BdMsg->Code;
ReplyMsg(BdMsg);
switch (Mclass) {
case CLOSEWINDOW:
clear_colors();
Cleanup();
exit(TRUE);
break;
case MENUPICK:
switch (ITEMNUM(Mcode)){
case 0:
poly();
break;
case 1:
palette(w);
break;
case 2:
if (cycle==0)
cycle=1;
else
cycle=0;
break;
case 3:
break;
case 4:
sav=save(w);
if (sav == 1){
color18=GetRGB4(p_Co,18);
color19=GetRGB4(p_Co,19);
SetRGB4(vp,18,15,0,0);
SetRGB4(vp,19,15,15,15);
SetPointer(w,&PointImage,14,16,0,0);
SavePicture();
ClearPointer(w);
*(p_ct+18)=(USHORT)color18;
*(p_ct+19)=(USHORT)color19;
LoadRGB4(vp,p_ct,CTSIZ);
}
break;
case 5:
clear_colors();
Cleanup();
exit(TRUE);
break;
}
}
}
}
init_scr()
{
SetMenuStrip(w,&BdMenu);
} /* end of init_scr */
Cleanup()
{
CloseWindow(w);
CloseScreen(screen);
}
cyclecolors()
{
int i,temp;
temp=*(p_ct+5);
for (i=5;i<=30;i++)
*(p_ct+i)=*(p_ct+i+1);
*(p_ct+31)=temp;
LoadRGB4(vp,p_ct,CTSIZ);
for (i=0;i<=delay;i++)
;
}
int stopcheck()
{
struct IntuiMessage *BdMsg; /* Intuition message structure */
ULONG Mclass; /* Message class */
USHORT Mcode,ItemNum;
int ex;
if (cycle==1)
cyclecolors();
ex = 0;
nf = 0;
while (BdMsg = (struct IntuiMessage *)GetMsg(w->UserPort)) {
Mclass = BdMsg->Class;
Mcode = BdMsg->Code;
ReplyMsg(BdMsg);
switch (Mclass) {
case CLOSEWINDOW:
Cleanup();
exit(TRUE);
break;
case MENUPICK:
ItemNum = ITEMNUM(Mcode);
switch (ItemNum){
case 0:
ex = 1;
nf = 1;
break;
case 1:
palette(w);
break;
case 2:
if (cycle==1)
cycle=0;
else
cycle=1;
break;
case 3:
ex=1;
break;
case 4:
break;
case 5:
clear_colors();
Cleanup();
exit(TRUE);
}
}
}
return(ex);
}