Socket
Socket
Sign inDemoInstall

hsluv

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hsluv - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

169

hsluv.js

@@ -1,35 +0,2 @@

(function() {
var HxOverrides = function() { };
HxOverrides.cca = function(s,index) {
var x = s.charCodeAt(index);
if(x != x) return undefined;
return x;
};
HxOverrides.substr = function(s,pos,len) {
if(pos != null && pos != 0 && len != null && len < 0) return "";
if(len == null) len = s.length;
if(pos < 0) {
pos = s.length + pos;
if(pos < 0) pos = 0;
} else if(len < 0) len = s.length + len - pos;
return s.substr(pos,len);
};
var Std = function() { };
Std.parseInt = function(x) {
var v = parseInt(x,10);
if(v == 0 && (HxOverrides.cca(x,1) == 120 || HxOverrides.cca(x,1) == 88)) v = parseInt(x);
if(isNaN(v)) return null;
return v;
};
var StringTools = function() { };
StringTools.hex = function(n,digits) {
var s = "";
var hexChars = "0123456789ABCDEF";
do {
s = hexChars.charAt(n & 15) + s;
n >>>= 4;
} while(n > 0);
if(digits != null) while(s.length < digits) s = "0" + s;
return s;
};
// Generated by Haxe 3.4.4
var hsluv = hsluv || {};

@@ -67,4 +34,3 @@ hsluv.Geometry = function() { };

var sub1 = Math.pow(L + 16,3) / 1560896;
var sub2;
if(sub1 > hsluv.Hsluv.epsilon) sub2 = sub1; else sub2 = L / hsluv.Hsluv.kappa;
var sub2 = sub1 > hsluv.Hsluv.epsilon ? sub1 : L / hsluv.Hsluv.kappa;
var _g = 0;

@@ -89,7 +55,8 @@ while(_g < 3) {

var bounds = hsluv.Hsluv.getBounds(L);
var min = 1.7976931348623157e+308;
var min = Infinity;
var _g = 0;
while(_g < 2) {
var i = _g++;
var length = hsluv.Geometry.distanceLineFromOrigin(bounds[i]);
while(_g < bounds.length) {
var bound = bounds[_g];
++_g;
var length = hsluv.Geometry.distanceLineFromOrigin(bound);
min = Math.min(min,length);

@@ -102,3 +69,3 @@ }

var bounds = hsluv.Hsluv.getBounds(L);
var min = 1.7976931348623157e+308;
var min = Infinity;
var _g = 0;

@@ -109,3 +76,5 @@ while(_g < bounds.length) {

var length = hsluv.Geometry.lengthOfRayUntilIntersect(hrad,bound);
if(length >= 0) min = Math.min(min,length);
if(length >= 0) {
min = Math.min(min,length);
}
}

@@ -125,6 +94,14 @@ return min;

hsluv.Hsluv.fromLinear = function(c) {
if(c <= 0.0031308) return 12.92 * c; else return 1.055 * Math.pow(c,0.416666666666666685) - 0.055;
if(c <= 0.0031308) {
return 12.92 * c;
} else {
return 1.055 * Math.pow(c,0.416666666666666685) - 0.055;
}
};
hsluv.Hsluv.toLinear = function(c) {
if(c > 0.04045) return Math.pow((c + 0.055) / 1.055,2.4); else return c / 12.92;
if(c > 0.04045) {
return Math.pow((c + 0.055) / 1.055,2.4);
} else {
return c / 12.92;
}
};

@@ -139,6 +116,14 @@ hsluv.Hsluv.xyzToRgb = function(tuple) {

hsluv.Hsluv.yToL = function(Y) {
if(Y <= hsluv.Hsluv.epsilon) return Y / hsluv.Hsluv.refY * hsluv.Hsluv.kappa; else return 116 * Math.pow(Y / hsluv.Hsluv.refY,0.333333333333333315) - 16;
if(Y <= hsluv.Hsluv.epsilon) {
return Y / hsluv.Hsluv.refY * hsluv.Hsluv.kappa;
} else {
return 116 * Math.pow(Y / hsluv.Hsluv.refY,0.333333333333333315) - 16;
}
};
hsluv.Hsluv.lToY = function(L) {
if(L <= 8) return hsluv.Hsluv.refY * L / hsluv.Hsluv.kappa; else return hsluv.Hsluv.refY * Math.pow((L + 16) / 116,3);
if(L <= 8) {
return hsluv.Hsluv.refY * L / hsluv.Hsluv.kappa;
} else {
return hsluv.Hsluv.refY * Math.pow((L + 16) / 116,3);
}
};

@@ -160,3 +145,5 @@ hsluv.Hsluv.xyzToLuv = function(tuple) {

var L = hsluv.Hsluv.yToL(Y);
if(L == 0) return [0,0,0];
if(L == 0) {
return [0,0,0];
}
var U = 13 * L * (varU - hsluv.Hsluv.refU);

@@ -170,3 +157,5 @@ var V = 13 * L * (varV - hsluv.Hsluv.refV);

var V = tuple[2];
if(L == 0) return [0,0,0];
if(L == 0) {
return [0,0,0];
}
var varU = U / (13 * L) + hsluv.Hsluv.refU;

@@ -185,6 +174,10 @@ var varV = V / (13 * L) + hsluv.Hsluv.refV;

var H;
if(C < 0.00000001) H = 0; else {
if(C < 0.00000001) {
H = 0;
} else {
var Hrad = Math.atan2(V,U);
H = Hrad * 180.0 / 3.1415926535897932;
if(H < 0) H = 360 + H;
H = Hrad * 180.0 / Math.PI;
if(H < 0) {
H = 360 + H;
}
}

@@ -206,4 +199,8 @@ return [L,C,H];

var L = tuple[2];
if(L > 99.9999999) return [100,0,H];
if(L < 0.00000001) return [0,0,H];
if(L > 99.9999999) {
return [100,0,H];
}
if(L < 0.00000001) {
return [0,0,H];
}
var max = hsluv.Hsluv.maxChromaForLH(L,H);

@@ -217,4 +214,8 @@ var C = max / 100 * S;

var H = tuple[2];
if(L > 99.9999999) return [H,0,100];
if(L < 0.00000001) return [H,0,0];
if(L > 99.9999999) {
return [H,0,100];
}
if(L < 0.00000001) {
return [H,0,0];
}
var max = hsluv.Hsluv.maxChromaForLH(L,H);

@@ -228,4 +229,8 @@ var S = C / max * 100;

var L = tuple[2];
if(L > 99.9999999) return [100,0,H];
if(L < 0.00000001) return [0,0,H];
if(L > 99.9999999) {
return [100,0,H];
}
if(L < 0.00000001) {
return [0,0,H];
}
var max = hsluv.Hsluv.maxSafeChromaForL(L);

@@ -239,4 +244,8 @@ var C = max / 100 * S;

var H = tuple[2];
if(L > 99.9999999) return [H,0,100];
if(L < 0.00000001) return [H,0,0];
if(L > 99.9999999) {
return [H,0,100];
}
if(L < 0.00000001) {
return [H,0,0];
}
var max = hsluv.Hsluv.maxSafeChromaForL(L);

@@ -248,8 +257,10 @@ var S = C / max * 100;

var h = "#";
var _g1 = 0;
var _g = tuple.length;
while(_g1 < _g) {
var i = _g1++;
var _g = 0;
while(_g < 3) {
var i = _g++;
var chan = tuple[i];
h += StringTools.hex(Math.round(chan * 255),2).toLowerCase();
var c = Math.round(chan * 255);
var digit2 = c % 16;
var digit1 = (c - digit2) / 16 | 0;
h += hsluv.Hsluv.hexChars.charAt(digit1) + hsluv.Hsluv.hexChars.charAt(digit2);
}

@@ -259,4 +270,13 @@ return h;

hsluv.Hsluv.hexToRgb = function(hex) {
hex = hex.toUpperCase();
return [Std.parseInt("0x" + HxOverrides.substr(hex,1,2)) / 255.0,Std.parseInt("0x" + HxOverrides.substr(hex,3,2)) / 255.0,Std.parseInt("0x" + HxOverrides.substr(hex,5,2)) / 255.0];
hex = hex.toLowerCase();
var ret = [];
var _g = 0;
while(_g < 3) {
var i = _g++;
var digit1 = hsluv.Hsluv.hexChars.indexOf(hex.charAt(i * 2 + 1));
var digit2 = hsluv.Hsluv.hexChars.indexOf(hex.charAt(i * 2 + 2));
var n = digit1 * 16 + digit2;
ret.push(n / 255.0);
}
return ret;
};

@@ -300,2 +320,3 @@ hsluv.Hsluv.lchToRgb = function(tuple) {

hsluv.Hsluv.epsilon = 0.0088564516;
hsluv.Hsluv.hexChars = "0123456789abcdef";
var root = {

@@ -310,16 +331,4 @@ "hsluvToRgb": hsluv.Hsluv.hsluvToRgb,

"hexToHpluv": hsluv.Hsluv.hexToHpluv
};// CommonJS module system (including Node)
if (typeof module !== 'undefined') {
module['exports'] = root;
}
};
// AMD module system
if (typeof define !== 'undefined') {
define(root);
}
// Export to browser
if (typeof window !== 'undefined') {
window['hsluv'] = root;
}
})();
module.exports = root;

@@ -5,3 +5,3 @@ {

"keywords": ["color", "color space", "CIE", "RGB", "HSL", "HSLuv", "HPLuv"],
"version": "0.0.1",
"version": "0.0.2",
"author": "Alexei Boronine <alexei@boronine.com>",

@@ -8,0 +8,0 @@ "license": "MIT",

@@ -1,2 +0,2 @@

# HSLuv - Human-friendly HSL
# HSL<sub>uv</sub> - Human-friendly HSL

@@ -15,2 +15,6 @@ ## Installation

Most functions take tuples, ie: Javascript arrays with three elements. Make sure you are using
`func([a,b,c])` and not `func(a,b,c)`. If you are getting NaN for output then this is probably
the problem.
**hsluvToHex([hue, saturation, lightness])**

@@ -30,4 +34,4 @@

Takes a hex string and returns the HSLuv color as array that contains
the hue (0-360), saturation(0-100) and lightness(0-100) channel.
_Note_: The result can have rounding errors. For example saturation can
the hue (0-360), saturation (0-100) and lightness (0-100) channel.
_Note:_ The result can have rounding errors. For example saturation can
be 100.00000000000007

@@ -44,3 +48,3 @@

HSLuv can also be used as a [Stylus](http://learnboost.github.com/stylus/)
plugin. See [here](https://github.com/hsluv/husl-stylus).
Also available for [Stylus](http://stylus-lang.com/). See
[here](https://github.com/hsluv/hsluv-stylus).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc