How to use the color-string.colorValue function in color-string

To help you get started, we’ve selected a few color-string examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nodebotsau / simplebot / lib / pixel.js View on Github external
}

    if (pixelcolor != null) {
        // fill out the values for the pixel and then send the message to update
        // it on the strip

        with (pixel.color) {
            r = pixelcolor[0];
            g = pixelcolor[1];
            b = pixelcolor[2];
            hexcode = ColorString.hexString(pixelcolor);
            color = ColorString.keyword(pixelcolor);
            rgb = pixelcolor;
        }

        color = ColorString.colorValue(pixelcolor);
        if (sendmsg) {
            var msg = "{" + pixel.addr + ":" + color + "}";
            pixel.firmata.sp.write(makeSysExString(msg));
        }
    } else {
        console.log("color supplied couldn't be parsed: " + pixelcolor);
    }
};
github ajfisher / node-pixel / lib / pixel.js View on Github external
if (e instanceof TypeError && ColorString.get(color) === null ) {
                    stripcolor = null;
                }
            }
        }
    }

    if (stripcolor != null) {
        // fill out the values for the pixels and then update the strip

        for (var i = 0; i < strip.pixels.length; i++) {
            strip.pixels[i].color(color, {sendmsg: false});
        }

        // set the whole strip color to the appropriate int value
        this.strip_color(ColorString.colorValue(stripcolor, strip.gtable));

    } else {
        console.log("Supplied colour couldn't be parsed: " + color);
    }
}
github nodebotsau / simplebot / lib / pixel.js View on Github external
stripcolor = ColorString.getRgb(color) || null;

    } else if (opts) {
        // use rgb array to determine color
        stripcolor = opts.rgb || null;
    }

    if (stripcolor != null) {
        // fill out the values for the pixels and then update the strip

        // TODO get this to update all of the pixels
/**        for (pixel in strip.pixels) {
            pixel.
        }**/

        color = ColorString.colorValue(stripcolor);
        var msg = "{a:" + color + "}";
        strip.firmata.sp.write(makeSysExString(msg));
    } else {
        console.log("color supplied couldn't be parsed: " + stripcolor);
    }
}
github ajfisher / node-pixel / lib / pixel.js View on Github external
// fill out the values for the pixel and then send the message to update
        // it on the strip

        pixel.color.r = pixelcolor.value[0];
        pixel.color.g = pixelcolor.value[1];
        pixel.color.b = pixelcolor.value[2];
        pixel.color.hexcode = ColorString.to.hex(pixelcolor.value);
        pixel.color.color = ColorString.to.keyword(pixelcolor.value);
        if (pixelcolor.value.length == 4) {
            pixelcolor.value.pop();
        }
        pixel.color.rgb = pixelcolor.value;


        //console.log(pixel.parent.gtable);
        color = ColorString.colorValue(pixelcolor.value, pixel.parent.gtable);
        if (sendmsg) {
            // TODO probably should be pulling the color off the obj rather than
            // sending it to this function....
            this.pixel_color(color);
        }
    } else {
        console.log("Color supplied couldn't be parsed: " + color);
    }
};