diff options
-rw-r--r-- | attract.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -46,6 +46,7 @@ static struct colour make_colour(double complex z){ struct config{ double unitsz; int width,height; + double midx,midy; double exponent; }; @@ -78,8 +79,8 @@ static void* thread_entry(void *arg_vp){ for(int iy=ystart;iy<yend;iy++){ for(int ix=0;ix<cfg.width;ix++){ const double complex start=CMPLX( - (double)(ix-cfg.width/2)/cfg.unitsz, - (double)(iy-cfg.height/2)/cfg.unitsz); + (double)(ix-cfg.width/2)/cfg.unitsz+cfg.midx, + (double)(iy-cfg.height/2)/cfg.unitsz+cfg.midy); double complex z=start; for(int i=0;i<MAXITER;i++){ z=att_func(z,cfg.exponent); @@ -115,12 +116,25 @@ static void* thread_entry(void *arg_vp){ } int main(int argc,char **argv){ + const double minx=-1.5,miny=-1.5; + const double maxx=1.5,maxy=1.5; + const double width=500; + struct config cfg={ - .unitsz=200, - .width=500, .height=500, + .unitsz=width/(maxx-minx), + .width=width, .height=width*(maxy-miny)/(maxx-minx), + .midx=(maxx+minx)/2, .midy=(maxy+miny)/2, .exponent=8.5 }; + printf("Config:\n"); + printf("unitsz = %lf\n",cfg.unitsz); + printf("width = %d\n",cfg.width); + printf("height = %d\n",cfg.height); + printf("midx = %lf\n",cfg.midx); + printf("midy = %lf\n",cfg.midy); + printf("exponent = %lf\n",cfg.exponent); + if(argc>=2){ cfg.exponent=strtod(argv[1],NULL); } |