home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
MM1
/
GRAPHICS
/
kwsaver25.lzh
/
programmer.lzh
/
kwsaver_lines.c
next >
Wrap
C/C++ Source or Header
|
1994-05-05
|
2KB
|
71 lines
/* kwsaver_lines.c */
/* by Joel Mathew Hegberg */
/* a simple kwsaver screen-saver program */
/* which runs on any type screen. */
/* Note: there is no exit to this program... it is killed when */
/* a signal is sent to it. This technique may be used */
/* since this program uses no K-Windows graphics buffers */
/* and requires no deinitialization before exiting... */
/* otherwise, a signal trap would have to be used. */
#include <stdio.h>
#define PATH 1
main()
{
int x1,y1,x2,y2,dx1,dy1,dx2,dy2,mx1,my1,mx2,my2,counter,color,maxcolors;
maxcolors=Get_Num_Colors(PATH); /* # of colors available on screen */
x1=50; x2=400; y1=100; y2=200; /* line starting coordinates */
dx1=2; dx2=-3; dy1=-1; dy2=2; /* line movement variables */
mx1=1; my1=1; mx2=3; my2=2; /* multipliers */
counter=0; color=1;
while(1)
{
FColor(PATH,color); /* set line color */
SetDPtr(PATH,x1,y1); /* start coordinate */
Line(PATH,x2,y2); /* draw the line */
/* next, move the line according to directionals */
x1+=dx1*mx1; x2+=dx2*mx2; y1+=dy1*my1; y2+=dy2*my2;
/* now, check if any directionals need to be reversed */
if (x1<0 || x1>639)
{
x1-=dx1*mx1;
dx1=-dx1;
if (++mx1>5) mx1=1;
}
if (x2<0 || x2>639)
{
x2-=dx2*mx2;
dx2=-dx2;
if (++mx2>5) mx2=1;
}
if (y1<0 || y1>207)
{
y1-=dy1*my1;
dy1=-dy1;
if (++my1>5) my1=1;
}
if (y2<0 || y2>207)
{
y2-=dy2*my2;
dy2=-dy2;
if (++my2>5) my2=1;
}
if (++counter>500) /* after 500 lines, clear the screen */
{
Clear(PATH);
counter=0;
}
if (++color>=maxcolors) color=1; /* select next color */
}
}