matthew Global Moderator
     member is offline
![[avatar] [avatar]](http://matthew-4gl.wikispaces.com/space/showimage/ken_4_basic4gl_large.gif)
![[aim] [aim]](http://s2.images.proboards.com/aim.gif)
![[homepage] [homepage]](http://s2.images.proboards.com/buttons/www_sm.gif) Joined: Apr 2006 Gender: Male  Posts: 1,861 Location: England
|  | Crazy Fractal Patterns « Thread Started on May 19, 2007, 12:43pm » | |
I came across this Programme when I was browsing through the FreeBasic Forum. 
I thought I'd convert it to Basic4GL. 
![[image] [image]](http://matthew-4gl.wikispaces.com/space/showimage/FreeBasic_Original_Crazy_Fractal_Patterns.png)
Just leave the Programme Running and it will draw Crazy Patterns on your Screen. 
Code:' This Programme is Based on One I found on the FreeBASIC Forum... '
' Define Our Variables and Constants here... '
Dim j#, k#, x#, Xx#, y# Dim XSize, YSize, i, Xp, Yp, RidX, XOffs, YOffs, c1, c2, c3
' Initialise any Variables and Constants here... '
XSize = WindowWidth() YSize = WindowHeight()
XOffs = (XSize / 2) YOffs = (YSize / 2) - 60
' Create a 2D Screen... '
glMatrixMode (GL_PROJECTION) glLoadIdentity () glOrtho (0, XSize, YSize, 0, 0, 1) glMatrixMode (GL_MODELVIEW) glDisable (GL_DEPTH_TEST) glDrawBuffer (GL_FRONT)
' Generate True Random Numbers... ' Randomize()
' Draw Our Scene... '
While TRUE
glClearColor (0.0, 0.0, 0.0, 0.0) glClear (GL_COLOR_BUFFER_BIT)
j# = Rnd() % 100 k# = Rnd() % 100 x# = 0 y# = 0 c1 = Rnd() % 255 c2 = Rnd() % 255 c3 = Rnd() % 255 For i = 0 to 500000 RidX = Rnd() % 4000 If RidX > 3998 then c1 = Rnd() % 255 c2 = Rnd() % 255 c3 = Rnd() % 255 EndIf Xx# = y# - Sgn(x#) * Sqr(Abs(k# * x# - 1)) y# = j# - x# x# = Xx# Xp = (x# * 2) + XOffs Yp = (y# * 2) + YOffs glBegin(GL_POINTS) glColor3ub(c1, c2, c3) glVertex2f(Xp, Yp) glEnd() glFlush()
Next
Wend
|
|
|
|
|
Nicky Peter Hollyoake Global Moderator
     member is offline
![[avatar] [avatar]](http://photos-b.ak.fbcdn.net/hphotos-ak-snc1/hs268.snc1/9520_1196013874092_1640842698_548013_2731706_n.jpg)
You only see what you believe.
Joined: Apr 2006 Gender: Male  Posts: 1,968 Location: uk
|  | Re: Crazy Fractal Patterns « Reply #1 on May 19, 2007, 1:47pm » | |
Excellent programme. The one you shown up there looks like some kinda spider web.
| |
|
matthew Global Moderator
     member is offline
![[avatar] [avatar]](http://matthew-4gl.wikispaces.com/space/showimage/ken_4_basic4gl_large.gif)
![[aim] [aim]](http://s2.images.proboards.com/aim.gif)
![[homepage] [homepage]](http://s2.images.proboards.com/buttons/www_sm.gif) Joined: Apr 2006 Gender: Male  Posts: 1,861 Location: England
|  | Re: Crazy Fractal Patterns « Reply #2 on May 19, 2007, 2:05pm » | |
Yeah, some of the patterns which get created look really strange. 
|
|
|
Nicky Peter Hollyoake Global Moderator
     member is offline
![[avatar] [avatar]](http://photos-b.ak.fbcdn.net/hphotos-ak-snc1/hs268.snc1/9520_1196013874092_1640842698_548013_2731706_n.jpg)
You only see what you believe.
Joined: Apr 2006 Gender: Male  Posts: 1,968 Location: uk
|  | Re: Crazy Fractal Patterns « Reply #3 on May 20, 2007, 4:10pm » | |
Could you explain the 'Randomize' command you use? What you mean by 'TRUE random numbers'?
| |
|
steven522 Posts
  member is offline
![[avatar] [avatar]](http://www.avatarsdb.com/avatars/the_voices_are_telling_me.gif)
Joined: May 2007 Gender: Male  Posts: 60 Location: USA
|  | Re: Crazy Fractal Patterns « Reply #4 on May 21, 2007, 9:15am » | |
If this came from the freebasic forum originally, then freebasic mimics QBasic's rnd function and returns a list of random numbers that are the same every time. You have to use the randomize(timer) function to make the numbers randomly random.
| |
|
Empyrion Martyr Posts a lot
    member is offline
![[avatar] [avatar]](http://www.avatarsdb.com/avatars/beware_drunk_people.jpg)
![[msn] [msn]](http://s2.images.proboards.com/msn.gif)
Joined: Jan 2007 Gender: Male  Posts: 349 Location: Bucharest, Romania
|  | Re: Crazy Fractal Patterns « Reply #5 on May 27, 2007, 4:35pm » | |
That is pseudorandom not truly random (the randomize thingie takes some numbers from the computer clock and initializes the rnd with that value as a seed). To build a roughly good random number generator you would probably need real life dice and coins . Anyways good fractals, that would be nice as a screensaver.
|
Omnis vulnerat, ultima necat... |
|
davy Global Moderator
     member is online member is offline
![[avatar] [avatar]](http://www.avatarsdb.com/avatars/shoot_cat.jpg)
![[aim] [aim]](http://s2.images.proboards.com/aim.gif)
![[homepage] [homepage]](http://s2.images.proboards.com/buttons/www_sm.gif) Joined: May 2006 Gender: Male  Posts: 1,049 Location: USA
|  | Re: Crazy Fractal Patterns « Reply #6 on May 29, 2007, 11:00am » | |
Quote:That is pseudorandom not truly random (the randomize thingie takes some numbers from the computer clock and initializes the rnd with that value as a seed). To build a roughly good random number generator you would probably need real life dice and coins . Anyways good fractals, that would be nice as a screensaver. |
|
Actually... It depends how you define random. But, there really is no TRUE random.
Even those dice and coins are playing out a physical situation based on it's initial velocity, sort of like the clock tick on a computer.
Random is basically another word for "unpredictable" and unless you know the exact tick cycle, you can't predict the computers random number.
Just like how you can't predict the outcome of a coin because you don't know how hard it will be tossed and at what angle.
|
|
|
Empyrion Martyr Posts a lot
    member is offline
![[avatar] [avatar]](http://www.avatarsdb.com/avatars/beware_drunk_people.jpg)
![[msn] [msn]](http://s2.images.proboards.com/msn.gif)
Joined: Jan 2007 Gender: Male  Posts: 349 Location: Bucharest, Romania
|  | Re: Crazy Fractal Patterns « Reply #7 on May 30, 2007, 1:53pm » | |
Well, yeah if that's the case i guess ya right, davy, there really is no true random. I think in the end all breaks down to what method gives you the most unpredictable numbers. (As for the coins and dice, yup, generally all phisical random outcomes of a situation, the Global Conciousness Project really shakes the belief that you can't influence the result, but that's why i said "ROUGHLY" above.)
|
Omnis vulnerat, ultima necat... |
|