From 6d2956f3bf33473e3ff9fe409ccdf7a2656a2d2c Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sat, 24 Dec 2022 11:48:35 +0100 Subject: [PATCH] Updated image docs --- docs/objects/Image.md | 18 ++++++++++++------ docs/objects/Image/getImageSize.md | 6 ++++++ docs/objects/Image/getMetadata.md | 9 +++++++++ docs/objects/Image/loadImage.md | 11 ++++++++--- docs/objects/Image/play.md | 10 ++++++++++ docs/objects/Image/resizeImage.md | 19 +++++++++++++++++++ docs/objects/Image/selectFrame.md | 19 +++++++++++++++++++ docs/objects/Image/setImage.md | 23 +++++++++++++++++++++++ docs/objects/Image/usePalette.md | 11 +++++++++++ 9 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 docs/objects/Image/getImageSize.md create mode 100644 docs/objects/Image/getMetadata.md create mode 100644 docs/objects/Image/play.md create mode 100644 docs/objects/Image/resizeImage.md create mode 100644 docs/objects/Image/selectFrame.md create mode 100644 docs/objects/Image/setImage.md create mode 100644 docs/objects/Image/usePalette.md diff --git a/docs/objects/Image.md b/docs/objects/Image.md index 9589b61..a025664 100644 --- a/docs/objects/Image.md +++ b/docs/objects/Image.md @@ -1,12 +1,18 @@ -The image object is for adding more advanced backgrounds. -It also provides a :shrink() function, where you can shrink the images to smaller ones. This functionallity is fully provided by the blittle library created by Bomb Bloke. I did not ask for permission to add it into the framework. If the creator wants me to remove the blittle part, just text me on discord! - -The image object is still not done. in the future i will provide more image formats. +The image object is for adding more advanced backgrounds to your interface. It supports the loading of .nfp and .bimg images. [Object](objects/Object.md) methods also apply for images. | | | |---|---| -|[loadImage](objects/Image/loadImage.md)|Adds a new object -|[shrink](objects/Image/shrink.md)|Sets the top bar text and colors - deprecated +|[loadImage](objects/Image/loadImage.md)|Loads an image from the specified file path +|[setImage](objects/Image/setImage.md)|Set's a new image +|[usePalette](objects/Image/usePalette.md)|Changes the used palette to the image prefered palette +|[play](objects/Image/play.md)|Plays an animated image +|[selectFrame](objects/Image/selectFrame.md)|Selects a specific frame in an animated image +|[getMetadata](objects/Image/getMetadata.md)|Returns the metadata of the image +|[getImageSize](objects/Image/getImageSize.md)|Returns the width and height of the image +|[resizeImage](objects/Image/resizeImage.md)|Resizes the image to the specified dimensions +# About Bimg + +Bimg is a custom image format that can be used in place of .nfp, it is a table which can store multiple frames and metadata. The frames can store text, background and foreground, which makes it possible to create any image you'd like. The image format is made by people from the Minecraft Computercraft Mods - Discord. Here's a Github page which explains how the Bimg format works: [bimg](https://github.com/SkyTheCodeMaster/bimg) diff --git a/docs/objects/Image/getImageSize.md b/docs/objects/Image/getImageSize.md new file mode 100644 index 0000000..47580e1 --- /dev/null +++ b/docs/objects/Image/getImageSize.md @@ -0,0 +1,6 @@ +## getImageSize +Returns the current image size + +#### Returns: +1. `number` width +2. `number` height \ No newline at end of file diff --git a/docs/objects/Image/getMetadata.md b/docs/objects/Image/getMetadata.md new file mode 100644 index 0000000..5d6f0b2 --- /dev/null +++ b/docs/objects/Image/getMetadata.md @@ -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 diff --git a/docs/objects/Image/loadImage.md b/docs/objects/Image/loadImage.md index 2d8748a..c4164d5 100644 --- a/docs/objects/Image/loadImage.md +++ b/docs/objects/Image/loadImage.md @@ -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 -``` \ No newline at end of file +``` diff --git a/docs/objects/Image/play.md b/docs/objects/Image/play.md new file mode 100644 index 0000000..1eac105 --- /dev/null +++ b/docs/objects/Image/play.md @@ -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 \ No newline at end of file diff --git a/docs/objects/Image/resizeImage.md b/docs/objects/Image/resizeImage.md new file mode 100644 index 0000000..4f3a953 --- /dev/null +++ b/docs/objects/Image/resizeImage.md @@ -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) +``` diff --git a/docs/objects/Image/selectFrame.md b/docs/objects/Image/selectFrame.md new file mode 100644 index 0000000..4bbeca8 --- /dev/null +++ b/docs/objects/Image/selectFrame.md @@ -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) +``` diff --git a/docs/objects/Image/setImage.md b/docs/objects/Image/setImage.md new file mode 100644 index 0000000..a66fbfc --- /dev/null +++ b/docs/objects/Image/setImage.md @@ -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) +``` diff --git a/docs/objects/Image/usePalette.md b/docs/objects/Image/usePalette.md new file mode 100644 index 0000000..3c6e3e1 --- /dev/null +++ b/docs/objects/Image/usePalette.md @@ -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