npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-chroma

v0.0.3

Published

color conversion based on chroma.js

Downloads

15

Readme

node-red-contrib-chroma

A Node-RED node for color conversions This node mostly is based on chroma.js with additional formats like RGBW and CIExyz

chroma.js is a small-ish zero-dependency JavaScript library (13.5kB) for all kinds of color conversions and color scales

features

  • conversion between various color formats
  • conversion between array format (chroma.js default) and objects
  • scaling of relative values either as 0..1 or 0..100
  • support of floating point and integer values
  • chroma.js api accessible to
    • manipulate colors
    • generate color scales

latest updates

0.0.3

  • fix: return callback function
  • updated examples
  • various minor fixes and typos

Install

Either use the Editor - Menu - Manage Palette - Install option, or run the following command in your Node-RED user directory (typically ~/.node-red) after installing Node-RED-dashboard.

npm i node-red-contrib-chroma

Examples

Examples can be imported via import/examples in the top right menu of the editor

  1. conversions test of all (except alpha channel) available formats
  2. mix use of chroma
  3. interactive scale use of chroma scales using the api (with a dashboard slider as input and a button to show the resulting color)

inputs

msg.payload

Alpha channel is supported to most color formats.

For relative values select the format 0..1 or 0..100 to be expected.

chroma.js input formats

  • Hex string: "#ff0000"
  • RGB string: "rgb(255, 0, 0)"
  • RGB object: {r: 255, g: 0, b: 0}
  • HSL string: "hsl(360, 50%, 100%)"
  • HSL object: {h: 360, s: 50, l: 100}
  • HSV object: {h: 360, s: 100, v: 50}
  • HSI object: {h: 360, s: 100, i: 50}
  • LAB object: {l: 1, a: 1, b: 1}
  • LCH object: {l: 1, c: 1, h: 1}
  • named colors: string
  • temperature: number 1000..40,000 k
  • luminance: number 0..1

additional formats

  • RGBW object {r:255, g:255, b:255, w:255} *useful for RGBW LEDs
  • CIExyz object {x:1, y:1, z:1} for home automation like zigbee

Node: CIExy can't be used as input as it can't be converted clearly to RGB (or somebody can to show me how)

msg.api

the api can be accessed by sending an arrayof objects

The first example of the chroma.js api documentation:

chroma.scale(['#fafa6e','#2A4858']).mode('lch').colors(6)

translates to

[
    { "scale": ["#fafa6e","#2A4858"] },
    { "mode": "lch" },
    { "colors": 6 }
]

This example will generate a six colors scale form yellow to dark green

If the api call returns a function msg.payload will be used as it's parameter. Subsequent messages (without msg.api) will return the result of the returned callback function

If no msg.payload is sent the callback function is send to the output (to be tested further).

output

All supported input formats can be selected as output. In addition CIExy can be selected

All chroma.js multi value results are formatted as an array. Tick the option to get the result as an object

For relative values select the format 0..1 or 0..100 to be emitted.

Numerical values can be rounded integers or returned as float values