Permalink
Browse files

now able to accept number & export number

  • Loading branch information...
1 parent 774dd4e commit 50754a1a9fd678aee527b7a90ed38a7758f75a5f @Cactusbone committed Sep 3, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 jquery.color.js
View
@@ -245,6 +245,15 @@ color.fn = jQuery.extend( color.prototype, {
return this;
}
+ //binary color without alpha
+ if ( type === "number" ) {
+ source=red;
+ red = Math.floor( source / 65536 );
+ green = Math.floor( ( source - ( red * 65536 ) ) / 256 );
+ blue = source - ( red * 65536 ) - ( green * 256 );
+ return this.parse( [ red , green , blue ] );
+ }
+
if ( type === "object" ) {
if ( red instanceof color ) {
each( spaces, function( spaceName, space ) {
@@ -414,6 +423,10 @@ color.fn = jQuery.extend( color.prototype, {
return v.length === 1 ? "0" + v : v;
}).join("");
},
+ toNumber: function() {
+ var r = this._rgba[0], g = this._rgba[1], b = this._rgba[2];
+ return r * 65536 + g * 256 + b;
+ },
toString: function() {
return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
}

0 comments on commit 50754a1

Please sign in to comment.