Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

work with strings or arrays of colors

  • Loading branch information...
commit 1c66acc69f2059be65e5db3b671f53703344f984 1 parent b7dfd1e
@rmurphey authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/rgbled.js
View
12 lib/rgbled.js
@@ -35,9 +35,15 @@ RGBLed.prototype.setColor = function( color ) {
return parseInt( val, 16 );
}
- red = hexToInt( color.slice(0, 2) );
- green = hexToInt( color.slice(2, 4) );
- blue = hexToInt( color.slice(4, 6) );
+ if ( typeof color === 'string' ) {
+ red = hexToInt( color.slice(0, 2) );
+ green = hexToInt( color.slice(2, 4) );
+ blue = hexToInt( color.slice(4, 6) );
+ } else {
+ red = color[ 0 ];
+ green = color[ 1 ];
+ blue = color[ 2 ];
+ }
priv.set( this, {
red: red,
Please sign in to comment.
Something went wrong with that request. Please try again.