Author Topic: [Snippet] Playing with fractal rules  (Read 4454 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
[Snippet] Playing with fractal rules
« on: July 12, 2009 »
Hey :D I wanted to play a bit with fractals and It brought me to this. The basis rule is nearly the mandelbrot one but I added some trigonometric functions. Here's the result :) It's not fast, sorry for that, just wanted to share the thing :)

Code: [Select]
Screenres 640,480,32,2

Dim as Uinteger ptr Scrptr = Screenptr

Dim as single zx,zy,cx,cy,norm,oldzx,offsetX,t,offsetY,g,b
Dim as integer nbloops

cx = 1.23
cy = 0.44

Do
t+=.1
offsetX = cos(t)
offsetY = sin(t)
cx = t

screenlock : cls

For i as integer = -320 to 319
for j as integer = -240 to 239

zx = i*.01 + offsetX
zy = j*.01 + offsetY

nbloops = 0

do
oldzx = zx
zx = cos(zx*zx + 2*zx*zy + cx)
zy = sin(zy*zy + 2*zy*oldzx + cy)

nbloops+=1

if nbloops>2 then exit do

Loop

norm = (zx*zx+zy*zy)
g = norm
b = norm

if norm>1 then norm=1
if g>1 then g=1
if b>1 then b=1

norm*=255
g*=255
b*=255

ScrPtr[i+320+(j+240)*640] = rgb(norm,g,b)

next
next

screenunlock : sleep 1,1
Loop until multikey(&h01)


Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [Snippet] Playing with fractal rules
« Reply #1 on: July 12, 2009 »
Screenie looks nice. Having a quick look at the
source - it seems that this baby is in motion, too.

Any chance of an compiled version ?
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: [Snippet] Playing with fractal rules
« Reply #2 on: July 12, 2009 »
Here's an exe.

It's an interesting display :) I'd like to see an optimised version using tinyptc.
I cant recall ever seeing this pattern before.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [Snippet] Playing with fractal rules
« Reply #3 on: July 13, 2009 »
Thanks for the exe, Shocky.

It looks indeed very interesting and stylish!
[ 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: [Snippet] Playing with fractal rules
« Reply #4 on: July 13, 2009 »
Thanks a lot mates :D

Sorry for not posting any exe, i'm under debian and I can't get the cross-compiling to work :S

Shockie > Hum.. I never used tiny ptc (but that's a good occasion to learn :P I'll try it in my next code :) )

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: [Snippet] Playing with fractal rules
« Reply #5 on: July 13, 2009 »
tinyptc_ext++ is the best version to use mate.
You will find it in this freebasic board :D
Shockwave ^ Codigos
Challenge Trophies Won: