The code below shows you how to create images and how to draw pixels into them. There is a function in the code that allows you to draw using r g b. The alpha value to 255 means not transparent. 0 alpha value is transparent.
Code below :
Import mojo Class MyGame Extends App Field image:Image Method OnCreate:Int() SetUpdateRate(15) image = CreateImage(320, 200) Local pixels:Int[320 * 200] For Local i:Int = 0 Until 320 * 200 pixels[i] = argb(255,255,255) Next image.WritePixels(pixels, 0, 0, 320, 200, 0) End Method OnRender:Int() Cls() DrawImage(image, 10, 10) End End Function Main:Int() New MyGame() End Function argb:Int(r:Int, g:Int, b:Int ,alpha:Int=255) Return (alpha Shl 24) | (r Shl 16) | (g Shl 8) | b End Function
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.