• Welcome to Dark Bit Factory & Gravity.
 

MATHCOMP Grinch Dragon.

Started by Shockwave, November 30, 2006

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Shockwave

Here's a nice little fractal in Freebasic..


' Grinch Dragon By Shockwave.
' Thanks to Paul Bourke ( formula taken from his site ).
' Rbraz + Jim for PTC Lib.
'
'-------------------------------------------------------------------------------
    OPTION STATIC
    OPTION EXPLICIT

    CONST   XRES = 800:' SCREEN WIDTH
    CONST   YRES = 600:' SCREEN HEIGHT
   
    #include "ptc.bi"
   
    DIM SHARED AS UINTEGER BUFFER ( XRES * YRES ) :' SCREEN BUFFER
    DIM SHARED AS DOUBLE XX,YY,ZZ,S1,S2,B,A,R,D13,D23,X1,Y1
    DIM  AS INTEGER L,XPL,YPL ,GADD,OX,OY
    DIM AS UINTEGER COLOURS(YRES)
    FOR L=0 TO YRES
        COLOURS(L) = RGB(125+124*SIN(L/44),125+124*SIN(L/74),125+124*SIN(L/114))
    NEXT
   
    D13 = 1/3
    D23 = 2/3

    XX=RND(1)
    YY=RND(1)
    ZZ=RND(1)
   
    A=0
    B=0
   
    S1 = 500
    S2 = S1 * 750 / 1026
   
    RANDOMIZE TIMER
   
    B = 1 / (SQR(3))
    R = 2.0
   
    PTC_SETFLIP(1) :' SCREEN SYNC ON.
   
    ' OPEN THE SCREEN;
   
        IF ( PTC_OPEN ( "GRINCH DRAGON.", XRES, YRES ) = 0 ) THEN
        END -1
        END IF
   
    ' MAIN LOOP;

    WHILE(1)
        GADD=GADD+2
        OX=(160*SIN(GADD/200))+160
        OY=(200*COS(GADD/177))+200
        FOR L=1 TO 20000
            A = RND(1)
            IF A<=D13 THEN
                X1 = (XX+YY*B)/R
                Y1 = (B*XX-YY)/R
            END IF
            IF A>D13 AND A <=D23  THEN
                X1 = (XX-B*YY)/R+1/R
                Y1 = (-B *XX-YY)/R+B/R
            END IF
            IF A>=D23 THEN
                X1 = ( XX+YY*B)/R+1
                Y1 = -(B*XX-YY) / R
            END IF
            XX=X1
            YY=Y1
            IF L>10 THEN
                XPL = OX+S1*XX/(1+ZZ/4)-200
                YPL = OY + S2 * YY/(1+ZZ/4)
                IF XPL>0 AND XPL<XRES AND YPL>0 AND YPL<YRES THEN
                    BUFFER(XPL+(YPL*XRES)) = COLOURS(YPL)
                END IF
            END IF
        NEXT
       
        PTC_UPDATE@BUFFER(0)
        ERASE BUFFER
    WEND
Shockwave ^ Codigos
Challenge Trophies Won:

mind

neat.. i was thinking about making one of those.. or a koch snowflake thingy or one of them smoking ship fractals.. but i decided on the buddha for my first submission.. might whip up something else later.. i still have like 2-3 days, right?
Challenge Trophies Won:

taj

Nice picture but I was vaguely disappointed by the lack of sexual references in the code!  ::) THATS an IFS shockwave :-)
Challenge Trophies Won:

benny!

n1 shockwave. Like the structure and the gradient colors of it.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

MrP

Again very nice, dont know how you manage to make everything look like its got some old school flavour in it somewhere..... All Hail the old school king......

rdc


Shockwave

Old school king? :) I'm beaming but I don't deserve the accolade. Thanks for the comments :)
Shockwave ^ Codigos
Challenge Trophies Won:

Jim

Yeah, it's only the 'old' part you deserve :p

Jim
Challenge Trophies Won:

Shockwave

Fucking right :) Karma up for that Jim!
Shockwave ^ Codigos
Challenge Trophies Won:

lilw4t3rdr0p

I love it, but you already know that I like lots of color. And you are NOT OLD! I also like the old school feel!

:clap: