bgrins / TinyColor

Fast, small color manipulation and conversion for JavaScript
https://bgrins.github.io/TinyColor/
MIT License
5.05k stars 439 forks source link

Is toFloatString() implemented? #232

Open wafflook opened 2 years ago

wafflook commented 2 years ago

Hi. In TinyColor v1.4.1 used in this project, toFloatString() is implemented. I checked the commit log, but it doesn't seem to have been implemented. Has this method been turned off at some point? It is a very useful method.

I added two methods to match the TinyColor base ;)

toFloatRgb: function() {
  return { r: +bound01(this._r, 255).toFixed(2), g: +bound01(this._g, 255).toFixed(2), b: +bound01(this._b, 255).toFixed(2), a: +bound01(this._a, 255).toFixed(2) };
},
toFloatRgbString: function() {
  return (this._a == 1) ?
    "3f(" + bound01(this._r, 255).toFixed(2) + ", " + bound01(this._g, 255).toFixed(2) + ", " + bound01(this._g, 255).toFixed(2) + ")" :
    "4f(" + bound01(this._r, 255).toFixed(2) + ", " + bound01(this._g, 255).toFixed(2) + ", " + bound01(this._g, 255).toFixed(2) + ", " + bound01(this._a, 255).toFixed(2) + ")";
}

thanks :)