Atari 520ST fractals (very simple)
Gyorgy Fekete
gyuri at cvl.UUCP
Fri Aug 9 13:20:26 AEST 1985
Enjoy:
--------------------------------------------------------------------
#include <osbind.h>
extern double sqrt();
int contrl[12], intin[256], ptsin[256], intout[256], ptsout[256];
int x_boundary;
int y_boundary;
double x_realpart;
double y_imagpart;
double x_plus_y_squared;
double window_size;
double temp_x,temp_y,temp1,temp2,temp3;
double x,y,tempr;
int i,plot_x,plot_y,count,num_random;
int dummy,handle,pxy[4],kbak;
int mx,my,width,height;
int rgb_in[3];
char decimal[80];
main()
{
x=0.50001;
y=0.;
/* The following is the setup to use the VDI and AES */
/* Set the system up to do GEM calls*/
appl_init();
/* Get the handle of the desktop */
handle=graf_handle(&width,&height,&dummy,&dummy);
/* Open the workstation. */
for (i=1; i<10; ++i) intin[i] = i;
intin[10] = 2;
v_opnvwk(intin, &handle, intout);
pxy[0]=0; pxy[1]=0; pxy[2]=intout[0]; pxy[3]=intout[1];
x_boundary=pxy[2]/2;
y_boundary=pxy[3]/2;
vs_clip(handle,1,pxy); /*turn on clipping*/
graf_mouse(3,&dummy);
/* The setup is now complete */
restart: rgb_in[0]=1000;
rgb_in[1]=1000;
rgb_in[2]=1000;
vs_color(handle,0,rgb_in);
v_hide_cursor(handle);
v_clrwk(handle);
v_gtext(handle,0,height*10,"Fractal drawing program by");
v_gtext(handle,0,height*11,"Alex Leavens and Leonard Tramiel");
v_gtext(handle,0,height*13,"Please enter x,y and window size, using");
v_gtext(handle,0,height*14,"the mouse and the bar. Left edge is 0,");
v_gtext(handle,0,height*15,"right edge of bar is 4.");
v_gtext(handle,0,height*17,"To input new starting values,");
v_gtext(handle,0,height*18,"press any key while program is");
v_gtext(handle,0,height*19,"drawing. To exit, press F1.");
v_gtext(handle,0,height*21,"Note: This program DOES take a while");
v_gtext(handle,0,height*22,"to run, especially in the monochrome");
v_gtext(handle,0,height*23,"mode. Just hang in there!");
/* Set color of polyline used to draw points */
vsl_color(handle,2);
v_show_cursor(handle,0);
initial();
for(count=0;count<10;++count)
{
function();
}
/*Now clear the screen*/
v_clrwk(handle);
rgb_in[0]=0;
rgb_in[1]=0;
rgb_in[2]=0;
vs_color(handle,0,rgb_in);
/* Now plot points */
while((evnt_multi(0x0021,
0,0,0,
0,0,0,0,0,
0,0,0,0,0,
&dummy,
0,0,
&dummy,&dummy,&dummy,
&dummy,&kbak,&dummy))==0x0020)
{
plotpoint();
function();
}
if (kbak!=0x3b00) goto restart;
rgb_in[0]=1000;
rgb_in[1]=1000;
rgb_in[2]=1000;
vs_color(handle,0,rgb_in);
v_clsvwk(handle);
}
/*-----------------End of main()---------------------*/
function()
{
temp_x=x;
temp_y=y;
x=temp_x * x_realpart - temp_y * y_imagpart;
y=temp_x * y_imagpart + temp_y * x_realpart;
x=1.-x;
temp1=y;
x_plus_y_squared=(x * x) + (y * y);
x_plus_y_squared=sqrt(x_plus_y_squared);
temp3=(x_plus_y_squared - x) / 2.;
if(temp3<0.)
temp3=temp3 * (-1.);
y=sqrt(temp3);
temp3=(-x) + x_plus_y_squared;
if(temp3<0.)
y=y * (-1.);
temp3=(x + x_plus_y_squared) / 2.;
if(temp3<0.)
temp3=temp3 * (-1.);
x=sqrt(temp3);
temp3=x + x_plus_y_squared;
if(temp3<0.)
x=x * (-1.);
if(temp1<0.)
x=x * (-1.);
num_random=rand();
if(num_random<16000)
{
x=x * (-1.);
y=y * (-1.);
}
x=1.-x;
x=x/2.;
y=y/2.;
}
/*-----------------End of Doroot()----------------------*/
plotpoint()
{
temp1=window_size * (x - .5) + x_boundary;
temp2=y_boundary - window_size * y;
plot_x=temp1;
plot_y=temp2;
Plot(plot_x,plot_y);
}
/*---------------END plotpoint()---------------------*/
initial()
{
/* Scale the values, depending upon what monitor is in use... */
temp3=x_boundary * 2.;
temp3=temp3 / 4.;
/* Get the x value of the equation... */
v_hide_cursor(handle);
v_gtext(handle,0,height,"what is x-->");
pxy[0]=0;pxy[1]=2*height;pxy[2]=2*x_boundary;pxy[3]=3*height;
v_bar(handle,pxy);
v_show_cursor(handle,0);
evnt_button(1,1,1,&mx,&my,&dummy,&dummy);
evnt_button(1,1,0,&dummy,&dummy,&dummy,&dummy);
v_hide_cursor(handle);
x_realpart=mx;
x_realpart=x_realpart / temp3; /*scale 0-200 to real # 0-4 */
ftoa(x_realpart,decimal,6);
decimal[79]=0; v_gtext(handle,width,4*height,decimal);
/* Get the y value of the equation */
v_gtext(handle,0,height,"what is y-->");
pxy[0]=0;pxy[1]=2*height;pxy[2]=2*x_boundary;pxy[3]=3*height;
v_bar(handle,pxy);
v_show_cursor(handle,0);
evnt_button(1,1,1,&mx,&my,&dummy,&dummy);
evnt_button(1,1,0,&dummy,&dummy,&dummy,&dummy);
v_hide_cursor(handle);
y_imagpart=mx;
y_imagpart=y_imagpart / temp3; /*scale 0-200 to real # 0-4 */
ftoa(y_imagpart,decimal,6);
decimal[79]=0; v_gtext(handle,width,4*height,decimal);
/* calculate values for the program */
x_plus_y_squared=(x_realpart * x_realpart) + (y_imagpart * y_imagpart);
x_realpart=4 * x_realpart/x_plus_y_squared;
y_imagpart=(-4) * y_imagpart/x_plus_y_squared;
/* Get the window size ... */
v_gtext(handle,0,height,"what's the window size-->");
pxy[0]=0;pxy[1]=2*height;pxy[2]=2*x_boundary;pxy[3]=3*height;
v_bar(handle,pxy);
v_show_cursor(handle,0);
evnt_button(1,1,1,&mx,&my,&dummy,&dummy);
evnt_button(1,1,0,&dummy,&dummy,&dummy,&dummy);
window_size=mx;
window_size=window_size / temp3; /* scale to 0-4 real */
tempr=2.; tempr=tempr * x_boundary;
window_size=tempr/ window_size;
ftoa(window_size,decimal,6);
v_hide_cursor(handle);
decimal[79]=0; v_gtext(handle,width,4*height,decimal);
}
/*------------------rand()-----------------*/
/*This function will return a 16 bit random number*/
rand()
{
return(Random()&0xffff);
}
/*__________End of rand_________________*/
/*------------Plot(x,y)------------------*/
Plot(x,y)
{
int pxy[4];
pxy[0]=x; pxy[1]=y; pxy[2]=x; pxy[3]=y;
v_pline(handle,2, pxy);
}
/*------------------End of Plot (x,y)---------------*/
--
Gyorgy Fekete --- University of MD, Computer Vision Lab, (301) 454-4526
gyuri at cvl.{ARPA,CSNet}
...seismo \
...allegra +-- !umcp-cs!cvl!gyuri.UUCP
...brl-bmd /
More information about the Comp.sources.unix
mailing list