Basalt 1.7 Update

- New Objects (Flexbox, Graph, Treeview)
- Pluginsystem to add/remove functionality
- Reworked the entire Object system, instead of one big Object Class we have multiple classes: Object, VisualObject, ChangeableObject
- Instead of one big Frame Class we have multiple Frame Classes: BaseFrame, Frame, MovableFrame, ScrollableFrame, MonitorFrame, Flexbox
- Removed the Animation Object, and added a animation plugin instead
- Removed the Graphic Object and merged it's functionality with the image object
- Updated currently existing objects
This commit is contained in:
Robert Jelic
2023-04-30 17:05:34 +02:00
parent e086c1abb2
commit bb1b1beb79
341 changed files with 15541 additions and 3862 deletions

View File

@@ -0,0 +1,29 @@
## addFrame
### Description
Adds a new frame to the image object. This is useful for creating animations with the image object by adding multiple frames that can be played in sequence.
### Parameters
1. `number` index - The index of the frame.
2. `table` frame - A table in bimg format representing a single frame of the animation.
### Returns
1. `object` The object in use
### Usage
* Adds a new frame to an existing image object's animation.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local frameToAdd = {
{"Hello", "fffff", "33333"}
}
aImage:addFrame(2, frameToAdd)
```

View File

@@ -0,0 +1,19 @@
## clear
### Description
Clears all frames from the image object.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, loads a bimg image, and clears all frames.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
aImage:clear()
```

View File

@@ -0,0 +1,20 @@
## getActiveFrame
### Description
Returns the index of the currently active frame in the image object.
### Returns
1. `number` The index of the currently active frame in the image object.
### Usage
* Creates a new image object, loads a bimg image, and retrieves the index of the active frame.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local activeFrame = aImage:getActiveFrame()
basalt.debug(activeFrame)
```

View File

@@ -0,0 +1,23 @@
## getFrame
### Description
Retrieves a frame from the image object at the specified index.
### Parameters
1. `number` index - The index of the frame to retrieve.
### Returns
1. `table` The frame at the specified index in bimg format.
### Usage
* Creates a new image object, loads a bimg image, and retrieves the frame at index 2.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local frame = aImage:getFrame(2)
```

View File

@@ -0,0 +1,20 @@
## getFrameCount
### Description
Returns the total number of frames in the image object.
### Returns
1. `number` The total number of frames in the image object.
### Usage
* Creates a new image object, loads a bimg image, and retrieves the frame count
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local frameCount = aImage:getFrameCount()
basalt.debug(frameCount)
```

View File

@@ -0,0 +1,23 @@
## getFrameObject
### Description
Retrieves a frame object from the image object at the specified index. This method works with bimg format images and can be used to access and manipulate individual frames.
### Parameters
1. `number` index - The index of the frame to retrieve.
### Returns
1. `object` The frame object at the specified index, with methods to interact and modify the frame.
### Usage
* Creates a new image object, loads a bimg image, and retrieves the frame object at index 2.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local frameObject = aImage:getFrameObject(2)
```

View File

@@ -0,0 +1,19 @@
## getFrames
### Description
Retrieves a table containing all the frames in the image object..
### Returns
1. `table` A table containing all the frames in the image object.
### Usage
* Creates a new image object, loads a bimg image, and retrieves all the frames.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local frames = aImage:getFrames()
```

View File

@@ -0,0 +1,19 @@
## getImage
### Description
Returns the current image of the image object in its internal format. This is useful if you need to access the raw image data for manipulation or analysis purposes.
### Returns
1. `table` The current image in the image object
### Usage
* Creates a new image object, loads an image, and gets the current image
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local currentImage = aImage:getImage()
```

View File

@@ -1,6 +1,21 @@
## getImageSize
### Description
Returns the current image size
#### Returns:
1. `number` width
2. `number` height
### Returns
1. `number` width - The current width of the image
2. `number` height - The current height of the image object
### Usage
* Gets the size of an image and prints it
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.nfp")
local width, height = aImage:getImageSize()
basalt.debug("Image width:", width, "Image height:", height)
```

View File

@@ -1,9 +1,23 @@
## getMetadata
### Description
Returns the metadata set in the image
#### Parameter:
### Parameter
1. `string` the metadata key (for example: title, description, author, creator, data, width, height,...)
#### Returns:
### Returns
1. `any` metadata value
### Usage
* Load an image and get the metadata for the "title" key
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
local title = aImage:getMetadata("title")
```

View File

@@ -0,0 +1,23 @@
## getOffset
### Description
Gets the image's current coordinate offset. The offset values represent the distance the image has been moved relative to its original position.
### Returns
1. `number` offsetX - The x direction offset (+/-)
2. `number` offsetY - The y direction offset (+/-)
### Usage
* Creates a new image object, loads the image, sets an offset, and retrieves the current offset values.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg"):setOffset(5, 3)
local offsetX, offsetY = aImage:getOffset()
basalt.debug("Offset X: ", offsetX)
basalt.debug("Offset Y: ", offsetY)
```

View File

@@ -1,15 +1,18 @@
## loadImage
### Description
This method is used to load an image file into the image object.
#### Parameters:
### Parameters
1. `path` the absolute file path
1. `string` path - The absolute file path
#### Returns:
### Returns
1. `object` The object in use
#### Usage:
### Usage
* Creates a default image and loads a test.nfp file

View File

@@ -0,0 +1,24 @@
## moveFrame
### Description
Moves a frame from one index to another within the image object. This method is useful when working with bimg format images and animations, allowing you to reorder frames in the animation sequence.
### Parameters
1. `number` fromIndex - The current index of the frame you want to move.
2. `number` toIndex - The new index where you want to move the frame.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, loads a bimg image, and moves the frame at index 1 to index 3.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
aImage:moveFrame(1, 3)
```

