Permalink
Browse files

work with strings or arrays of colors

  • Loading branch information...
1 parent b7dfd1e commit 1c66acc69f2059be65e5db3b671f53703344f984 @rmurphey committed Sep 16, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/rgbled.js
View
@@ -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,

0 comments on commit 1c66acc

Please sign in to comment.