Dark Bit Factory & Gravity

GENERAL => Projects => Topic started by: Hezad on October 25, 2008

Title: Fractal "standalone" (fullscreen fixed)
Post by: Hezad on October 25, 2008
Hey :)

I hesitated before starting a new topic because the basis of this code has been used in "Cities" (the fractal part). But since I worked on a "standalone" version for the fractal to be directly visible, I decided to start a new thread. If there's something wrong with this, please suppress this post, I'll repost in the "Cities" thread  ;)

Okay so there are new colors and alpha stuff .. I'm quite glad of the graphics, it's imho good-looking, but I'll let you "judge" this yourself  ;D

Code: [Select]
#include "fbgfx.bi"

Const BGND_COLOR as integer = rgb(15,15,15)

Screenres 320,200,32,2,fb.gfx_alpha_Primitives or fb.GFX_FULLSCREEN

dim shared as single CURVATURE1 = 1
dim shared as single CURVATURE2 = 1

Dim shared as any ptr Particule

Particule = ImageCreate(5,5)

dim shared as single AMPLITUDE1 = .7
dim shared as single AMPLITUDE2 = -.7

For i as integer = -2 to 2
    For j as integer = -2 to 2
        Pset Particule,(i,j),rgb(200,230,255)
    next
next


Sub SpreadTrigo(x as single, y as single, Amp as single, Angle as single, alpha as integer=255)
   
    If alpha<=110 then exit sub
   
    dim as single sa,ca,cca,ssa
    Dim as integer cR,cG,cB
   
    cca = cos(angle)
    ssa = sin(angle)
    ca = amp*cca
    sa = amp*ssa
   
    if alpha<220 then

        dim as integer xd,yd
       
        Cr = 60+35*cca
        Cg = 80+30*ssa
        Cb = 170+55*cca
       
        '' new
       
        xd = (160+(x+ca)*.4) mod 320
        yd = (100+(y-sa)*.4) mod 200
       
        if xd<0 then xd = (320+xd) mod 320
        if yd<0 then yd = (200+yd) mod 200
       
        Line(xd-2,yd-2)-(xd+2,yd+2),rgba(cr,cg,cb,alpha*.1),bf
        Put(xd-2,yd-2),Particule,alpha,alpha*.1
       
        '' old for "motion blur"
       
        xd = (160+(x+ca+ca)*.38) mod 320
        yd = (100+(y-sa-sa)*.38) mod 200
       
        if xd<0 then xd = (320+xd) mod 320
        if yd<0 then yd = (200+yd) mod 200
       
        Line(xd-2,yd-2)-(xd+2,yd+2),rgba(cr,cg,cb,alpha*.05),bf
        Put(xd-2,yd-2),Particule,alpha,alpha*.05
    end if
   
    SpreadTrigo(x-ca,y+sa,Amp*AMPLITUDE1,Angle+CURVATURE1,alpha-12)
    SpreadTrigo(x+ca,y-sa,amp*AMPLITUDE2,Angle+CURVATURE2,alpha-10)
   
End Sub
       
dim as single angle=3.1415
dim as integer mx,my

setmouse ,,0

do : screenlock : cls
   
    Paint(0,0),BGND_COLOR
   
    Spreadtrigo(100*cos(angle),100*sin(angle),100,angle)
   
    angle -= .01
   
    Curvature2 -= .005
    Curvature1 -= .00025
   
    Amplitude2 = .7+.05*sin(angle*2)
   
screenunlock : sleep 1,1
Loop until multikey(&h01)

setmouse ,,1

imageDestroy Particule
Title: Re: Fractal "standalone" (new colors/alpha/res/etc..)
Post by: Shockwave on October 25, 2008
It looks like it's made of 3D cubes in windowed mode :D

This would look totally brilliant if it was rendered out of GLUspheres in opengl :D
Title: Re: Fractal "standalone" (new colors/alpha/res/etc..)
Post by: Hezad on October 26, 2008
hey ! hum yeah it's a nice idea :D I may try this with Open gl.


