News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

BlitImageAlphaMultColour

Started by kevin, July 11, 2007, 02:20:04 PM

Previous topic - Next topic

kevin

 
Added a Colour mult blit mode.  Bellow shows how it can be used to colour an image and fade it in/out without changing the original image.    



This code is for  PB1.63h retail.



PlayBASIC Code: [Select]
   #include "Blitimage"

LoadFXIMage "..\..\..\gfx\tree.jpg",1

FadeCol=rgb(255,255,255)

NextChange=timer()+5000

Do
; Ping/ pong the Fade colour
FadeLevel#=cosNewvalue(50,angle#,50)

; Move the angle to keep the image fading in/out
angle#=wrapangle(angle#,1)


; Calc the fade col to merge with the image during the blit
Col=rgbfade(FadeCol,FadeLevel#)


; Draw them around the screen to create infinite scrolling platfeild

For lp=-Xpos to 800 Step 800
; Blit the Image scaled by the fade colour
BlitImageAlphaMultColour 1,lp,0,col
next

; Change the Xpos
Xpos=mod(Xpos+1,800)



; Randomly Change the fade colour
if Spacekey()=true or Timer()>NextChange
NextChange=timer()+5000

FadeCOl=RndRgb()
endif



; Display the FPS
text 10,10,fps()

; Show the display
Sync
loop







kevin

#1
 Here's the MMX (machine code) opt'd version. About 100fps faster in 32bit.

Also, the MMX 16bit version clocks at 550fps now.

Adaz

Very nice!
But...you forgot to include the new BlitImage.PBA with BlitImageAlphaMultColour  ;)

Ádáz

Hungary

kevin


See,

Quote
This code is for  PB1.63h retail.