Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4eb0b02

Browse files
authoredNov 12, 2016
Create Beginners - Clamp
1 parent cec8ae5 commit 4eb0b02

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
 

‎Beginners - Clamp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#Import "<std>"
2+
#Import "<mojo>"
3+
4+
Using std..
5+
Using mojo..
6+
7+
8+
Class MyWindow Extends Window
9+
10+
Method New()
11+
End method
12+
13+
Method OnRender( canvas:Canvas ) Override
14+
App.RequestRender() ' Activate this method
15+
' if key escape then quit
16+
If Keyboard.KeyReleased(Key.Escape) Then App.Terminate()
17+
'
18+
canvas.DrawText("Clamp example",0,0)
19+
canvas.DrawText("a value = -10. b value = Clamp(a,0,10)",0,20)
20+
Local a:Int=-10
21+
' If the value of the clamp is lower then the lowest clamp value is set
22+
' if the value of the clamp is higher then the highest clamp value is set
23+
Local b:Int=Clamp(a,0,10)
24+
canvas.DrawText("value b after clamping = "+b,0,40)
25+
End Method
26+
27+
End Class
28+
29+
Function Main()
30+
New AppInstance
31+
New MyWindow
32+
App.Run()
33+
End Function

0 commit comments

Comments
 (0)
Please sign in to comment.