View File

@@ -1,10 +1,22 @@
## play
### Description
Plays a bimg animation. This can only work if the bimg has more than 1 frame.
#### Parameters:
### Parameters
1. `boolean` If the image animation should play
#### Returns:
### Returns
1. `object` The object in use
1. `object` The object in use
### Usage
* Creates an image and plays the animation.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("animated_bimg.bimg"):play(true)
```

View File

@@ -0,0 +1,23 @@
## removeFrame
### Description
Removes a frame from the image object at the specified index.
### Parameters
1. `number` index - The index of the frame to remove.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, loads a bimg image, and removes the frame at index 2.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg")
aImage:removeFrame(2)
```

View File

@@ -1,19 +1,23 @@
## 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:
### Description
1. `number` the new width
2. `number` the new height
This method is used to resize the 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` width - The new width for the image
2. `number` height - The new height for the image
### Returns
#### Returns:
1. `object` The object in use
#### Usage:
### Usage
* Creates a new image object, loads the image and changes it's size.
* Creates a new image object, loads the image, and changes its size
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg"):resizeImage(40, 20)
local aImage = mainFrame:addImage():loadImage("resize_example.bimg"):resizeImage(40, 20)
```

View File

@@ -1,17 +1,20 @@
## selectFrame
### Description
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:
### Parameters
1. `number` the frame index
#### Returns:
### Returns
1. `object` The object in use
#### Usage:
### Usage
* Creates a default image and loads a test.nfp file
* Creates a default image and loads a test.bimg file, then selects the second frame
```lua
local mainFrame = basalt.createFrame()

View File

@@ -0,0 +1,24 @@
## setBg
### Description
Sets or modifies the background color of a specified position in the currently active frame of the image object.
### Parameters
1. `string` backgroundColor - The color of the background at the specified position.
2. `number` x - The x-coordinate of the text position.
3. `number` y - The y-coordinate of the text position.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, adds a frame, and sets the background color in the active frame.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():addFrame():setBg(1, 1, "000000")
```

View File

@@ -0,0 +1,24 @@
## setFg
### Description
Sets or modifies the foreground color of a specified position in the currently active frame of the image object.
### Parameters
1. `string` foregroundColor - The color of the foreground at the specified position.
2. `number` x - The x-coordinate of the text position.
3. `number` y - The y-coordinate of the text position.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, adds a frame, and sets the foreground color in the active frame.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():addFrame():setFg(1, 1, "ffffff")
```

View File

@@ -1,14 +1,17 @@
## setImage
### Description
Sets a new image
#### Parameter:
### 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:
### Usage
* Creates a default image and loads a test.nfp file
* Creates a default image and loads a test.nfp
```lua
local mainFrame = basalt.createFrame()

View File

@@ -0,0 +1,23 @@
## setImageSize
### Description
Sets the size of the image object. This can be useful when you need to scale an image to fit a specific area.
### Parameters
1. `number` width - The desired width of the image object
2. `number` height - The desired height of the image object
### Returns
1. `object` The object in use
### Usage
* Creates an image and sets its size to 10x5
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.nfp"):setImageSize(10, 5)
```

View File

@@ -0,0 +1,23 @@
## setOffset
### Description
Sets the image's coordinate offset. The offset moves the image relative to its original position. It can be used to adjust the position of the image without affecting its layout within the container.
### Parameters
1. `number` offsetX - The x direction offset (+/-)
2. `number` offsetY - The y direction offset (+/-)
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, loads the image, and sets an offset of 5 in the x direction and 3 in the y direction.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.bimg"):setOffset(5, 3)
```

View File

@@ -0,0 +1,25 @@
## setText
### Description
Sets or modifies the text at a specified position in the currently active frame of the image object. This allows you to create or modify text within an image directly.
### Parameters
1. `string` text - The text to be placed at the specified position
2. `number` x - The x-coordinate of the text position.
3. `number` y - The y-coordinate of the text position.
### Returns
1. `object` The object in use
### Usage
* Creates a new image object, adds a frame, and sets the text in the active frame.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():addFrame():setText("Hello", 1, 1)
```

View File

@@ -1,11 +1,22 @@
## usePalette
### Description
Changes the palette colors of the image, if the bimg image has palette metadata.
#### Parameter:
### Parameter
1. `boolean` if the image should change the palette
#### Returns:
### Returns
1. `object` The object in use
### Usage
* Creates an image and enables the use of the palette.
```lua
local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test_with_palette.bimg"):usePalette(true)
```