/*
this file demonstrates how to use the
Simple Graphical Interface
*/
#include <math.h>
main()
{
int ws;
while(1)
{
printf("\nChoose WS (1 X11, 2 Postscript, 3 REGIS, 4 TEKxxx, 5 Exit): ");
scanf("%d", &ws);
if( ws >= 1 && ws <= 4)
{
spirale( ws);
}
else
{
break;
}
}
return;
}
int spirale( int ws)
{
double t, r = 1.0;
double x, y;
int i = 0;
sgi_open( ws);
sgi_cls();
/*
Colours:
0 white
1 black
2 red
3 green
4 blue
5 ...
*/
sgi_colour( 2);
sgi_move_to( 0.5, 0.5);
sgi_text( "Hello world");
sgi_move_to( 1.0, 0.5);
for( t=0.; t < 200.; t += 0.1)
{
i++;
sgi_colour( i % 10);
y = 0.5*(r*sin(t) + 1.);
x = 0.5*(r*cos(t) + 1.);
r *= 0.999;
sgi_line_to( x, y);
}
sgi_move_to( 0.1, 0.1);
sgi_update();
sleep(2);
sgi_close();
}
|