home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d5xx
/
d584
/
spli.lha
/
SpLi
/
SpLi.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-04
|
3KB
|
145 lines
/******************************************
* *
* Sphere-Lissajous.c - Lissajous Curves *
* *
* written by C.Raufuß of ! WIZARD WORKS ! *
* *
* with SAS/C 5.10, on 06/04/91 *
* *
* Version 1.00 *
* *
******************************************/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
int CXBRK(void) { return(0); }
int chkabort(void) { return(0); }
void main(int argc,char **argv)
{
struct IntuitionBase *IntuitionBase=NULL;
struct GfxBase *GfxBase=NULL;
struct IntuiMessage *IMsg;
struct Screen *s=NULL;
struct NewScreen ns =
{
0,0,
640,256,
2,
1,0,
HIRES,
CUSTOMSCREEN,
NULL,
NULL,
NULL,
NULL
};
struct Window *w=NULL;
struct NewWindow nw =
{
0,0,
640,256,
-1,-1,
MOUSEBUTTONS,
BORDERLESS|SMART_REFRESH|ACTIVATE|RMBTRAP,
NULL,NULL,
NULL,
NULL,
NULL,
NULL,NULL,
NULL,NULL,
CUSTOMSCREEN
};
ULONG class;
double a,b,m,n,o,x,y,z;
register int t;
if(argc!=3)
{
printf("Sphere Lissajous v1.00 by C.Raufuß ©1991\nUsage: SpLi a b\n");
goto cleanexit;
}
printf("Sphere Lissajous v1.00 by C.Raufuß of ! WIZARD WORKS ! ©1991\n");
a=atof(argv[1]);
b=atof(argv[2]);
if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0)))
{
goto cleanexit;
}
if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0)))
{
goto cleanexit;
}
if(!(s=(struct Screen *)OpenScreen(&ns)))
{
goto cleanexit;
}
nw.Screen=s;
if(!(w=(struct Window *)OpenWindow(&nw)))
{
goto cleanexit;
}
/******** Lissajous Algorithm ***********/
SetAPen(w->RPort,(ULONG)3);
DrawEllipse(w->RPort,(ULONG)320,(ULONG)128,(ULONG)240,(ULONG)120);
for(t=0;t<=100000;t++)
{
m=a*t;
n=b*t;
o=sin(m);
x=o*cos(n);
y=o*sin(n);
z=cos(m);
SetAPen(w->RPort,(ULONG)1);
WritePixel(w->RPort,(ULONG)((x*240)+320),(ULONG)((z*120)+128));
SetAPen(w->RPort,(ULONG)2);
WritePixel(w->RPort,(ULONG)((x*240)+320),(ULONG)((y*120)+128));
if((IMsg=(struct IntuiMessage *)GetMsg(w->UserPort)))
{
class=IMsg->Class;
ReplyMsg((struct Message *)IMsg);
if(class==MOUSEBUTTONS) goto cleanexit;
}
}
/****************************************/
Wait(1<<w->UserPort->mp_SigBit);
cleanexit:
if(w)
{
CloseWindow((struct Window *)w);
}
if(s)
{
CloseScreen((struct Screen *)s);
}
if(GfxBase)
{
CloseLibrary((struct GfxBase *)GfxBase);
}
if(IntuitionBase)
{
CloseLibrary((struct IntuitionBase *)IntuitionBase);
}
}