Get started with offscreen images
Here is a simple example to get you started with creating offscreen images:
image = new Image( 64, 64 )
// use setRGB or setRGBA to edit your image pixel by pixel
for i=0 to image.width-1 by 1
for j=0 to image.height-1 by 1
// or use the same drawing functions as for the screen
// note that the coordinates system is different
// 1 unit == 1 pixel
// 0,0 is top left
// y-axis is pointing down
screen.drawImage( image, 0, 0, 100, 100 )
update = function()
if mouse.press then
// save the image on the user's PC
system.file.save(image) // saves a png with default name
// or system.file.save(image,"myfilename","jpg",0.95)
:0 yess this gives me so many ideas of things to do! Now we can make custom noise, texture mapping, etc.
Oh oh, another tinkerer on the loose :)
Live Long and Tinker
The possibilities are nearly endless ;)
Is there any way to get the RGB value of a certain pixel?
image.getRGB( x, y [,result])
Check the new API cheatsheet for more toys :)
Is there a way to draw a procedural generated image to the screen?
Something not as ugly as:
init = function()
sprite = sprites["icon"]
img = sprite.frames
draw = function()
@HomineLudens like this:
img = new Image(16,16)
screen.drawImage( img, 0, 0, 100 )
You also have
drawImagePart for drawing only a part of your image to the screen. Note that you can also pass an image object to
drawSprite, it will work just as well.
drawImagePart were just added for the sake of clarity but they are the very same functions as
drawSpritePart. They all accept either an Image, a Sprite or the name of a sprite as first argument.
Thanks @gilles, I don't know how I miss it.
Just what I was looking for.