home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Hack-Phreak Scene Programs
/
cleanhpvac.zip
/
cleanhpvac
/
FGDEMO40.ZIP
/
SOURCE.COM
/
FUNDMTLS.C
< prev
next >
Wrap
Text File
|
1995-02-12
|
14KB
|
631 lines
/**********************************************************************\
* *
* fundmtls.c -- graphics fundamentals: points, lines, rects, etc. *
* *
\**********************************************************************/
#include "defs.h"
/**********************************************************************\
* *
* do_boxes -- draw a bunch of hollow rectangles *
* *
\**********************************************************************/
do_boxes()
{
register int i,j;
int x1,x2,y1,y2;
int color;
fg_mousevis(OFF);
/* set the clip region */
fg_setclip(5,xlimit-5,menu_bottom,ylimit-4);
/* clear the bottom of the screen */
fg_setcolor(14);
fg_rect(5,xlimit-5,menu_bottom,ylimit-4);
/* draw some boxes */
for (j = 20; j<= 420; j+=200)
{
x1 = j;
x2 = x1+200;
y1 = 50;
y2 = 170;
if (x1 == 220)
fg_boxdepth(1,4);
else
fg_boxdepth(3,2);
color = 1;
for (i = 0; i < 15; i++)
{
fg_setcolor(color);
fg_box(x1,x2,y1,y2);
x1 += 3;
x2 -= 8;
y2 -= 2;
y1 += 6;
color = 10 - color;
}
}
for (j = 20; j<= 420; j+=200)
{
x1 = j;
x2 = x1+200;
y1 = 170;
y2 = 290;
if (x1 == 220)
fg_boxdepth(3,2);
else
fg_boxdepth(1,4);
color = 1;
for (i = 0; i < 15; i++)
{
fg_setcolor(color);
fg_box(x1,x2,y1,y2);
x1 += 3;
x2 -= 8;
y2 -= 2;
y1 += 6;
color = 10 - color;
}
}
/* restore box size to the default */
fg_boxdepth(1,1);
/* wait for a keystroke or mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_circles -- draw a bunch of circles *
* *
\**********************************************************************/
do_circles()
{
register int i;
int x1,x2,y1;
fg_mousevis(OFF);
fg_setcolor(1);
fg_rect(5,xlimit-5,menu_bottom,ylimit-4);
/* move to the center of the screen */
x1 = xlimit / 2;
y1 = (ylimit + menu_bottom) / 2;
fg_move(x1,y1);
/* draw concentric circles */
x2 = 4;
fg_setcolor(15);
for (i = 0; i < 25; i++)
{
fg_circle(x2);
x2 += 8;
}
/* wait for a keystroke */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_ellipses -- draw a bunch of elipses *
* *
\**********************************************************************/
do_ellipses()
{
register int i;
int x1,x2,x3,y1;
/* clear the screen */
fg_mousevis(OFF);
fg_setcolor(9);
fg_rect(5,xlimit-5,menu_bottom,ylimit-4);
/* move to the center of the screen */
x1 = xlimit / 2;
y1 = (ylimit + menu_bottom) / 2;
fg_move(x1,y1);
/* draw concentric ellipses */
x2 = 4;
x3 = 1;
fg_setcolor(0);
for (i = 0; i < 80; i++)
{
fg_ellipse(x2,x3);
x2 += 3;
x3++;
}
/* wait for a keystroke or mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_lines -- draw lines to create a plaid pattern *
* *
\**********************************************************************/
do_lines()
{
register int i,j;
int x1,x2,y1,y2;
int xinc;
static int lcolor[] = {2,1,9,11,11,9,1,2};
/* clear bottom part of screen */
fg_mousevis(OFF);
fg_setclip(5,xlimit-5,menu_bottom,ylimit-4);
fg_setcolor(15);
fg_rect(5,xlimit-5,menu_bottom,ylimit-4);
/* draw horizontal lines */
fg_setcolor(0);
for (i = menu_bottom; i < ylimit; i+=40)
{
for (j = 0; j < 8; j++)
{
fg_setcolor(lcolor[j]);
y1 = i + 3*j;
fg_move(0,y1);
fg_draw(xlimit,y1);
}
}
/* draw vertical lines */
y1 = menu_bottom;
y2 = ylimit;
for (i = 0; i < 640; i+=60)
{
for (j = 0; j < 8; j++)
{
fg_setcolor(lcolor[j]);
x1 = i + 3*j;
fg_move(x1,y1);
fg_draw(x1,y2);
}
}
/* draw red diagonal lines */
y1 = menu_bottom;
y2 = ylimit;
xinc = ylimit - menu_bottom;
fg_setcolor(12);
for (x1 = -640; x1 < 640; x1+=60)
{
x2 = x1 + xinc;
fg_move(x1,y1);
fg_draw(x2,y2);
}
y1 = menu_bottom;
y2 = ylimit;
xinc = ylimit - menu_bottom;
/* draw red diagonal lines */
fg_setcolor(12);
for (x1 = 0; x1 < 1280; x1+=60)
{
x2 = x1 - xinc;
fg_move(x1,y1);
fg_draw(x2,y2);
}
/* restore the clipping limits */
fg_setclip(0,fg_getmaxx(),0,fg_getmaxy());
/* wait for a keystroke or mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_paint -- draw a quartered circle, then paint around it *
* *
\**********************************************************************/
do_paint()
{
int x1,x2,y1,y2;
/* restor the screen */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
/* draw a rectangle */
y1 = menu_bottom + 20;
y2 = ylimit - 20;
x1 = 40;
x2 = xlimit - 40;
fg_setcolor(11);
fg_rect(x1,x2,y1,y2);
/* outline the rectangle */
fg_setcolor(0);
fg_box(x1,x2,y1,y2);
y1 = (ylimit + menu_bottom) / 2;
x1 = xlimit / 2;
fg_move(x1,y1);
/* draw the circle */
fg_setcolor(0);
fg_circle(80);
/* draw cross bars in the circle */
y2 = 80;
fg_move(x1,y1-y2);
fg_draw(x1,y1+y2);
x2 = 100;
fg_move(x1-x2,y1);
fg_draw(x1+x2,y1);
/* paint each quarter of the circle */
fg_setcolor(1);
fg_paint(x1-6,y1-6);
fg_setcolor(2);
fg_paint(x1+6,y1+6);
fg_setcolor(3);
fg_paint(x1+6,y1-6);
fg_setcolor(4);
fg_paint(x1-6,y1+6);
/* paint the box */
x1 = 41;
y1 = menu_bottom + 20 + 1;
fg_setcolor(14);
fg_paint(x1,y1);
/* wait for a keystroke or a mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_points -- draw a nice pattern of points *
* *
\**********************************************************************/
do_points()
{
register int i,j;
int yinc;
/* clear the bottom part of the screen */
fg_mousevis(OFF);
fg_setclip(5,xlimit-5,menu_bottom,ylimit-4);
fg_setcolor(1);
fg_rect(5,xlimit-5,menu_bottom,ylimit-4);
yinc = 8;
/* draw the patterns of points */
fg_setcolor(15);
for (i = 7; i < xlimit; i+=20)
{
for (j = menu_bottom+2; j < ylimit; j+=yinc)
fg_point(i,j);
}
for (i = 17; i < xlimit; i+=20)
{
for (j = menu_bottom+yinc/2+2; j < ylimit; j+=yinc)
fg_point(i,j);
}
/* restore the clipping limits */
fg_setclip(0,fg_getmaxx(),0,fg_getmaxy());
/* wait for a keystroke or mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_polygons -- draw a polygon pattern with a 3-D effect *
* *
\**********************************************************************/
do_polygons()
{
register int i,j;
int vertices = 4;
static int xy_dkblue[] = {0,16, 24,0, 24,40, 0,56};
static int xy_ltblue[] = {24,0, 72,0, 72,40, 24,40};
static int xy_magenta[] = {0,56, 24,40, 72,40, 48,56};
int work_array[120];
fg_mousevis(OFF);
/* set the clipping limits */
fg_setclip(5,xlimit-5,menu_bottom,ylimit-4);
for (j = 0; j < 10; j++)
{
for (i = 0; i < 12; i++)
{
fg_polyoff(i*72-j*24,i*-16+j*56);
fg_setcolor(1);
fg_polyfill(xy_dkblue,work_array,vertices);
fg_setcolor(9);
fg_polyfill(xy_ltblue,work_array,vertices);
fg_setcolor(10);
fg_polyfill(xy_magenta,work_array,vertices);
}
}
/* restore the clipping limits */
fg_setclip(0,fg_getmaxx(),0,fg_getmaxy());
/* wait for a keystroke or mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_rects -- draw a pattern of solid rectangles *
* *
\**********************************************************************/
do_rects()
{
register int i,j;
int x0,x1,x2,y1,y2;
int xinc,yinc;
int color;
x0 = 5;
x1 = x0;
xinc = (xlimit - x0 - 1) / 10;
x2 = x1 + xinc;
yinc = (ylimit - menu_bottom) / 10;
y1 = menu_bottom;
y2 = y1 + yinc;
color = 0;
/* draw 100 solid rectangles */
fg_mousevis(OFF);
for (i = 0; i < 10; i++)
{
for (j = 0; j < 10; j++)
{
fg_setcolor(color);
fg_rect(x1,x2,y1,y2);
color++;
if (color > 14) color = 0;
x1 = x2;
x2 = x1 + xinc;
}
x1 = x0;
x2 = x1 + xinc;
y1 = y2;
y2 = y1 + yinc;
if (y2 > 345) y2 = 345;
}
/* wait for a keystroke or mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_text -- demonstrate ROM text *
* *
\**********************************************************************/
do_text()
{
register int i;
register int row;
int x1,x2,y1,y2;
static char *string[] = {
"Fastgraph allows you to display",
"ROM text, a stroke character font,",
"or define your own bitmapped font.",
"This message is displayed using",
"ROM text. The menus use bitmapped",
"characters."
};
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
/* convert rows and columns to x's and y's */
x1 = fg_xconvert(20);
x2 = fg_xconvert(60);
y1 = fg_yconvert(5);
y2 = fg_yconvert(13);
/* draw a small rectangle */
fg_setcolor(1);
fg_rect(x1,x2,y1,y2);
/* draw a white boarder around the box */
fg_setcolor(15);
fg_box(x1+1,x2-1,y1+1,y2-1);
/* put ROM text in the box */
row = 6;
for (i = 0; i < 6; i++)
{
fg_locate(row,23);
fg_text(string[i],strlen(string[i]));
row++;
}
/* wait for a keystroke or mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}