Community Project: BlitzMax Examples in Helpfiles

BlitzMax Forums/BlitzMax Programming/Community Project: BlitzMax Examples in Helpfiles

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.

Here are some more.
'GetColor()
Graphics 640,480
Local Red,Green,Blue
SetColor Rnd(255),Rnd(255),Rnd(255)
GetColor(Red,Green,Blue)
DrawText "Red: "+Red+"  Green: "+Green+"  Blue: "+Blue , 10 , 10
Flip
WaitKey()
End

'SetAlpha()/GetAlpha()
Graphics 640,480
SetBlend ALPHABLEND
Repeat 
	SetAlpha(Rnd(0,1))
	Alpha#=GetAlpha()
	DrawOval 270,190,100,100
	SetAlpha(1)
	DrawText "Alpha: "+Alpha , 10 , 10
	Delay 500
	Flip
	Cls
Until KeyHit(key_escape) Or AppTerminate()
End

'GetBlend()
Graphics 640,480
SetBlend ALPHABLEND '<- Set to Any ONE Blend Mode
Select GetBlend()
	Case ALPHABLEND
		DrawText "AlphaBlend is On" , 10 , 10
	Case LIGHTBLEND
		DrawText "LightBlend is On" , 10 , 10
	Case MASKBLEND
		DrawText "MaskBlend is On" , 10 , 10
	Case SOLIDBLEND
		DrawText "SolidBlend is On" , 10 , 10
EndSelect
Flip
WaitKey()
End

'GetOrigin()
Graphics 640,480
SetOrigin Rnd(640),Rnd(480)
Local OriginX#,OriginY#
GetOrigin(OriginX,OriginY) 
DrawText "Origin: "+OriginX+" , "+OriginY, 0 , 0
Flip
WaitKey()
End

'GetScale()
Graphics 640,480
SetScale Rnd(0.5,2),Rnd(0.5,2)
DrawOval 270,190,100,100
Local ScaleX#,ScaleY#
GetScale(ScaleX,ScaleY) 
SetScale 1,1
DrawText "Scale: "+ScaleX+" , "+ScaleY, 10 , 10
Flip
WaitKey()
End

'GetRotation()
Graphics 640,480
SetScale 1.5,1.5
SetRotation Rnd(360) 
DrawText "Rotation: "+GetRotation(), 320 , 240
Flip
WaitKey()
End

'GetLineWidth()
Graphics 640,480
SetLineWidth Rnd(10) 
DrawLine 0,0,640,480
DrawText "Line Width: "+GetLineWidth(), 10 , 10
Flip
WaitKey()
End

'HideMouse()/ShowMouse()
Graphics 640,480
Repeat
DrawText "Press Space to Hide/Show Cursor", 10 , 10
If KeyHit(key_space)
	If Hide=True
		Hide=False
		ShowMouse()
	Else
		Hide=True
		HideMouse()
	EndIf
EndIf
Flip
Cls
Until KeyHit(key_escape) Or AppTerminate()
End

'MoveMouse()
Graphics 640,480
Repeat
DrawText "Press Space to Move Cursor to the Middle of the Window", 10 , 10
If KeyHit(key_space) Then MoveMouse(320,240)
Flip
Cls
Until KeyHit(key_escape) Or AppTerminate()
End

'Replace()
Str$="This is a test of the Replace command."
Print "Original: "+Str
Str=Replace(Str,"e","*")
Print "Altered: "+Str

'HideGadget()/ShowGadget()
win=CreateWindow("HideGadget()/ShowGadget()",0,0,300,300,Null,WINDOW_TITLEBAR|INDOW_CLIENTCOORDS)
button=CreateButton("Hide/Show",0,0,300,30,win)
panel=CreatePanel(25,50,250,200,win,PANEL_BORDER) 
Repeat
WaitEvent()
If EventSourceHandle()=button
	If Hide=True
		Hide=False
		ShowGadget(panel)
	Else
		Hide=True
		HideGadget(panel)
	EndIf
EndIf
Until EventID()=EVENT_WINDOWCLOSE
End

'Desktop()
Print "Desktop Width: "+GadgetWidth(Desktop())+"  Desktop Height: "+GadgetHeight(Desktop())

'GraphicsWidth()\GraphicsHeight()\GraphicsDepth()\GraphicsHertz()
Graphics 640,480,32,60
DrawText "Graphics Width: "+GraphicsWidth(), 10 , 10
DrawText "Graphics Height: "+GraphicsHeight(), 10 , 30
DrawText "Graphics Depth: "+GraphicsDepth(), 10 , 50
DrawText "Graphics Hertz: "+GraphicsHertz(), 10 , 70
Flip
WaitKey()
End