28 Commits

Author SHA1 Message Date
Robert Jelic
bb921c57cd v1.6.5 2023-01-07 02:31:11 +01:00
Robert Jelic
2b85ab9746 Small fix
Forgot to check if program is active or not
2023-01-01 22:46:34 +01:00
Robert Jelic
29ebd7d4d7 Update Program.lua 2023-01-01 22:24:03 +01:00
Robert Jelic
8ab7bc4bde Auto Resizing fix
Forgot to move code for term_resize events to customEventHandler..
2023-01-01 22:21:52 +01:00
Robert Jelic
1b8f62ce41 schedule filter
Added event filters for schedules, now they should work properly.
2022-12-31 01:42:12 +01:00
Robert Jelic
61e38d89e8 Update images.lua 2022-12-30 02:30:48 +01:00
Robert Jelic
a0db5ecb61 Fixed nfp
Forgot i didn't add nfp support >.<
2022-12-30 02:14:58 +01:00
Robert Jelic
3ef7aa91bf Frame Resize
Forgot to add basalt_resize event for base frames
2022-12-26 15:51:25 +01:00
Robert Jelic
09e8589938 Update install.lua 2022-12-26 12:12:31 +01:00
Robert Jelic
e9aba2498b Small XML Fix
-fixed dyn value for width, height, x and y.
- added bgSymbol and bgSymbolColor for xml
- added texture for xml
2022-12-25 19:12:34 +01:00
Robert Jelic
20ceb6b56f Small event fix for programs 2022-12-25 16:56:13 +01:00
Robert Jelic
6d2956f3bf Updated image docs 2022-12-24 11:48:35 +01:00
Robert Jelic
91e42e096c Update utils.lua 2022-12-24 00:28:07 +01:00
Robert Jelic
5f00dfe401 Update Button.lua 2022-12-19 20:32:35 +01:00
Robert Jelic
2c4c059a70 Fixed a fix
Forgot i have to split by words and not just split when width has reached.
2022-12-18 00:43:09 +01:00
Robert Jelic
923b570d48 CreateText & splitString improvements
Improved the createText and splitString functions.
2022-12-18 00:31:52 +01:00
Robert Jelic
5499057e7e Merge pull request #43 from Erb3/path-6
✏️ Fix small typo ("sotred" -> "stored")
2022-12-16 18:31:21 +01:00
Erlend
d6091b312c ✏️ Fix small typo ("sotred" -> "stored") 2022-12-16 15:28:11 +01:00
Robert Jelic
f19c0ebb49 Update Frame.lua 2022-12-14 20:34:17 +01:00
Robert Jelic
01b83822b1 Merge branch 'master' of https://github.com/Pyroxenium/Basalt 2022-12-14 20:33:05 +01:00
Robert Jelic
c81f24cca2 Made a small mistake.. 2022-12-14 20:31:01 +01:00
Robert Jelic
ed894cb390 Monitor mouse event fix
Fixed mouse event's on monitor frames not working
2022-12-14 20:25:49 +01:00
Robert Jelic
355db9a82c Merge pull request #42 from Erb3/patch-3
📝 Fix a small typo in How-To.md
2022-12-14 20:10:28 +01:00
Erlend
8112378c70 📝 Fix a small typo in How-To.md
Fixed typo where it said `mainFrame` instead of `main`.
Reported by Broso56#0465 in the Discord.
2022-12-14 15:10:36 +01:00
Robert Jelic
a181496052 Update Frame.lua
This is just a small workaround for an actual bug - i need to figure out where it comes from.
2022-12-09 12:38:20 +01:00
Robert Jelic
636ed0001f Update init.lua
Accidentally changed package.path to nil in certain cases. Oopsie #fixed
2022-12-09 07:18:00 +01:00
Robert Jelic
0e3da7eda5 Update install.lua 2022-11-27 00:47:16 +01:00
Robert Jelic
3cf5adaef1 Add files via upload 2022-11-23 17:52:04 +01:00
23 changed files with 9295 additions and 2633 deletions

View File

@@ -92,6 +92,7 @@ return function(name, parent, pTerm, basalt)
end end
end end
end end
local function getDeepObject(name) local function getDeepObject(name)
local o = getObject(name) local o = getObject(name)
if(o~=nil)then return o end if(o~=nil)then return o end
@@ -825,9 +826,7 @@ return function(name, parent, pTerm, basalt)
if (events["other_event"][index] ~= nil) then if (events["other_event"][index] ~= nil) then
for _, value in rpairs(events["other_event"][index]) do for _, value in rpairs(events["other_event"][index]) do
if (value.eventHandler ~= nil) then if (value.eventHandler ~= nil) then
if (value:eventHandler(event, ...)) then value:eventHandler(event, ...)
return true
end
end end
end end
end end
@@ -836,6 +835,7 @@ return function(name, parent, pTerm, basalt)
if(autoSize)and not(isMonitor)then if(autoSize)and not(isMonitor)then
if(self.parent==nil)then if(self.parent==nil)then
if(event=="term_resize")then if(event=="term_resize")then
self:sendEvent("basalt_resize", self, event, ...)
self:setSize(termObject.getSize()) self:setSize(termObject.getSize())
autoSize = true autoSize = true
end end

View File

@@ -108,11 +108,25 @@ return function(name)
setValuesByXMLData = function(self, data) setValuesByXMLData = function(self, data)
local baseFrame = self:getBaseFrame() local baseFrame = self:getBaseFrame()
if(xmlValue("x", data)~=nil)then self:setPosition(xmlValue("x", data), self:getY()) end local tex, mode, infPlay
if(xmlValue("y", data)~=nil)then self:setPosition(self:getX(), xmlValue("y", data)) end if(xmlValue("texture", data)~=nil)then tex = xmlValue("texture", data) end
if(xmlValue("width", data)~=nil)then self:setSize(xmlValue("width", data), self.height) end if(xmlValue("mode", data)~=nil)then mode = xmlValue("mode", data) end
if(xmlValue("height", data)~=nil)then self:setSize(self.width, xmlValue("height", data)) end if(xmlValue("texturePlay", data)~=nil)then infPlay = xmlValue("texturePlay", data) end
local x, y
if(xmlValue("x", data)~=nil)then x = xmlValue("x", data) end
if(xmlValue("y", data)~=nil)then y = xmlValue("y", data) end
if(x~=nil)or(y~=nil)then
self:setPosition(x, y)
end
local w, h
if(xmlValue("width", data)~=nil)then w = xmlValue("width", data) end
if(xmlValue("height", data)~=nil)then h = xmlValue("height", data) end
if(w~=nil)or(h~=nil)then
self:setSize(w, h)
end
if(xmlValue("bg", data)~=nil)then self:setBackground(colors[xmlValue("bg", data)]) end if(xmlValue("bg", data)~=nil)then self:setBackground(colors[xmlValue("bg", data)]) end
if(xmlValue("bgSymbol", data)~=nil)then self:setBackground(self.bgColor, xmlValue("bgSymbol", data)) end
if(xmlValue("bgSymbolColor", data)~=nil)then self:setBackground(self.bgColor, self.bgSymbol, colors[xmlValue("bgSymbolColor", data)]) end
if(xmlValue("fg", data)~=nil)then self:setForeground(colors[xmlValue("fg", data)]) end if(xmlValue("fg", data)~=nil)then self:setForeground(colors[xmlValue("fg", data)]) end
if(xmlValue("value", data)~=nil)then self:setValue(colors[xmlValue("value", data)]) end if(xmlValue("value", data)~=nil)then self:setValue(colors[xmlValue("value", data)]) end
if(xmlValue("visible", data)~=nil)then if(xmlValue("visible", data))then self:show() else self:hide() end end if(xmlValue("visible", data)~=nil)then if(xmlValue("visible", data))then self:show() else self:hide() end end
@@ -141,6 +155,9 @@ return function(name)
if(xmlValue("onEvent", data)~=nil)then self:generateXMLEventFunction(self.onEvent, xmlValue("onEvent", data)) end if(xmlValue("onEvent", data)~=nil)then self:generateXMLEventFunction(self.onEvent, xmlValue("onEvent", data)) end
if(xmlValue("onGetFocus", data)~=nil)then self:generateXMLEventFunction(self.onGetFocus, xmlValue("onGetFocus", data)) end if(xmlValue("onGetFocus", data)~=nil)then self:generateXMLEventFunction(self.onGetFocus, xmlValue("onGetFocus", data)) end
if(xmlValue("onLoseFocus", data)~=nil)then self:generateXMLEventFunction(self.onLoseFocus, xmlValue("onLoseFocus", data)) end if(xmlValue("onLoseFocus", data)~=nil)then self:generateXMLEventFunction(self.onLoseFocus, xmlValue("onLoseFocus", data)) end
if(tex~=nil)then
self:setTexture(tex, mode, infPlay)
end
self:updateDraw() self:updateDraw()
return self return self
end, end,

View File

@@ -1,7 +1,7 @@
local curDir = fs.getDir(table.pack(...)[2]) or "" local curDir = fs.getDir(table.pack(...)[2]) or ""
local defaultPath = package.path
if not(packed)then if not(packed)then
local defaultPath = package.path
local format = "path;/path/?.lua;/path/?/init.lua;" local format = "path;/path/?.lua;/path/?/init.lua;"
local main = format:gsub("path", curDir) local main = format:gsub("path", curDir)

View File

@@ -1,7 +1,15 @@
local sub,floor = string.sub,math.floor local sub,floor,rep = string.sub,math.floor,string.rep
local function loadNFPAsBimg(path) local function loadNFPAsBimg(path)
return {[1]={{}, {}, paintutils.loadImage(path)}}, "bimg" local bimg = {{}}
local nfp = fs.open(path, "r")
if(nfp~=nil)then
for line in nfp.readLine do
table.insert(bimg[1], {rep(" ",#line), rep(" ",#line), line})
end
nfp.close()
return bimg
end
end end
local function loadNFP(path) local function loadNFP(path)

View File

@@ -1,14 +1,19 @@
local sub = string.sub local sub,find,reverse = string.sub,string.find,string.reverse
local splitString = function(str, sep) local function splitString(str, delimiter)
if sep == nil then local result = {}
sep = "%s" if str == "" or delimiter == "" then
return result
end
local start = 1
local delim_start, delim_end = find(str, delimiter, start)
while delim_start do
table.insert(result, sub(str, start, delim_start - 1))
start = delim_end + 1
delim_start, delim_end = find(str, delimiter, start)
end end
local t={} table.insert(result, sub(str, start))
for v in string.gmatch(str, "([^"..sep.."]+)") do return result
table.insert(t, v)
end
return t
end end
local relations = {[0] = {8, 4, 3, 6, 5}, {4, 14, 8, 7}, {6, 10, 8, 7}, {9, 11, 8, 0}, {1, 14, 8, 0}, {13, 12, 8, 0}, {2, 10, 8, 0}, {15, 8, 10, 11, 12, 14}, local relations = {[0] = {8, 4, 3, 6, 5}, {4, 14, 8, 7}, {6, 10, 8, 7}, {9, 11, 8, 0}, {1, 14, 8, 0}, {13, 12, 8, 0}, {2, 10, 8, 0}, {15, 8, 10, 11, 12, 14},
@@ -81,7 +86,7 @@ end
return { return {
getTextHorizontalAlign = function(text, width, textAlign, replaceChar) getTextHorizontalAlign = function(text, width, textAlign, replaceChar)
text = string.sub(text, 1, width) text = sub(text, 1, width)
local offset = width - string.len(text) local offset = width - string.len(text)
if (textAlign == "right") then if (textAlign == "right") then
text = string.rep(replaceChar or " ", offset) .. text text = string.rep(replaceChar or " ", offset) .. text
@@ -132,22 +137,25 @@ splitString = splitString,
createText = function(str, width) createText = function(str, width)
local uniqueLines = splitString(str, "\n") local uniqueLines = splitString(str, "\n")
local lines = {} local result = {}
for k,v in pairs(uniqueLines)do for k,v in pairs(uniqueLines)do
local line = "" if(#v==0)then table.insert(result, "") end
local words = splitString(v, " ") while #v > width do
for a,b in pairs(words)do local last_space = find(reverse(sub(v, 1, width)), " ")
if(#line+#b <= width)then if not last_space then
line = line=="" and b or line.." "..b last_space = width
if(a==#words)then table.insert(lines, line) end
else else
table.insert(lines, line) last_space = width - last_space + 1
line = b:sub(1,width)
if(a==#words)then table.insert(lines, line) end
end end
local line = sub(v, 1, last_space)
table.insert(result, line)
v = sub(v, last_space + 1)
end
if #v > 0 then
table.insert(result, v)
end end
end end
return lines return result
end, end,
getValueFromXML = function(name, tab) getValueFromXML = function(name, tab)

View File

@@ -68,7 +68,7 @@ return function(...)
local co = coroutine.create(f) local co = coroutine.create(f)
local ok, result = coroutine.resume(co, ...) local ok, result = coroutine.resume(co, ...)
if(ok)then if(ok)then
table.insert(schedules, co) table.insert(schedules, {co, result})
else else
basaltError(result) basaltError(result)
end end
@@ -154,15 +154,26 @@ local bInstance = {
end end
} }
local function handleSchedules(event, p1, p2, p3, p4) local function handleSchedules(event, ...)
if(#schedules>0)then if(#schedules>0)then
local finished = {} local finished = {}
for n=1,#schedules do for n=1,#schedules do
if(schedules[n]~=nil)then if(schedules[n]~=nil)then
if (coroutine.status(schedules[n]) == "suspended")then if (coroutine.status(schedules[n][1]) == "suspended")then
local ok, result = coroutine.resume(schedules[n], event, p1, p2, p3, p4) if(schedules[n][2]~=nil)then
if not(ok)then if(schedules[n][2]==event)then
basaltError(result) local ok, result = coroutine.resume(schedules[n][1], event, ...)
schedules[n][2] = result
if not(ok)then
basaltError(result)
end
end
else
local ok, result = coroutine.resume(schedules[n][1], event, ...)
schedules[n][2] = result
if not(ok)then
basaltError(result)
end
end end
else else
table.insert(finished, n) table.insert(finished, n)
@@ -240,21 +251,23 @@ local function basaltUpdateEvent(event, ...)
local mouseEvent = mouseEvents[event] local mouseEvent = mouseEvents[event]
if(mouseEvent~=nil)then if(mouseEvent~=nil)then
mouseEvent(mainFrame, ...) mouseEvent(mainFrame, ...)
handleSchedules(event, ...)
drawFrames() drawFrames()
return return
end end
end end
if(event == "monitor_touch") then if(event == "monitor_touch") then
if(monFrames[p1]~=nil)then if(monFrames[a[1]]~=nil)then
monFrames[p1]:mouseHandler(1, a[2], a[3], true) monFrames[a[1]]:mouseHandler(1, a[2], a[3], true)
activeFrame = monFrames[p1] activeFrame = monFrames[a[1]]
end end
if(count(monGroups)>0)then if(count(monGroups)>0)then
for k,v in pairs(monGroups)do for k,v in pairs(monGroups)do
v[1]:mouseHandler(1, a[2], a[3], true, a[1]) v[1]:mouseHandler(1, a[2], a[3], true, a[1])
end end
end end
handleSchedules(event, ...)
drawFrames() drawFrames()
return return
end end
@@ -273,6 +286,7 @@ local function basaltUpdateEvent(event, ...)
activeKey[a[1]] = false activeKey[a[1]] = false
end end
keyEvent(activeFrame, ...) keyEvent(activeFrame, ...)
handleSchedules(event, ...)
drawFrames() drawFrames()
return return
end end

View File

@@ -38,7 +38,7 @@ return function(name)
end; end;
setText = function(self, text) setText = function(self, text)
base:setValue(text) base:setValue(tostring(text))
self:updateDraw() self:updateDraw()
return self return self
end; end;

View File

@@ -706,49 +706,54 @@ return function(name, parent)
end end
end, end,
customEventHandler = function(self, event, ...)
base.customEventHandler(self, event, ...)
if (curProcess == nil) then
return
end
if(event=="basalt_resize")then
local w, h = pWindow.getSize()
local pW, pH = self:getSize()
if(w~=pW)or(h~=pH)then
pWindow.basalt_resize(pW, pH)
if not (curProcess:isDead()) then
resumeProcess(self, "term_resize")
end
end
pWindow.basalt_reposition(self:getAnchorPosition())
end
end,
eventHandler = function(self, event, p1, p2, p3, p4) eventHandler = function(self, event, p1, p2, p3, p4)
if(base.eventHandler(self, event, p1, p2, p3, p4))then base.eventHandler(self, event, p1, p2, p3, p4)
if (curProcess == nil) then if (curProcess == nil) then
return return
end end
if(event=="dynamicValueEvent")then if not (curProcess:isDead()) then
local w, h = pWindow.getSize() if not (paused) then
local pW, pH = self:getSize() if(event ~= "terminate") then
if(w~=pW)or(h~=pH)then resumeProcess(self, event, p1, p2, p3, p4)
pWindow.basalt_resize(pW, pH)
if not (curProcess:isDead()) then
resumeProcess(self, "term_resize")
end
end end
pWindow.basalt_reposition(self:getAnchorPosition()) if (self:isFocused()) then
local obx, oby = self:getAnchorPosition()
end local xCur, yCur = pWindow.getCursorPos()
if not (curProcess:isDead()) then if (self.parent ~= nil) then
if not (paused) then local w,h = self:getSize()
if(event ~= "terminate") then if (obx + xCur - 1 >= 1 and obx + xCur - 1 <= obx + w - 1 and yCur + oby - 1 >= 1 and yCur + oby - 1 <= oby + h - 1) then
resumeProcess(self, event, p1, p2, p3, p4) self.parent:setCursor(pWindow.getCursorBlink(), obx + xCur - 1, yCur + oby - 1, pWindow.getTextColor())
end
if (self:isFocused()) then
local obx, oby = self:getAnchorPosition()
local xCur, yCur = pWindow.getCursorPos()
if (self.parent ~= nil) then
local w,h = self:getSize()
if (obx + xCur - 1 >= 1 and obx + xCur - 1 <= obx + w - 1 and yCur + oby - 1 >= 1 and yCur + oby - 1 <= oby + h - 1) then
self.parent:setCursor(pWindow.getCursorBlink(), obx + xCur - 1, yCur + oby - 1, pWindow.getTextColor())
end
end
if (event == "terminate") then
resumeProcess(self, event)
self.parent:setCursor(false)
return true
end end
end end
else
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } }) if (event == "terminate") then
resumeProcess(self, event)
self.parent:setCursor(false)
return true
end
end end
else
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } })
end end
return false
end end
end, end,

View File

@@ -1,3 +1,5 @@
# How-To
After downloading the project you can finally start creating your own program and use basalt. The first thing you want to use in your program is always: After downloading the project you can finally start creating your own program and use basalt. The first thing you want to use in your program is always:
```lua ```lua
@@ -24,7 +26,7 @@ local basalt = require("basalt") --> Load the basalt framework into the variable
--> Now we want to create a base frame, we call the variable "main" - by default everything you create is visible. (you don't need to use :show()) --> Now we want to create a base frame, we call the variable "main" - by default everything you create is visible. (you don't need to use :show())
local main = basalt.createFrame() local main = basalt.createFrame()
local button = mainFrame:addButton() --> Here we add our first button local button = main:addButton() --> Here we add our first button
button:setPosition(4, 4) -- of course we want to change the default position of our button button:setPosition(4, 4) -- of course we want to change the default position of our button
button:setSize(16, 3) -- and the default size. button:setSize(16, 3) -- and the default size.
button:setText("Click me!") --> This method displays what the text of our button should look like button:setText("Click me!") --> This method displays what the text of our button should look like

View File

@@ -243,6 +243,7 @@ function installer.generateWebVersion(file, version)
if(request~=nil)then if(request~=nil)then
if(fs.exists(file))then if(fs.exists(file))then
fs.delete(file) fs.delete(file)
end
local f = fs.open(file, "w") local f = fs.open(file, "w")
local link = "https://basalt.madefor.cc/versions/"..version local link = "https://basalt.madefor.cc/versions/"..version
local content = 'local request = http.get("'..link..'", _G._GIT_API_KEY and {Authorization = "token ".._G._GIT_API_KEY})\n' local content = 'local request = http.get("'..link..'", _G._GIT_API_KEY and {Authorization = "token ".._G._GIT_API_KEY})\n'
@@ -257,7 +258,6 @@ end
f.write(content) f.write(content)
f.close() f.close()
printStatus("Web version successfully downloaded!") printStatus("Web version successfully downloaded!")
end
else else
error("Version doesn't exist!") error("Version doesn't exist!")
end end
@@ -367,7 +367,7 @@ if(#args>0)then
installer.downloadProject(args[2] or "basalt", args[3] or "master", args[4]~=nil and installer.createIgnoreList(args[4]) or nil) installer.downloadProject(args[2] or "basalt", args[3] or "master", args[4]~=nil and installer.createIgnoreList(args[4]) or nil)
elseif(string.lower(args[1])=="web")then elseif(string.lower(args[1])=="web")then
installer.generateWebVersion(args[3] or "basaltWeb.lua", args[2] or "latest.lua") installer.generateWebVersion(args[3] or "basaltWeb.lua", args[2] or "latest.lua")
elseif(string.lower(args[1])=="file")then elseif(string.lower(args[1])=="file")or(string.lower(args[1])=="release")then
installer.download("https://basalt.madefor.cc/versions/"..args[2] or "latest.lua", args[3] or "basalt.lua") installer.download("https://basalt.madefor.cc/versions/"..args[2] or "latest.lua", args[3] or "basalt.lua")
end end
end end

View File

@@ -1,14 +1,19 @@
## setTheme ## setTheme
Sets the default theme of that frame children objects always try to get the theme of its parent frame, if it does not exist it goes to its parent parent frame, and so on until it reaches the basalt managers theme - which is sotred in theme.lua (Please checkout [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for how it could look like.
Sets the default theme, of that frame children objects always try to get the theme of its parent frame, if it does not exist it goes to its parent parent frame, and so on until it reaches the basalt manager's theme - which is stored in theme.lua (Please checkout [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for how it could look like.
#### Parameters: #### Parameters:
1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example 1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
#### Returns: #### Returns:
1. `frame` The frame being used 1. `frame` The frame being used
#### Usage: #### Usage:
* Creates a new base frame and adds a new theme which only changes the default color of buttons.
- Creates a new base frame and adds a new theme which only changes the default color of buttons.
```lua ```lua
local myFrame = basalt.createFrame():setTheme({ local myFrame = basalt.createFrame():setTheme({
ButtonBG = colors.yellow, ButtonBG = colors.yellow,

View File

@@ -1,12 +1,18 @@
The image object is for adding more advanced backgrounds. The image object is for adding more advanced backgrounds to your interface. It supports the loading of .nfp and .bimg images.
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.
[Object](objects/Object.md) methods also apply for images. [Object](objects/Object.md) methods also apply for images.
| | | | | |
|---|---| |---|---|
|[loadImage](objects/Image/loadImage.md)|Adds a new object |[loadImage](objects/Image/loadImage.md)|Loads an image from the specified file path
|[shrink](objects/Image/shrink.md)|Sets the top bar text and colors - deprecated |[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)

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 ## loadImage
loads a default .nfp file into the object. This method is used to load an image file into the image object.
#### Parameters: #### Parameters:
1. `string` the absolute file path
1. `path` the absolute file path
#### Returns: #### Returns:
1. `object` The object in use 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.nfp file
```lua ```lua
local mainFrame = basalt.createFrame() local mainFrame = basalt.createFrame()
local aImage = mainFrame:addImage():loadImage("test.nfp") local aImage = mainFrame:addImage():loadImage("test.nfp")
``` ```
```xml ```xml
<image path="test.nfp" /> <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

File diff suppressed because one or more lines are too long

3083
docs/versions/basalt.lua Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long