#include "stdio.h" #include "stdlib.h" #include "math.h" #include "paulslib.h" /* Example that creates the burning ship fractal and saves it as a raw image file. */ typedef struct { char r,g,b; } BYTECOLOUR; #define MAXGRID 100 BYTECOLOUR image[MAXGRID][MAXGRID]; int main(int argc,char **argv) { int i,j,k,kmax=250; FILE *fptr; double dcx,dcy,dxy; double value; double cx,cy,xi,yi,xip1,yip1; if (argc < 5) { fprintf(stderr,"Usage: %s cx cy dxy outfilename\n",argv[0]); exit(0); } dcx = atof(argv[1]); dcy = atof(argv[2]); dxy = atof(argv[3]); for (j=0;j 200) break; } value = sqrt(k / (double)kmax); value *= value; image[i][j].r = 255 * value; image[i][j].g = image[i][j].r; image[i][j].b = image[i][j].r; } } fprintf(stderr,"Writing output image\n"); if ((fptr = fopen(argv[4],"w")) == NULL) { fprintf(stderr,"Error occured writing the image\n"); exit(0); } for (j=0;j