Strange visual effect

Everything else that doesn't fall into one of the other PB categories.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Strange visual effect

Post 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
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Strange visual effect

Post 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.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Strange visual effect

Post 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.
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Strange visual effect

Post 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?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Strange visual effect

Post 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...
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Strange visual effect

Post 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
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Strange visual effect

Post 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...
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Strange visual effect

Post by Foz »

:lol:
Post Reply