Skip to content

Commit

Permalink
Create Example - Draw to Image at mouse pos.monkey2
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakz001 committed Jul 1, 2016
1 parent 5cfab25 commit 931a1a4
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Example - Draw to Image at mouse pos.monkey2
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#Import "<std>"
#Import "<mojo>"

Using std..
Using mojo..

Global instance:AppInstance

Class MyWindow Extends Window

Field image:Image

Field icanvas:Canvas

Method New()
image=New Image( 256,256,TextureFlags.Mipmap|TextureFlags.Dynamic )
image.Handle=New Vec2f( 0,0 )
icanvas=New Canvas( image )


icanvas.Color=Color.White
icanvas.DrawText( "This way up!",icanvas.Viewport.Width/2,0,.5,0 )
icanvas.Flush()

End Method

Method OnRender( canvas:Canvas ) Override

App.RequestRender()

canvas.DrawImage( image,App.MouseLocation.x,App.MouseLocation.y,0,.5,.5 )

canvas.DrawText( "Here!",0,0 )

End Method

Method OnKeyEvent( event:KeyEvent ) Override

Select event.Type
Case EventType.KeyDown
Select event.Key
Case Key.Escape
instance.Terminate()
End Select
End Select
End Method

End Class

Function Main()
instance = New AppInstance

New MyWindow

App.Run()

End function

0 comments on commit 931a1a4

Please sign in to comment.