Image controls can be used to display images such like png, jpg or gif.
Just pass the file path and you're done.

img = app.CreateImage( file?, width=-1, height=-1, options='', pxw=-1, pxh=-1 ) → app object: Image

Without the width and height dimensions the image will be shown without any scaling.

Example - Original Size click to expand contents 

If you specify one of them and leave the other null, -1 or blank, it will be scaled so that the aspect ratio is kept.

Example - Maintain Aspect click to expand contents 

And if you specify both parameters it will be scaled to your wishes.

Example - Stretched click to expand contents 

If you want images to depress like buttons if touched you can use the “Button” option.

Example - Button click to expand contents 

Drawing on Images

Images are also useful for drawing basic shapes and other images on it and therefore for creating dynamic animations or even basic games. To create an empty image you can pass null as file parameter.

This way you can also specify a fixed pixel size to the image you can use the “fix” option and pass values for the pxw and pxh parameters.

img = app.CreateImage( null, 0.8, 0.5, "fix", 20, 20 );
img.DrawLine( 0, 0, 1, 1 );

If you dislike the anti-alias effect you can apply the “alias” option on a higher resolution image and draw a low-resolution image on it:

img2 = app.CreateImage( null, .8, .5, "alias" );
img2.DrawImage( img, 0, 0, 1, 1, 0 );

There are a whole bunch of drawing methods defined here. Some of the were already used above. You can draw lines, rectangles, circles and other images, just to name a few. You can even draw a transformed image using an transformation matrix. Check out the Draw* methods in the method list below to get more details about all drawing functions.

Example - Draw Shapes click to expand contents 

Drawing on Images fast

If you have many draw operations to perform at runtime (ie. for games) you might want to disable the automatic canvas update after each Draw* call using the SetAutoUpdate method. To force the rendering now, you have to call Update.

Another way to increase the animation speed is using the NoDom configuration. This will disable html and js Dom elements in your app that consume a lot of resources, but app functions can still be used.
For animations you can then use the Animate function of the app object which calls a function for a given amount per second. Note that the canvas still needs some time to refresh - so going over 60 fps makes no sense at all.

Example - Advanced Clock Animating click to expand contents 

Properties

The following properties are available on the Image object:

dataObject: { key, value }

Methods

The following methods are available on the Image object:

Clear()
DrawLine( x1, y1, x2, y2 )
DrawPoint( x, y )
DrawText( txt, x, y )
Focus()
GetAbsHeight() → Number: integer
GetAbsWidth() → Number: integer
GetHeight( options? ) → Number
GetLeft( options? ) → Number
GetName() → String
GetParent() → app object
GetPixelColor( x, y ) → List: [ red, green, blue ]
GetPixelData( format, left?, top?, width=-1, height=-1 ) → String: base64 encoded
GetPosition( options? ) → Object: { left, top, width, height }
GetTop( options? ) → Number
GetType() → String: “Image”
GetVisibility() → String: “Show” or “Hide” or “Gone”
GetWidth( options? ) → Number
Gone()
Hide()
IsEnabled() → Boolean
IsOverlap( obj, depth? ) → Boolean
IsVisible() → Boolean
MeasureText( txt ) → Object: { width, height }
Method( name, types?, p1?, p2?, p3?, p4? ) → all types
Move( x, y )
Reset()
Resize()
Scale( x, y )
SetScale( x, y )
Show()
Skew( x, y )
Update()