Closed lautriva closed 3 years ago
Hi, you can add your own color display format by modifying _~/.config/gpick/userinit.lua file. To add your desired display format, use the following code:
local gpick = require('gpick')
gpick:addConverter('example', 'Example', function(colorObject)
local c = colorObject:getColor()
local previousLocale = os.setlocale(nil, "numeric")
os.setlocale("C", "numeric")
local result = string.format('%0.6f, %0.6f, %0.6f', c:red(), c:green(), c:blue())
os.setlocale(previousLocale, "numeric")
return result
end)
After _userinit.lua file modification, restart Gpick and open Edit -> Edit Converters... dialog. Select Example in Displays drop-down list to use newly defined function for color value display in widgets. If the same format should be used in palette, then select Example in Color list drop-down list. If you want to be able to copy colors in this format, then select Copy checkbox in corresponding row. Finally, if this format should be used by default to copy/drag colors to other programs, then drag Example row to the top of the list.
Configuration example:
Additional information can be found here: http://www.gpick.org/help/converters.html
Doesn't work on my side :( It seems I'm lacking a dependency?
I'm using Linux Mint 20.1 (Xfce flavor)
$ gpick
/home/MY_USERNAME/.config/gpick/user_init.lua:1: module 'gpick' not found:
no field package.preload['gpick']
no file '/usr/share/gpick/gpick.lua'
no file '/home/MY_USERNAME/.config/gpick/gpick.lua'
no file '/usr/local/lib/lua/5.2/gpick.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.2/gpick.so'
no file '/usr/lib/lua/5.2/gpick.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './gpick.so'
$ cat ~/.config/gpick/user_init.lua
local gpick = require('gpick')
gpick:addConverter('example', 'Example', function(colorObject)
local c = colorObject:getColor()
local previousLocale = os.setlocale(nil, "numeric")
os.setlocale("C", "numeric")
local result = string.format('%0.6f, %0.6f, %0.6f', c:red(), c:green(), c:blue())
os.setlocale(previousLocale, "numeric")
return result
end)
Looks like Linux Mint does not use the latest release version yet, so slightly different code must be used. The following code should work:
gpick.converters['example'] = { human_readable = 'Example', serialize = function(colorObject)
local c = colorObject:get_color()
local previousLocale = os.setlocale(nil, "numeric")
os.setlocale("C", "numeric")
local result = string.format('%0.6f, %0.6f, %0.6f', c:red(), c:green(), c:blue())
os.setlocale(previousLocale, "numeric")
return result
end, deserialize = nil }
Yes, it works Thank you :)
I work with OpenGL-like colors and I wanted to ask for a feature to display colors as decimal numbers (between 0.0 and 1.0). At the moment, I need to pick the color on gpick then convert myself before filling in the 3d engine
For example, the color shown as
rgb(255, 143, 255)
would be shown as1.000000, 0.560784, 1.000000
Nothing too complicated: Under the hood, that's just the result of
color / 255.0
Is it possible?