dim as double x, y, x1, x11, y1, e1, e2, e3, s1, s2, z, c
screen 18, 32, 3
DIM image_buffer AS ANY PTR
   image_buffer = ImageCreate( 1280, 960, rgb(0,0,0))
   
   
   
   s1=1/1000
s2=2/1000

for x = -1 to 1 step s1
    for y = -1 to 1 step s2
        x1=x
        y1=y
        
        n=0
        
        again:
        
        n=n+1
        
        e1=(x1+1)^2+y1^2
        e2=(x1-1/2)^2+(y1+sqr(3)/2)^2
        e3=(x1-1/2)^2+(y1-sqr(3)/2)^2
        
        c=255/(((n-1)/10)^2+1)

        if e1<.0001 then
            color rgb(c,0,0)
            pset image_buffer, ((x+1)*640,(y+1)*480)
            goto loopout
        elseif e2<.0001 then
            color rgb (0,c,0)
            pset image_buffer, ((x+1)*640,(y+1)*480)
            goto loopout 
        elseif e3<.0001 then
            color rgb (0,0,c)
            pset image_buffer, ((x+1)*640,(y+1)*480)
            goto loopout
        endif
        

        
        
            x11=-(x1^2-y1^2)/(3*(x1^4+2*x1^2*y1^2+y1^4))+2*x1/3
            
            y1=2*y1/3+(2*x1*y1)/(3*(x1^4+2*x1^2*y1^2+y1^4))
            x1=x11
        
            goto again
        loopout:
    next
next

s=1

c=-200

do

screenset 2, 1

cls
PUT(1+c,1+c ), image_buffer, PSET

c=c+.25*s

if c > 0 then s=-1
if c < -450 then s = 1

screenset 1, 2

cls
PUT(1+c,1+c ), image_buffer, PSET

c=c+.25*s

if c > 0 then s=-1
if c < -450 then s = 1




loop while inkey$=""

