Page 2 of 2
Re: Cheap 2D Water ripples
Posted: Wed May 09, 2018 10:04 am
by Kukulkan
Hello wilbert,
it is better (no longer crashing) but it steals the mouse from the whole desktop and I can see nothing if I click the mouse or move it. Pressing ESC releases the mouse and program closes. Maybe my graphics card (Intel HD 630 Kabby Lake GT2) with MESA Graphics and OpenGL 3.0 is not supported by PB?
I'm currently on KDE Neon LTS 5.12 (64 bit) with PDE Plasma 5.12.5.
Re: Cheap 2D Water ripples
Posted: Wed May 09, 2018 12:06 pm
by wilbert
Don't know what is causing the problems
Here's a variation for Canvas.
Performance of course isn't as good as Screen but the effect is more or less the same.
If more speed is required, it could be converted to asm.
Code: Select all
DisableDebugger
#X=400:#Y=300
#Dampening=0.995 ;change this value to make the wave last longer (closer to 1)
Dim Buffer.f(#X*2-1,#Y-1)
If OpenWindow(0, 0, 0,#X, #Y, "2D Waves", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, #X, #Y, #PB_Canvas_Container)
ButtonGadget(1, 10, 10, 80, 30, "Clean up")
CloseGadgetList()
AddWindowTimer(0, 0, 32)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Timer
StartDrawing(CanvasOutput(0))
For k=1 To #X-2
i=k+#X
For j=1 To #Y-2
Buffer(i,j)=((Buffer(k-1,j)+Buffer(k+1,j)+Buffer(k,j-1)+Buffer(k,j+1))*0.5-Buffer(i,j))*#Dampening
Next
Next
For i=1 To #X-2
k=i+#X
For j=1 To #Y-2
Buffer(i,j)=((Buffer(k-1,j)+Buffer(k+1,j)+Buffer(k,j-1)+Buffer(k,j+1))*0.5-Buffer(i,j))*#Dampening
Plot(i,j,$010101*Int(Buffer(i,j)*10))
Next
Next
StopDrawing()
ElseIf Event = #PB_Event_Gadget
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
Buffer(GetGadgetAttribute(0, #PB_Canvas_MouseX), GetGadgetAttribute(0, #PB_Canvas_MouseY))=20
EndIf
Case 1
FillMemory(@Buffer(0,0), #X*#Y<<3)
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Re: Cheap 2D Water ripples
Posted: Wed May 09, 2018 2:31 pm
by Kukulkan
Hi wilbert,
this version is working! I had to remove #PB_Canvas_Container, because 5.46 LTS does not know this flag, but now it's working. Thank you!
@Fig: Great effect

Re: Cheap 2D Water ripples
Posted: Fri May 11, 2018 12:42 pm
by Kuron
Fig wrote:Did you left click, Kuron ? I don't know if your reading system can render what's going on with ripples on screen...
It produces concentric circles with a height map in greyish color. (more than 50 grey of shade ^^)
Yes, I did left-click. Not sure if I am doing something wrong or it just doesn't like me. Sounds interesting, though.

Re: Cheap 2D Water ripples
Posted: Fri Sep 07, 2018 9:34 pm
by zefiro_flashparty
I'll see if I can do something similar with a background photo,
expanding with box, the pixels to create the magnifying effect ;D