6. Table gif

A table gif inherit from renderizable and implement all methods as usual. Also the animation has a shader table by default which can be accessed by getShader method.

6.1. gif methods

6.1.1. gif new

new(string * world, number * x, number * y, number * z)

Create a new instance of a gif passing the world desired (detail) and position.

Parameters
  • stringworld can be 2ds, 2dw or 3d.

  • numberx position (optional).

  • numbery position (optional).

  • numberz position (optional).

Returns

gif table.

Example:

tGif = gif:new('2dw')

6.1.2. gif load

For the gif example we will use the following gif:

_images/Lion-King.gif

Figure 6.1 Lion-King gif animated

download Lion-King.gif

load(string file_name)

Load a gif from file.

Parameters

stringfile name from file.

Example:

mbm.setColor(0.3,0.3,0.7) --blue color of background

tGif = gif:new('2dw')
if tGif:load('Lion-King.gif') then
   print('Successfully loaded gif:','Lion-King.gif')
else
   print('Failed to loaded gif:','Lion-King.gif')
end
_images/gif-from-gif.gif

Figure 6.2 Lion-King gif running

Note

The load method will search in all known path.
You can add a path to search by the method addPath.

6.1.3. gif setSize

setSize(number width, number height)

Resize the frame size from gif.

Parameters
  • numberwidth from frame.

  • numberheight from frame.

Example:

mbm.setColor(1,1,1) --White color of background

tGif = gif:new('2dw')
if tGif:load('Lion-King.gif') then
   tGif:setSize(100,100)
else
   print('Failed to loaded gif:','Lion-King.gif')
end
_images/Lion-King.gif

Figure 6.3 Lion-King gif resized to 100 x 100

Note

Always the image gif will adapt to the frame size.