Buttons

Blitz3D Forums/Blitz3D Beginners Area/Buttons

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

For gfx commands you need to set the current drawing buffer to a canvas.

setbuffer canvasbuffer(mylousydorkycanvas)
; your gfx commands here
flipcanvas mylousydorkycanvas

here, try this: (it's a fullscreen gfx-app based on a canvas, with all the advantages of the GUI stuff)
notice: in the beginning I define a canvas, the size of 640x480. This means: the amount of pixels in the canvas, if you stretch the canvas (setgadgetshape, using setgadgetlayout settings), then you get bigger blurred pixels.

Global sw=ClientWidth(Desktop())
Global sh=ClientHeight(Desktop())

Global APP=CreateWindow("",0,0,sw,sh,0,0)

Global APPcanvas=CreateCanvas(0,0,640,480,APP)

SetGadgetLayout APPcanvas,1,0,1,0

SetGadgetShape APPcanvas,0,0,sw,sh

yourbutt=CreateButton ("quit!",64,32,32,32,APPcanvas)

; make a starfield!
SetBuffer CanvasBuffer(APPcanvas)
	For t=0 To 1000
		b#=Rnd(0,1)
		r#=b# * b# * b#
		g#=b# * b#
		b#=b#
		Color r#*255,g#*255,b*255
		Plot Rnd(0,640),Rnd(0,480)
	Next
FlipCanvas APPcanvas

Confirm "u like it ? :)"

quit=False

timer=CreateTimer(50)

Repeat

	f=f+1

	WaitEvent()
	
	
	If EventID()=$803 ; alt f4
		quit=True
	EndIf
	
	
	If EventID()=$401 ; button pressed
		quit=True
	EndIf

	
	If EventID()=$4001 ; timer event
	
		SetBuffer CanvasBuffer(APPcanvas)
		
			If (f Mod 100)=0
				Cls
				
				SetGadgetShape yourbutt,Rnd(0,sw-32),Rnd(0,sh-32),32,32
			EndIf

			Color Rnd(0,255),Rnd(0,255),Rnd(32,255)
			
			amp=Sin(f*11)*100
			x=Sin(f*3)*(100-amp)
			y=Cos(f*2)*(100+amp)
			
			Line 320+x,240+y,0,0
			Line 320+x,240+y,639,479
			Line 320+x,240+y,639,0
			Line 320+x,240+y,0,479
		
		FlipCanvas APPcanvas
		
	EndIf

	
Until quit

; opportunity to free images, banks, etc. here..

End