Gui Tutorial

4. Using an Image

Using an image

For this section we’ll use this image as the texture for our button.
It’s dimensions are 64x72pixels.
upThink.png

For this example we'll be saving the image to ~/images however you can put it wherever you like.

To make this change we can replace this line

local button = myGui.newRectangle(5,5,20,12)
button.setColor( 0xFFFFFFFF ) --opaque white, 0x FF FF FF FF

with this

local button = myGui.newImage("~/images/upThink.png",5,5,20,12)
If you're following along in REPL, you can do button.remove() to remove the current rectangle before making the image.

and if we open it now… gui with distorted image We can see
64 / 72 * 20 = 17.7

button.setSize(20,17)

gui with distorted image We can see our image on the button.



  1. Getting Started
  2. Adding a button
  3. Making it better
  4. Using an Image
  5. Using Code