Still, I fixed this version to run full screen under all windows versions (I just learned Vista can't render resolution lower then 640*480 in full-screen). Here is the code :


Code: [Select]
#include "fbgfx.bi"

Const BGND_COLOR as integer = rgb(15,15,15)

Screenres 640,480,32,2,fb.gfx_alpha_Primitives or fb.GFX_FULLSCREEN

dim shared as single CURVATURE1 = 1
dim shared as single CURVATURE2 = 1

Dim shared as any ptr Particule

Particule = ImageCreate(5,5)

dim shared as single AMPLITUDE1 = .7
dim shared as single AMPLITUDE2 = -.7

For i as integer = -2 to 2
    For j as integer = -2 to 2
        Pset Particule,(i,j),rgb(200,230,255)
    next
next


Sub SpreadTrigo(x as single, y as single, Amp as single, Angle as single, alpha as integer=255)
   
    If alpha<=110 then exit sub
   
    dim as single sa,ca,cca,ssa
    Dim as integer cR,cG,cB
   
    cca = cos(angle)
    ssa = sin(angle)
    ca = amp*cca
    sa = amp*ssa
   
    if alpha<220 then

        dim as integer xd,yd
       
        Cr = 60+35*cca
        Cg = 80+30*ssa
        Cb = 170+55*cca
       
        '' new
       
        xd = (320+(x+ca)*.4) mod 640
        yd = (240+(y-sa)*.4) mod 480
       
        if xd<0 then xd = (320+xd) mod 640
        if yd<0 then yd = (200+yd) mod 480
       
        Line(xd-2,yd-2)-(xd+2,yd+2),rgba(cr,cg,cb,alpha*.1),bf
        Put(xd-2,yd-2),Particule,alpha,alpha*.1
       
        '' old for "motion blur"
       
        xd = (320+(x+ca+ca)*.38) mod 640
        yd = (240+(y-sa-sa)*.38) mod 480
       
        if xd<0 then xd = (320+xd) mod 640
        if yd<0 then yd = (200+yd) mod 480
       
        Line(xd-2,yd-2)-(xd+2,yd+2),rgba(cr,cg,cb,alpha*.05),bf
        Put(xd-2,yd-2),Particule,alpha,alpha*.05
    end if
   
    SpreadTrigo(x-ca,y+sa,Amp*AMPLITUDE1,Angle+CURVATURE1,alpha-12)
    SpreadTrigo(x+ca,y-sa,amp*AMPLITUDE2,Angle+CURVATURE2,alpha-10)
   
End Sub
       
dim as single angle=3.1415
dim as integer mx,my

setmouse ,,0

do : screenlock : cls
   
    Paint(0,0),BGND_COLOR
   
    Spreadtrigo(100*cos(angle),100*sin(angle),200,angle)
   
    angle -= .01
   
    Curvature2 -= .005
    Curvature1 -= .00025
   
    Amplitude2 = .7+.05*sin(angle*2)
   
screenunlock : sleep 1,1
Loop until multikey(&h01)

setmouse ,,1

imageDestroy Particule
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: Rbz on October 26, 2008
Fractal effects are always nice to look at, nice work :)
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: Clyde on October 27, 2008
Looks amazing dude, great job.

I dont know what version of Freebasic you are using but in Fb20b in line 5: Screenres 640,480,32,2,fb.gfx_alpha_Primitives or fb.GFX_FULLSCREEN

It says implicit variable allocation at the fb.gfx_alpha_primitives or fb.GFX_FULLSCREEN parts.
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: Hezad on October 27, 2008
thanks :)

Quote
I dont know what version of Freebasic you are using but in Fb20b in line 5: Screenres 640,480,32,2,fb.gfx_alpha_Primitives or fb.GFX_FULLSCREEN

It says implicit variable allocation at the fb.gfx_alpha_primitives or fb.GFX_FULLSCREEN parts.

oh .. Well I'm using v0.18 (yeah i'm a bit late..) and to be honest, I don't have any idea about what can cause this :S
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: Shockwave on October 28, 2008
Oh my..

That looks really effective Hezad :D
Well done that man!
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: Hezad on October 28, 2008
Hey thanks mate :)
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: va!n on November 03, 2008
@Hezad:
any compiled/exe version available for testing? thx
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: Hezad on November 03, 2008
Sure :)
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: benny! on November 04, 2008
@Hezad:
Thanks for supplying exe. It just looks fantastic.
Somehow it seems it morphs from an L-System
generated tree/leaf to another fractal and then
to a snow-flake fractal. Very cool. And it runs
very smooth here too.

Thumb up !
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: Hezad on November 04, 2008
thanks a lot :)

Oh and yeah :"L-System", I was looking for this expression for days, I could'nt remember  :updance:
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: va!n on November 23, 2008
@Hezad:
Wow! The effect looks really very cool (like 3d cubes as shockwave said before) and works very smooth here!
I like esp. the very nice morphing from one to another object... amazing cool! Thanks for the exe!
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: Hezad on November 23, 2008
thanks  ;D
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: bikerboy on November 30, 2008
it's really really nice :goodpost: , if you guys make a demo or something you should definitely put this one inside, it's top stuff ;D
Title: Re: Fractal "standalone" (fullscreen fixed)
Post by: Hezad on November 30, 2008
Thanks  :cheers: