summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--attract.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/attract.c b/attract.c
index 16f1703..47f4a42 100644
--- a/attract.c
+++ b/attract.c
@@ -15,7 +15,7 @@
const int MAXITER=200;
const double EPS=1e-1;
-static double complex att_func(double complex x){
+static double complex att_func(double complex x,double exponent){
#if 0
static const int N=9;
@@ -27,8 +27,7 @@ static double complex att_func(double complex x){
r+=y;
return clog(r);
#else
- static const double N=8.5;
- return clog((1-cpow(x,N+1))/(1-x));
+ return clog((1-cpow(x,exponent+1))/(1-x));
#endif
}
@@ -49,8 +48,9 @@ static struct colour make_colour(int index){
}
struct config{
- const double unitsz;
- const int width,height;
+ double unitsz;
+ int width,height;
+ double exponent;
};
struct thread_info{
@@ -86,7 +86,7 @@ static void* thread_entry(void *arg_vp){
(double)(iy-cfg.height/2)/cfg.unitsz);
double complex z=start;
for(int i=0;i<MAXITER;i++){
- z=att_func(z);
+ z=att_func(z,cfg.exponent);
}
if(do_basins){
int bi;
@@ -121,8 +121,9 @@ static void* thread_entry(void *arg_vp){
int main(void){
struct config cfg={
- 200,
- 500, 500
+ .unitsz=200,
+ .width=500, .height=500,
+ .exponent=8.5
};
unsigned char img[cfg.width*cfg.height*3];
@@ -145,7 +146,7 @@ int main(void){
ths[i].yend=(i+1)*cfg.height/nthreads;
ths[i].img=img;
ths[i].do_basins=nthreads==1;
- memcpy(&ths[i].cfg,&cfg,sizeof(struct config));
+ ths[i].cfg=cfg;
int ret=pthread_create(&ths[i].th,&attr,thread_entry,&ths[i]);
if(ret!=0){
perror("pthread_create");