When using the drawtext command in the onrender on imagecanvasses it does not work in html5 but it does work in glfw.
Import mojo2
Global canvas:Canvas
Global image:Image
Global imagecanvas:Canvas
Global image2:Image
Global imagecanvas2:Canvas
Global image3:Image
Global imagecanvas3:Canvas
Class MyApp Extends App
Field refresh:Int
Method OnCreate()
canvas=New Canvas
image=New Image(128,64,0,0)
image2=New Image(128,64,.5,.5)
image3=New Image(238,64,1,1)
imagecanvas=New Canvas(image)
imagecanvas2=New Canvas(image2)
imagecanvas3=New Canvas(image3)
createimages()
createimages()
SetUpdateRate(60)
End Method
Method OnUpdate()
End Method
Method OnRender()
canvas.Clear 0,0,0
canvas.DrawImage image,DeviceWidth()/2,50
canvas.DrawImage image2,DeviceWidth()/2,50+96
canvas.DrawImage image3,DeviceWidth()/2,50+(96*2)
canvas.Flush
End
End Class
Function createimages()
imagecanvas.Clear
imagecanvas.SetColor(0.1,0.1,0.1,1)
imagecanvas.DrawRect(0,0,image.Width(),image.Height())
imagecanvas.SetColor(1,1,1)
imagecanvas.DrawText("Image...1",0,0)
imagecanvas.Flush
imagecanvas2.Clear
imagecanvas2.SetColor(1,1,1,1)
imagecanvas2.DrawRect(0,0,image.Width(),image.Height())
imagecanvas2.SetColor(0,0,0,1)
imagecanvas2.DrawText("Image...2",0,0)
imagecanvas2.Flush
imagecanvas3.Clear
imagecanvas3.SetColor(1,1,1,1)
imagecanvas3.DrawRect(0,0,image.Width(),image.Height())
imagecanvas3.SetColor(0,0,0,1)
imagecanvas3.DrawText("Image...3",0,0)
imagecanvas3.Flush
End Function
Function Main()
New MyApp
End
Here the original link in the beginners forum : http://www.monkey-x.com/Community/posts.php?topic=10553
|