A simple library for creating stateful colorpicker objects in starbound.
In the interface config file:
"gui": {
//...
"mywidget" : {
"type" : "canvas",
"rect" : [0, 0, 1, 1], //can be anything only the position generated is needed
"captureMouseEvents" : true
}
//...
}
//...
"canvasClickCallbacks" : {
"mywidget" : "some_name"
}
In your script:
require"/scripts/colorpicker/widget.lua"
function init()
self.picker = colorpicker.new"mywidget"
...
end
function update()
self.picker:update()
...
end
Loads the colorpicker module.
Creates a new
colorpicker
object from the given widget name stringname
.
Updates the color in the
colorpicker
. This should be called inside the script'supdate
hook.Can also be called as a method from a
colorpicker
i.epicker:update()
.
Returns the red channel value for the given
colorpicker
.Can also be called as a method from a
colorpicker
i.epicker:red()
.
Returns the green channel value for the given
colorpicker
.Can also be called as a method from a
colorpicker
i.epicker:green()
.
Returns the blue channel value for the given
colorpicker
.Can also be called as a method from a
colorpicker
i.epicker:blue()
.
Returns the RGB table representation of the current color.
Can also be called as a method from a
colorpicker
i.epicker:rgb()
.
Returns the hexadecimal number representation of the current color. Lit.
("%06x"):format(c.selected)
.Can also be called as a method from a
colorpicker
i.epicker:hex()
.
The currently selected color.
The underlying canvas widget used by the colorpicker.
The mouse coordinates (relative) for the selected color.