I installed the gradient module I want to use...
$ npm install javascript-color-gradient
I set the module in settings.js file...
functionGlobalContext: {
os:require('os'),
i2c:require('i2c-bus'),
gradient:require('javascript-color-gradient')
},
Restart NR, then I try use same in a function node...
const YELLOW = '#FFFF00',
BLUE = '#0000FF',
RED = '#FF0000',
GREEN = '#008000';
var theGradient = global.get('gradient');
theGradient.setMidpoint(100);
theGradient.setGradient(BLUE, GREEN, YELLOW, RED);
But I get an error stating that 'setMidpoint' is not function? It definitely is in the module.
Sample flow...
[{"id":"61ba5336.7bee9c","type":"inject","z":"fe68c827.8d72","name":"Test","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":320,"wires":[["843ec91f.5c2d3"]]},{"id":"843ec91f.5c2d3","type":"function","z":"fe68c827.8d72","name":"Test","func":"const YELLOW = '#FFFF00',\n BLUE = '#0000FF',\n RED = '#FF0000',\n GREEN = '#008000';\n \nvar theGradient = global.get('gradient');\n\ntheGradient.setMidpoint(100);\ntheGradient.setGradient(BLUE, GREEN, YELLOW, RED);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":230,"y":320,"wires":[[]]}]