Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* A Mandelbrot renderer in a single MySQL-query. */
- /* Use a monospace-font to correctly display the output! */
- /* by niktator<at>live.com */
- SELECT if(ASCII(concat(
- @w:=180, /* width */
- @h:=72, /* height. max. resolution: w*h=78125 */
- @max_iter:=20, /* max. iterations - max.: 64 */
- @xmin:=-2.025, /* left */
- @xmax:=0.625, /* right */
- @ymin:=-1.25, /* top */
- @ymax:=1.25 /* bottom */
- ))+(@cm:=(4/@max_iter))+(@xs:=(@xmax-@xmin)/@w)+(@ys:=(@ymax-@ymin)/@h)+(@cnt:=0)+(@y0:=@ymin)+(@run:=1)+ASCII(@r:=SPACE(0))+(SELECT count(if(@run,if(mod(@cnt,@w),0,(@y0:=@y0+@ys)+if(@cnt,ASCII(@r:=concat(@r,0x0d0a)),0))+(@x0:=@xmin+mod(@cnt,@w)*@xs)+(@i:=@x:=@y:=0)+(@runi:=1)+(SELECT count(if(@runi,+(@xt:=@x*@x-@y*@y+@x0)+(@y:=2*@x*@y+@y0)+(@x:=@xt)+(@i:=@i+1)+if(@i=@max_iter or (@x*@x+@y*@y)>4,@runi:=0,0),0)) from (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) a CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) b CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) c)+(@c:=ceil(@i*@cm))+(@v:=(CASE when @c=4 then char(0xE29688 using utf8) when @c=3 then char(0xE29693 using utf8) when @c=2 then char(0xE29692 using utf8) else char(0xE29691 using utf8) END))+ASCII(@r:=concat(@r,@v))+(@cnt:=@cnt+1)+if(@cnt=@w*@h,(@run:=0),0),0)) FROM (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 ) a CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) b CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) c CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) d CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) e CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) f CROSS JOIN (SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) g),@r,0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement