One-liner challenge

I wanted to try a code-golf challenge:

m=1 repeat $1 { e {expr('$m+x',$>+1)} m+=$>+1 }

The above code prints pyramid of numbers. 47 bytes.

So, what does this do?

sample square 100%,100%,1,2,[x,y] +spiralbw {w},{h},0 negate. pixelsort.. +,xy,. rm. resize[-1] {wh},1,1,100%,-1 +pal wcmyk eval.. ">"color_ind=vector(#whd#-1,0);cur_col=I(#-3,I);repeat(s#-1,k,color_ind+=sqr(crop(#-1,0,0,0,k,w#-1,1,1,1)-cur_col[k]););color_ind=sqrt(color_ind);p=argmin(color_ind);color=I[#-1,p];quant_error=I(#-3,I)-color;I(#-3,J(1))+=quant_error*3/16;I(#-3,J(2))+=quant_error*5/16;I(#-3,I)=color; k[0]

I must admit the artifact is interesting:

Reminiscent of index, but mostly constrained in the amount of error diffusion it is allowed to do.

indexerrdiff: -check ${"is_image_arg $1"} -skip "${$2=1}"

   errdiff=$2
   pass$1 1
   index.. .,$errdiff,1
   rm.

 $ gmic /dev/shm/errdiff.gmic sp square,800 pal wcmyk -v + indexerrdiff.. .,0.375 rm.
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input custom command file '/dev/shm/errdiff.gmic' (1 new, total: 4572).
[gmic]-1./ Input sample image 'square' (1 image 800x533x1x3).
[gmic]-2./+pal/ Create palette(s) 'wcmyk'.
[gmic]-2./ Increment verbosity level (set to 2).
[gmic]-1./indexerrdiff/ Set local variable 'errdiff=0.375'.
[gmic]-1./indexerrdiff/ Insert image [1] from parent context in shared state.
[gmic]-2./indexerrdiff/ Index values in image [0] by LUT [1], with dithering level 0.375 and index mapping.
[gmic]-2./indexerrdiff/ Remove image [1] (1 image left).
[gmic]-2./ Remove image [1] (1 image left).
[gmic]-1./ Display image [0] = 'square'.
[0] = 'square':
  size = (800,533,1,3) [4996 Kio of float32].
  data = (0,0,0,0,0,0,0,0,0,0,0,0,(...),255,0,255,0,255,0,255,0,255,0,255,0).
  min = 0, max = 255, mean = 118.349, std = 127.171, coords_min = (0,0,0,0), coords_max = (1,1,0,0).

However, in your case, the means of error diffusion differs from that of index. If I were just glitching, anything goes, I suppose, but if I were driven by obtaining as smooth and uniform distribution of error as possible, Iā€™d be concerned with the diagonal seam artifacts visible in your example, (upper left hand corner, in the sky, as is less visible in the other corners) which ā€” if I am reading the expression correctly ā€” seems to be a characteristic of your half-toning image. Iā€™d have to sit down with this during a pleasant Sunday Morning After Breakfast period, and not going headlong into Manhattan. Not a good time to be parsing things.

Somewhat reminds me of Gmic Exercises - #960 also. Thank you for this fun, early morning exercise.

Zooming Julia Set Fractal:
gmic zoom=1 264,164,1,1 mx=0 my=0 do zoom*=1.01 mx+=({*0,x}-(w/2))/(10*$zoom*w) my+=({*0,y}-(h/2))/(10*$zoom*h) f. "max_iter=100;cx=-1;cy=-0.27815;wf=0.5*$zoom*w;hf=0.5*$zoom*h;zx=(1.5*(x-(w/2))/wf)+$mx;zy=((y-(h/2))/hf)+$my;for(i=max_iter,(zx*zx)+(zy*zy)<4 && i>1, tmp=(zx*zx)-(zy*zy)+cx;zy=(2*zx*zy)+cy;zx=tmp;i-=1);i" window. wait 50 while {*} rm

Not super refined, but works well enough.
image
image
image

3 Likes
gmic sp david kaleidoscope ,,30,100