📄 svgadem2.c
字号:
d3scale(10,i,i,i,pointarray,playarray);
d3project(10,&proj,playarray,plotarray);
showhouse(plotarray,oplotarray);
sdelay(2);
}
ret = getkey();
if ((ret=='s') || (ret=='q')) {
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* show d3rotate
*/
setview(0,16,maxx,31);
fillview(0);
sprintf(buf,"d3rotate(points,xorigin,yorigin,zorigin,zangle,yangle,xangle,inarray,outarray);");
drwstring(1,7,0,buf,10,16);
setview(0,32,maxx,maxy);
for(i=0;i<=360;i+=3) {
d3rotate(10,0,0,0,0,i,i,pointarray,playarray);
d3project(10,&proj,playarray,plotarray);
showhouse(plotarray,oplotarray);
sdelay(2);
}
ret = getkey();
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/***********
* DOMOUSE *
***********/
char domouse(void)
{
int i, mouse;
int colr, x1, x2, y1, y2;
int lb, cb, rb, x, y, mbuts;
int spcing;
char ret;
char title[TITLEN];
char buf[TITLEN];
/*
* Set up the title
*/
sprintf(title,"DEMO 9: Mouse functions");
fillscreen(0);
palset(pal,0,255);
setview(0,0,maxx,maxy);
/*
* Check to see if we have a mouse so we can do the mouse demo
*/
mouse = whichmouse();
if (mouse < 1) {
drwstring(1,7,0,title,10,0);
sprintf(buf,"Sorry, no mouse detected... Can not do the mouse demo.");
drwstring(1,7,0,buf,10,16);
ret = getkey();
fillscreen(0);
return(ret);
}
colr = 16;
for(i=0;i<=maxx/2;i++) {
drwcircle(1,colr,maxx/4 + i, maxy/2, maxy/5);
colr+=2;
if (colr>255)
colr = 16;
}
/*
* Show mouseshow
*/
setview(0,0,maxx,31);
fillview(0);
drwstring(1,7,0,title,10,0);
sprintf(buf,"mouseshow();");
drwstring(1,7,0,buf,10,16);
setview(0,32,maxx,maxy);
mouseenter(); /* MUST BE CALLED FIRST TO ENABLE MOUSE FUNCTIONS */
mouseshow();
ret = getkey();
if ((ret=='s') || (ret=='q')) {
mouseexit(); /* MUST BE CALLED TO DISABLE MOUSE FUNCTIONS */
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* Show mousestatus
*/
mousehide();
setview(0,16,maxx,31);
fillview(0);
sprintf(buf,"mousestatus(xloc,yloc,mbuts);");
drwstring(1,7,0,buf,10,16);
mouseshow();
setview(0,32,maxx,maxy);
beep();
while(!kbhit()) {
lb = cb = rb = 0;
mousestatus(&x,&y,&mbuts);
if (mbuts & 1)
lb = 1;
if (mbuts & 2)
rb = 1;
if (mbuts & 4)
cb = 1;
sprintf(buf,"X= %4d Y= %4d LB= %1d CB= %1d RB= %1d",x,y,lb,cb,rb);
drwstring(1,15,8,buf,10,32);
}
ret = (char)getch();
if ( (ret == 'Q') || (ret == 'q') )
endit = 1;
if (ret == 'Q')
ret = 'q';
if (ret == 'S')
ret = 's';
if ((ret=='s') || (ret=='q')) {
mouseexit(); /* MUST BE CALLED TO DISABLE MOUSE FUNCTIONS */
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* Show mousehide
*/
mousehide();
setview(0,16,maxx,31);
fillview(0);
sprintf(buf,"mousehide(xloc,yloc,mbuts);");
drwstring(1,7,0,buf,10,16);
setview(0,32,maxx,maxy);
beep();
while(!kbhit()) {
lb = cb = rb = 0;
mousestatus(&x,&y,&mbuts);
if (mbuts & 1)
lb = 1;
if (mbuts & 2)
rb = 1;
if (mbuts & 4)
cb = 1;
sprintf(buf,"X= %4d Y= %4d LB= %1d CB= %1d RB= %1d",x,y,lb,cb,rb);
drwstring(1,15,8,buf,10,32);
}
ret = (char)getch();
if ( (ret == 'Q') || (ret == 'q') )
endit = 1;
if (ret == 'Q')
ret = 'q';
if (ret == 'S')
ret = 's';
if ((ret=='s') || (ret=='q')) {
mouseexit(); /* MUST BE CALLED TO DISABLE MOUSE FUNCTIONS */
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* Show mouserangeset
*/
mousehide();
setview(0,16,maxx,maxy);
fillview(0);
sprintf(buf,"mouserangeset(x1,y1,x2,y2);");
drwstring(1,7,0,buf,10,16);
setview(0,32,maxx,maxy);
spcing = (maxy - 32) / 3;
x1 = spcing;
y1 = 32 + spcing;
x2 = maxx - spcing;
y2 = maxy - spcing;
drwbox(1,15,x1,y1,x2,y2);
mouseshow();
mouserangeset(x1,y1,x2,y2);
ret = getkey();
mouserangeset(0,0,maxx,maxy);
if ((ret=='s') || (ret=='q')) {
mouseexit(); /* MUST BE CALLED TO DISABLE MOUSE FUNCTIONS */
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* Show mousecursorset - use the magnifier
*/
setview(0,16,maxx,31);
fillview(0);
sprintf(buf,"mousecursorset(mousecursor);");
drwstring(1,7,0,buf,10,16);
setview(0,32,maxx,maxy);
mousecursorset(&magmousecursor);
ret = getkey();
if ((ret=='s') || (ret=='q')) {
mouseexit(); /* MUST BE CALLED TO DISABLE MOUSE FUNCTIONS */
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* Show mousecursorset - use the big arrow
*/
setview(0,32,maxx,maxy);
mousecursorset(&bigmousecursor);
ret = getkey();
if ((ret=='s') || (ret=='q')) {
mouseexit(); /* MUST BE CALLED TO DISABLE MOUSE FUNCTIONS */
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* Show mousecursorset - use the stopwatch
*/
setview(0,32,maxx,maxy);
mousecursorset(&stwmousecursor);
ret = getkey();
if ((ret=='s') || (ret=='q')) {
mouseexit(); /* MUST BE CALLED TO DISABLE MOUSE FUNCTIONS */
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*
* Show mousecursordefault
*/
mousehide();
setview(0,16,maxx,31);
fillview(0);
sprintf(buf,"mousecursordefault();");
drwstring(1,7,0,buf,10,16);
mouseshow();
setview(0,32,maxx,maxy);
mousecursordefault();
ret = getkey();
mouseexit(); /* MUST BE CALLED TO DISABLE MOUSE FUNCTIONS */
fillscreen(0);
setview(0,0,maxx,maxy);
return(ret);
}
/*********
* DOGIF *
*********/
char dogif(void)
{
int endthis;
int ext, length;
char c, ret;
char title[TITLEN];
char buf[TITLEN];
char *fname;
fname=malloc(128);
/*
* Setup the title
*/
sprintf(title,"DEMO 8: GIF functions");
/*
* Show gifgetinfo
*/
setview(0,0,maxx,maxy);
fillscreen(0);
drwstring(1,7,0,title,10,0);
endthis = 0;
ret = '\0';
while (!endthis) {
sprintf(buf,"Please provide the name (and full path if not in the current drive/directory)");
drwstring(1,7,0,buf,10,64);
sprintf(buf,"of a GIF file you would like to see...");
drwstring(1,7,0,buf,10,80);
sprintf(buf,"Filename:");
drwstring(1,7,0,buf,10,96);
sprintf(fname,"_");
length = 0;
ext = 0;
c = '\0';
while(!ext) {
drwstring(1,7,0,fname,82,96);
c = (char)getch();
if(c>=' ' && c<='~') {
fname[length] = c;
fname[length+1] = '_';
fname[length+2] = '\0';
length++;
}
else
if (c==8 && length>0) {
drwstring(1,15,0," ",82+length*8,96);
length--;
fname[length] = '_';
fname[length+1] = '\0';
}
else
if (c==13)
ext = 1;
}
if (length==0) {
free(fname);
return(ret);
}
fname[length] = '\0';
ret = showgif(fname);
if ((ret=='s') || (ret=='q')) {
fillscreen(0);
free(fname);
return(ret);
}
drwstring(1,7,0,title,10,0);
sprintf(buf,"Would you like to see another (Y/N) ?");
drwstring(1,7,0,buf,10,64);
ext = 0;
while(!ext) {
c=(char)getch();
if ((c=='n') || (c=='N')) {
ext = 1;
endthis = 1;
}
else
if ((c=='y') || (c=='Y'))
ext = 1;
}
}
fillscreen(0);
free(fname);
return(ret);
}
/**************
* DOJOYSTICK *
**************/
char dojoystick(void)
{
int maxxa, maxya, minxa, minya;
int maxxb, maxyb, minxb, minyb;
int jax, jay, jabuts, jbx, jby, jbbuts;
int joystick, spcing, dist;
int x1, y1, x2, y2, x3, y3, x4, y4;
int cntax, cntay, cntbx, cntby;
int rangexa, rangeya, rangexb, rangeyb;
int jabax, jabay, jabbx, jabby;
int jbbax, jbbay, jbbbx, jbbby;
int oax, oay, obx, oby;
char ret;
char title[TITLEN];
char buf[TITLEN];
oax = oay = obx = oby = 0;
/*
* Set up the title
*/
sprintf(title,"DEMO 10: Joystick functions");
palset(pal,0,255);
fillscreen(0);
setview(0,0,maxx,maxy);
drwstring(1,7,0,title,10,0);
/*
* Check to see if we have a joystick so we can do the joystick demo
*/
joystick = whichjoystick();
if (joystick < 1) {
sprintf(buf,"Sorry, no joystick detected... Can not do the joystick demo.");
drwstring(1,7,0,buf,10,16);
ret = getkey();
fillscreen(0);
return(ret);
}
/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -