Page 1 of 1

Strange visual effect

Posted: Wed Mar 24, 2010 10:16 pm
by Trond
When I tried to come up with a nice-looking noise, I stumbled upon this strange effect:

Code: Select all

#w = 800
#h = 600

CreateImage(0, #w, #h, 24)

Procedure Noise(x, y)
  Static salt = 'salt'
  salt = salt ! x & y
  ProcedureReturn salt
EndProcedure

Procedure UpdateImage()
  StartDrawing(ImageOutput(0))
  For x = 0 To #w-1
    For y = 0 To #H-1
      Plot(x, y, Noise(x, y))
    Next
  Next
  StopDrawing()
EndProcedure

OpenWindow(0, 0, 0, #w, #h, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
UpdateImage()
ImageGadget(0, 0, 0, 0, 0, ImageID(0))

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver
I know I have seen it before, does anyone know what it's called?

I have no idea why it happens, or why it's interlaced. If you got any other small visual effect you want to share, feel free.
:D

Re: Strange visual effect

Posted: Wed Mar 24, 2010 11:42 pm
by c4s
It's called the Sierpinski Triangle ...or at least kind of. The images here look similar: http://en.wikipedia.org/wiki/Sierpinski_triangle
Funny that it is so easy to generate. No wonder all these (older) cracktros, demos etc. have this effect.

Re: Strange visual effect

Posted: Thu Mar 25, 2010 12:03 am
by Trond

Code: Select all

#w = 640
#h = 480

CreateImage(0, #w, #h, 24)

Procedure FRandom(x, y)
  Static salt = 'salt'
  salt = salt & x | y
  salt & $7FFFFFF
  ProcedureReturn salt % (x+1)
EndProcedure


Procedure Noise(x, y)
  Static Phase.d
  Phase + 0.001
  ProcedureReturn FRandom(x, y)*Cos(x/10) + FRandom(y, x)*Sin(y/10+phase)
EndProcedure

Procedure UpdateImage()
  StartDrawing(ImageOutput(0))
  For x = 0 To #w-1
    For y = 0 To #H-1
      Plot(x, y, Noise(x, y))
      ;Plot(x, y, FRandom(x, y))
    Next
  Next
  StopDrawing()
EndProcedure

OpenWindow(0, 0, 0, #w, #h, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
UpdateImage()
ImageGadget(0, 0, 0, 0, 0, ImageID(0))

AddWindowTimer(0, 0, 60)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Timer
      UpdateImage()
      SetGadgetState(0, ImageID(0))
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver
I could stare at this for hours.

If I got paid for it.

Re: Strange visual effect

Posted: Thu Mar 25, 2010 3:38 pm
by Foz
First effect is very cool, it will be something that I place into my toolbox set! (I am currently teaching myself about noise in an attempt to build a 3d rpg game in less than 100kb :))

Second one... it looks like a corrupt animation to me... anyone else get that?

Re: Strange visual effect

Posted: Thu Mar 25, 2010 5:11 pm
by Trond
Foz wrote:Second one... it looks like a corrupt animation to me... anyone else get that?
I think it's supposed to be like that...

Re: Strange visual effect

Posted: Thu Mar 25, 2010 5:17 pm
by Foz
It looks pretty good with with a smaller phase (0.0001) ;)
Like some sort of cellular effect or something. A inside a magic mushroom level maybe? :D

Re: Strange visual effect

Posted: Thu Mar 25, 2010 6:26 pm
by Rook Zimbabwe
The second one I hacked in to a screensaver... I left it on the wifes computer... (hehehehehe!)

She freaked when she came back. :twisted:

But now she is letting me run defrag and update malwarebytes and avast... she hadn't done ANY of those things in a LONG time...

Re: Strange visual effect

Posted: Thu Mar 25, 2010 6:28 pm
by Foz
:lol: