You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The origin palette function does make a bad sence to human vision , the dark and cycled color let eyes go tired .
I'd like to recommend a new function to paint here .
It is based on the times of iteration . While the number of colors is much less than the times of iter , it is important to alloc a reasonable range of color to each iter time . The "number of pixels - iter times" function is just like y=1/x , less iter time means more area , while the larger iter time corresponds to the detail of fractal . So it can make the final image more beautiful by letting each color occupy the same area of the above function .
It definitely makes a better view .
structimage{
int *step;//iteration times
byte *black;//it is 3 when the point goes to infinity
};
boolcheck(int n,int *cnt,int p,int *lim,int g){//(pixels*iter time range) should be equal to each color .
u64 lc=0,lp=0,mul=1;
int i,j,k,cc;
for(i=0,k=0;i<n;++i){
for(j=0,cc=0;j<cnt[i];++j){
++lc;
if(lc*((j+1)*mul+lp*cnt[i])>g*mul*cnt[i]){
lc=0;lp=0;
mul=cnt[i];
lim[k++]=i;
if(++cc>16)--k;//to limit each iter time up to 16 colorsif(k>=p)return0;
}
}
if(lc>=cnt[i])lp+=mul;
else lp+=lc;
}return1;
}
intsplix(int n,int *cnt,int p,int *lim){
int l=0,r=n*p,m;
while(l+1!=r){
m=(l+r)>>1;
if(check(n,cnt,p,lim,m))r=m;
else l=m;
}check(n,cnt,p,lim,r);
return r;
}
voidsmooth(image g){
int max=0,min=1<<30,n=0,k=sx*sy,*cnt,*lim,i,j;
for(i=0;i<k;++i)if(g.black[i]==3){
if(max<g.step[i])max=g.step[i];
if(min>g.step[i])min=g.step[i];
}
if(min==(1<<30))return;
max=max-min+1;
cnt=newint[max];
for(i=0;i<max;++i)cnt[i]=0;
for(i=0;i<k;++i)if(g.black[i]==3)++cnt[g.step[i]-min];
lim=newint[512];//say we have 512 colors in totalsplix(max,cnt,512,lim);
for(i=j=0;i<512;++i)for(;j<=lim[i]&&j<max;++j)cnt[j]=i;
for(i=0;i<k;++i)if(g.black[i]==3)g.step[i]=cnt[g.step[i]-min];
delete cnt;
delete lim;
}
The colors should be picked up in the color ring . Bright colors refresh eyes .
rgb getrgb(double h){//h is in [0,1)while(h>=1)h-=1;
double x=h*6,r=0,g=0,b=0;
while(x>=2)x-=2;
if(x>1)x=2-x;
int a=h*6;
if(a==0||a==5)r=1;
elseif(a==1||a==2)g=1;
else b=1;
if(a==1||a==4)r=x;
elseif(a==0||a==3)g=x;
else b=x;
byte r0=r*255,g0=g*255,b0=b*255;
return (rgb){r0,g0,b0};
}
The text was updated successfully, but these errors were encountered:
The origin palette function does make a bad sence to human vision , the dark and cycled color let eyes go tired .
I'd like to recommend a new function to paint here .
It is based on the times of iteration . While the number of colors is much less than the times of iter , it is important to alloc a reasonable range of color to each iter time . The "number of pixels - iter times" function is just like y=1/x , less iter time means more area , while the larger iter time corresponds to the detail of fractal . So it can make the final image more beautiful by letting each color occupy the same area of the above function .
It definitely makes a better view .
The colors should be picked up in the color ring . Bright colors refresh eyes .
The text was updated successfully, but these errors were encountered: