• Welcome to Dark Bit Factory & Gravity.
 

Short intro challenge 20 line fractal

Started by Shockwave, June 12, 2006

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Shockwave

Taking the Keftales and the Axial on a bit, also I've seen the Xor texture used in this comp, I decided to see if I could squeeze a proper fractal into 20 lines, I managed to squash the serpinski gasket down to 18 lines, could get it to 17 lines if I lost the windowed mode.


#define PTC_win
#Include Once "tinyptc.bi"
If( ptc_open( "DBF 18 LINE SERPINSKI GASKET FRACTAL BY SHOCKWAVE", 800, 600 ) = 1 ) Then dim shared buffer(800*600) as integer,points(1 to 8) as integer => { 400,5 , 5,595 , 795,595 , 400 , 5}
do     
    for n=0 to 250
        buffer((points(7)+(points(8)*800))) = rgb(n shr 2 ,n , n shr 1)
        r=int(rnd*3)+1
        if r=1 then
             points(7) = (points(7) + points(1))  shr 1
             points(8) = (points(8) + points(2))  shr 1
        elseif r=2 then points(7) = (points(7) + points(3)) shr 1
            points(8) = (points(8) + points(4)) shr 1
        elseif r=3 then points(7) = (points(7) + points(5)) shr 1
            points(8) = (points(8) + points(6)) shr 1
        end if
    next
ptc_update@buffer(0)
loop until inkey$<>""

Shockwave ^ Codigos
Challenge Trophies Won:

Shockwave

And here it is again, I have squashed this further, doing away with 5 lines to enable me to add some nice colours and rotate it in a nice way.
It's sort of a fake textured poly thing now :)


Still in 18 lines!!


#define ptc_win
#define dbfcls redim buffer(800*600)
#Include Once "tinyptc.bi"
If( ptc_open( "DBF 18 LINE ROTATING SERPINSKI GASKET FRACTAL BY SHOCKWAVE", 800, 600 ) = 1 ) Then dim shared points(8) as integer
  do 
    dbfcls     
    for a=1 to 6
        if a mod 2=0 then points(a) = 299*sin((a*120)+timer *2.5)+300 else if a mod 2 <>0 then points(a) = 399*cos((a*120)+timer *1.5)+400 end if       
        if a= 2 then points(7)=points(1) else if a=3 then points(8)=points(2) end if
    next               
    for n=0 to 25000
        buffer((points(7)+(points(8)*800))) = rgb(points(7) shr 2,points(8) shr 3+points(7) shr 3,points(8) shr 2)
        r=int(rnd*3)+1       
             points(7) = (points(7) + points(r*2-1))  shr 1
             points(8) = (points(8) + points(r*2))  shr 1       
    next
ptc_update@buffer(0)
loop until inkey$<>""
Shockwave ^ Codigos
Challenge Trophies Won:

Tetra

Good oneÃ,  :)
if only you could subdivide polys to fill them in ;)
Challenge Trophies Won:

Rbz

Quote from: Tetra on June 12, 2006
Good oneÃ,  :)
if only you could subdivide polys to fill them in ;)

Or change colors like a plasma effect... But still very smart for 18 lines of code :)
Challenge Trophies Won:

Shockwave

Shockwave ^ Codigos
Challenge Trophies Won: