Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb921c57cd | ||
|
|
2b85ab9746 | ||
|
|
29ebd7d4d7 | ||
|
|
8ab7bc4bde | ||
|
|
1b8f62ce41 | ||
|
|
61e38d89e8 | ||
|
|
a0db5ecb61 | ||
|
|
3ef7aa91bf | ||
|
|
09e8589938 | ||
|
|
e9aba2498b | ||
|
|
20ceb6b56f | ||
|
|
6d2956f3bf | ||
|
|
91e42e096c | ||
|
|
5f00dfe401 | ||
|
|
2c4c059a70 | ||
|
|
923b570d48 | ||
|
|
5499057e7e | ||
|
|
d6091b312c | ||
|
|
f19c0ebb49 | ||
|
|
01b83822b1 | ||
|
|
c81f24cca2 | ||
|
|
ed894cb390 | ||
|
|
355db9a82c | ||
|
|
8112378c70 | ||
|
|
a181496052 | ||
|
|
636ed0001f | ||
|
|
0e3da7eda5 | ||
|
|
3cf5adaef1 |
@@ -92,6 +92,7 @@ return function(name, parent, pTerm, basalt)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function getDeepObject(name)
|
||||
local o = getObject(name)
|
||||
if(o~=nil)then return o end
|
||||
@@ -825,9 +826,7 @@ return function(name, parent, pTerm, basalt)
|
||||
if (events["other_event"][index] ~= nil) then
|
||||
for _, value in rpairs(events["other_event"][index]) do
|
||||
if (value.eventHandler ~= nil) then
|
||||
if (value:eventHandler(event, ...)) then
|
||||
return true
|
||||
end
|
||||
value:eventHandler(event, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -836,6 +835,7 @@ return function(name, parent, pTerm, basalt)
|
||||
if(autoSize)and not(isMonitor)then
|
||||
if(self.parent==nil)then
|
||||
if(event=="term_resize")then
|
||||
self:sendEvent("basalt_resize", self, event, ...)
|
||||
self:setSize(termObject.getSize())
|
||||
autoSize = true
|
||||
end
|
||||
|
||||
@@ -108,11 +108,25 @@ return function(name)
|
||||
|
||||
setValuesByXMLData = function(self, data)
|
||||
local baseFrame = self:getBaseFrame()
|
||||
if(xmlValue("x", data)~=nil)then self:setPosition(xmlValue("x", data), self:getY()) end
|
||||
if(xmlValue("y", data)~=nil)then self:setPosition(self:getX(), xmlValue("y", data)) end
|
||||
if(xmlValue("width", data)~=nil)then self:setSize(xmlValue("width", data), self.height) end
|
||||
if(xmlValue("height", data)~=nil)then self:setSize(self.width, xmlValue("height", data)) end
|
||||
local tex, mode, infPlay
|
||||
if(xmlValue("texture", data)~=nil)then tex = xmlValue("texture", data) end
|
||||
if(xmlValue("mode", data)~=nil)then mode = xmlValue("mode", 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("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("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
|
||||
@@ -141,6 +155,9 @@ return function(name)
|
||||
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("onLoseFocus", data)~=nil)then self:generateXMLEventFunction(self.onLoseFocus, xmlValue("onLoseFocus", data)) end
|
||||
if(tex~=nil)then
|
||||
self:setTexture(tex, mode, infPlay)
|
||||
end
|
||||
self:updateDraw()
|
||||
return self
|
||||
end,
|
||||
@@ -1051,4 +1068,4 @@ return function(name)
|
||||
|
||||
object.__index = object
|
||||
return object
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local curDir = fs.getDir(table.pack(...)[2]) or ""
|
||||
|
||||
local defaultPath = package.path
|
||||
if not(packed)then
|
||||
local defaultPath = package.path
|
||||
local format = "path;/path/?.lua;/path/?/init.lua;"
|
||||
|
||||
local main = format:gsub("path", curDir)
|
||||
@@ -14,4 +14,4 @@ end
|
||||
local Basalt = require("main")
|
||||
package.path = defaultPath
|
||||
|
||||
return Basalt
|
||||
return Basalt
|
||||
|
||||
@@ -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)
|
||||
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
|
||||
|
||||
local function loadNFP(path)
|
||||
@@ -86,4 +94,4 @@ return {
|
||||
resizeBIMG = resizeBIMG,
|
||||
loadImageAsBimg = loadImageAsBimg,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
local sub = string.sub
|
||||
local sub,find,reverse = string.sub,string.find,string.reverse
|
||||
|
||||
local splitString = function(str, sep)
|
||||
if sep == nil then
|
||||
sep = "%s"
|
||||
local function splitString(str, delimiter)
|
||||
local result = {}
|
||||
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
|
||||
local t={}
|
||||
for v in string.gmatch(str, "([^"..sep.."]+)") do
|
||||
table.insert(t, v)
|
||||
end
|
||||
return t
|
||||
table.insert(result, sub(str, start))
|
||||
return result
|
||||
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},
|
||||
@@ -81,7 +86,7 @@ end
|
||||
|
||||
return {
|
||||
getTextHorizontalAlign = function(text, width, textAlign, replaceChar)
|
||||
text = string.sub(text, 1, width)
|
||||
text = sub(text, 1, width)
|
||||
local offset = width - string.len(text)
|
||||
if (textAlign == "right") then
|
||||
text = string.rep(replaceChar or " ", offset) .. text
|
||||
@@ -132,22 +137,25 @@ splitString = splitString,
|
||||
|
||||
createText = function(str, width)
|
||||
local uniqueLines = splitString(str, "\n")
|
||||
local lines = {}
|
||||
local result = {}
|
||||
for k,v in pairs(uniqueLines)do
|
||||
local line = ""
|
||||
local words = splitString(v, " ")
|
||||
for a,b in pairs(words)do
|
||||
if(#line+#b <= width)then
|
||||
line = line=="" and b or line.." "..b
|
||||
if(a==#words)then table.insert(lines, line) end
|
||||
if(#v==0)then table.insert(result, "") end
|
||||
while #v > width do
|
||||
local last_space = find(reverse(sub(v, 1, width)), " ")
|
||||
if not last_space then
|
||||
last_space = width
|
||||
else
|
||||
table.insert(lines, line)
|
||||
line = b:sub(1,width)
|
||||
if(a==#words)then table.insert(lines, line) end
|
||||
last_space = width - last_space + 1
|
||||
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
|
||||
return lines
|
||||
return result
|
||||
end,
|
||||
|
||||
getValueFromXML = function(name, tab)
|
||||
|
||||
@@ -68,7 +68,7 @@ return function(...)
|
||||
local co = coroutine.create(f)
|
||||
local ok, result = coroutine.resume(co, ...)
|
||||
if(ok)then
|
||||
table.insert(schedules, co)
|
||||
table.insert(schedules, {co, result})
|
||||
else
|
||||
basaltError(result)
|
||||
end
|
||||
@@ -154,15 +154,26 @@ local bInstance = {
|
||||
end
|
||||
}
|
||||
|
||||
local function handleSchedules(event, p1, p2, p3, p4)
|
||||
local function handleSchedules(event, ...)
|
||||
if(#schedules>0)then
|
||||
local finished = {}
|
||||
for n=1,#schedules do
|
||||
if(schedules[n]~=nil)then
|
||||
if (coroutine.status(schedules[n]) == "suspended")then
|
||||
local ok, result = coroutine.resume(schedules[n], event, p1, p2, p3, p4)
|
||||
if not(ok)then
|
||||
basaltError(result)
|
||||
if (coroutine.status(schedules[n][1]) == "suspended")then
|
||||
if(schedules[n][2]~=nil)then
|
||||
if(schedules[n][2]==event)then
|
||||
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
|
||||
else
|
||||
table.insert(finished, n)
|
||||
@@ -240,21 +251,23 @@ local function basaltUpdateEvent(event, ...)
|
||||
local mouseEvent = mouseEvents[event]
|
||||
if(mouseEvent~=nil)then
|
||||
mouseEvent(mainFrame, ...)
|
||||
handleSchedules(event, ...)
|
||||
drawFrames()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if(event == "monitor_touch") then
|
||||
if(monFrames[p1]~=nil)then
|
||||
monFrames[p1]:mouseHandler(1, a[2], a[3], true)
|
||||
activeFrame = monFrames[p1]
|
||||
if(monFrames[a[1]]~=nil)then
|
||||
monFrames[a[1]]:mouseHandler(1, a[2], a[3], true)
|
||||
activeFrame = monFrames[a[1]]
|
||||
end
|
||||
if(count(monGroups)>0)then
|
||||
for k,v in pairs(monGroups)do
|
||||
v[1]:mouseHandler(1, a[2], a[3], true, a[1])
|
||||
end
|
||||
end
|
||||
handleSchedules(event, ...)
|
||||
drawFrames()
|
||||
return
|
||||
end
|
||||
@@ -273,6 +286,7 @@ local function basaltUpdateEvent(event, ...)
|
||||
activeKey[a[1]] = false
|
||||
end
|
||||
keyEvent(activeFrame, ...)
|
||||
handleSchedules(event, ...)
|
||||
drawFrames()
|
||||
return
|
||||
end
|
||||
|
||||
@@ -38,7 +38,7 @@ return function(name)
|
||||
end;
|
||||
|
||||
setText = function(self, text)
|
||||
base:setValue(text)
|
||||
base:setValue(tostring(text))
|
||||
self:updateDraw()
|
||||
return self
|
||||
end;
|
||||
|
||||
@@ -705,50 +705,55 @@ return function(name, parent)
|
||||
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)
|
||||
if(base.eventHandler(self, event, p1, p2, p3, p4))then
|
||||
if (curProcess == nil) then
|
||||
return
|
||||
end
|
||||
if(event=="dynamicValueEvent")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
|
||||
base.eventHandler(self, event, p1, p2, p3, p4)
|
||||
if (curProcess == nil) then
|
||||
return
|
||||
end
|
||||
if not (curProcess:isDead()) then
|
||||
if not (paused) then
|
||||
if(event ~= "terminate") then
|
||||
resumeProcess(self, event, p1, p2, p3, p4)
|
||||
end
|
||||
pWindow.basalt_reposition(self:getAnchorPosition())
|
||||
|
||||
end
|
||||
if not (curProcess:isDead()) then
|
||||
if not (paused) then
|
||||
if(event ~= "terminate") then
|
||||
resumeProcess(self, event, p1, p2, p3, p4)
|
||||
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
|
||||
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
|
||||
if (event == "terminate") then
|
||||
resumeProcess(self, event)
|
||||
self.parent:setCursor(false)
|
||||
return true
|
||||
end
|
||||
else
|
||||
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } })
|
||||
end
|
||||
else
|
||||
table.insert(queuedEvent, { event = event, args = { p1, p2, p3, p4 } })
|
||||
end
|
||||
return false
|
||||
end
|
||||
end,
|
||||
|
||||
@@ -800,4 +805,4 @@ return function(name, parent)
|
||||
}
|
||||
|
||||
return setmetatable(object, base)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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:
|
||||
|
||||
```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())
|
||||
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:setSize(16, 3) -- and the default size.
|
||||
button:setText("Click me!") --> This method displays what the text of our button should look like
|
||||
|
||||
@@ -243,6 +243,7 @@ function installer.generateWebVersion(file, version)
|
||||
if(request~=nil)then
|
||||
if(fs.exists(file))then
|
||||
fs.delete(file)
|
||||
end
|
||||
local f = fs.open(file, "w")
|
||||
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'
|
||||
@@ -257,7 +258,6 @@ end
|
||||
f.write(content)
|
||||
f.close()
|
||||
printStatus("Web version successfully downloaded!")
|
||||
end
|
||||
else
|
||||
error("Version doesn't exist!")
|
||||
end
|
||||
@@ -367,9 +367,9 @@ if(#args>0)then
|
||||
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
|
||||
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")
|
||||
end
|
||||
end
|
||||
|
||||
return installer
|
||||
return installer
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
## 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.
|
||||
|
||||
#### Parameters:
|
||||
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:
|
||||
|
||||
1. `table` theme layout look into [theme](https://github.com/Pyroxenium/Basalt/blob/master/Basalt/theme.lua) for a example
|
||||
|
||||
#### Returns:
|
||||
|
||||
1. `frame` The frame being used
|
||||
|
||||
#### 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
|
||||
local myFrame = basalt.createFrame():setTheme({
|
||||
ButtonBG = colors.yellow,
|
||||
ButtonText = colors.red,
|
||||
})
|
||||
```
|
||||
```
|
||||
|
||||
@@ -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)
|
||||
|
||||
6
docs/objects/Image/getImageSize.md
Normal file
6
docs/objects/Image/getImageSize.md
Normal file
@@ -0,0 +1,6 @@
|
||||
## getImageSize
|
||||
Returns the current image size
|
||||
|
||||
#### Returns:
|
||||
1. `number` width
|
||||
2. `number` height
|
||||
9
docs/objects/Image/getMetadata.md
Normal file
9
docs/objects/Image/getMetadata.md
Normal 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
|
||||
@@ -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" />
|
||||
```
|
||||
```
|
||||
|
||||
10
docs/objects/Image/play.md
Normal file
10
docs/objects/Image/play.md
Normal 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
|
||||
19
docs/objects/Image/resizeImage.md
Normal file
19
docs/objects/Image/resizeImage.md
Normal 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)
|
||||
```
|
||||
19
docs/objects/Image/selectFrame.md
Normal file
19
docs/objects/Image/selectFrame.md
Normal 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)
|
||||
```
|
||||
23
docs/objects/Image/setImage.md
Normal file
23
docs/objects/Image/setImage.md
Normal 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)
|
||||
```
|
||||
11
docs/objects/Image/usePalette.md
Normal file
11
docs/objects/Image/usePalette.md
Normal 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
|
||||
3066
docs/versions/basalt-1.6.4.lua
Normal file
3066
docs/versions/basalt-1.6.4.lua
Normal file
File diff suppressed because one or more lines are too long
3083
docs/versions/basalt.lua
Normal file
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
Reference in New Issue
Block a user