Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions tinycolor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ var trimLeft = /^\s+/,
mathRandom = Math.random;

function tinycolor (color, opts) {

color = (color) ? color : '';
opts = opts || { };
opts = opts || {'preserve': false};

// If input is already a tinycolor, return itself
if (color instanceof tinycolor) {
Expand Down Expand Up @@ -44,8 +44,11 @@ function tinycolor (color, opts) {
if (this._g < 1) { this._g = mathRound(this._g); }
if (this._b < 1) { this._b = mathRound(this._b); }

this._ok = rgb.ok;
this._ok = opts.preserve?opts.ok:rgb.ok;
opts.preserve = false;
opts.ok = this._ok;
this._tc_id = tinyCounter++;
this._opts = opts;
}

tinycolor.prototype = {
Expand Down Expand Up @@ -210,7 +213,8 @@ tinycolor.prototype = {
return formattedString || this.toHexString();
},
clone: function() {
return tinycolor(this.toString());
this._opts.preserve = true;
return tinycolor(this.toString(), this._opts);
},

_applyModification: function(fn, args) {
Expand Down