March 05, 2021, 07:55:44 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Like stats
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Fade by skidracer [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Fade by skidracer [ 1+ years ago ] (Read 418 times)
BlitzBot
Jr. Member
Posts: 1
Total likes: 0
[bb] Fade by skidracer [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:40 AM »
Title :
Fade
Author :
skidracer
Posted :
1+ years ago
Description :
Not exactly fast, but probably the most optimal way to fade the screen in blitz currently.
Code :
Code: BlitzBasic
; fade.bb
; by simon@acid.co.nz
; as readpixel is slow this fade routine copies the graphics buffer to a bank
; and uses the bank as a pixel source for subsequent calls to fade
Graphics
640
,
480
,
32
While
Not
MouseHit
(
1
)
Color
Rnd
(
255
)
,
Rnd
(
255
)
,
Rnd
(
255
)
Line
Rnd
(
640
)
,
Rnd
(
480
)
,
Rnd
(
640
)
,
Rnd
(
480
)
Wend
gfxbank=GrabBank
(
)
; use double buffering for clean fade
SetBuffer
BackBuffer
(
)
For
i=
1
To
32
Fade
(
gfxbank
)
Flip
Next
FreeBank
gfxbank
MouseWait
End
Function
GrabBank
(
)
w=
GraphicsWidth
(
)
h=
GraphicsHeight
(
)
bank=
CreateBank
(
w*h*
4
)
gbuffer=
GraphicsBuffer
(
)
LockBuffer
gbuffer
For
y=
0
To
h-
1
For
x=
0
To
w-
1
PokeInt
bank,o,
ReadPixelFast
(
x,y
)
o=o+
4
Next
Next
UnlockBuffer
gbuffer
Return
bank
End Function
Function
Fade
(
bank
)
w=
GraphicsWidth
(
)
-
1
h=
GraphicsHeight
(
)
-
1
gbuffer=
GraphicsBuffer
(
)
LockBuffer
gbuffer
For
y=
0
To
h
For
x=
0
To
w
rgb=
PeekInt
(
bank,o
)
d=
(
rgb
Shr
3
)
And
$1f1f1f
If
d=
0
d=rgb
rgb=rgb-d
WritePixelFast
x,y,rgb
PokeInt
(
bank,o,rgb
)
o=o+
4
Next
Next
UnlockBuffer
gbuffer
End Function
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Fade by skidracer [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal