07-28-2023, 10:19 PM
(07-28-2023, 12:44 PM)euklides Wrote: Second line put ...
Randomize Timer
... so to have changing pictures...
I didn't because I could test _PUTIMAGE placements easier with the screen looking the same each time. But here it is in, and I made this a blur defined area routine now.
Sometimes this program will hang up on me when closing the window by the mouse (X), I will have to use task kill to close it.
- Dav
Code: (Select All)
'==============
'BLURSCREEN.BAS
'==============
'Blurs area of screen
'Coded by Dav, JULY/2023
Randomize Timer
Screen _NewImage(800, 600, 32)
For t = 1 To 1000
size = Rnd * 255
x = Rnd * _Width: y = Rnd * _Height
Line (x, y)-(x + size, y + size), _RGB(Rnd * 255, Rnd * 255, Rnd * 255), BF
Next
For t = 1 To 50000
PSet (Rnd * _Width, Rnd * _Height), _RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Next
Do
BlurScreen 100, 100, _Width - 100, _Height - 100
'put a line around it, just for show
Line (100, 100)-(_Width - 100, _Height - 100), _RGBA(0, 0, 0, 2), B
_Limit 30
Loop Until InKey$ <> ""
Sub BlurScreen (x1, y1, x2, y2)
odisp% = _AutoDisplay: _Display
currentscreen& = _CopyImage(_Display)
'get defined area of screen to image, make it semi-transparent
tmpback& = _NewImage(Abs(x2 - x1) + 1, Abs(y2 - y1) + 1, 32) 'make image
_PutImage , currentscreen&, tmpback&, (x1, y1)-(x2, y2) 'copy area to image
_SetAlpha 50, , tmpback&
_PutImage (x1 - 1, y1), tmpback&: _PutImage (x1 + 1, y1), tmpback&
_PutImage (x1, y1 - 1), tmpback&: _PutImage (x1, y1 + 1), tmpback&
_PutImage (x1 - 1, y1 - 1), tmpback&: _PutImage (x1 + 1, y1 - 1), tmpback&
_PutImage (x1 - 1, y1 + 1), tmpback&: _PutImage (x1 + 1, y1 + 1), tmpback&
_PutImage (x1, y1), tmpback&
_Display
_FreeImage tmpback&
_FreeImage currentscreen&
If odisp% = -1 Then _AutoDisplay
End Sub