It is currently Thu Jul 02, 2020 8:48 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Cheap 2D Water ripples
PostPosted: Wed May 09, 2018 10:04 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 1239
Location: germany
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Cheap 2D Water ripples
PostPosted: Wed May 09, 2018 12:06 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3617
Location: Netherlands
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:
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

_________________
macOS 10.15 Catalina, Windows 10


Last edited by wilbert on Wed May 09, 2018 5:39 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Cheap 2D Water ripples
PostPosted: Wed May 09, 2018 2:31 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 1239
Location: germany
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 :-)


Top
 Profile  
Reply with quote  
 Post subject: Re: Cheap 2D Water ripples
PostPosted: Fri May 11, 2018 12:42 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 17, 2009 10:51 pm
Posts: 1387
Location: Nashville
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. :mrgreen:


Top
 Profile  
Reply with quote  
 Post subject: Re: Cheap 2D Water ripples
PostPosted: Fri Sep 07, 2018 9:34 pm 
Offline
User
User
User avatar

Joined: Fri Mar 04, 2005 7:46 pm
Posts: 73
Location: argentina
:mrgreen:
I'll see if I can do something similar with a background photo,
expanding with box, the pixels to create the magnifying effect ;D

_________________
Amd Vishera fx8350 ,16Gbram, Gtx650 ti, 2gb,Win 10pro. 13tbs. 8)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye