News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

MakeMaskedCircleImage function

Started by kevin, July 04, 2020, 12:09:20 PM

Previous topic - Next topic

kevin

 MakeMaskedCircleImage Function


    This function grabs a chunk from another image, then draws a circle to alpha channel to mask out the bits we want, giving up a 007 sort of circle reveal effect




Video:








PlayBASIC Code: [Select]
   screen = makeBackDrop()

setfps 30

do
cls $304050



mx=mousex()
my=mousey()

rendertoimage screen
mask=MakeMaskedCircleImage(mx,my,50,5)
rendertoscreen

drawimage mask,mx,my,true

deleteimage mask

sync
loop spacekey()





Function MakeMaskedCircleImage(Xpos,Ypos,Size,Pad=5)

oldinkmode =GetInkmode()

RadiusX=Size
RadiusY=Size
Width =Pad+(RadiusX*2)+Pad
Height=Pad+(RadiusY*2)+Pad

Mask=NewFximage(Width,height,true)
OldSurface=getsurface()


Xpos-=Pad
Ypos-=Pad

copyrect OldSurface,xpos,ypos,Xpos+Width*2,Ypos+Height,Mask,0,0

rendertoimage Mask
inkmode 1+512
Circlec Width/2,Height/2,Size,true,$ff000000

rendertoimage OldSurface
inkmode OldInkMode




EndFunction Mask






Function MakeBackDrop()

Screen=NewFXImage(800,600)
rendertoimage Screen
shadebox 0,0,800,600,$112233,$445566,$aa88bb,$332288

loadfont "veranda",2,100,0
setfont 2
centertext 400,240,"Hello World"
setfont 1
rendertoscreen


rgbmaskimage Screen,$00ffffff
EndFunction Screen