Author Topic: Fractal "standalone" (fullscreen fixed)  (Read 6191 times)

0 Members and 1 Guest are viewing this topic.

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Fractal "standalone" (fullscreen fixed)
« 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
« Last Edit: October 26, 2008 by Hezad »

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Fractal "standalone" (new colors/alpha/res/etc..)
« Reply #1 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
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Fractal "standalone" (new colors/alpha/res/etc..)
« Reply #2 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

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Fractal "standalone" (fullscreen fixed)
« Reply #3 on: October 26, 2008 »
Fractal effects are always nice to look at, nice work :)
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Fractal "standalone" (fullscreen fixed)
« Reply #4 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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Fractal "standalone" (fullscreen fixed)
« Reply #5 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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Fractal "standalone" (fullscreen fixed)
« Reply #6 on: October 28, 2008 »
Oh my..

That looks really effective Hezad :D
Well done that man!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Fractal "standalone" (fullscreen fixed)
« Reply #7 on: October 28, 2008 »
Hey thanks mate :)

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Fractal "standalone" (fullscreen fixed)
« Reply #8 on: November 03, 2008 »
@Hezad:
any compiled/exe version available for testing? thx
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Fractal "standalone" (fullscreen fixed)
« Reply #9 on: November 03, 2008 »
Sure :)

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Fractal "standalone" (fullscreen fixed)
« Reply #10 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 !
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Fractal "standalone" (fullscreen fixed)
« Reply #11 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:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Fractal "standalone" (fullscreen fixed)
« Reply #12 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!
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Fractal "standalone" (fullscreen fixed)
« Reply #13 on: November 23, 2008 »
thanks  ;D

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Fractal "standalone" (fullscreen fixed)
« Reply #14 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


Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Fractal "standalone" (fullscreen fixed)
« Reply #15 on: November 30, 2008 »
Thanks  :cheers: