Updated image docs

This commit is contained in:
Robert Jelic
2022-12-24 11:48:35 +01:00
parent 91e42e096c
commit 6d2956f3bf
9 changed files with 117 additions and 9 deletions

View File

@@ -0,0 +1,6 @@
## getImageSize
Returns the current image size
#### Returns:
1. `number` width
2. `number` height

View File

@@ -0,0 +1,9 @@
## getMetadata
Returns the metadata set in the image
#### Parameter:
1. `string` the metadata key (for example: title, description, author, creator, data, width, height,...)
#### Returns:
1. `any` metadata value

View File

@@ -1,18 +1,23 @@
## loadImage
loads a default .nfp file into the object.
This method is used to load an image file into the image object.
#### Parameters:
1. `string` the absolute file path
1. `path` the absolute file path
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a default image and loads a test.nfp file
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.nfp")
```
```xml
<image path="test.nfp" />
```
```

View File

@@ -0,0 +1,10 @@
## play
Plays a bimg animation. This can only work if the bimg has more than 1 frame.
#### Parameters:
1. `boolean` If the image animation should play
#### Returns:
1. `object` The object in use

View File

@@ -0,0 +1,19 @@
## resizeImage
This method is used to resize a bimg image. It takes two parameters: the new width, and the new height. It is important to note that resizing images can result in a loss of quality, as the original pixel data is being transformed and resampled to fit the new dimensions. This is especially noticeable when increasing the size of an image, as new pixels must be generated to fill in the gaps. As a result, it is generally recommended to use the original image at its full size whenever possible, rather than resizing it.
#### Parameters:
1. `number` the new width
2. `number` the new height
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a new image object, loads the image and changes it's size.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg"):resizeImage(40, 20)
```

View File

@@ -0,0 +1,19 @@
## selectFrame
The selectFrame method allows you to change the current frame of an image object. It takes a single parameter, the index of the frame you want to display.
#### Parameters:
1. `number` the frame index
#### Returns:
1. `object` The object in use
#### Usage:
* Creates a default image and loads a test.nfp file
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg"):selectFrame(2)
```

View File

@@ -0,0 +1,23 @@
## setImage
Sets a new image
#### Parameter:
1. `table` A table in bimg or nfp format.
1. `string` The format in which the image should be loaded (nfp or bimg)
#### Usage:
* Creates a default image and loads a test.nfp file
```lua
local mainFrame = basalt.createFrame()
local bimg = {
[1] = {
{"Hello", "fffff", "33333"}
}
}
local aImage = mainFrame:addImage():setImage(bimg)
```

View File

@@ -0,0 +1,11 @@
## usePalette
Changes the palette colors of the image, if the bimg image has palette metadata.
#### Parameter:
1. `boolean` if the image should change the palette
#### Returns:
1. `object` The object in use