EXAMPLE SOURCE CODES


     This is a small collection of mostly game example source codes. These source codes are made available to help PlayBasic programmers kick start their game programming journey. Looking for more source code / tutorials & media, then remember to visit the PlayBasic Resource board on our forums.

Found #1 item in Image category

 MakeMaskedCircleImage Function

By: Kevin Picone Added: July 5th, 2020

Category: All,Image

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:
	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
	







Viewing Page [1] of [0]



Want More Source Codes?:



Release Type: The source code & tutorials found on this site are released as license ware for PlayBasic Users. No Person or Company may redistribute any file (tutorial / source code or media files) from this site, without explicit written permission.

 

 
     
 
       

(c) Copyright 2002 / 2024 Kevin Picone , UnderwareDesign.com  - Privacy Policy   Site: V0.99a [Alpha]