From ea59fe00cccf3b3c51fec6593275b545aeb44dbc Mon Sep 17 00:00:00 2001 From: David Aerne Date: Thu, 23 Sep 2021 13:31:13 +0200 Subject: [PATCH] build(typescript): uses strict typing, fixes #4 --- dist/index.d.ts | 24 ++++++++++++------------ dist/index.esm.js | 2 +- dist/index.iife.js | 2 +- dist/index.js | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index 9d692e7..9f1998f 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,6 +1,6 @@ -export declare type curveMethod = 'lamé' | 'arc' | 'pow' | 'powY' | 'powX'; -declare type vector2 = [number, number]; -declare type hsx = [number, number, number]; +export declare type CurveMethod = 'lamé' | 'arc' | 'pow' | 'powY' | 'powX'; +declare type Vector2 = [number, number]; +declare type Vector3 = [number, number, number]; declare type mainFunctionArguments = { total?: number; centerHue?: number; @@ -9,11 +9,11 @@ declare type mainFunctionArguments = { offsetShade?: number; curveAccent?: number; tintShadeHueShift?: number; - curveMethod?: curveMethod; + curveMethod?: CurveMethod; offsetCurveModTint?: number; offsetCurveModShade?: number; - minSaturationLight?: vector2; - maxSaturationLight?: vector2; + minSaturationLight?: Vector2; + maxSaturationLight?: Vector2; }; /** * function hsv2hsl @@ -22,7 +22,7 @@ declare type mainFunctionArguments = { * @param v {Number} value 0...1 * @returns {Array} h:0...360 s:0...1 l:0...1 */ -export declare const hsv2hsl: (h: number, s: number, v: number, l?: number, m?: number) => hsx; +export declare const hsv2hsl: (h: number, s: number, v: number, l?: number, m?: number) => Vector3; /** * function random * @param min {Number} minimum number @@ -40,7 +40,7 @@ export declare const random: (min: number, max: number) => number; * @param max {Number} Stop of the curve [0...1, 0...1] * @returns {Array} Vector on curve x, y */ -export declare const pointOnCurve: (curveMethod: curveMethod, i: number, total: number, curveAccent: number, min?: vector2, max?: vector2) => number[]; +export declare const pointOnCurve: (curveMethod: CurveMethod, i: number, total: number, curveAccent: number, min?: Vector2, max?: Vector2) => Vector2; /** * generateRandomColorRamp() * @param total: int 3... > Amount of base colors. @@ -63,9 +63,9 @@ export declare const pointOnCurve: (curveMethod: curveMethod, i: number, total: } */ export default function generateRandomColorRamp({ total, centerHue, hueCycle, offsetTint, offsetShade, curveAccent, tintShadeHueShift, curveMethod, offsetCurveModTint, offsetCurveModShade, minSaturationLight, maxSaturationLight }?: mainFunctionArguments): { - light: hsx[]; - dark: hsx[]; - base: hsx[]; - all: hsx[]; + light: Vector3[]; + dark: Vector3[]; + base: Vector3[]; + all: Vector3[]; }; export {}; diff --git a/dist/index.esm.js b/dist/index.esm.js index 0abb5c8..668f80a 100644 --- a/dist/index.esm.js +++ b/dist/index.esm.js @@ -1 +1 @@ -var i=(s,n,r,e=r-r*n/2,o=Math.min(e,1-e))=>[s,o?(r-e)/o:0,e],X=(s,n)=>(n||(n=s,s=0),Math.random()*(n-s)+s),y=(s,n,r,e,o=[0,0],a=[1,1])=>{let x=Math.PI/2,b=x/r,t,h;if(s==="lam\xE9"){let m=n/r*x,u=2/(2+20*e),p=Math.cos(m),M=Math.sin(m);t=Math.sign(p)*Math.abs(p)**u,h=Math.sign(M)*Math.abs(M)**u}else s==="arc"?(h=Math.cos(-Math.PI/2+n*b+e),t=Math.sin(Math.PI/2+n*b-e)):s==="pow"?(t=Math.pow(1-n/r,1-e),h=Math.pow(n/r,1-e)):s==="powY"?(t=Math.pow(1-n/r,e),h=Math.pow(n/r,1-e)):s==="powX"&&(t=Math.pow(n/r,e),h=Math.pow(n/r,1-e));return t=o[0]+Math.min(Math.max(t,0),1)*(a[0]-o[0]),h=o[1]+Math.min(Math.max(h,0),1)*(a[1]-o[1]),[t,h]};function R({total:s=3,centerHue:n=0,hueCycle:r=.3,offsetTint:e=.1,offsetShade:o=.1,curveAccent:a=0,tintShadeHueShift:x=.1,curveMethod:b="arc",offsetCurveModTint:t=.03,offsetCurveModShade:h=.03,minSaturationLight:m=[0,0],maxSaturationLight:u=[1,1]}={}){let p=[],M=[],w=[];for(let l=1;l[e,t?(n-o)/t:0,o],R=(e,r)=>(r||(r=e,e=0),Math.random()*(r-e)+e),d=(e,r,n,o,t=[0,0],a=[1,1])=>{let V=Math.PI/2,b=V/n,s=0,h=0;if(e==="lam\xE9"){let m=r/n*V,u=2/(2+20*o),p=Math.cos(m),M=Math.sin(m);s=Math.sign(p)*Math.abs(p)**u,h=Math.sign(M)*Math.abs(M)**u}else e==="arc"?(h=Math.cos(-Math.PI/2+r*b+o),s=Math.sin(Math.PI/2+r*b-o)):e==="pow"?(s=Math.pow(1-r/n,1-o),h=Math.pow(r/n,1-o)):e==="powY"?(s=Math.pow(1-r/n,o),h=Math.pow(r/n,1-o)):e==="powX"&&(s=Math.pow(r/n,o),h=Math.pow(r/n,1-o));return s=t[0]+Math.min(Math.max(s,0),1)*(a[0]-t[0]),h=t[1]+Math.min(Math.max(h,0),1)*(a[1]-t[1]),[s,h]};function F({total:e=3,centerHue:r=0,hueCycle:n=.3,offsetTint:o=.1,offsetShade:t=.1,curveAccent:a=0,tintShadeHueShift:V=.1,curveMethod:b="arc",offsetCurveModTint:s=.03,offsetCurveModShade:h=.03,minSaturationLight:m=[0,0],maxSaturationLight:u=[1,1]}={}){let p=[],M=[],c=[];for(let l=1;l{var k=Object.defineProperty;var g=Math.pow;var D=s=>k(s,"__esModule",{value:!0});var H=(s,n)=>{D(s);for(var e in n)k(s,e,{get:n[e],enumerable:!0})};var j={};H(j,{default:()=>I,hsv2hsl:()=>w,pointOnCurve:()=>d,random:()=>O});var w=(s,n,e,r=e-e*n/2,o=Math.min(r,1-r))=>[s,o?(e-r)/o:0,r],O=(s,n)=>(n||(n=s,s=0),Math.random()*(n-s)+s),d=(s,n,e,r,o=[0,0],a=[1,1])=>{let x=Math.PI/2,b=x/e,t,h;if(s==="lam\xE9"){let m=n/e*x,u=2/(2+20*r),p=Math.cos(m),M=Math.sin(m);t=Math.sign(p)*g(Math.abs(p),u),h=Math.sign(M)*g(Math.abs(M),u)}else s==="arc"?(h=Math.cos(-Math.PI/2+n*b+r),t=Math.sin(Math.PI/2+n*b-r)):s==="pow"?(t=Math.pow(1-n/e,1-r),h=Math.pow(n/e,1-r)):s==="powY"?(t=Math.pow(1-n/e,r),h=Math.pow(n/e,1-r)):s==="powX"&&(t=Math.pow(n/e,r),h=Math.pow(n/e,1-r));return t=o[0]+Math.min(Math.max(t,0),1)*(a[0]-o[0]),h=o[1]+Math.min(Math.max(h,0),1)*(a[1]-o[1]),[t,h]};function I({total:s=3,centerHue:n=0,hueCycle:e=.3,offsetTint:r=.1,offsetShade:o=.1,curveAccent:a=0,tintShadeHueShift:x=.1,curveMethod:b="arc",offsetCurveModTint:t=.03,offsetCurveModShade:h=.03,minSaturationLight:m=[0,0],maxSaturationLight:u=[1,1]}={}){let p=[],M=[],i=[];for(let l=1;l{var y=Object.defineProperty;var i=Math.pow;var Y=e=>y(e,"__esModule",{value:!0});var D=(e,r)=>{Y(e);for(var o in r)y(e,o,{get:r[o],enumerable:!0})};var O={};D(O,{default:()=>g,hsv2hsl:()=>c,pointOnCurve:()=>w,random:()=>H});var c=(e,r,o,n=o-o*r/2,t=Math.min(n,1-n))=>[e,t?(o-n)/t:0,n],H=(e,r)=>(r||(r=e,e=0),Math.random()*(r-e)+e),w=(e,r,o,n,t=[0,0],a=[1,1])=>{let V=Math.PI/2,b=V/o,s=0,h=0;if(e==="lam\xE9"){let m=r/o*V,u=2/(2+20*n),p=Math.cos(m),M=Math.sin(m);s=Math.sign(p)*i(Math.abs(p),u),h=Math.sign(M)*i(Math.abs(M),u)}else e==="arc"?(h=Math.cos(-Math.PI/2+r*b+n),s=Math.sin(Math.PI/2+r*b-n)):e==="pow"?(s=Math.pow(1-r/o,1-n),h=Math.pow(r/o,1-n)):e==="powY"?(s=Math.pow(1-r/o,n),h=Math.pow(r/o,1-n)):e==="powX"&&(s=Math.pow(r/o,n),h=Math.pow(r/o,1-n));return s=t[0]+Math.min(Math.max(s,0),1)*(a[0]-t[0]),h=t[1]+Math.min(Math.max(h,0),1)*(a[1]-t[1]),[s,h]};function g({total:e=3,centerHue:r=0,hueCycle:o=.3,offsetTint:n=.1,offsetShade:t=.1,curveAccent:a=0,tintShadeHueShift:V=.1,curveMethod:b="arc",offsetCurveModTint:s=.03,offsetCurveModShade:h=.03,minSaturationLight:m=[0,0],maxSaturationLight:u=[1,1]}={}){let p=[],M=[],d=[];for(let l=1;l[s,o?(r-e)/o:0,e],random=(s,n)=>(n||(n=s,s=0),Math.random()*(n-s)+s),pointOnCurve=(s,n,r,e,o=[0,0],a=[1,1])=>{const x=Math.PI/2,b=x/r;let t,h;if(s==="lam\xE9"){let m=n/r*x;const u=2/(2+20*e),p=Math.cos(m),M=Math.sin(m);t=Math.sign(p)*Math.abs(p)**u,h=Math.sign(M)*Math.abs(M)**u}else s==="arc"?(h=Math.cos(-Math.PI/2+n*b+e),t=Math.sin(Math.PI/2+n*b-e)):s==="pow"?(t=Math.pow(1-n/r,1-e),h=Math.pow(n/r,1-e)):s==="powY"?(t=Math.pow(1-n/r,e),h=Math.pow(n/r,1-e)):s==="powX"&&(t=Math.pow(n/r,e),h=Math.pow(n/r,1-e));return t=o[0]+Math.min(Math.max(t,0),1)*(a[0]-o[0]),h=o[1]+Math.min(Math.max(h,0),1)*(a[1]-o[1]),[t,h]};export default function T({total:s=3,centerHue:n=0,hueCycle:r=.3,offsetTint:e=.1,offsetShade:o=.1,curveAccent:a=0,tintShadeHueShift:x=.1,curveMethod:b="arc",offsetCurveModTint:t=.03,offsetCurveModShade:h=.03,minSaturationLight:m=[0,0],maxSaturationLight:u=[1,1]}={}){const p=[],M=[],w=[];for(let l=1;l[e,t?(n-o)/t:0,o],random=(e,r)=>(r||(r=e,e=0),Math.random()*(r-e)+e),pointOnCurve=(e,r,n,o,t=[0,0],a=[1,1])=>{const V=Math.PI/2,b=V/n;let s=0,h=0;if(e==="lam\xE9"){let m=r/n*V;const u=2/(2+20*o),p=Math.cos(m),M=Math.sin(m);s=Math.sign(p)*Math.abs(p)**u,h=Math.sign(M)*Math.abs(M)**u}else e==="arc"?(h=Math.cos(-Math.PI/2+r*b+o),s=Math.sin(Math.PI/2+r*b-o)):e==="pow"?(s=Math.pow(1-r/n,1-o),h=Math.pow(r/n,1-o)):e==="powY"?(s=Math.pow(1-r/n,o),h=Math.pow(r/n,1-o)):e==="powX"&&(s=Math.pow(r/n,o),h=Math.pow(r/n,1-o));return s=t[0]+Math.min(Math.max(s,0),1)*(a[0]-t[0]),h=t[1]+Math.min(Math.max(h,0),1)*(a[1]-t[1]),[s,h]};export default function P({total:e=3,centerHue:r=0,hueCycle:n=.3,offsetTint:o=.1,offsetShade:t=.1,curveAccent:a=0,tintShadeHueShift:V=.1,curveMethod:b="arc",offsetCurveModTint:s=.03,offsetCurveModShade:h=.03,minSaturationLight:m=[0,0],maxSaturationLight:u=[1,1]}={}){const p=[],M=[],c=[];for(let l=1;l