Skip to content

Instantly share code, notes, and snippets.

@hahastudio
Created November 19, 2012 10:29
Show Gist options
  • Save hahastudio/4110009 to your computer and use it in GitHub Desktop.
Save hahastudio/4110009 to your computer and use it in GitHub Desktop.
A Mandelbrot-Shaped Python Script that generate a Mandelbrot Fractal
_ = (
255,
lambda
V ,B,c
:c and Y(V*V+B,B, c
-1)if(abs(V)<6)else
( 2+c-4*abs(V)**-0.4)/i
) ;v, x=1500,1000;C=range(v*x
);import struct;P=struct.pack;M,\
j ='<QIIHHHH',open('M.bmp','wb').write
for X in j('BM'+P(M,v*x*3+26,26,12,v,x,1,24))or C:
i ,Y=_;j(P('BBB',*(lambda T:(T*80+T**9
*i-950*T **99,T*70-880*T**18+701*
T **9 ,T*i**(1-T**45*2)))(sum(
[ Y(0,(A%3/3.+X%v+(X/v+
A/3/3.-x/2)/1j)*2.5
/x -2.7,i)**2 for \
A in C
[:9]])
/9)
) )
@ambv
Copy link

ambv commented Feb 11, 2025

Python 3 version:

_                                      =   (
                                        255,
                                      lambda
                               V       ,B,c
                             :c   and Y(V*V+B,B,  c
                               -1)if(abs(V)<6)else
               (              2+c-4*abs(V)**-0.4)/i
                 )  ;v,   x=1500,1000;C=list(range(v*x)
                  );import struct,sys;P=struct.pack;M,I,\
            j  =  '<QIIHHHH',int,sys.stdout.buffer.write
for X in j(b'BM'+P(M,v*x*3+26,26,12,v,x,1,24)) and C:
            i  ,  Y=_;j(P('BBB',*(lambda T:(I(T*80+T**9
                  *i-950*T  **99),I(T*70-880*T**18+701.*
                 T  **9     ),I(T*i**(1-T**45*2))))(sum(
               [              Y(0,(A%3/3.+X%v+(X/v+
                               A/3/3.-x/2)/1j)*2.5
                             /x   -2.7,i)**2 for  \
                               A       in C
                                      [:9]])
                                        /9)
                                       )   )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment