colorio is a color picker(eyedropper) GUI tool, implemented as a node.js module with a native macOS
binary that represents GUI layer. It can be used in any stand-alone node.js
or Electron.js
applications running on macOS
.
$ npm install colorio
Requires macOS 10.12 or later.
A minimalistic Electron based demo can be found by the following url:
- Multiple displays support
- Retina displays support
- No dependencies
- Tiny binary ->
59 kb
- Electron integraion out of the box
const pickColor = require('colorio').pickColor;
pickColor().then((res) => {
console.log(res);
//=> on color pick
// {
// "result": "picked",
// "color": {
// "r": 0.2980392156862745,
// "g": 0.6078431372549019,
// "b": 0.2980392156862745
// }
// }
//=> on hitting `Esc` key
// {
// "result": "canceled",
// }
});
NOTE: In Electrion applications this function should be called from the main process.
Executes native binary file and returns a Promise
for the result.
Fullfills when user picks color from the screen or aborts the action by hitting Esc
key.
Type: string
Default: undefined
A custom path to the colorio's binary. Might be helpful in case of custom dev
environment setup using webpack
. If not set, path is resolved automatically based on __dirname
with respect to app.asar.unpacked
in case module is used in an Electron
app.
Returns a promise with an object when promise is fullfilled. In case color is picked, the object will look like this, where color
property contains r
, g
, b
keys representing rgb
color components in 0...1
range (0.0 -> 0, 1.0 => 255):
{
"result": "picked",
"color": {
"r": 0.2980392156862745,
"g": 0.6078431372549019,
"b": 0.2980392156862745
}
}
In case user cancels the action by hitting Esc
key, the resulting object's result
's key value will be set to canceled
:
{
"result": "canceled"
}
Currently colorio
doesn't support custom color spaces. Picked colors are converted via genericRGBColorSpace, thus the resulting colors might be a bit different from color pickers in other apps.
MIT