🚀 Socket Launch Week Day 4:Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection.Learn more
Sign In

poline

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poline - npm Package Compare versions

Comparing version
0.5.2
to
0.6.0
+48
-19
dist/index.cjs

@@ -32,3 +32,3 @@ "use strict";

module.exports = __toCommonJS(src_exports);
var pointToHSL = (xyz) => {
var pointToHSL = (xyz, invertedLightness) => {
const [x, y, z] = xyz;

@@ -43,5 +43,5 @@ const cx = 0.5;

const l = dist / cx;
return [deg, s, l];
return [deg, s, invertedLightness ? 1 - l : l];
};
var hslToPoint = (hsl) => {
var hslToPoint = (hsl, invertedLightness) => {
const [h, s, l] = hsl;

@@ -51,3 +51,3 @@ const cx = 0.5;

const radians = h / (180 / Math.PI);
const dist = l * cx;
const dist = (invertedLightness ? 1 - l : l) * cx;
const x = cx + dist * Math.cos(radians);

@@ -171,3 +171,3 @@ const y = cy + dist * Math.sin(radians);

var ColorPoint = class {
constructor({ xyz, color } = {}) {
constructor({ xyz, color, invertedLightness } = {}) {
this.x = 0;

@@ -177,5 +177,7 @@ this.y = 0;

this.color = [0, 0, 0];
this.positionOrColor({ xyz, color });
this._invertedLightness = false;
this._invertedLightness = invertedLightness || false;
this.positionOrColor({ xyz, color, invertedLightness });
}
positionOrColor({ xyz, color }) {
positionOrColor({ xyz, color, invertedLightness }) {
if (xyz && color) {

@@ -187,6 +189,9 @@ throw new Error("Point must be initialized with either x,y,z or hsl");

this.z = xyz[2];
this.color = pointToHSL([this.x, this.y, this.z]);
this.color = pointToHSL(
[this.x, this.y, this.z],
invertedLightness || false
);
} else if (color) {
this.color = color;
[this.x, this.y, this.z] = hslToPoint(color);
[this.x, this.y, this.z] = hslToPoint(color, invertedLightness || false);
}

@@ -198,3 +203,6 @@ }

this.z = z;
this.color = pointToHSL([this.x, this.y, this.z]);
this.color = pointToHSL(
[this.x, this.y, this.z],
this._invertedLightness
);
}

@@ -206,3 +214,6 @@ get position() {

this.color = [h, s, l];
[this.x, this.y, this.z] = hslToPoint(this.color);
[this.x, this.y, this.z] = hslToPoint(
this.color,
this._invertedLightness
);
}

@@ -219,3 +230,6 @@ get hsl() {

this.color[0] = (360 + (this.color[0] + angle)) % 360;
[this.x, this.y, this.z] = hslToPoint(this.color);
[this.x, this.y, this.z] = hslToPoint(
this.color,
this._invertedLightness
);
}

@@ -231,3 +245,4 @@ };

positionFunctionZ,
closedLoop
closedLoop,
invertedLightness
} = {

@@ -245,2 +260,3 @@ anchorColors: randomHSLPair(),

this._animationFrame = null;
this._invertedLightness = false;
if (!anchorColors || anchorColors.length < 2) {

@@ -250,3 +266,3 @@ throw new Error("Must have at least two anchor colors");

this._anchorPoints = anchorColors.map(
(point) => new ColorPoint({ color: point })
(point) => new ColorPoint({ color: point, invertedLightness })
);

@@ -257,3 +273,4 @@ this._numPoints = numPoints + 2;

this._positionFunctionZ = positionFunctionZ || positionFunction || sinusoidalPosition;
this.connectLastAndFirstAnchor = closedLoop;
this.connectLastAndFirstAnchor = closedLoop || false;
this._invertedLightness = invertedLightness || false;
this.updateAnchorPairs();

@@ -348,3 +365,5 @@ }

this.positionFunctionZ
).map((p) => new ColorPoint({ xyz: p }));
).map(
(p) => new ColorPoint({ xyz: p, invertedLightness: this._invertedLightness })
);
});

@@ -357,3 +376,7 @@ }

}) {
const newAnchor = new ColorPoint({ xyz, color });
const newAnchor = new ColorPoint({
xyz,
color,
invertedLightness: this._invertedLightness
});
if (insertAtIndex) {

@@ -441,2 +464,9 @@ this.anchorPoints.splice(insertAtIndex, 0, newAnchor);

}
set invertedLightness(newStatus) {
this._invertedLightness = newStatus;
this.updateAnchorPairs();
}
get invertedLightness() {
return this._invertedLightness;
}
get flattenedPoints() {

@@ -470,4 +500,3 @@ return this.points.flat().filter((p, i) => i != 0 ? i % this._numPoints : true);

const polineColors = () => poline.colors.map(
(c) => /*p5.Color(c)*/
`hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`
(c) => `hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`
);

@@ -474,0 +503,0 @@ p5.prototype.polineColors = polineColors;

@@ -17,3 +17,3 @@ export type FuncNumberReturn = (arg0: number) => Vector2;

**/
export declare const pointToHSL: (xyz: [number, number, number]) => [number, number, number];
export declare const pointToHSL: (xyz: [number, number, number], invertedLightness: boolean) => [number, number, number];
/**

@@ -32,3 +32,3 @@ * Converts the given HSL color to an (x, y, z) coordinate

**/
export declare const hslToPoint: (hsl: [number, number, number]) => [number, number, number];
export declare const hslToPoint: (hsl: [number, number, number], invertedLightness: boolean) => [number, number, number];
export declare const randomHSLPair: (startHue?: number, saturations?: Vector2, lightnesses?: Vector2) => [Vector3, Vector3];

@@ -51,2 +51,3 @@ export declare const randomHSLTriple: (startHue?: number, saturations?: [number, number, number], lightnesses?: [number, number, number]) => [Vector3, Vector3, Vector3];

color?: Vector3;
invertedLightness?: boolean;
};

@@ -58,4 +59,5 @@ declare class ColorPoint {

color: Vector3;
constructor({ xyz, color }?: ColorPointCollection);
positionOrColor({ xyz, color }: ColorPointCollection): void;
private _invertedLightness;
constructor({ xyz, color, invertedLightness }?: ColorPointCollection);
positionOrColor({ xyz, color, invertedLightness }: ColorPointCollection): void;
set position([x, y, z]: Vector3);

@@ -75,3 +77,4 @@ get position(): Vector3;

positionFunctionZ?: (t: number, invert?: boolean) => number;
closedLoop: boolean;
invertedLightness?: boolean;
closedLoop?: boolean;
};

@@ -89,3 +92,4 @@ export declare class Poline {

private _animationFrame;
constructor({ anchorColors, numPoints, positionFunction, positionFunctionX, positionFunctionY, positionFunctionZ, closedLoop, }?: PolineOptions);
private _invertedLightness;
constructor({ anchorColors, numPoints, positionFunction, positionFunctionX, positionFunctionY, positionFunctionZ, closedLoop, invertedLightness, }?: PolineOptions);
get numPoints(): number;

@@ -122,2 +126,4 @@ set numPoints(numPoints: number);

get closedLoop(): boolean;
set invertedLightness(newStatus: boolean);
get invertedLightness(): boolean;
get flattenedPoints(): ColorPoint[];

@@ -124,0 +130,0 @@ get colors(): [number, number, number][];

@@ -31,3 +31,3 @@ "use strict";

});
var pointToHSL = (xyz) => {
var pointToHSL = (xyz, invertedLightness) => {
const [x, y, z] = xyz;

@@ -42,5 +42,5 @@ const cx = 0.5;

const l = dist / cx;
return [deg, s, l];
return [deg, s, invertedLightness ? 1 - l : l];
};
var hslToPoint = (hsl) => {
var hslToPoint = (hsl, invertedLightness) => {
const [h, s, l] = hsl;

@@ -50,3 +50,3 @@ const cx = 0.5;

const radians = h / (180 / Math.PI);
const dist = l * cx;
const dist = (invertedLightness ? 1 - l : l) * cx;
const x = cx + dist * Math.cos(radians);

@@ -170,3 +170,3 @@ const y = cy + dist * Math.sin(radians);

var ColorPoint = class {
constructor({ xyz, color } = {}) {
constructor({ xyz, color, invertedLightness } = {}) {
this.x = 0;

@@ -176,5 +176,7 @@ this.y = 0;

this.color = [0, 0, 0];
this.positionOrColor({ xyz, color });
this._invertedLightness = false;
this._invertedLightness = invertedLightness || false;
this.positionOrColor({ xyz, color, invertedLightness });
}
positionOrColor({ xyz, color }) {
positionOrColor({ xyz, color, invertedLightness }) {
if (xyz && color) {

@@ -186,6 +188,9 @@ throw new Error("Point must be initialized with either x,y,z or hsl");

this.z = xyz[2];
this.color = pointToHSL([this.x, this.y, this.z]);
this.color = pointToHSL(
[this.x, this.y, this.z],
invertedLightness || false
);
} else if (color) {
this.color = color;
[this.x, this.y, this.z] = hslToPoint(color);
[this.x, this.y, this.z] = hslToPoint(color, invertedLightness || false);
}

@@ -197,3 +202,6 @@ }

this.z = z;
this.color = pointToHSL([this.x, this.y, this.z]);
this.color = pointToHSL(
[this.x, this.y, this.z],
this._invertedLightness
);
}

@@ -205,3 +213,6 @@ get position() {

this.color = [h, s, l];
[this.x, this.y, this.z] = hslToPoint(this.color);
[this.x, this.y, this.z] = hslToPoint(
this.color,
this._invertedLightness
);
}

@@ -218,3 +229,6 @@ get hsl() {

this.color[0] = (360 + (this.color[0] + angle)) % 360;
[this.x, this.y, this.z] = hslToPoint(this.color);
[this.x, this.y, this.z] = hslToPoint(
this.color,
this._invertedLightness
);
}

@@ -230,3 +244,4 @@ };

positionFunctionZ,
closedLoop
closedLoop,
invertedLightness
} = {

@@ -244,2 +259,3 @@ anchorColors: randomHSLPair(),

this._animationFrame = null;
this._invertedLightness = false;
if (!anchorColors || anchorColors.length < 2) {

@@ -249,3 +265,3 @@ throw new Error("Must have at least two anchor colors");

this._anchorPoints = anchorColors.map(
(point) => new ColorPoint({ color: point })
(point) => new ColorPoint({ color: point, invertedLightness })
);

@@ -256,3 +272,4 @@ this._numPoints = numPoints + 2;

this._positionFunctionZ = positionFunctionZ || positionFunction || sinusoidalPosition;
this.connectLastAndFirstAnchor = closedLoop;
this.connectLastAndFirstAnchor = closedLoop || false;
this._invertedLightness = invertedLightness || false;
this.updateAnchorPairs();

@@ -347,3 +364,5 @@ }

this.positionFunctionZ
).map((p) => new ColorPoint({ xyz: p }));
).map(
(p) => new ColorPoint({ xyz: p, invertedLightness: this._invertedLightness })
);
});

@@ -356,3 +375,7 @@ }

}) {
const newAnchor = new ColorPoint({ xyz, color });
const newAnchor = new ColorPoint({
xyz,
color,
invertedLightness: this._invertedLightness
});
if (insertAtIndex) {

@@ -440,2 +463,9 @@ this.anchorPoints.splice(insertAtIndex, 0, newAnchor);

}
set invertedLightness(newStatus) {
this._invertedLightness = newStatus;
this.updateAnchorPairs();
}
get invertedLightness() {
return this._invertedLightness;
}
get flattenedPoints() {

@@ -469,4 +499,3 @@ return this.points.flat().filter((p, i) => i != 0 ? i % this._numPoints : true);

const polineColors = () => poline.colors.map(
(c) => /*p5.Color(c)*/
`hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`
(c) => `hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`
);

@@ -473,0 +502,0 @@ p5.prototype.polineColors = polineColors;

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

"use strict";var F=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var u=Math.pow;var w=(n,o)=>{for(var t in o)F(n,t,{get:o[t],enumerable:!0})},v=(n,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of y(o))!C.call(n,r)&&r!==t&&F(n,r,{get:()=>o[r],enumerable:!(i=x(o,r))||i.enumerable});return n};var g=n=>v(F({},"__esModule",{value:!0}),n);var H={};w(H,{Poline:()=>d,hslToPoint:()=>m,pointToHSL:()=>M,positionFunctions:()=>$,randomHSLPair:()=>_,randomHSLTriple:()=>L});module.exports=g(H);var M=n=>{let[o,t,i]=n,r=.5,c=.5,s=Math.atan2(t-c,o-r)*(180/Math.PI);s=(360+s)%360;let e=i,p=Math.sqrt(Math.pow(t-c,2)+Math.pow(o-r,2))/r;return[s,e,p]},m=n=>{let[o,t,i]=n,r=.5,c=.5,h=o/(180/Math.PI),s=i*r,e=r+s*Math.cos(h),l=c+s*Math.sin(h);return[e,l,t]},_=(n=Math.random()*360,o=[Math.random(),Math.random()],t=[.75+Math.random()*.2,.3+Math.random()*.2])=>[[n,o[0],t[0]],[(n+60+Math.random()*180)%360,o[1],t[1]]],L=(n=Math.random()*360,o=[Math.random(),Math.random(),Math.random()],t=[.75+Math.random()*.2,Math.random()*.2,.75+Math.random()*.2])=>[[n,o[0],t[0]],[(n+60+Math.random()*180)%360,o[1],t[1]],[(n+60+Math.random()*180)%360,o[2],t[2]]],X=(n,o,t,i=!1,r=(s,e)=>e?1-s:s,c=(s,e)=>e?1-s:s,h=(s,e)=>e?1-s:s)=>{let s=r(n,i),e=c(n,i),l=h(n,i),p=(1-s)*o[0]+s*t[0],f=(1-e)*o[1]+e*t[1],A=(1-l)*o[2]+l*t[2];return[p,f,A]},z=(n,o,t=4,i=!1,r=(s,e)=>e?1-s:s,c=(s,e)=>e?1-s:s,h=(s,e)=>e?1-s:s)=>{let s=[];for(let e=0;e<t;e++){let[l,p,f]=X(e/(t-1),n,o,i,r,c,h);s.push([l,p,f])}return s},Y=n=>n,Z=(n,o=!1)=>o?1-u(1-n,2):u(n,2),E=(n,o=!1)=>o?1-u(1-n,3):u(n,3),S=(n,o=!1)=>o?1-u(1-n,4):u(n,4),I=(n,o=!1)=>o?1-u(1-n,5):u(n,5),a=(n,o=!1)=>o?1-Math.sin((1-n)*Math.PI/2):Math.sin(n*Math.PI/2),O=(n,o=!1)=>o?1-Math.asin(1-n)/(Math.PI/2):Math.asin(n)/(Math.PI/2),q=(n,o=!1)=>o?Math.sqrt(1-u(1-n,2)):1-Math.sqrt(1-n),T=n=>u(n,2)*(3-2*n),$={linearPosition:Y,exponentialPosition:Z,quadraticPosition:E,cubicPosition:S,quarticPosition:I,sinusoidalPosition:a,asinusoidalPosition:O,arcPosition:q,smoothStepPosition:T},V=(n,o,t=!1)=>{let i=n[0],r=o[0],c=0;t&&i!==null&&r!==null?(c=Math.min(Math.abs(i-r),360-Math.abs(i-r)),c=c/360):c=i===null||r===null?0:i-r;let h=c,s=n[1]===null||o[1]===null?0:o[1]-n[1],e=n[2]===null||o[2]===null?0:o[2]-n[2];return Math.sqrt(h*h+s*s+e*e)},b=class{constructor({xyz:o,color:t}={}){this.x=0;this.y=0;this.z=0;this.color=[0,0,0];this.positionOrColor({xyz:o,color:t})}positionOrColor({xyz:o,color:t}){if(o&&t)throw new Error("Point must be initialized with either x,y,z or hsl");o?(this.x=o[0],this.y=o[1],this.z=o[2],this.color=M([this.x,this.y,this.z])):t&&(this.color=t,[this.x,this.y,this.z]=m(t))}set position([o,t,i]){this.x=o,this.y=t,this.z=i,this.color=M([this.x,this.y,this.z])}get position(){return[this.x,this.y,this.z]}set hsl([o,t,i]){this.color=[o,t,i],[this.x,this.y,this.z]=m(this.color)}get hsl(){return this.color}get hslCSS(){return`hsl(${this.color[0].toFixed(2)}, ${(this.color[1]*100).toFixed(2)}%, ${(this.color[2]*100).toFixed(2)}%)`}shiftHue(o){this.color[0]=(360+(this.color[0]+o))%360,[this.x,this.y,this.z]=m(this.color)}},d=class{constructor({anchorColors:o=_(),numPoints:t=4,positionFunction:i=a,positionFunctionX:r,positionFunctionY:c,positionFunctionZ:h,closedLoop:s}={anchorColors:_(),numPoints:4,positionFunction:a,closedLoop:!1}){this._needsUpdate=!0;this._positionFunctionX=a;this._positionFunctionY=a;this._positionFunctionZ=a;this.connectLastAndFirstAnchor=!1;this._animationFrame=null;if(!o||o.length<2)throw new Error("Must have at least two anchor colors");this._anchorPoints=o.map(e=>new b({color:e})),this._numPoints=t+2,this._positionFunctionX=r||i||a,this._positionFunctionY=c||i||a,this._positionFunctionZ=h||i||a,this.connectLastAndFirstAnchor=s,this.updateAnchorPairs()}get numPoints(){return this._numPoints-2}set numPoints(o){if(o<1)throw new Error("Must have at least one point");this._numPoints=o+2,this.updateAnchorPairs()}set positionFunction(o){if(Array.isArray(o)){if(o.length!==3)throw new Error("Position function array must have 3 elements");if(typeof o[0]!="function"||typeof o[1]!="function"||typeof o[2]!="function")throw new Error("Position function array must have 3 functions");this._positionFunctionX=o[0],this._positionFunctionY=o[1],this._positionFunctionZ=o[2]}else this._positionFunctionX=o,this._positionFunctionY=o,this._positionFunctionZ=o;this.updateAnchorPairs()}get positionFunction(){return this._positionFunctionX===this._positionFunctionY&&this._positionFunctionX===this._positionFunctionZ?this._positionFunctionX:[this._positionFunctionX,this._positionFunctionY,this._positionFunctionZ]}set positionFunctionX(o){this._positionFunctionX=o,this.updateAnchorPairs()}get positionFunctionX(){return this._positionFunctionX}set positionFunctionY(o){this._positionFunctionY=o,this.updateAnchorPairs()}get positionFunctionY(){return this._positionFunctionY}set positionFunctionZ(o){this._positionFunctionZ=o,this.updateAnchorPairs()}get positionFunctionZ(){return this._positionFunctionZ}get anchorPoints(){return this._anchorPoints}set anchorPoints(o){this._anchorPoints=o,this.updateAnchorPairs()}updateAnchorPairs(){this._anchorPairs=[];let o=this.connectLastAndFirstAnchor?this.anchorPoints.length:this.anchorPoints.length-1;for(let t=0;t<o;t++){let i=[this.anchorPoints[t],this.anchorPoints[(t+1)%this.anchorPoints.length]];this._anchorPairs.push(i)}this.points=this._anchorPairs.map((t,i)=>{let r=t[0]?t[0].position:[0,0,0],c=t[1]?t[1].position:[0,0,0];return z(r,c,this._numPoints,!!(i%2),this.positionFunctionX,this.positionFunctionY,this.positionFunctionZ).map(h=>new b({xyz:h}))})}addAnchorPoint({xyz:o,color:t,insertAtIndex:i}){let r=new b({xyz:o,color:t});return i?this.anchorPoints.splice(i,0,r):this.anchorPoints.push(r),this.updateAnchorPairs(),r}removeAnchorPoint({point:o,index:t}){if(!o&&t===void 0)throw new Error("Must provide a point or index");let i;if(t!==void 0?i=t:o&&(i=this.anchorPoints.indexOf(o)),i>-1&&i<this.anchorPoints.length)this.anchorPoints.splice(i,1),this.updateAnchorPairs();else throw new Error("Point not found")}updateAnchorPoint({point:o,pointIndex:t,xyz:i,color:r}){if(t&&(o=this.anchorPoints[t]),!o)throw new Error("Must provide a point or pointIndex");if(!i&&!r)throw new Error("Must provide a new xyz position or color");return i&&(o.position=i),r&&(o.hsl=r),this.updateAnchorPairs(),o}getClosestAnchorPoint({xyz:o,hsl:t,maxDistance:i=1}){if(!o&&!t)throw new Error("Must provide a xyz or hsl");let r;o?r=this.anchorPoints.map(s=>V(s.position,o)):t&&(r=this.anchorPoints.map(s=>V(s.hsl,t,!0)));let c=Math.min(...r);if(c>i)return null;let h=r.indexOf(c);return this.anchorPoints[h]||null}set closedLoop(o){this.connectLastAndFirstAnchor=o,this.updateAnchorPairs()}get closedLoop(){return this.connectLastAndFirstAnchor}get flattenedPoints(){return this.points.flat().filter((o,t)=>t!=0?t%this._numPoints:!0)}get colors(){let o=this.flattenedPoints.map(t=>t.color);return this.connectLastAndFirstAnchor&&o.pop(),o}get colorsCSS(){let o=this.flattenedPoints.map(t=>t.hslCSS);return this.connectLastAndFirstAnchor&&o.pop(),o}shiftHue(o=20){this.anchorPoints.forEach(t=>t.shiftHue(o)),this.updateAnchorPairs()}},{p5:P}=globalThis;if(P){console.info("p5 detected, adding poline to p5 prototype");let n=new d;P.prototype.poline=n;let o=()=>n.colors.map(t=>`hsl(${Math.round(t[0])},${t[1]*100}%,${t[2]*100}%)`);P.prototype.polineColors=o,P.prototype.registerMethod("polineColors",P.prototype.polineColors),globalThis.poline=n,globalThis.polineColors=o}
"use strict";var F=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var a=Math.pow;var y=(n,t)=>{for(var o in t)F(n,o,{get:t[o],enumerable:!0})},C=(n,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of A(t))!x.call(n,s)&&s!==o&&F(n,s,{get:()=>t[s],enumerable:!(i=g(t,s))||i.enumerable});return n};var L=n=>C(F({},"__esModule",{value:!0}),n);var H={};y(H,{Poline:()=>f,hslToPoint:()=>m,pointToHSL:()=>_,positionFunctions:()=>$,randomHSLPair:()=>M,randomHSLTriple:()=>w});module.exports=L(H);var _=(n,t)=>{let[o,i,s]=n,c=.5,h=.5,e=Math.atan2(i-h,o-c)*(180/Math.PI);e=(360+e)%360;let u=s,p=Math.sqrt(Math.pow(i-h,2)+Math.pow(o-c,2))/c;return[e,u,t?1-p:p]},m=(n,t)=>{let[o,i,s]=n,c=.5,h=.5,r=o/(180/Math.PI),e=(t?1-s:s)*c,u=c+e*Math.cos(r),P=h+e*Math.sin(r);return[u,P,i]},M=(n=Math.random()*360,t=[Math.random(),Math.random()],o=[.75+Math.random()*.2,.3+Math.random()*.2])=>[[n,t[0],o[0]],[(n+60+Math.random()*180)%360,t[1],o[1]]],w=(n=Math.random()*360,t=[Math.random(),Math.random(),Math.random()],o=[.75+Math.random()*.2,Math.random()*.2,.75+Math.random()*.2])=>[[n,t[0],o[0]],[(n+60+Math.random()*180)%360,t[1],o[1]],[(n+60+Math.random()*180)%360,t[2],o[2]]],X=(n,t,o,i=!1,s=(r,e)=>e?1-r:r,c=(r,e)=>e?1-r:r,h=(r,e)=>e?1-r:r)=>{let r=s(n,i),e=c(n,i),u=h(n,i),P=(1-r)*t[0]+r*o[0],p=(1-e)*t[1]+e*o[1],V=(1-u)*t[2]+u*o[2];return[P,p,V]},z=(n,t,o=4,i=!1,s=(r,e)=>e?1-r:r,c=(r,e)=>e?1-r:r,h=(r,e)=>e?1-r:r)=>{let r=[];for(let e=0;e<o;e++){let[u,P,p]=X(e/(o-1),n,t,i,s,c,h);r.push([u,P,p])}return r},Y=n=>n,Z=(n,t=!1)=>t?1-a(1-n,2):a(n,2),E=(n,t=!1)=>t?1-a(1-n,3):a(n,3),S=(n,t=!1)=>t?1-a(1-n,4):a(n,4),I=(n,t=!1)=>t?1-a(1-n,5):a(n,5),l=(n,t=!1)=>t?1-Math.sin((1-n)*Math.PI/2):Math.sin(n*Math.PI/2),O=(n,t=!1)=>t?1-Math.asin(1-n)/(Math.PI/2):Math.asin(n)/(Math.PI/2),q=(n,t=!1)=>t?Math.sqrt(1-a(1-n,2)):1-Math.sqrt(1-n),T=n=>a(n,2)*(3-2*n),$={linearPosition:Y,exponentialPosition:Z,quadraticPosition:E,cubicPosition:S,quarticPosition:I,sinusoidalPosition:l,asinusoidalPosition:O,arcPosition:q,smoothStepPosition:T},v=(n,t,o=!1)=>{let i=n[0],s=t[0],c=0;o&&i!==null&&s!==null?(c=Math.min(Math.abs(i-s),360-Math.abs(i-s)),c=c/360):c=i===null||s===null?0:i-s;let h=c,r=n[1]===null||t[1]===null?0:t[1]-n[1],e=n[2]===null||t[2]===null?0:t[2]-n[2];return Math.sqrt(h*h+r*r+e*e)},b=class{constructor({xyz:t,color:o,invertedLightness:i}={}){this.x=0;this.y=0;this.z=0;this.color=[0,0,0];this._invertedLightness=!1;this._invertedLightness=i||!1,this.positionOrColor({xyz:t,color:o,invertedLightness:i})}positionOrColor({xyz:t,color:o,invertedLightness:i}){if(t&&o)throw new Error("Point must be initialized with either x,y,z or hsl");t?(this.x=t[0],this.y=t[1],this.z=t[2],this.color=_([this.x,this.y,this.z],i||!1)):o&&(this.color=o,[this.x,this.y,this.z]=m(o,i||!1))}set position([t,o,i]){this.x=t,this.y=o,this.z=i,this.color=_([this.x,this.y,this.z],this._invertedLightness)}get position(){return[this.x,this.y,this.z]}set hsl([t,o,i]){this.color=[t,o,i],[this.x,this.y,this.z]=m(this.color,this._invertedLightness)}get hsl(){return this.color}get hslCSS(){return`hsl(${this.color[0].toFixed(2)}, ${(this.color[1]*100).toFixed(2)}%, ${(this.color[2]*100).toFixed(2)}%)`}shiftHue(t){this.color[0]=(360+(this.color[0]+t))%360,[this.x,this.y,this.z]=m(this.color,this._invertedLightness)}},f=class{constructor({anchorColors:t=M(),numPoints:o=4,positionFunction:i=l,positionFunctionX:s,positionFunctionY:c,positionFunctionZ:h,closedLoop:r,invertedLightness:e}={anchorColors:M(),numPoints:4,positionFunction:l,closedLoop:!1}){this._needsUpdate=!0;this._positionFunctionX=l;this._positionFunctionY=l;this._positionFunctionZ=l;this.connectLastAndFirstAnchor=!1;this._animationFrame=null;this._invertedLightness=!1;if(!t||t.length<2)throw new Error("Must have at least two anchor colors");this._anchorPoints=t.map(u=>new b({color:u,invertedLightness:e})),this._numPoints=o+2,this._positionFunctionX=s||i||l,this._positionFunctionY=c||i||l,this._positionFunctionZ=h||i||l,this.connectLastAndFirstAnchor=r||!1,this._invertedLightness=e||!1,this.updateAnchorPairs()}get numPoints(){return this._numPoints-2}set numPoints(t){if(t<1)throw new Error("Must have at least one point");this._numPoints=t+2,this.updateAnchorPairs()}set positionFunction(t){if(Array.isArray(t)){if(t.length!==3)throw new Error("Position function array must have 3 elements");if(typeof t[0]!="function"||typeof t[1]!="function"||typeof t[2]!="function")throw new Error("Position function array must have 3 functions");this._positionFunctionX=t[0],this._positionFunctionY=t[1],this._positionFunctionZ=t[2]}else this._positionFunctionX=t,this._positionFunctionY=t,this._positionFunctionZ=t;this.updateAnchorPairs()}get positionFunction(){return this._positionFunctionX===this._positionFunctionY&&this._positionFunctionX===this._positionFunctionZ?this._positionFunctionX:[this._positionFunctionX,this._positionFunctionY,this._positionFunctionZ]}set positionFunctionX(t){this._positionFunctionX=t,this.updateAnchorPairs()}get positionFunctionX(){return this._positionFunctionX}set positionFunctionY(t){this._positionFunctionY=t,this.updateAnchorPairs()}get positionFunctionY(){return this._positionFunctionY}set positionFunctionZ(t){this._positionFunctionZ=t,this.updateAnchorPairs()}get positionFunctionZ(){return this._positionFunctionZ}get anchorPoints(){return this._anchorPoints}set anchorPoints(t){this._anchorPoints=t,this.updateAnchorPairs()}updateAnchorPairs(){this._anchorPairs=[];let t=this.connectLastAndFirstAnchor?this.anchorPoints.length:this.anchorPoints.length-1;for(let o=0;o<t;o++){let i=[this.anchorPoints[o],this.anchorPoints[(o+1)%this.anchorPoints.length]];this._anchorPairs.push(i)}this.points=this._anchorPairs.map((o,i)=>{let s=o[0]?o[0].position:[0,0,0],c=o[1]?o[1].position:[0,0,0];return z(s,c,this._numPoints,!!(i%2),this.positionFunctionX,this.positionFunctionY,this.positionFunctionZ).map(h=>new b({xyz:h,invertedLightness:this._invertedLightness}))})}addAnchorPoint({xyz:t,color:o,insertAtIndex:i}){let s=new b({xyz:t,color:o,invertedLightness:this._invertedLightness});return i?this.anchorPoints.splice(i,0,s):this.anchorPoints.push(s),this.updateAnchorPairs(),s}removeAnchorPoint({point:t,index:o}){if(!t&&o===void 0)throw new Error("Must provide a point or index");let i;if(o!==void 0?i=o:t&&(i=this.anchorPoints.indexOf(t)),i>-1&&i<this.anchorPoints.length)this.anchorPoints.splice(i,1),this.updateAnchorPairs();else throw new Error("Point not found")}updateAnchorPoint({point:t,pointIndex:o,xyz:i,color:s}){if(o&&(t=this.anchorPoints[o]),!t)throw new Error("Must provide a point or pointIndex");if(!i&&!s)throw new Error("Must provide a new xyz position or color");return i&&(t.position=i),s&&(t.hsl=s),this.updateAnchorPairs(),t}getClosestAnchorPoint({xyz:t,hsl:o,maxDistance:i=1}){if(!t&&!o)throw new Error("Must provide a xyz or hsl");let s;t?s=this.anchorPoints.map(r=>v(r.position,t)):o&&(s=this.anchorPoints.map(r=>v(r.hsl,o,!0)));let c=Math.min(...s);if(c>i)return null;let h=s.indexOf(c);return this.anchorPoints[h]||null}set closedLoop(t){this.connectLastAndFirstAnchor=t,this.updateAnchorPairs()}get closedLoop(){return this.connectLastAndFirstAnchor}set invertedLightness(t){this._invertedLightness=t,this.updateAnchorPairs()}get invertedLightness(){return this._invertedLightness}get flattenedPoints(){return this.points.flat().filter((t,o)=>o!=0?o%this._numPoints:!0)}get colors(){let t=this.flattenedPoints.map(o=>o.color);return this.connectLastAndFirstAnchor&&t.pop(),t}get colorsCSS(){let t=this.flattenedPoints.map(o=>o.hslCSS);return this.connectLastAndFirstAnchor&&t.pop(),t}shiftHue(t=20){this.anchorPoints.forEach(o=>o.shiftHue(t)),this.updateAnchorPairs()}},{p5:d}=globalThis;if(d){console.info("p5 detected, adding poline to p5 prototype");let n=new f;d.prototype.poline=n;let t=()=>n.colors.map(o=>`hsl(${Math.round(o[0])},${o[1]*100}%,${o[2]*100}%)`);d.prototype.polineColors=t,d.prototype.registerMethod("polineColors",d.prototype.polineColors),globalThis.poline=n,globalThis.polineColors=t}

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

"use strict";var poline=(()=>{var F=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var u=Math.pow;var w=(n,o)=>{for(var t in o)F(n,t,{get:o[t],enumerable:!0})},v=(n,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of y(o))!C.call(n,r)&&r!==t&&F(n,r,{get:()=>o[r],enumerable:!(i=x(o,r))||i.enumerable});return n};var g=n=>v(F({},"__esModule",{value:!0}),n);var H={};w(H,{Poline:()=>d,hslToPoint:()=>m,pointToHSL:()=>M,positionFunctions:()=>$,randomHSLPair:()=>_,randomHSLTriple:()=>L});var M=n=>{let[o,t,i]=n,r=.5,c=.5,s=Math.atan2(t-c,o-r)*(180/Math.PI);s=(360+s)%360;let e=i,p=Math.sqrt(Math.pow(t-c,2)+Math.pow(o-r,2))/r;return[s,e,p]},m=n=>{let[o,t,i]=n,r=.5,c=.5,h=o/(180/Math.PI),s=i*r,e=r+s*Math.cos(h),l=c+s*Math.sin(h);return[e,l,t]},_=(n=Math.random()*360,o=[Math.random(),Math.random()],t=[.75+Math.random()*.2,.3+Math.random()*.2])=>[[n,o[0],t[0]],[(n+60+Math.random()*180)%360,o[1],t[1]]],L=(n=Math.random()*360,o=[Math.random(),Math.random(),Math.random()],t=[.75+Math.random()*.2,Math.random()*.2,.75+Math.random()*.2])=>[[n,o[0],t[0]],[(n+60+Math.random()*180)%360,o[1],t[1]],[(n+60+Math.random()*180)%360,o[2],t[2]]],X=(n,o,t,i=!1,r=(s,e)=>e?1-s:s,c=(s,e)=>e?1-s:s,h=(s,e)=>e?1-s:s)=>{let s=r(n,i),e=c(n,i),l=h(n,i),p=(1-s)*o[0]+s*t[0],f=(1-e)*o[1]+e*t[1],A=(1-l)*o[2]+l*t[2];return[p,f,A]},z=(n,o,t=4,i=!1,r=(s,e)=>e?1-s:s,c=(s,e)=>e?1-s:s,h=(s,e)=>e?1-s:s)=>{let s=[];for(let e=0;e<t;e++){let[l,p,f]=X(e/(t-1),n,o,i,r,c,h);s.push([l,p,f])}return s},Y=n=>n,Z=(n,o=!1)=>o?1-u(1-n,2):u(n,2),E=(n,o=!1)=>o?1-u(1-n,3):u(n,3),S=(n,o=!1)=>o?1-u(1-n,4):u(n,4),I=(n,o=!1)=>o?1-u(1-n,5):u(n,5),a=(n,o=!1)=>o?1-Math.sin((1-n)*Math.PI/2):Math.sin(n*Math.PI/2),O=(n,o=!1)=>o?1-Math.asin(1-n)/(Math.PI/2):Math.asin(n)/(Math.PI/2),q=(n,o=!1)=>o?Math.sqrt(1-u(1-n,2)):1-Math.sqrt(1-n),T=n=>u(n,2)*(3-2*n),$={linearPosition:Y,exponentialPosition:Z,quadraticPosition:E,cubicPosition:S,quarticPosition:I,sinusoidalPosition:a,asinusoidalPosition:O,arcPosition:q,smoothStepPosition:T},V=(n,o,t=!1)=>{let i=n[0],r=o[0],c=0;t&&i!==null&&r!==null?(c=Math.min(Math.abs(i-r),360-Math.abs(i-r)),c=c/360):c=i===null||r===null?0:i-r;let h=c,s=n[1]===null||o[1]===null?0:o[1]-n[1],e=n[2]===null||o[2]===null?0:o[2]-n[2];return Math.sqrt(h*h+s*s+e*e)},b=class{constructor({xyz:o,color:t}={}){this.x=0;this.y=0;this.z=0;this.color=[0,0,0];this.positionOrColor({xyz:o,color:t})}positionOrColor({xyz:o,color:t}){if(o&&t)throw new Error("Point must be initialized with either x,y,z or hsl");o?(this.x=o[0],this.y=o[1],this.z=o[2],this.color=M([this.x,this.y,this.z])):t&&(this.color=t,[this.x,this.y,this.z]=m(t))}set position([o,t,i]){this.x=o,this.y=t,this.z=i,this.color=M([this.x,this.y,this.z])}get position(){return[this.x,this.y,this.z]}set hsl([o,t,i]){this.color=[o,t,i],[this.x,this.y,this.z]=m(this.color)}get hsl(){return this.color}get hslCSS(){return`hsl(${this.color[0].toFixed(2)}, ${(this.color[1]*100).toFixed(2)}%, ${(this.color[2]*100).toFixed(2)}%)`}shiftHue(o){this.color[0]=(360+(this.color[0]+o))%360,[this.x,this.y,this.z]=m(this.color)}},d=class{constructor({anchorColors:o=_(),numPoints:t=4,positionFunction:i=a,positionFunctionX:r,positionFunctionY:c,positionFunctionZ:h,closedLoop:s}={anchorColors:_(),numPoints:4,positionFunction:a,closedLoop:!1}){this._needsUpdate=!0;this._positionFunctionX=a;this._positionFunctionY=a;this._positionFunctionZ=a;this.connectLastAndFirstAnchor=!1;this._animationFrame=null;if(!o||o.length<2)throw new Error("Must have at least two anchor colors");this._anchorPoints=o.map(e=>new b({color:e})),this._numPoints=t+2,this._positionFunctionX=r||i||a,this._positionFunctionY=c||i||a,this._positionFunctionZ=h||i||a,this.connectLastAndFirstAnchor=s,this.updateAnchorPairs()}get numPoints(){return this._numPoints-2}set numPoints(o){if(o<1)throw new Error("Must have at least one point");this._numPoints=o+2,this.updateAnchorPairs()}set positionFunction(o){if(Array.isArray(o)){if(o.length!==3)throw new Error("Position function array must have 3 elements");if(typeof o[0]!="function"||typeof o[1]!="function"||typeof o[2]!="function")throw new Error("Position function array must have 3 functions");this._positionFunctionX=o[0],this._positionFunctionY=o[1],this._positionFunctionZ=o[2]}else this._positionFunctionX=o,this._positionFunctionY=o,this._positionFunctionZ=o;this.updateAnchorPairs()}get positionFunction(){return this._positionFunctionX===this._positionFunctionY&&this._positionFunctionX===this._positionFunctionZ?this._positionFunctionX:[this._positionFunctionX,this._positionFunctionY,this._positionFunctionZ]}set positionFunctionX(o){this._positionFunctionX=o,this.updateAnchorPairs()}get positionFunctionX(){return this._positionFunctionX}set positionFunctionY(o){this._positionFunctionY=o,this.updateAnchorPairs()}get positionFunctionY(){return this._positionFunctionY}set positionFunctionZ(o){this._positionFunctionZ=o,this.updateAnchorPairs()}get positionFunctionZ(){return this._positionFunctionZ}get anchorPoints(){return this._anchorPoints}set anchorPoints(o){this._anchorPoints=o,this.updateAnchorPairs()}updateAnchorPairs(){this._anchorPairs=[];let o=this.connectLastAndFirstAnchor?this.anchorPoints.length:this.anchorPoints.length-1;for(let t=0;t<o;t++){let i=[this.anchorPoints[t],this.anchorPoints[(t+1)%this.anchorPoints.length]];this._anchorPairs.push(i)}this.points=this._anchorPairs.map((t,i)=>{let r=t[0]?t[0].position:[0,0,0],c=t[1]?t[1].position:[0,0,0];return z(r,c,this._numPoints,!!(i%2),this.positionFunctionX,this.positionFunctionY,this.positionFunctionZ).map(h=>new b({xyz:h}))})}addAnchorPoint({xyz:o,color:t,insertAtIndex:i}){let r=new b({xyz:o,color:t});return i?this.anchorPoints.splice(i,0,r):this.anchorPoints.push(r),this.updateAnchorPairs(),r}removeAnchorPoint({point:o,index:t}){if(!o&&t===void 0)throw new Error("Must provide a point or index");let i;if(t!==void 0?i=t:o&&(i=this.anchorPoints.indexOf(o)),i>-1&&i<this.anchorPoints.length)this.anchorPoints.splice(i,1),this.updateAnchorPairs();else throw new Error("Point not found")}updateAnchorPoint({point:o,pointIndex:t,xyz:i,color:r}){if(t&&(o=this.anchorPoints[t]),!o)throw new Error("Must provide a point or pointIndex");if(!i&&!r)throw new Error("Must provide a new xyz position or color");return i&&(o.position=i),r&&(o.hsl=r),this.updateAnchorPairs(),o}getClosestAnchorPoint({xyz:o,hsl:t,maxDistance:i=1}){if(!o&&!t)throw new Error("Must provide a xyz or hsl");let r;o?r=this.anchorPoints.map(s=>V(s.position,o)):t&&(r=this.anchorPoints.map(s=>V(s.hsl,t,!0)));let c=Math.min(...r);if(c>i)return null;let h=r.indexOf(c);return this.anchorPoints[h]||null}set closedLoop(o){this.connectLastAndFirstAnchor=o,this.updateAnchorPairs()}get closedLoop(){return this.connectLastAndFirstAnchor}get flattenedPoints(){return this.points.flat().filter((o,t)=>t!=0?t%this._numPoints:!0)}get colors(){let o=this.flattenedPoints.map(t=>t.color);return this.connectLastAndFirstAnchor&&o.pop(),o}get colorsCSS(){let o=this.flattenedPoints.map(t=>t.hslCSS);return this.connectLastAndFirstAnchor&&o.pop(),o}shiftHue(o=20){this.anchorPoints.forEach(t=>t.shiftHue(o)),this.updateAnchorPairs()}},{p5:P}=globalThis;if(P){console.info("p5 detected, adding poline to p5 prototype");let n=new d;P.prototype.poline=n;let o=()=>n.colors.map(t=>`hsl(${Math.round(t[0])},${t[1]*100}%,${t[2]*100}%)`);P.prototype.polineColors=o,P.prototype.registerMethod("polineColors",P.prototype.polineColors),globalThis.poline=n,globalThis.polineColors=o}return g(H);})();
"use strict";var poline=(()=>{var F=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var a=Math.pow;var y=(n,t)=>{for(var o in t)F(n,o,{get:t[o],enumerable:!0})},C=(n,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of A(t))!x.call(n,s)&&s!==o&&F(n,s,{get:()=>t[s],enumerable:!(i=g(t,s))||i.enumerable});return n};var L=n=>C(F({},"__esModule",{value:!0}),n);var H={};y(H,{Poline:()=>f,hslToPoint:()=>m,pointToHSL:()=>_,positionFunctions:()=>$,randomHSLPair:()=>M,randomHSLTriple:()=>w});var _=(n,t)=>{let[o,i,s]=n,c=.5,h=.5,e=Math.atan2(i-h,o-c)*(180/Math.PI);e=(360+e)%360;let u=s,p=Math.sqrt(Math.pow(i-h,2)+Math.pow(o-c,2))/c;return[e,u,t?1-p:p]},m=(n,t)=>{let[o,i,s]=n,c=.5,h=.5,r=o/(180/Math.PI),e=(t?1-s:s)*c,u=c+e*Math.cos(r),P=h+e*Math.sin(r);return[u,P,i]},M=(n=Math.random()*360,t=[Math.random(),Math.random()],o=[.75+Math.random()*.2,.3+Math.random()*.2])=>[[n,t[0],o[0]],[(n+60+Math.random()*180)%360,t[1],o[1]]],w=(n=Math.random()*360,t=[Math.random(),Math.random(),Math.random()],o=[.75+Math.random()*.2,Math.random()*.2,.75+Math.random()*.2])=>[[n,t[0],o[0]],[(n+60+Math.random()*180)%360,t[1],o[1]],[(n+60+Math.random()*180)%360,t[2],o[2]]],X=(n,t,o,i=!1,s=(r,e)=>e?1-r:r,c=(r,e)=>e?1-r:r,h=(r,e)=>e?1-r:r)=>{let r=s(n,i),e=c(n,i),u=h(n,i),P=(1-r)*t[0]+r*o[0],p=(1-e)*t[1]+e*o[1],V=(1-u)*t[2]+u*o[2];return[P,p,V]},z=(n,t,o=4,i=!1,s=(r,e)=>e?1-r:r,c=(r,e)=>e?1-r:r,h=(r,e)=>e?1-r:r)=>{let r=[];for(let e=0;e<o;e++){let[u,P,p]=X(e/(o-1),n,t,i,s,c,h);r.push([u,P,p])}return r},Y=n=>n,Z=(n,t=!1)=>t?1-a(1-n,2):a(n,2),E=(n,t=!1)=>t?1-a(1-n,3):a(n,3),S=(n,t=!1)=>t?1-a(1-n,4):a(n,4),I=(n,t=!1)=>t?1-a(1-n,5):a(n,5),l=(n,t=!1)=>t?1-Math.sin((1-n)*Math.PI/2):Math.sin(n*Math.PI/2),O=(n,t=!1)=>t?1-Math.asin(1-n)/(Math.PI/2):Math.asin(n)/(Math.PI/2),q=(n,t=!1)=>t?Math.sqrt(1-a(1-n,2)):1-Math.sqrt(1-n),T=n=>a(n,2)*(3-2*n),$={linearPosition:Y,exponentialPosition:Z,quadraticPosition:E,cubicPosition:S,quarticPosition:I,sinusoidalPosition:l,asinusoidalPosition:O,arcPosition:q,smoothStepPosition:T},v=(n,t,o=!1)=>{let i=n[0],s=t[0],c=0;o&&i!==null&&s!==null?(c=Math.min(Math.abs(i-s),360-Math.abs(i-s)),c=c/360):c=i===null||s===null?0:i-s;let h=c,r=n[1]===null||t[1]===null?0:t[1]-n[1],e=n[2]===null||t[2]===null?0:t[2]-n[2];return Math.sqrt(h*h+r*r+e*e)},b=class{constructor({xyz:t,color:o,invertedLightness:i}={}){this.x=0;this.y=0;this.z=0;this.color=[0,0,0];this._invertedLightness=!1;this._invertedLightness=i||!1,this.positionOrColor({xyz:t,color:o,invertedLightness:i})}positionOrColor({xyz:t,color:o,invertedLightness:i}){if(t&&o)throw new Error("Point must be initialized with either x,y,z or hsl");t?(this.x=t[0],this.y=t[1],this.z=t[2],this.color=_([this.x,this.y,this.z],i||!1)):o&&(this.color=o,[this.x,this.y,this.z]=m(o,i||!1))}set position([t,o,i]){this.x=t,this.y=o,this.z=i,this.color=_([this.x,this.y,this.z],this._invertedLightness)}get position(){return[this.x,this.y,this.z]}set hsl([t,o,i]){this.color=[t,o,i],[this.x,this.y,this.z]=m(this.color,this._invertedLightness)}get hsl(){return this.color}get hslCSS(){return`hsl(${this.color[0].toFixed(2)}, ${(this.color[1]*100).toFixed(2)}%, ${(this.color[2]*100).toFixed(2)}%)`}shiftHue(t){this.color[0]=(360+(this.color[0]+t))%360,[this.x,this.y,this.z]=m(this.color,this._invertedLightness)}},f=class{constructor({anchorColors:t=M(),numPoints:o=4,positionFunction:i=l,positionFunctionX:s,positionFunctionY:c,positionFunctionZ:h,closedLoop:r,invertedLightness:e}={anchorColors:M(),numPoints:4,positionFunction:l,closedLoop:!1}){this._needsUpdate=!0;this._positionFunctionX=l;this._positionFunctionY=l;this._positionFunctionZ=l;this.connectLastAndFirstAnchor=!1;this._animationFrame=null;this._invertedLightness=!1;if(!t||t.length<2)throw new Error("Must have at least two anchor colors");this._anchorPoints=t.map(u=>new b({color:u,invertedLightness:e})),this._numPoints=o+2,this._positionFunctionX=s||i||l,this._positionFunctionY=c||i||l,this._positionFunctionZ=h||i||l,this.connectLastAndFirstAnchor=r||!1,this._invertedLightness=e||!1,this.updateAnchorPairs()}get numPoints(){return this._numPoints-2}set numPoints(t){if(t<1)throw new Error("Must have at least one point");this._numPoints=t+2,this.updateAnchorPairs()}set positionFunction(t){if(Array.isArray(t)){if(t.length!==3)throw new Error("Position function array must have 3 elements");if(typeof t[0]!="function"||typeof t[1]!="function"||typeof t[2]!="function")throw new Error("Position function array must have 3 functions");this._positionFunctionX=t[0],this._positionFunctionY=t[1],this._positionFunctionZ=t[2]}else this._positionFunctionX=t,this._positionFunctionY=t,this._positionFunctionZ=t;this.updateAnchorPairs()}get positionFunction(){return this._positionFunctionX===this._positionFunctionY&&this._positionFunctionX===this._positionFunctionZ?this._positionFunctionX:[this._positionFunctionX,this._positionFunctionY,this._positionFunctionZ]}set positionFunctionX(t){this._positionFunctionX=t,this.updateAnchorPairs()}get positionFunctionX(){return this._positionFunctionX}set positionFunctionY(t){this._positionFunctionY=t,this.updateAnchorPairs()}get positionFunctionY(){return this._positionFunctionY}set positionFunctionZ(t){this._positionFunctionZ=t,this.updateAnchorPairs()}get positionFunctionZ(){return this._positionFunctionZ}get anchorPoints(){return this._anchorPoints}set anchorPoints(t){this._anchorPoints=t,this.updateAnchorPairs()}updateAnchorPairs(){this._anchorPairs=[];let t=this.connectLastAndFirstAnchor?this.anchorPoints.length:this.anchorPoints.length-1;for(let o=0;o<t;o++){let i=[this.anchorPoints[o],this.anchorPoints[(o+1)%this.anchorPoints.length]];this._anchorPairs.push(i)}this.points=this._anchorPairs.map((o,i)=>{let s=o[0]?o[0].position:[0,0,0],c=o[1]?o[1].position:[0,0,0];return z(s,c,this._numPoints,!!(i%2),this.positionFunctionX,this.positionFunctionY,this.positionFunctionZ).map(h=>new b({xyz:h,invertedLightness:this._invertedLightness}))})}addAnchorPoint({xyz:t,color:o,insertAtIndex:i}){let s=new b({xyz:t,color:o,invertedLightness:this._invertedLightness});return i?this.anchorPoints.splice(i,0,s):this.anchorPoints.push(s),this.updateAnchorPairs(),s}removeAnchorPoint({point:t,index:o}){if(!t&&o===void 0)throw new Error("Must provide a point or index");let i;if(o!==void 0?i=o:t&&(i=this.anchorPoints.indexOf(t)),i>-1&&i<this.anchorPoints.length)this.anchorPoints.splice(i,1),this.updateAnchorPairs();else throw new Error("Point not found")}updateAnchorPoint({point:t,pointIndex:o,xyz:i,color:s}){if(o&&(t=this.anchorPoints[o]),!t)throw new Error("Must provide a point or pointIndex");if(!i&&!s)throw new Error("Must provide a new xyz position or color");return i&&(t.position=i),s&&(t.hsl=s),this.updateAnchorPairs(),t}getClosestAnchorPoint({xyz:t,hsl:o,maxDistance:i=1}){if(!t&&!o)throw new Error("Must provide a xyz or hsl");let s;t?s=this.anchorPoints.map(r=>v(r.position,t)):o&&(s=this.anchorPoints.map(r=>v(r.hsl,o,!0)));let c=Math.min(...s);if(c>i)return null;let h=s.indexOf(c);return this.anchorPoints[h]||null}set closedLoop(t){this.connectLastAndFirstAnchor=t,this.updateAnchorPairs()}get closedLoop(){return this.connectLastAndFirstAnchor}set invertedLightness(t){this._invertedLightness=t,this.updateAnchorPairs()}get invertedLightness(){return this._invertedLightness}get flattenedPoints(){return this.points.flat().filter((t,o)=>o!=0?o%this._numPoints:!0)}get colors(){let t=this.flattenedPoints.map(o=>o.color);return this.connectLastAndFirstAnchor&&t.pop(),t}get colorsCSS(){let t=this.flattenedPoints.map(o=>o.hslCSS);return this.connectLastAndFirstAnchor&&t.pop(),t}shiftHue(t=20){this.anchorPoints.forEach(o=>o.shiftHue(t)),this.updateAnchorPairs()}},{p5:d}=globalThis;if(d){console.info("p5 detected, adding poline to p5 prototype");let n=new f;d.prototype.poline=n;let t=()=>n.colors.map(o=>`hsl(${Math.round(o[0])},${o[1]*100}%,${o[2]*100}%)`);d.prototype.polineColors=t,d.prototype.registerMethod("polineColors",d.prototype.polineColors),globalThis.poline=n,globalThis.polineColors=t}return L(H);})();

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

var f=n=>{let[o,t,i]=n,s=.5,c=.5,r=Math.atan2(t-c,o-s)*(180/Math.PI);r=(360+r)%360;let e=i,l=Math.sqrt(Math.pow(t-c,2)+Math.pow(o-s,2))/s;return[r,e,l]},m=n=>{let[o,t,i]=n,s=.5,c=.5,h=o/(180/Math.PI),r=i*s,e=s+r*Math.cos(h),a=c+r*Math.sin(h);return[e,a,t]},F=(n=Math.random()*360,o=[Math.random(),Math.random()],t=[.75+Math.random()*.2,.3+Math.random()*.2])=>[[n,o[0],t[0]],[(n+60+Math.random()*180)%360,o[1],t[1]]],z=(n=Math.random()*360,o=[Math.random(),Math.random(),Math.random()],t=[.75+Math.random()*.2,Math.random()*.2,.75+Math.random()*.2])=>[[n,o[0],t[0]],[(n+60+Math.random()*180)%360,o[1],t[1]],[(n+60+Math.random()*180)%360,o[2],t[2]]],V=(n,o,t,i=!1,s=(r,e)=>e?1-r:r,c=(r,e)=>e?1-r:r,h=(r,e)=>e?1-r:r)=>{let r=s(n,i),e=c(n,i),a=h(n,i),l=(1-r)*o[0]+r*t[0],b=(1-e)*o[1]+e*t[1],_=(1-a)*o[2]+a*t[2];return[l,b,_]},A=(n,o,t=4,i=!1,s=(r,e)=>e?1-r:r,c=(r,e)=>e?1-r:r,h=(r,e)=>e?1-r:r)=>{let r=[];for(let e=0;e<t;e++){let[a,l,b]=V(e/(t-1),n,o,i,s,c,h);r.push([a,l,b])}return r},x=n=>n,y=(n,o=!1)=>o?1-(1-n)**2:n**2,C=(n,o=!1)=>o?1-(1-n)**3:n**3,w=(n,o=!1)=>o?1-(1-n)**4:n**4,v=(n,o=!1)=>o?1-(1-n)**5:n**5,u=(n,o=!1)=>o?1-Math.sin((1-n)*Math.PI/2):Math.sin(n*Math.PI/2),g=(n,o=!1)=>o?1-Math.asin(1-n)/(Math.PI/2):Math.asin(n)/(Math.PI/2),L=(n,o=!1)=>o?Math.sqrt(1-(1-n)**2):1-Math.sqrt(1-n),X=n=>n**2*(3-2*n),Y={linearPosition:x,exponentialPosition:y,quadraticPosition:C,cubicPosition:w,quarticPosition:v,sinusoidalPosition:u,asinusoidalPosition:g,arcPosition:L,smoothStepPosition:X},M=(n,o,t=!1)=>{let i=n[0],s=o[0],c=0;t&&i!==null&&s!==null?(c=Math.min(Math.abs(i-s),360-Math.abs(i-s)),c=c/360):c=i===null||s===null?0:i-s;let h=c,r=n[1]===null||o[1]===null?0:o[1]-n[1],e=n[2]===null||o[2]===null?0:o[2]-n[2];return Math.sqrt(h*h+r*r+e*e)},P=class{constructor({xyz:o,color:t}={}){this.x=0;this.y=0;this.z=0;this.color=[0,0,0];this.positionOrColor({xyz:o,color:t})}positionOrColor({xyz:o,color:t}){if(o&&t)throw new Error("Point must be initialized with either x,y,z or hsl");o?(this.x=o[0],this.y=o[1],this.z=o[2],this.color=f([this.x,this.y,this.z])):t&&(this.color=t,[this.x,this.y,this.z]=m(t))}set position([o,t,i]){this.x=o,this.y=t,this.z=i,this.color=f([this.x,this.y,this.z])}get position(){return[this.x,this.y,this.z]}set hsl([o,t,i]){this.color=[o,t,i],[this.x,this.y,this.z]=m(this.color)}get hsl(){return this.color}get hslCSS(){return`hsl(${this.color[0].toFixed(2)}, ${(this.color[1]*100).toFixed(2)}%, ${(this.color[2]*100).toFixed(2)}%)`}shiftHue(o){this.color[0]=(360+(this.color[0]+o))%360,[this.x,this.y,this.z]=m(this.color)}},d=class{constructor({anchorColors:o=F(),numPoints:t=4,positionFunction:i=u,positionFunctionX:s,positionFunctionY:c,positionFunctionZ:h,closedLoop:r}={anchorColors:F(),numPoints:4,positionFunction:u,closedLoop:!1}){this._needsUpdate=!0;this._positionFunctionX=u;this._positionFunctionY=u;this._positionFunctionZ=u;this.connectLastAndFirstAnchor=!1;this._animationFrame=null;if(!o||o.length<2)throw new Error("Must have at least two anchor colors");this._anchorPoints=o.map(e=>new P({color:e})),this._numPoints=t+2,this._positionFunctionX=s||i||u,this._positionFunctionY=c||i||u,this._positionFunctionZ=h||i||u,this.connectLastAndFirstAnchor=r,this.updateAnchorPairs()}get numPoints(){return this._numPoints-2}set numPoints(o){if(o<1)throw new Error("Must have at least one point");this._numPoints=o+2,this.updateAnchorPairs()}set positionFunction(o){if(Array.isArray(o)){if(o.length!==3)throw new Error("Position function array must have 3 elements");if(typeof o[0]!="function"||typeof o[1]!="function"||typeof o[2]!="function")throw new Error("Position function array must have 3 functions");this._positionFunctionX=o[0],this._positionFunctionY=o[1],this._positionFunctionZ=o[2]}else this._positionFunctionX=o,this._positionFunctionY=o,this._positionFunctionZ=o;this.updateAnchorPairs()}get positionFunction(){return this._positionFunctionX===this._positionFunctionY&&this._positionFunctionX===this._positionFunctionZ?this._positionFunctionX:[this._positionFunctionX,this._positionFunctionY,this._positionFunctionZ]}set positionFunctionX(o){this._positionFunctionX=o,this.updateAnchorPairs()}get positionFunctionX(){return this._positionFunctionX}set positionFunctionY(o){this._positionFunctionY=o,this.updateAnchorPairs()}get positionFunctionY(){return this._positionFunctionY}set positionFunctionZ(o){this._positionFunctionZ=o,this.updateAnchorPairs()}get positionFunctionZ(){return this._positionFunctionZ}get anchorPoints(){return this._anchorPoints}set anchorPoints(o){this._anchorPoints=o,this.updateAnchorPairs()}updateAnchorPairs(){this._anchorPairs=[];let o=this.connectLastAndFirstAnchor?this.anchorPoints.length:this.anchorPoints.length-1;for(let t=0;t<o;t++){let i=[this.anchorPoints[t],this.anchorPoints[(t+1)%this.anchorPoints.length]];this._anchorPairs.push(i)}this.points=this._anchorPairs.map((t,i)=>{let s=t[0]?t[0].position:[0,0,0],c=t[1]?t[1].position:[0,0,0];return A(s,c,this._numPoints,!!(i%2),this.positionFunctionX,this.positionFunctionY,this.positionFunctionZ).map(h=>new P({xyz:h}))})}addAnchorPoint({xyz:o,color:t,insertAtIndex:i}){let s=new P({xyz:o,color:t});return i?this.anchorPoints.splice(i,0,s):this.anchorPoints.push(s),this.updateAnchorPairs(),s}removeAnchorPoint({point:o,index:t}){if(!o&&t===void 0)throw new Error("Must provide a point or index");let i;if(t!==void 0?i=t:o&&(i=this.anchorPoints.indexOf(o)),i>-1&&i<this.anchorPoints.length)this.anchorPoints.splice(i,1),this.updateAnchorPairs();else throw new Error("Point not found")}updateAnchorPoint({point:o,pointIndex:t,xyz:i,color:s}){if(t&&(o=this.anchorPoints[t]),!o)throw new Error("Must provide a point or pointIndex");if(!i&&!s)throw new Error("Must provide a new xyz position or color");return i&&(o.position=i),s&&(o.hsl=s),this.updateAnchorPairs(),o}getClosestAnchorPoint({xyz:o,hsl:t,maxDistance:i=1}){if(!o&&!t)throw new Error("Must provide a xyz or hsl");let s;o?s=this.anchorPoints.map(r=>M(r.position,o)):t&&(s=this.anchorPoints.map(r=>M(r.hsl,t,!0)));let c=Math.min(...s);if(c>i)return null;let h=s.indexOf(c);return this.anchorPoints[h]||null}set closedLoop(o){this.connectLastAndFirstAnchor=o,this.updateAnchorPairs()}get closedLoop(){return this.connectLastAndFirstAnchor}get flattenedPoints(){return this.points.flat().filter((o,t)=>t!=0?t%this._numPoints:!0)}get colors(){let o=this.flattenedPoints.map(t=>t.color);return this.connectLastAndFirstAnchor&&o.pop(),o}get colorsCSS(){let o=this.flattenedPoints.map(t=>t.hslCSS);return this.connectLastAndFirstAnchor&&o.pop(),o}shiftHue(o=20){this.anchorPoints.forEach(t=>t.shiftHue(o)),this.updateAnchorPairs()}},{p5:p}=globalThis;if(p){console.info("p5 detected, adding poline to p5 prototype");let n=new d;p.prototype.poline=n;let o=()=>n.colors.map(t=>`hsl(${Math.round(t[0])},${t[1]*100}%,${t[2]*100}%)`);p.prototype.polineColors=o,p.prototype.registerMethod("polineColors",p.prototype.polineColors),globalThis.poline=n,globalThis.polineColors=o}export{d as Poline,m as hslToPoint,f as pointToHSL,Y as positionFunctions,F as randomHSLPair,z as randomHSLTriple};
var f=(n,t)=>{let[o,i,r]=n,c=.5,h=.5,e=Math.atan2(i-h,o-c)*(180/Math.PI);e=(360+e)%360;let a=r,l=Math.sqrt(Math.pow(i-h,2)+Math.pow(o-c,2))/c;return[e,a,t?1-l:l]},b=(n,t)=>{let[o,i,r]=n,c=.5,h=.5,s=o/(180/Math.PI),e=(t?1-r:r)*c,a=c+e*Math.cos(s),p=h+e*Math.sin(s);return[a,p,i]},F=(n=Math.random()*360,t=[Math.random(),Math.random()],o=[.75+Math.random()*.2,.3+Math.random()*.2])=>[[n,t[0],o[0]],[(n+60+Math.random()*180)%360,t[1],o[1]]],z=(n=Math.random()*360,t=[Math.random(),Math.random(),Math.random()],o=[.75+Math.random()*.2,Math.random()*.2,.75+Math.random()*.2])=>[[n,t[0],o[0]],[(n+60+Math.random()*180)%360,t[1],o[1]],[(n+60+Math.random()*180)%360,t[2],o[2]]],v=(n,t,o,i=!1,r=(s,e)=>e?1-s:s,c=(s,e)=>e?1-s:s,h=(s,e)=>e?1-s:s)=>{let s=r(n,i),e=c(n,i),a=h(n,i),p=(1-s)*t[0]+s*o[0],l=(1-e)*t[1]+e*o[1],M=(1-a)*t[2]+a*o[2];return[p,l,M]},V=(n,t,o=4,i=!1,r=(s,e)=>e?1-s:s,c=(s,e)=>e?1-s:s,h=(s,e)=>e?1-s:s)=>{let s=[];for(let e=0;e<o;e++){let[a,p,l]=v(e/(o-1),n,t,i,r,c,h);s.push([a,p,l])}return s},g=n=>n,A=(n,t=!1)=>t?1-(1-n)**2:n**2,x=(n,t=!1)=>t?1-(1-n)**3:n**3,y=(n,t=!1)=>t?1-(1-n)**4:n**4,C=(n,t=!1)=>t?1-(1-n)**5:n**5,u=(n,t=!1)=>t?1-Math.sin((1-n)*Math.PI/2):Math.sin(n*Math.PI/2),L=(n,t=!1)=>t?1-Math.asin(1-n)/(Math.PI/2):Math.asin(n)/(Math.PI/2),w=(n,t=!1)=>t?Math.sqrt(1-(1-n)**2):1-Math.sqrt(1-n),X=n=>n**2*(3-2*n),Y={linearPosition:g,exponentialPosition:A,quadraticPosition:x,cubicPosition:y,quarticPosition:C,sinusoidalPosition:u,asinusoidalPosition:L,arcPosition:w,smoothStepPosition:X},_=(n,t,o=!1)=>{let i=n[0],r=t[0],c=0;o&&i!==null&&r!==null?(c=Math.min(Math.abs(i-r),360-Math.abs(i-r)),c=c/360):c=i===null||r===null?0:i-r;let h=c,s=n[1]===null||t[1]===null?0:t[1]-n[1],e=n[2]===null||t[2]===null?0:t[2]-n[2];return Math.sqrt(h*h+s*s+e*e)},d=class{constructor({xyz:t,color:o,invertedLightness:i}={}){this.x=0;this.y=0;this.z=0;this.color=[0,0,0];this._invertedLightness=!1;this._invertedLightness=i||!1,this.positionOrColor({xyz:t,color:o,invertedLightness:i})}positionOrColor({xyz:t,color:o,invertedLightness:i}){if(t&&o)throw new Error("Point must be initialized with either x,y,z or hsl");t?(this.x=t[0],this.y=t[1],this.z=t[2],this.color=f([this.x,this.y,this.z],i||!1)):o&&(this.color=o,[this.x,this.y,this.z]=b(o,i||!1))}set position([t,o,i]){this.x=t,this.y=o,this.z=i,this.color=f([this.x,this.y,this.z],this._invertedLightness)}get position(){return[this.x,this.y,this.z]}set hsl([t,o,i]){this.color=[t,o,i],[this.x,this.y,this.z]=b(this.color,this._invertedLightness)}get hsl(){return this.color}get hslCSS(){return`hsl(${this.color[0].toFixed(2)}, ${(this.color[1]*100).toFixed(2)}%, ${(this.color[2]*100).toFixed(2)}%)`}shiftHue(t){this.color[0]=(360+(this.color[0]+t))%360,[this.x,this.y,this.z]=b(this.color,this._invertedLightness)}},m=class{constructor({anchorColors:t=F(),numPoints:o=4,positionFunction:i=u,positionFunctionX:r,positionFunctionY:c,positionFunctionZ:h,closedLoop:s,invertedLightness:e}={anchorColors:F(),numPoints:4,positionFunction:u,closedLoop:!1}){this._needsUpdate=!0;this._positionFunctionX=u;this._positionFunctionY=u;this._positionFunctionZ=u;this.connectLastAndFirstAnchor=!1;this._animationFrame=null;this._invertedLightness=!1;if(!t||t.length<2)throw new Error("Must have at least two anchor colors");this._anchorPoints=t.map(a=>new d({color:a,invertedLightness:e})),this._numPoints=o+2,this._positionFunctionX=r||i||u,this._positionFunctionY=c||i||u,this._positionFunctionZ=h||i||u,this.connectLastAndFirstAnchor=s||!1,this._invertedLightness=e||!1,this.updateAnchorPairs()}get numPoints(){return this._numPoints-2}set numPoints(t){if(t<1)throw new Error("Must have at least one point");this._numPoints=t+2,this.updateAnchorPairs()}set positionFunction(t){if(Array.isArray(t)){if(t.length!==3)throw new Error("Position function array must have 3 elements");if(typeof t[0]!="function"||typeof t[1]!="function"||typeof t[2]!="function")throw new Error("Position function array must have 3 functions");this._positionFunctionX=t[0],this._positionFunctionY=t[1],this._positionFunctionZ=t[2]}else this._positionFunctionX=t,this._positionFunctionY=t,this._positionFunctionZ=t;this.updateAnchorPairs()}get positionFunction(){return this._positionFunctionX===this._positionFunctionY&&this._positionFunctionX===this._positionFunctionZ?this._positionFunctionX:[this._positionFunctionX,this._positionFunctionY,this._positionFunctionZ]}set positionFunctionX(t){this._positionFunctionX=t,this.updateAnchorPairs()}get positionFunctionX(){return this._positionFunctionX}set positionFunctionY(t){this._positionFunctionY=t,this.updateAnchorPairs()}get positionFunctionY(){return this._positionFunctionY}set positionFunctionZ(t){this._positionFunctionZ=t,this.updateAnchorPairs()}get positionFunctionZ(){return this._positionFunctionZ}get anchorPoints(){return this._anchorPoints}set anchorPoints(t){this._anchorPoints=t,this.updateAnchorPairs()}updateAnchorPairs(){this._anchorPairs=[];let t=this.connectLastAndFirstAnchor?this.anchorPoints.length:this.anchorPoints.length-1;for(let o=0;o<t;o++){let i=[this.anchorPoints[o],this.anchorPoints[(o+1)%this.anchorPoints.length]];this._anchorPairs.push(i)}this.points=this._anchorPairs.map((o,i)=>{let r=o[0]?o[0].position:[0,0,0],c=o[1]?o[1].position:[0,0,0];return V(r,c,this._numPoints,!!(i%2),this.positionFunctionX,this.positionFunctionY,this.positionFunctionZ).map(h=>new d({xyz:h,invertedLightness:this._invertedLightness}))})}addAnchorPoint({xyz:t,color:o,insertAtIndex:i}){let r=new d({xyz:t,color:o,invertedLightness:this._invertedLightness});return i?this.anchorPoints.splice(i,0,r):this.anchorPoints.push(r),this.updateAnchorPairs(),r}removeAnchorPoint({point:t,index:o}){if(!t&&o===void 0)throw new Error("Must provide a point or index");let i;if(o!==void 0?i=o:t&&(i=this.anchorPoints.indexOf(t)),i>-1&&i<this.anchorPoints.length)this.anchorPoints.splice(i,1),this.updateAnchorPairs();else throw new Error("Point not found")}updateAnchorPoint({point:t,pointIndex:o,xyz:i,color:r}){if(o&&(t=this.anchorPoints[o]),!t)throw new Error("Must provide a point or pointIndex");if(!i&&!r)throw new Error("Must provide a new xyz position or color");return i&&(t.position=i),r&&(t.hsl=r),this.updateAnchorPairs(),t}getClosestAnchorPoint({xyz:t,hsl:o,maxDistance:i=1}){if(!t&&!o)throw new Error("Must provide a xyz or hsl");let r;t?r=this.anchorPoints.map(s=>_(s.position,t)):o&&(r=this.anchorPoints.map(s=>_(s.hsl,o,!0)));let c=Math.min(...r);if(c>i)return null;let h=r.indexOf(c);return this.anchorPoints[h]||null}set closedLoop(t){this.connectLastAndFirstAnchor=t,this.updateAnchorPairs()}get closedLoop(){return this.connectLastAndFirstAnchor}set invertedLightness(t){this._invertedLightness=t,this.updateAnchorPairs()}get invertedLightness(){return this._invertedLightness}get flattenedPoints(){return this.points.flat().filter((t,o)=>o!=0?o%this._numPoints:!0)}get colors(){let t=this.flattenedPoints.map(o=>o.color);return this.connectLastAndFirstAnchor&&t.pop(),t}get colorsCSS(){let t=this.flattenedPoints.map(o=>o.hslCSS);return this.connectLastAndFirstAnchor&&t.pop(),t}shiftHue(t=20){this.anchorPoints.forEach(o=>o.shiftHue(t)),this.updateAnchorPairs()}},{p5:P}=globalThis;if(P){console.info("p5 detected, adding poline to p5 prototype");let n=new m;P.prototype.poline=n;let t=()=>n.colors.map(o=>`hsl(${Math.round(o[0])},${o[1]*100}%,${o[2]*100}%)`);P.prototype.polineColors=t,P.prototype.registerMethod("polineColors",P.prototype.polineColors),globalThis.poline=n,globalThis.polineColors=t}export{m as Poline,b as hslToPoint,f as pointToHSL,Y as positionFunctions,F as randomHSLPair,z as randomHSLTriple};
// src/index.ts
var pointToHSL = (xyz) => {
var pointToHSL = (xyz, invertedLightness) => {
const [x, y, z] = xyz;

@@ -12,5 +12,5 @@ const cx = 0.5;

const l = dist / cx;
return [deg, s, l];
return [deg, s, invertedLightness ? 1 - l : l];
};
var hslToPoint = (hsl) => {
var hslToPoint = (hsl, invertedLightness) => {
const [h, s, l] = hsl;

@@ -20,3 +20,3 @@ const cx = 0.5;

const radians = h / (180 / Math.PI);
const dist = l * cx;
const dist = (invertedLightness ? 1 - l : l) * cx;
const x = cx + dist * Math.cos(radians);

@@ -140,3 +140,3 @@ const y = cy + dist * Math.sin(radians);

var ColorPoint = class {
constructor({ xyz, color } = {}) {
constructor({ xyz, color, invertedLightness } = {}) {
this.x = 0;

@@ -146,5 +146,7 @@ this.y = 0;

this.color = [0, 0, 0];
this.positionOrColor({ xyz, color });
this._invertedLightness = false;
this._invertedLightness = invertedLightness || false;
this.positionOrColor({ xyz, color, invertedLightness });
}
positionOrColor({ xyz, color }) {
positionOrColor({ xyz, color, invertedLightness }) {
if (xyz && color) {

@@ -156,6 +158,9 @@ throw new Error("Point must be initialized with either x,y,z or hsl");

this.z = xyz[2];
this.color = pointToHSL([this.x, this.y, this.z]);
this.color = pointToHSL(
[this.x, this.y, this.z],
invertedLightness || false
);
} else if (color) {
this.color = color;
[this.x, this.y, this.z] = hslToPoint(color);
[this.x, this.y, this.z] = hslToPoint(color, invertedLightness || false);
}

@@ -167,3 +172,6 @@ }

this.z = z;
this.color = pointToHSL([this.x, this.y, this.z]);
this.color = pointToHSL(
[this.x, this.y, this.z],
this._invertedLightness
);
}

@@ -175,3 +183,6 @@ get position() {

this.color = [h, s, l];
[this.x, this.y, this.z] = hslToPoint(this.color);
[this.x, this.y, this.z] = hslToPoint(
this.color,
this._invertedLightness
);
}

@@ -188,3 +199,6 @@ get hsl() {

this.color[0] = (360 + (this.color[0] + angle)) % 360;
[this.x, this.y, this.z] = hslToPoint(this.color);
[this.x, this.y, this.z] = hslToPoint(
this.color,
this._invertedLightness
);
}

@@ -200,3 +214,4 @@ };

positionFunctionZ,
closedLoop
closedLoop,
invertedLightness
} = {

@@ -214,2 +229,3 @@ anchorColors: randomHSLPair(),

this._animationFrame = null;
this._invertedLightness = false;
if (!anchorColors || anchorColors.length < 2) {

@@ -219,3 +235,3 @@ throw new Error("Must have at least two anchor colors");

this._anchorPoints = anchorColors.map(
(point) => new ColorPoint({ color: point })
(point) => new ColorPoint({ color: point, invertedLightness })
);

@@ -226,3 +242,4 @@ this._numPoints = numPoints + 2;

this._positionFunctionZ = positionFunctionZ || positionFunction || sinusoidalPosition;
this.connectLastAndFirstAnchor = closedLoop;
this.connectLastAndFirstAnchor = closedLoop || false;
this._invertedLightness = invertedLightness || false;
this.updateAnchorPairs();

@@ -317,3 +334,5 @@ }

this.positionFunctionZ
).map((p) => new ColorPoint({ xyz: p }));
).map(
(p) => new ColorPoint({ xyz: p, invertedLightness: this._invertedLightness })
);
});

@@ -326,3 +345,7 @@ }

}) {
const newAnchor = new ColorPoint({ xyz, color });
const newAnchor = new ColorPoint({
xyz,
color,
invertedLightness: this._invertedLightness
});
if (insertAtIndex) {

@@ -410,2 +433,9 @@ this.anchorPoints.splice(insertAtIndex, 0, newAnchor);

}
set invertedLightness(newStatus) {
this._invertedLightness = newStatus;
this.updateAnchorPairs();
}
get invertedLightness() {
return this._invertedLightness;
}
get flattenedPoints() {

@@ -439,4 +469,3 @@ return this.points.flat().filter((p, i) => i != 0 ? i % this._numPoints : true);

const polineColors = () => poline.colors.map(
(c) => /*p5.Color(c)*/
`hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`
(c) => `hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`
);

@@ -443,0 +472,0 @@ p5.prototype.polineColors = polineColors;

{
"version": 3,
"sources": ["../src/index.ts"],
"sourcesContent": ["/* eslint-disable @typescript-eslint/ban-ts-comment */\nexport type FuncNumberReturn = (arg0: number) => Vector2;\nexport type Vector2 = [number, number];\nexport type Vector3 = [number, ...Vector2];\nexport type PartialVector3 = [number | null, number | null, number | null];\n\n/**\n * Converts the given (x, y, z) coordinate to an HSL color\n * The (x, y) values are used to calculate the hue, while the z value is used as the saturation\n * The lightness value is calculated based on the distance of (x, y) from the center (0.5, 0.5)\n * Returns an array [hue, saturation, lightness]\n * @param xyz:Vector3 [x, y, z] coordinate array in (x, y, z) format (0-1, 0-1, 0-1)\n * @returns [hue, saturation, lightness]: Vector3 color array in HSL format (0-360, 0-1, 0-1)\n * @example\n * pointToHSL(0.5, 0.5, 1) // [0, 1, 0.5]\n * pointToHSL(0.5, 0.5, 0) // [0, 1, 0]\n * pointToHSL(0.5, 0.5, 1) // [0, 1, 1]\n **/\n\nexport const pointToHSL = (xyz: Vector3): Vector3 => {\n const [x, y, z] = xyz;\n\n // cy and cx are the center (y and x) values\n const cx = 0.5;\n const cy = 0.5;\n\n // Calculate the angle between the point (x, y) and the center (cx, cy)\n const radians = Math.atan2(y - cy, x - cx);\n\n // Convert the angle to degrees and shift it so that it goes from 0 to 360\n let deg = radians * (180 / Math.PI);\n deg = (360 + deg) % 360;\n\n // The saturation value is taken from the z coordinate\n const s = z;\n\n // Calculate the lightness value based on the distance from the center\n const dist = Math.sqrt(Math.pow(y - cy, 2) + Math.pow(x - cx, 2));\n const l = dist / cx;\n\n // Return the HSL color as an array [hue, saturation, lightness]\n return [deg, s, l];\n};\n\n/**\n * Converts the given HSL color to an (x, y, z) coordinate\n * The hue value is used to calculate the (x, y) position, while the saturation value is used as the z coordinate\n * The lightness value is used to calculate the distance from the center (0.5, 0.5)\n * Returns an array [x, y, z]\n * @param hsl:Vector3 [hue, saturation, lightness] color array in HSL format (0-360, 0-1, 0-1)\n * @returns [x, y, z]:Vector3 coordinate array in (x, y, z) format (0-1, 0-1, 0-1)\n * @example\n * hslToPoint([0, 1, 0.5]) // [0.5, 0.5, 1]\n * hslToPoint([0, 1, 0]) // [0.5, 0.5, 1]\n * hslToPoint([0, 1, 1]) // [0.5, 0.5, 1]\n * hslToPoint([0, 0, 0.5]) // [0.5, 0.5, 0]\n **/\nexport const hslToPoint = (hsl: Vector3): Vector3 => {\n // Destructure the input array into separate hue, saturation, and lightness values\n const [h, s, l] = hsl;\n // cx and cy are the center (x and y) values\n const cx = 0.5;\n const cy = 0.5;\n // Calculate the angle in radians based on the hue value\n const radians = h / (180 / Math.PI);\n // Calculate the distance from the center based on the lightness value\n const dist = l * cx;\n // Calculate the x and y coordinates based on the distance and angle\n const x = cx + dist * Math.cos(radians);\n const y = cy + dist * Math.sin(radians);\n // The z coordinate is equal to the saturation value\n const z = s;\n // Return the (x, y, z) coordinate as an array [x, y, z]\n return [x, y, z];\n};\n\nexport const randomHSLPair = (\n startHue: number = Math.random() * 360,\n saturations: Vector2 = [Math.random(), Math.random()],\n lightnesses: Vector2 = [0.75 + Math.random() * 0.2, 0.3 + Math.random() * 0.2]\n): [Vector3, Vector3] => [\n [startHue, saturations[0], lightnesses[0]],\n [(startHue + 60 + Math.random() * 180) % 360, saturations[1], lightnesses[1]],\n];\n\nexport const randomHSLTriple = (\n startHue: number = Math.random() * 360,\n saturations: Vector3 = [Math.random(), Math.random(), Math.random()],\n lightnesses: Vector3 = [\n 0.75 + Math.random() * 0.2,\n Math.random() * 0.2,\n 0.75 + Math.random() * 0.2,\n ]\n): [Vector3, Vector3, Vector3] => [\n [startHue, saturations[0], lightnesses[0]],\n [(startHue + 60 + Math.random() * 180) % 360, saturations[1], lightnesses[1]],\n [(startHue + 60 + Math.random() * 180) % 360, saturations[2], lightnesses[2]],\n];\n\nconst vectorOnLine = (\n t: number,\n p1: Vector3,\n p2: Vector3,\n invert = false,\n fx = (t: number, invert: boolean): number => (invert ? 1 - t : t),\n fy = (t: number, invert: boolean): number => (invert ? 1 - t : t),\n fz = (t: number, invert: boolean): number => (invert ? 1 - t : t)\n): Vector3 => {\n const tModifiedX = fx(t, invert);\n const tModifiedY = fy(t, invert);\n const tModifiedZ = fz(t, invert);\n const x = (1 - tModifiedX) * p1[0] + tModifiedX * p2[0];\n const y = (1 - tModifiedY) * p1[1] + tModifiedY * p2[1];\n const z = (1 - tModifiedZ) * p1[2] + tModifiedZ * p2[2];\n\n return [x, y, z];\n};\n\nconst vectorsOnLine = (\n p1: Vector3,\n p2: Vector3,\n numPoints = 4,\n invert = false,\n fx = (t: number, invert: boolean): number => (invert ? 1 - t : t),\n fy = (t: number, invert: boolean): number => (invert ? 1 - t : t),\n fz = (t: number, invert: boolean): number => (invert ? 1 - t : t)\n): Vector3[] => {\n const points: Vector3[] = [];\n\n for (let i = 0; i < numPoints; i++) {\n const [x, y, z] = vectorOnLine(\n i / (numPoints - 1),\n p1,\n p2,\n invert,\n fx,\n fy,\n fz\n );\n points.push([x, y, z]);\n }\n\n return points;\n};\n\nexport type PositionFunction = (t: number, reverse?: boolean) => number;\n\nconst linearPosition: PositionFunction = (t: number) => {\n return t;\n};\n\nconst exponentialPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - (1 - t) ** 2;\n }\n return t ** 2;\n};\n\nconst quadraticPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - (1 - t) ** 3;\n }\n return t ** 3;\n};\n\nconst cubicPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - (1 - t) ** 4;\n }\n return t ** 4;\n};\n\nconst quarticPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - (1 - t) ** 5;\n }\n return t ** 5;\n};\n\nconst sinusoidalPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - Math.sin(((1 - t) * Math.PI) / 2);\n }\n return Math.sin((t * Math.PI) / 2);\n};\n\nconst asinusoidalPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - Math.asin(1 - t) / (Math.PI / 2);\n }\n return Math.asin(t) / (Math.PI / 2);\n};\n\nconst arcPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return Math.sqrt(1 - (1 - t) ** 2);\n }\n return 1 - Math.sqrt(1 - t);\n};\n\nconst smoothStepPosition: PositionFunction = (t: number) => {\n return t ** 2 * (3 - 2 * t);\n};\n\nexport const positionFunctions = {\n linearPosition,\n exponentialPosition,\n quadraticPosition,\n cubicPosition,\n quarticPosition,\n sinusoidalPosition,\n asinusoidalPosition,\n arcPosition,\n smoothStepPosition,\n};\n\n/**\n * Calculates the distance between two points\n * @param p1 The first point\n * @param p2 The second point\n * @param hueMode Whether to use the hue distance function\n * @returns The distance between the two points\n * @example\n * const p1 = [0, 0, 0];\n * const p2 = [1, 1, 1];\n * const dist = distance(p1, p2);\n * console.log(dist); // 1.7320508075688772\n **/\nconst distance = (\n p1: PartialVector3,\n p2: PartialVector3,\n hueMode = false\n): number => {\n const a1 = p1[0];\n const a2 = p2[0];\n let diffA = 0;\n\n if (hueMode && a1 !== null && a2 !== null) {\n diffA = Math.min(Math.abs(a1 - a2), 360 - Math.abs(a1 - a2));\n diffA = diffA / 360;\n } else {\n diffA = a1 === null || a2 === null ? 0 : a1 - a2;\n }\n\n const a = diffA;\n const b = p1[1] === null || p2[1] === null ? 0 : p2[1] - p1[1];\n const c = p1[2] === null || p2[2] === null ? 0 : p2[2] - p1[2];\n\n return Math.sqrt(a * a + b * b + c * c);\n};\n\nexport type ColorPointCollection = {\n xyz?: Vector3;\n color?: Vector3;\n};\n\nclass ColorPoint {\n public x = 0;\n public y = 0;\n public z = 0;\n public color: Vector3 = [0, 0, 0];\n\n constructor({ xyz, color }: ColorPointCollection = {}) {\n this.positionOrColor({ xyz, color });\n }\n\n positionOrColor({ xyz, color }: ColorPointCollection) {\n if (xyz && color) {\n throw new Error(\"Point must be initialized with either x,y,z or hsl\");\n } else if (xyz) {\n this.x = xyz[0];\n this.y = xyz[1];\n this.z = xyz[2];\n this.color = pointToHSL([this.x, this.y, this.z]);\n } else if (color) {\n this.color = color;\n [this.x, this.y, this.z] = hslToPoint(color);\n }\n }\n\n set position([x, y, z]: Vector3) {\n this.x = x;\n this.y = y;\n this.z = z;\n this.color = pointToHSL([this.x, this.y, this.z]);\n }\n\n get position(): Vector3 {\n return [this.x, this.y, this.z];\n }\n\n set hsl([h, s, l]: Vector3) {\n this.color = [h, s, l];\n [this.x, this.y, this.z] = hslToPoint(this.color);\n }\n\n get hsl(): Vector3 {\n return this.color;\n }\n\n get hslCSS(): string {\n return `hsl(${this.color[0].toFixed(2)}, ${(this.color[1] * 100).toFixed(\n 2\n )}%, ${(this.color[2] * 100).toFixed(2)}%)`;\n }\n\n shiftHue(angle: number): void {\n this.color[0] = (360 + (this.color[0] + angle)) % 360;\n [this.x, this.y, this.z] = hslToPoint(this.color);\n }\n}\n\nexport type PolineOptions = {\n anchorColors: Vector3[];\n numPoints: number;\n positionFunction?: (t: number, invert?: boolean) => number;\n positionFunctionX?: (t: number, invert?: boolean) => number;\n positionFunctionY?: (t: number, invert?: boolean) => number;\n positionFunctionZ?: (t: number, invert?: boolean) => number;\n closedLoop: boolean;\n};\nexport class Poline {\n private _needsUpdate = true;\n private _anchorPoints: ColorPoint[];\n\n private _numPoints: number;\n private points: ColorPoint[][];\n\n private _positionFunctionX = sinusoidalPosition;\n private _positionFunctionY = sinusoidalPosition;\n private _positionFunctionZ = sinusoidalPosition;\n\n private _anchorPairs: ColorPoint[][];\n\n private connectLastAndFirstAnchor = false;\n\n private _animationFrame: null | number = null;\n\n constructor(\n {\n anchorColors = randomHSLPair(),\n numPoints = 4,\n positionFunction = sinusoidalPosition,\n positionFunctionX,\n positionFunctionY,\n positionFunctionZ,\n closedLoop,\n }: PolineOptions = {\n anchorColors: randomHSLPair(),\n numPoints: 4,\n positionFunction: sinusoidalPosition,\n closedLoop: false,\n }\n ) {\n if (!anchorColors || anchorColors.length < 2) {\n throw new Error(\"Must have at least two anchor colors\");\n }\n\n this._anchorPoints = anchorColors.map(\n (point) => new ColorPoint({ color: point })\n );\n\n this._numPoints = numPoints + 2; // add two for the anchor points\n\n this._positionFunctionX =\n positionFunctionX || positionFunction || sinusoidalPosition;\n this._positionFunctionY =\n positionFunctionY || positionFunction || sinusoidalPosition;\n this._positionFunctionZ =\n positionFunctionZ || positionFunction || sinusoidalPosition;\n\n this.connectLastAndFirstAnchor = closedLoop;\n\n this.updateAnchorPairs();\n }\n\n public get numPoints(): number {\n return this._numPoints - 2;\n }\n\n public set numPoints(numPoints: number) {\n if (numPoints < 1) {\n throw new Error(\"Must have at least one point\");\n }\n this._numPoints = numPoints + 2; // add two for the anchor points\n this.updateAnchorPairs();\n }\n\n public set positionFunction(\n positionFunction: PositionFunction | PositionFunction[]\n ) {\n if (Array.isArray(positionFunction)) {\n if (positionFunction.length !== 3) {\n throw new Error(\"Position function array must have 3 elements\");\n }\n if (\n typeof positionFunction[0] !== \"function\" ||\n typeof positionFunction[1] !== \"function\" ||\n typeof positionFunction[2] !== \"function\"\n ) {\n throw new Error(\"Position function array must have 3 functions\");\n }\n this._positionFunctionX = positionFunction[0];\n this._positionFunctionY = positionFunction[1];\n this._positionFunctionZ = positionFunction[2];\n } else {\n this._positionFunctionX = positionFunction;\n this._positionFunctionY = positionFunction;\n this._positionFunctionZ = positionFunction;\n }\n\n this.updateAnchorPairs();\n }\n\n public get positionFunction(): PositionFunction | PositionFunction[] {\n // not to sure what to do here, because the position function is a combination of the three\n if (\n this._positionFunctionX === this._positionFunctionY &&\n this._positionFunctionX === this._positionFunctionZ\n ) {\n return this._positionFunctionX;\n }\n\n return [\n this._positionFunctionX,\n this._positionFunctionY,\n this._positionFunctionZ,\n ];\n }\n\n public set positionFunctionX(positionFunctionX: PositionFunction) {\n this._positionFunctionX = positionFunctionX;\n this.updateAnchorPairs();\n }\n\n public get positionFunctionX(): PositionFunction {\n return this._positionFunctionX;\n }\n\n public set positionFunctionY(positionFunctionY: PositionFunction) {\n this._positionFunctionY = positionFunctionY;\n this.updateAnchorPairs();\n }\n\n public get positionFunctionY(): PositionFunction {\n return this._positionFunctionY;\n }\n\n public set positionFunctionZ(positionFunctionZ: PositionFunction) {\n this._positionFunctionZ = positionFunctionZ;\n this.updateAnchorPairs();\n }\n\n public get positionFunctionZ(): PositionFunction {\n return this._positionFunctionZ;\n }\n\n public get anchorPoints(): ColorPoint[] {\n return this._anchorPoints;\n }\n\n public set anchorPoints(anchorPoints: ColorPoint[]) {\n this._anchorPoints = anchorPoints;\n this.updateAnchorPairs();\n }\n\n public updateAnchorPairs(): void {\n this._anchorPairs = [] as ColorPoint[][];\n\n const anchorPointsLength = this.connectLastAndFirstAnchor\n ? this.anchorPoints.length\n : this.anchorPoints.length - 1;\n\n for (let i = 0; i < anchorPointsLength; i++) {\n const pair = [\n this.anchorPoints[i],\n this.anchorPoints[(i + 1) % this.anchorPoints.length],\n ] as ColorPoint[];\n\n this._anchorPairs.push(pair);\n }\n\n this.points = this._anchorPairs.map((pair, i) => {\n const p1position = pair[0] ? pair[0].position : ([0, 0, 0] as Vector3);\n const p2position = pair[1] ? pair[1].position : ([0, 0, 0] as Vector3);\n\n return vectorsOnLine(\n p1position,\n p2position,\n this._numPoints,\n i % 2 ? true : false,\n this.positionFunctionX,\n this.positionFunctionY,\n this.positionFunctionZ\n ).map((p) => new ColorPoint({ xyz: p }));\n });\n }\n\n public addAnchorPoint({\n xyz,\n color,\n insertAtIndex,\n }: ColorPointCollection & { insertAtIndex: number }): ColorPoint {\n const newAnchor = new ColorPoint({ xyz, color });\n if (insertAtIndex) {\n this.anchorPoints.splice(insertAtIndex, 0, newAnchor);\n } else {\n this.anchorPoints.push(newAnchor);\n }\n this.updateAnchorPairs();\n return newAnchor;\n }\n\n public removeAnchorPoint({\n point,\n index,\n }: {\n point?: ColorPoint;\n index?: number;\n }): void {\n if (!point && index === undefined) {\n throw new Error(\"Must provide a point or index\");\n }\n\n let apid;\n\n if (index !== undefined) {\n apid = index;\n } else if (point) {\n apid = this.anchorPoints.indexOf(point);\n }\n\n if (apid > -1 && apid < this.anchorPoints.length) {\n this.anchorPoints.splice(apid, 1);\n this.updateAnchorPairs();\n } else {\n throw new Error(\"Point not found\");\n }\n }\n\n public updateAnchorPoint({\n point,\n pointIndex,\n xyz,\n color,\n }: {\n point?: ColorPoint;\n pointIndex?: number;\n } & ColorPointCollection): ColorPoint {\n if (pointIndex) {\n point = this.anchorPoints[pointIndex];\n }\n\n if (!point) {\n throw new Error(\"Must provide a point or pointIndex\");\n }\n\n if (!xyz && !color) {\n throw new Error(\"Must provide a new xyz position or color\");\n }\n\n if (xyz) point.position = xyz;\n if (color) point.hsl = color;\n\n this.updateAnchorPairs();\n\n return point;\n }\n\n public getClosestAnchorPoint({\n xyz,\n hsl,\n maxDistance = 1,\n }: {\n xyz?: PartialVector3;\n hsl?: PartialVector3;\n maxDistance?: number;\n }): ColorPoint | null {\n if (!xyz && !hsl) {\n throw new Error(\"Must provide a xyz or hsl\");\n }\n\n let distances;\n\n if (xyz) {\n distances = this.anchorPoints.map((anchor) =>\n distance(anchor.position, xyz)\n );\n } else if (hsl) {\n distances = this.anchorPoints.map((anchor) =>\n distance(anchor.hsl, hsl, true)\n );\n }\n\n const minDistance = Math.min(...distances);\n\n if (minDistance > maxDistance) {\n return null;\n }\n\n const closestAnchorIndex = distances.indexOf(minDistance);\n\n return this.anchorPoints[closestAnchorIndex] || null;\n }\n\n public set closedLoop(newStatus: boolean) {\n this.connectLastAndFirstAnchor = newStatus;\n this.updateAnchorPairs();\n }\n\n public get closedLoop(): boolean {\n return this.connectLastAndFirstAnchor;\n }\n\n public get flattenedPoints() {\n return this.points\n .flat()\n .filter((p, i) => (i != 0 ? i % this._numPoints : true));\n }\n\n public get colors() {\n const colors = this.flattenedPoints.map((p) => p.color);\n if (this.connectLastAndFirstAnchor) {\n colors.pop();\n }\n return colors;\n }\n\n public get colorsCSS() {\n const cssColors = this.flattenedPoints.map((p) => p.hslCSS);\n if (this.connectLastAndFirstAnchor) {\n cssColors.pop();\n }\n return cssColors;\n }\n\n public shiftHue(hShift = 20): void {\n this.anchorPoints.forEach((p) => p.shiftHue(hShift));\n this.updateAnchorPairs();\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst { p5 } = globalThis as any;\n\nif (p5) {\n console.info(\"p5 detected, adding poline to p5 prototype\");\n \n //console.log(p5.color('red'))\n \n const poline = new Poline();\n p5.prototype.poline = poline;\n\n const polineColors = () => poline.colors.map((c) => /*p5.Color(c)*/ `hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`);\n p5.prototype.polineColors = polineColors;\n p5.prototype.registerMethod('polineColors', p5.prototype.polineColors);\n\n globalThis.poline = poline;\n globalThis.polineColors = polineColors;\n}\n"],
"mappings": ";;;AAmBO,IAAM,aAAa,CAAC,QAA0B;AACnD,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI;AAGlB,QAAM,KAAK;AACX,QAAM,KAAK;AAGX,QAAM,UAAU,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;AAGzC,MAAI,MAAM,WAAW,MAAM,KAAK;AAChC,SAAO,MAAM,OAAO;AAGpB,QAAM,IAAI;AAGV,QAAM,OAAO,KAAK,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC;AAChE,QAAM,IAAI,OAAO;AAGjB,SAAO,CAAC,KAAK,GAAG,CAAC;AACnB;AAeO,IAAM,aAAa,CAAC,QAA0B;AAEnD,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI;AAElB,QAAM,KAAK;AACX,QAAM,KAAK;AAEX,QAAM,UAAU,KAAK,MAAM,KAAK;AAEhC,QAAM,OAAO,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E,SAAS,MAAM,CAAC;AACnD,SAAK,kBAAkB;AAAA,EACzB;AACF;AAGA,IAAM,EAAE,GAAG,IAAI;AAEf,IAAI,IAAI;AACN,UAAQ,KAAK,4CAA4C;AAIzD,QAAM,SAAS,IAAI,OAAO;AAC1B,KAAG,UAAU,SAAS;AAEtB,QAAM,eAAe,MAAM,OAAO,OAAO,IAAI,CAAC;AAAA,EAAsB,OAAO,KAAK,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC,IAAI,OAAO;AAC5H,KAAG,UAAU,eAAe;AAC5B,KAAG,UAAU,eAAe,gBAAgB,GAAG,UAAU,YAAY;AAErE,aAAW,SAAS;AACpB,aAAW,eAAe;AAC5B;",
"sourcesContent": ["/* eslint-disable @typescript-eslint/ban-ts-comment */\nexport type FuncNumberReturn = (arg0: number) => Vector2;\nexport type Vector2 = [number, number];\nexport type Vector3 = [number, ...Vector2];\nexport type PartialVector3 = [number | null, number | null, number | null];\n\n/**\n * Converts the given (x, y, z) coordinate to an HSL color\n * The (x, y) values are used to calculate the hue, while the z value is used as the saturation\n * The lightness value is calculated based on the distance of (x, y) from the center (0.5, 0.5)\n * Returns an array [hue, saturation, lightness]\n * @param xyz:Vector3 [x, y, z] coordinate array in (x, y, z) format (0-1, 0-1, 0-1)\n * @returns [hue, saturation, lightness]: Vector3 color array in HSL format (0-360, 0-1, 0-1)\n * @example\n * pointToHSL(0.5, 0.5, 1) // [0, 1, 0.5]\n * pointToHSL(0.5, 0.5, 0) // [0, 1, 0]\n * pointToHSL(0.5, 0.5, 1) // [0, 1, 1]\n **/\n\nexport const pointToHSL = (\n xyz: Vector3,\n invertedLightness: boolean\n): Vector3 => {\n const [x, y, z] = xyz;\n\n // cy and cx are the center (y and x) values\n const cx = 0.5;\n const cy = 0.5;\n\n // Calculate the angle between the point (x, y) and the center (cx, cy)\n const radians = Math.atan2(y - cy, x - cx);\n\n // Convert the angle to degrees and shift it so that it goes from 0 to 360\n let deg = radians * (180 / Math.PI);\n deg = (360 + deg) % 360;\n\n // The saturation value is taken from the z coordinate\n const s = z;\n\n // Calculate the lightness value based on the distance from the center\n const dist = Math.sqrt(Math.pow(y - cy, 2) + Math.pow(x - cx, 2));\n const l = dist / cx;\n\n // Return the HSL color as an array [hue, saturation, lightness]\n return [deg, s, invertedLightness ? 1 - l : l];\n};\n\n/**\n * Converts the given HSL color to an (x, y, z) coordinate\n * The hue value is used to calculate the (x, y) position, while the saturation value is used as the z coordinate\n * The lightness value is used to calculate the distance from the center (0.5, 0.5)\n * Returns an array [x, y, z]\n * @param hsl:Vector3 [hue, saturation, lightness] color array in HSL format (0-360, 0-1, 0-1)\n * @returns [x, y, z]:Vector3 coordinate array in (x, y, z) format (0-1, 0-1, 0-1)\n * @example\n * hslToPoint([0, 1, 0.5]) // [0.5, 0.5, 1]\n * hslToPoint([0, 1, 0]) // [0.5, 0.5, 1]\n * hslToPoint([0, 1, 1]) // [0.5, 0.5, 1]\n * hslToPoint([0, 0, 0.5]) // [0.5, 0.5, 0]\n **/\nexport const hslToPoint = (\n hsl: Vector3,\n invertedLightness: boolean\n): Vector3 => {\n // Destructure the input array into separate hue, saturation, and lightness values\n const [h, s, l] = hsl;\n // cx and cy are the center (x and y) values\n const cx = 0.5;\n const cy = 0.5;\n // Calculate the angle in radians based on the hue value\n const radians = h / (180 / Math.PI);\n\n // Calculate the distance from the center based on the lightness value\n const dist = (invertedLightness ? 1 - l : l) * cx;\n\n // Calculate the x and y coordinates based on the distance and angle\n const x = cx + dist * Math.cos(radians);\n const y = cy + dist * Math.sin(radians);\n // The z coordinate is equal to the saturation value\n const z = s;\n // Return the (x, y, z) coordinate as an array [x, y, z]\n return [x, y, z];\n};\n\nexport const randomHSLPair = (\n startHue: number = Math.random() * 360,\n saturations: Vector2 = [Math.random(), Math.random()],\n lightnesses: Vector2 = [0.75 + Math.random() * 0.2, 0.3 + Math.random() * 0.2]\n): [Vector3, Vector3] => [\n [startHue, saturations[0], lightnesses[0]],\n [(startHue + 60 + Math.random() * 180) % 360, saturations[1], lightnesses[1]],\n];\n\nexport const randomHSLTriple = (\n startHue: number = Math.random() * 360,\n saturations: Vector3 = [Math.random(), Math.random(), Math.random()],\n lightnesses: Vector3 = [\n 0.75 + Math.random() * 0.2,\n Math.random() * 0.2,\n 0.75 + Math.random() * 0.2,\n ]\n): [Vector3, Vector3, Vector3] => [\n [startHue, saturations[0], lightnesses[0]],\n [(startHue + 60 + Math.random() * 180) % 360, saturations[1], lightnesses[1]],\n [(startHue + 60 + Math.random() * 180) % 360, saturations[2], lightnesses[2]],\n];\n\nconst vectorOnLine = (\n t: number,\n p1: Vector3,\n p2: Vector3,\n invert = false,\n fx = (t: number, invert: boolean): number => (invert ? 1 - t : t),\n fy = (t: number, invert: boolean): number => (invert ? 1 - t : t),\n fz = (t: number, invert: boolean): number => (invert ? 1 - t : t)\n): Vector3 => {\n const tModifiedX = fx(t, invert);\n const tModifiedY = fy(t, invert);\n const tModifiedZ = fz(t, invert);\n const x = (1 - tModifiedX) * p1[0] + tModifiedX * p2[0];\n const y = (1 - tModifiedY) * p1[1] + tModifiedY * p2[1];\n const z = (1 - tModifiedZ) * p1[2] + tModifiedZ * p2[2];\n\n return [x, y, z];\n};\n\nconst vectorsOnLine = (\n p1: Vector3,\n p2: Vector3,\n numPoints = 4,\n invert = false,\n fx = (t: number, invert: boolean): number => (invert ? 1 - t : t),\n fy = (t: number, invert: boolean): number => (invert ? 1 - t : t),\n fz = (t: number, invert: boolean): number => (invert ? 1 - t : t)\n): Vector3[] => {\n const points: Vector3[] = [];\n\n for (let i = 0; i < numPoints; i++) {\n const [x, y, z] = vectorOnLine(\n i / (numPoints - 1),\n p1,\n p2,\n invert,\n fx,\n fy,\n fz\n );\n points.push([x, y, z]);\n }\n\n return points;\n};\n\nexport type PositionFunction = (t: number, reverse?: boolean) => number;\n\nconst linearPosition: PositionFunction = (t: number) => {\n return t;\n};\n\nconst exponentialPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - (1 - t) ** 2;\n }\n return t ** 2;\n};\n\nconst quadraticPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - (1 - t) ** 3;\n }\n return t ** 3;\n};\n\nconst cubicPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - (1 - t) ** 4;\n }\n return t ** 4;\n};\n\nconst quarticPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - (1 - t) ** 5;\n }\n return t ** 5;\n};\n\nconst sinusoidalPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - Math.sin(((1 - t) * Math.PI) / 2);\n }\n return Math.sin((t * Math.PI) / 2);\n};\n\nconst asinusoidalPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return 1 - Math.asin(1 - t) / (Math.PI / 2);\n }\n return Math.asin(t) / (Math.PI / 2);\n};\n\nconst arcPosition: PositionFunction = (t: number, reverse = false) => {\n if (reverse) {\n return Math.sqrt(1 - (1 - t) ** 2);\n }\n return 1 - Math.sqrt(1 - t);\n};\n\nconst smoothStepPosition: PositionFunction = (t: number) => {\n return t ** 2 * (3 - 2 * t);\n};\n\nexport const positionFunctions = {\n linearPosition,\n exponentialPosition,\n quadraticPosition,\n cubicPosition,\n quarticPosition,\n sinusoidalPosition,\n asinusoidalPosition,\n arcPosition,\n smoothStepPosition,\n};\n\n/**\n * Calculates the distance between two points\n * @param p1 The first point\n * @param p2 The second point\n * @param hueMode Whether to use the hue distance function\n * @returns The distance between the two points\n * @example\n * const p1 = [0, 0, 0];\n * const p2 = [1, 1, 1];\n * const dist = distance(p1, p2);\n * console.log(dist); // 1.7320508075688772\n **/\nconst distance = (\n p1: PartialVector3,\n p2: PartialVector3,\n hueMode = false\n): number => {\n const a1 = p1[0];\n const a2 = p2[0];\n let diffA = 0;\n\n if (hueMode && a1 !== null && a2 !== null) {\n diffA = Math.min(Math.abs(a1 - a2), 360 - Math.abs(a1 - a2));\n diffA = diffA / 360;\n } else {\n diffA = a1 === null || a2 === null ? 0 : a1 - a2;\n }\n\n const a = diffA;\n const b = p1[1] === null || p2[1] === null ? 0 : p2[1] - p1[1];\n const c = p1[2] === null || p2[2] === null ? 0 : p2[2] - p1[2];\n\n return Math.sqrt(a * a + b * b + c * c);\n};\n\nexport type ColorPointCollection = {\n xyz?: Vector3;\n color?: Vector3;\n invertedLightness?: boolean;\n};\n\nclass ColorPoint {\n public x = 0;\n public y = 0;\n public z = 0;\n public color: Vector3 = [0, 0, 0];\n private _invertedLightness = false;\n\n constructor({ xyz, color, invertedLightness }: ColorPointCollection = {}) {\n this._invertedLightness = invertedLightness || false;\n this.positionOrColor({ xyz, color, invertedLightness });\n }\n\n positionOrColor({ xyz, color, invertedLightness }: ColorPointCollection) {\n if (xyz && color) {\n throw new Error(\"Point must be initialized with either x,y,z or hsl\");\n } else if (xyz) {\n this.x = xyz[0];\n this.y = xyz[1];\n this.z = xyz[2];\n this.color = pointToHSL(\n [this.x, this.y, this.z],\n invertedLightness || false\n );\n } else if (color) {\n this.color = color;\n [this.x, this.y, this.z] = hslToPoint(color, invertedLightness || false);\n }\n }\n\n set position([x, y, z]: Vector3) {\n this.x = x;\n this.y = y;\n this.z = z;\n this.color = pointToHSL(\n [this.x, this.y, this.z] as Vector3,\n this._invertedLightness\n );\n }\n\n get position(): Vector3 {\n return [this.x, this.y, this.z];\n }\n\n set hsl([h, s, l]: Vector3) {\n this.color = [h, s, l];\n [this.x, this.y, this.z] = hslToPoint(\n this.color as Vector3,\n this._invertedLightness\n );\n }\n\n get hsl(): Vector3 {\n return this.color;\n }\n\n get hslCSS(): string {\n return `hsl(${this.color[0].toFixed(2)}, ${(this.color[1] * 100).toFixed(\n 2\n )}%, ${(this.color[2] * 100).toFixed(2)}%)`;\n }\n\n shiftHue(angle: number): void {\n this.color[0] = (360 + (this.color[0] + angle)) % 360;\n [this.x, this.y, this.z] = hslToPoint(\n this.color as Vector3,\n this._invertedLightness\n );\n }\n}\n\nexport type PolineOptions = {\n anchorColors: Vector3[];\n numPoints: number;\n positionFunction?: (t: number, invert?: boolean) => number;\n positionFunctionX?: (t: number, invert?: boolean) => number;\n positionFunctionY?: (t: number, invert?: boolean) => number;\n positionFunctionZ?: (t: number, invert?: boolean) => number;\n invertedLightness?: boolean;\n closedLoop?: boolean;\n};\nexport class Poline {\n private _needsUpdate = true;\n private _anchorPoints: ColorPoint[];\n\n private _numPoints: number;\n private points: ColorPoint[][];\n\n private _positionFunctionX = sinusoidalPosition;\n private _positionFunctionY = sinusoidalPosition;\n private _positionFunctionZ = sinusoidalPosition;\n\n private _anchorPairs: ColorPoint[][];\n\n private connectLastAndFirstAnchor = false;\n\n private _animationFrame: null | number = null;\n\n private _invertedLightness = false;\n\n constructor(\n {\n anchorColors = randomHSLPair(),\n numPoints = 4,\n positionFunction = sinusoidalPosition,\n positionFunctionX,\n positionFunctionY,\n positionFunctionZ,\n closedLoop,\n invertedLightness,\n }: PolineOptions = {\n anchorColors: randomHSLPair(),\n numPoints: 4,\n positionFunction: sinusoidalPosition,\n closedLoop: false,\n }\n ) {\n if (!anchorColors || anchorColors.length < 2) {\n throw new Error(\"Must have at least two anchor colors\");\n }\n\n this._anchorPoints = anchorColors.map(\n (point) => new ColorPoint({ color: point, invertedLightness })\n );\n\n this._numPoints = numPoints + 2; // add two for the anchor points\n\n this._positionFunctionX =\n positionFunctionX || positionFunction || sinusoidalPosition;\n this._positionFunctionY =\n positionFunctionY || positionFunction || sinusoidalPosition;\n this._positionFunctionZ =\n positionFunctionZ || positionFunction || sinusoidalPosition;\n\n this.connectLastAndFirstAnchor = closedLoop || false;\n\n this._invertedLightness = invertedLightness || false;\n\n this.updateAnchorPairs();\n }\n\n public get numPoints(): number {\n return this._numPoints - 2;\n }\n\n public set numPoints(numPoints: number) {\n if (numPoints < 1) {\n throw new Error(\"Must have at least one point\");\n }\n this._numPoints = numPoints + 2; // add two for the anchor points\n this.updateAnchorPairs();\n }\n\n public set positionFunction(\n positionFunction: PositionFunction | PositionFunction[]\n ) {\n if (Array.isArray(positionFunction)) {\n if (positionFunction.length !== 3) {\n throw new Error(\"Position function array must have 3 elements\");\n }\n if (\n typeof positionFunction[0] !== \"function\" ||\n typeof positionFunction[1] !== \"function\" ||\n typeof positionFunction[2] !== \"function\"\n ) {\n throw new Error(\"Position function array must have 3 functions\");\n }\n this._positionFunctionX = positionFunction[0];\n this._positionFunctionY = positionFunction[1];\n this._positionFunctionZ = positionFunction[2];\n } else {\n this._positionFunctionX = positionFunction;\n this._positionFunctionY = positionFunction;\n this._positionFunctionZ = positionFunction;\n }\n\n this.updateAnchorPairs();\n }\n\n public get positionFunction(): PositionFunction | PositionFunction[] {\n // not to sure what to do here, because the position function is a combination of the three\n if (\n this._positionFunctionX === this._positionFunctionY &&\n this._positionFunctionX === this._positionFunctionZ\n ) {\n return this._positionFunctionX;\n }\n\n return [\n this._positionFunctionX,\n this._positionFunctionY,\n this._positionFunctionZ,\n ];\n }\n\n public set positionFunctionX(positionFunctionX: PositionFunction) {\n this._positionFunctionX = positionFunctionX;\n this.updateAnchorPairs();\n }\n\n public get positionFunctionX(): PositionFunction {\n return this._positionFunctionX;\n }\n\n public set positionFunctionY(positionFunctionY: PositionFunction) {\n this._positionFunctionY = positionFunctionY;\n this.updateAnchorPairs();\n }\n\n public get positionFunctionY(): PositionFunction {\n return this._positionFunctionY;\n }\n\n public set positionFunctionZ(positionFunctionZ: PositionFunction) {\n this._positionFunctionZ = positionFunctionZ;\n this.updateAnchorPairs();\n }\n\n public get positionFunctionZ(): PositionFunction {\n return this._positionFunctionZ;\n }\n\n public get anchorPoints(): ColorPoint[] {\n return this._anchorPoints;\n }\n\n public set anchorPoints(anchorPoints: ColorPoint[]) {\n this._anchorPoints = anchorPoints;\n this.updateAnchorPairs();\n }\n\n public updateAnchorPairs(): void {\n this._anchorPairs = [] as ColorPoint[][];\n\n const anchorPointsLength = this.connectLastAndFirstAnchor\n ? this.anchorPoints.length\n : this.anchorPoints.length - 1;\n\n for (let i = 0; i < anchorPointsLength; i++) {\n const pair = [\n this.anchorPoints[i],\n this.anchorPoints[(i + 1) % this.anchorPoints.length],\n ] as ColorPoint[];\n\n this._anchorPairs.push(pair);\n }\n\n this.points = this._anchorPairs.map((pair, i) => {\n const p1position = pair[0] ? pair[0].position : ([0, 0, 0] as Vector3);\n const p2position = pair[1] ? pair[1].position : ([0, 0, 0] as Vector3);\n\n return vectorsOnLine(\n p1position,\n p2position,\n this._numPoints,\n i % 2 ? true : false,\n this.positionFunctionX,\n this.positionFunctionY,\n this.positionFunctionZ\n ).map(\n (p) =>\n new ColorPoint({ xyz: p, invertedLightness: this._invertedLightness })\n );\n });\n }\n\n public addAnchorPoint({\n xyz,\n color,\n insertAtIndex,\n }: ColorPointCollection & { insertAtIndex: number }): ColorPoint {\n const newAnchor = new ColorPoint({\n xyz,\n color,\n invertedLightness: this._invertedLightness,\n });\n if (insertAtIndex) {\n this.anchorPoints.splice(insertAtIndex, 0, newAnchor);\n } else {\n this.anchorPoints.push(newAnchor);\n }\n this.updateAnchorPairs();\n return newAnchor;\n }\n\n public removeAnchorPoint({\n point,\n index,\n }: {\n point?: ColorPoint;\n index?: number;\n }): void {\n if (!point && index === undefined) {\n throw new Error(\"Must provide a point or index\");\n }\n\n let apid;\n\n if (index !== undefined) {\n apid = index;\n } else if (point) {\n apid = this.anchorPoints.indexOf(point);\n }\n\n if (apid > -1 && apid < this.anchorPoints.length) {\n this.anchorPoints.splice(apid, 1);\n this.updateAnchorPairs();\n } else {\n throw new Error(\"Point not found\");\n }\n }\n\n public updateAnchorPoint({\n point,\n pointIndex,\n xyz,\n color,\n }: {\n point?: ColorPoint;\n pointIndex?: number;\n } & ColorPointCollection): ColorPoint {\n if (pointIndex) {\n point = this.anchorPoints[pointIndex];\n }\n\n if (!point) {\n throw new Error(\"Must provide a point or pointIndex\");\n }\n\n if (!xyz && !color) {\n throw new Error(\"Must provide a new xyz position or color\");\n }\n\n if (xyz) point.position = xyz;\n if (color) point.hsl = color;\n\n this.updateAnchorPairs();\n\n return point;\n }\n\n public getClosestAnchorPoint({\n xyz,\n hsl,\n maxDistance = 1,\n }: {\n xyz?: PartialVector3;\n hsl?: PartialVector3;\n maxDistance?: number;\n }): ColorPoint | null {\n if (!xyz && !hsl) {\n throw new Error(\"Must provide a xyz or hsl\");\n }\n\n let distances;\n\n if (xyz) {\n distances = this.anchorPoints.map((anchor) =>\n distance(anchor.position, xyz)\n );\n } else if (hsl) {\n distances = this.anchorPoints.map((anchor) =>\n distance(anchor.hsl, hsl, true)\n );\n }\n\n const minDistance = Math.min(...distances);\n\n if (minDistance > maxDistance) {\n return null;\n }\n\n const closestAnchorIndex = distances.indexOf(minDistance);\n\n return this.anchorPoints[closestAnchorIndex] || null;\n }\n\n public set closedLoop(newStatus: boolean) {\n this.connectLastAndFirstAnchor = newStatus;\n this.updateAnchorPairs();\n }\n\n public get closedLoop(): boolean {\n return this.connectLastAndFirstAnchor;\n }\n\n public set invertedLightness(newStatus: boolean) {\n this._invertedLightness = newStatus;\n this.updateAnchorPairs();\n }\n\n public get invertedLightness(): boolean {\n return this._invertedLightness;\n }\n\n public get flattenedPoints() {\n return this.points\n .flat()\n .filter((p, i) => (i != 0 ? i % this._numPoints : true));\n }\n\n public get colors() {\n const colors = this.flattenedPoints.map((p) => p.color);\n if (this.connectLastAndFirstAnchor) {\n colors.pop();\n }\n return colors;\n }\n\n public get colorsCSS() {\n const cssColors = this.flattenedPoints.map((p) => p.hslCSS);\n if (this.connectLastAndFirstAnchor) {\n cssColors.pop();\n }\n return cssColors;\n }\n\n public shiftHue(hShift = 20): void {\n this.anchorPoints.forEach((p) => p.shiftHue(hShift));\n this.updateAnchorPairs();\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst { p5 } = globalThis as any;\n\nif (p5) {\n console.info(\"p5 detected, adding poline to p5 prototype\");\n\n const poline = new Poline();\n p5.prototype.poline = poline;\n\n const polineColors = () =>\n poline.colors.map(\n (c) => `hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`\n );\n p5.prototype.polineColors = polineColors;\n p5.prototype.registerMethod(\"polineColors\", p5.prototype.polineColors);\n\n globalThis.poline = poline;\n globalThis.polineColors = polineColors;\n}\n"],
"mappings": ";;;AAmBO,IAAM,aAAa,CACxB,KACA,sBACY;AACZ,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI;AAGlB,QAAM,KAAK;AACX,QAAM,KAAK;AAGX,QAAM,UAAU,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;AAGzC,MAAI,MAAM,WAAW,MAAM,KAAK;AAChC,SAAO,MAAM,OAAO;AAGpB,QAAM,IAAI;AAGV,QAAM,OAAO,KAAK,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC;AAChE,QAAM,IAAI,OAAO;AAGjB,SAAO,CAAC,KAAK,GAAG,oBAAoB,IAAI,IAAI,CAAC;AAC/C;AAeO,IAAM,aAAa,CACxB,KACA,sBACY;AAEZ,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI;AAElB,QAAM,KAAK;AACX,QAAM,KAAK;AAEX,QAAM,UAAU,KAAK,MAAM,KAAK;AAGhC,QAAM,QAAQ,oBAAoB,IAAI,IAAI,KAAK;AAG/C,QAAM,IAAI,KAAK,OAAO,KAAK,IAAI,OAAO;AACtC,QAAM,IAAI,KAAK,OAAO,KAAK,IAAI,OAAO;AAEtC,QAAM,IAAI;AAEV,SAAO,CAAC,GAAG,GAAG,CAAC;AACjB;AAEO,IAAM,gBAAgB,CAC3B,WAAmB,KAAK,OAAO,IAAI,KACnC,cAAuB,CAAC,KAAK,OAAO,GAAG,KAAK,OAAO,CAAC,GACpD,cAAuB,CAAC,OAAO,KAAK,OAAO,IAAI,KAAK,MAAM,KAAK,OAAO,IAAI,GAAG,MACtD;AAAA,EACvB,CAAC,UAAU,YAAY,CAAC,GAAG,YAAY,CAAC,CAAC;AAAA,E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AAAA,EAEO,SAAS,SAAS,IAAU;AACjC,SAAK,aAAa,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,CAAC;AACnD,SAAK,kBAAkB;AAAA,EACzB;AACF;AAGA,IAAM,EAAE,GAAG,IAAI;AAEf,IAAI,IAAI;AACN,UAAQ,KAAK,4CAA4C;AAEzD,QAAM,SAAS,IAAI,OAAO;AAC1B,KAAG,UAAU,SAAS;AAEtB,QAAM,eAAe,MACnB,OAAO,OAAO;AAAA,IACZ,CAAC,MAAM,OAAO,KAAK,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC,IAAI;AAAA,EAC1D;AACF,KAAG,UAAU,eAAe;AAC5B,KAAG,UAAU,eAAe,gBAAgB,GAAG,UAAU,YAAY;AAErE,aAAW,SAAS;AACpB,aAAW,eAAe;AAC5B;",
"names": ["t", "invert"]
}

@@ -42,3 +42,3 @@ (function(root, factory) {

});
var pointToHSL = (xyz) => {
var pointToHSL = (xyz, invertedLightness) => {
const [x, y, z] = xyz;

@@ -53,5 +53,5 @@ const cx = 0.5;

const l = dist / cx;
return [deg, s, l];
return [deg, s, invertedLightness ? 1 - l : l];
};
var hslToPoint = (hsl) => {
var hslToPoint = (hsl, invertedLightness) => {
const [h, s, l] = hsl;

@@ -61,3 +61,3 @@ const cx = 0.5;

const radians = h / (180 / Math.PI);
const dist = l * cx;
const dist = (invertedLightness ? 1 - l : l) * cx;
const x = cx + dist * Math.cos(radians);

@@ -181,3 +181,3 @@ const y = cy + dist * Math.sin(radians);

var ColorPoint = class {
constructor({ xyz, color } = {}) {
constructor({ xyz, color, invertedLightness } = {}) {
this.x = 0;

@@ -187,5 +187,7 @@ this.y = 0;

this.color = [0, 0, 0];
this.positionOrColor({ xyz, color });
this._invertedLightness = false;
this._invertedLightness = invertedLightness || false;
this.positionOrColor({ xyz, color, invertedLightness });
}
positionOrColor({ xyz, color }) {
positionOrColor({ xyz, color, invertedLightness }) {
if (xyz && color) {

@@ -197,6 +199,9 @@ throw new Error("Point must be initialized with either x,y,z or hsl");

this.z = xyz[2];
this.color = pointToHSL([this.x, this.y, this.z]);
this.color = pointToHSL(
[this.x, this.y, this.z],
invertedLightness || false
);
} else if (color) {
this.color = color;
[this.x, this.y, this.z] = hslToPoint(color);
[this.x, this.y, this.z] = hslToPoint(color, invertedLightness || false);
}

@@ -208,3 +213,6 @@ }

this.z = z;
this.color = pointToHSL([this.x, this.y, this.z]);
this.color = pointToHSL(
[this.x, this.y, this.z],
this._invertedLightness
);
}

@@ -216,3 +224,6 @@ get position() {

this.color = [h, s, l];
[this.x, this.y, this.z] = hslToPoint(this.color);
[this.x, this.y, this.z] = hslToPoint(
this.color,
this._invertedLightness
);
}

@@ -229,3 +240,6 @@ get hsl() {

this.color[0] = (360 + (this.color[0] + angle)) % 360;
[this.x, this.y, this.z] = hslToPoint(this.color);
[this.x, this.y, this.z] = hslToPoint(
this.color,
this._invertedLightness
);
}

@@ -241,3 +255,4 @@ };

positionFunctionZ,
closedLoop
closedLoop,
invertedLightness
} = {

@@ -255,2 +270,3 @@ anchorColors: randomHSLPair(),

this._animationFrame = null;
this._invertedLightness = false;
if (!anchorColors || anchorColors.length < 2) {

@@ -260,3 +276,3 @@ throw new Error("Must have at least two anchor colors");

this._anchorPoints = anchorColors.map(
(point) => new ColorPoint({ color: point })
(point) => new ColorPoint({ color: point, invertedLightness })
);

@@ -267,3 +283,4 @@ this._numPoints = numPoints + 2;

this._positionFunctionZ = positionFunctionZ || positionFunction || sinusoidalPosition;
this.connectLastAndFirstAnchor = closedLoop;
this.connectLastAndFirstAnchor = closedLoop || false;
this._invertedLightness = invertedLightness || false;
this.updateAnchorPairs();

@@ -358,3 +375,5 @@ }

this.positionFunctionZ
).map((p) => new ColorPoint({ xyz: p }));
).map(
(p) => new ColorPoint({ xyz: p, invertedLightness: this._invertedLightness })
);
});

@@ -367,3 +386,7 @@ }

}) {
const newAnchor = new ColorPoint({ xyz, color });
const newAnchor = new ColorPoint({
xyz,
color,
invertedLightness: this._invertedLightness
});
if (insertAtIndex) {

@@ -451,2 +474,9 @@ this.anchorPoints.splice(insertAtIndex, 0, newAnchor);

}
set invertedLightness(newStatus) {
this._invertedLightness = newStatus;
this.updateAnchorPairs();
}
get invertedLightness() {
return this._invertedLightness;
}
get flattenedPoints() {

@@ -480,4 +510,3 @@ return this.points.flat().filter((p, i) => i != 0 ? i % this._numPoints : true);

const polineColors = () => poline.colors.map(
(c) => /*p5.Color(c)*/
`hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`
(c) => `hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`
);

@@ -484,0 +513,0 @@ p5.prototype.polineColors = polineColors;

@@ -6,3 +6,3 @@ <!DOCTYPE html>

<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.5.0/p5.js"></script>
<script type="module" src="index.mjs"></script>
<script src="index.js"></script>
</head>

@@ -9,0 +9,0 @@ <body>

{
"name": "poline",
"version": "0.5.2",
"version": "0.6.0",
"description": "color palette generator mico-lib",

@@ -5,0 +5,0 @@ "type": "module",

@@ -20,3 +20,6 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */

export const pointToHSL = (xyz: Vector3): Vector3 => {
export const pointToHSL = (
xyz: Vector3,
invertedLightness: boolean
): Vector3 => {
const [x, y, z] = xyz;

@@ -43,3 +46,3 @@

// Return the HSL color as an array [hue, saturation, lightness]
return [deg, s, l];
return [deg, s, invertedLightness ? 1 - l : l];
};

@@ -60,3 +63,6 @@

**/
export const hslToPoint = (hsl: Vector3): Vector3 => {
export const hslToPoint = (
hsl: Vector3,
invertedLightness: boolean
): Vector3 => {
// Destructure the input array into separate hue, saturation, and lightness values

@@ -69,4 +75,6 @@ const [h, s, l] = hsl;

const radians = h / (180 / Math.PI);
// Calculate the distance from the center based on the lightness value
const dist = l * cx;
const dist = (invertedLightness ? 1 - l : l) * cx;
// Calculate the x and y coordinates based on the distance and angle

@@ -259,2 +267,3 @@ const x = cx + dist * Math.cos(radians);

color?: Vector3;
invertedLightness?: boolean;
};

@@ -267,8 +276,10 @@

public color: Vector3 = [0, 0, 0];
private _invertedLightness = false;
constructor({ xyz, color }: ColorPointCollection = {}) {
this.positionOrColor({ xyz, color });
constructor({ xyz, color, invertedLightness }: ColorPointCollection = {}) {
this._invertedLightness = invertedLightness || false;
this.positionOrColor({ xyz, color, invertedLightness });
}
positionOrColor({ xyz, color }: ColorPointCollection) {
positionOrColor({ xyz, color, invertedLightness }: ColorPointCollection) {
if (xyz && color) {

@@ -280,6 +291,9 @@ throw new Error("Point must be initialized with either x,y,z or hsl");

this.z = xyz[2];
this.color = pointToHSL([this.x, this.y, this.z]);
this.color = pointToHSL(
[this.x, this.y, this.z],
invertedLightness || false
);
} else if (color) {
this.color = color;
[this.x, this.y, this.z] = hslToPoint(color);
[this.x, this.y, this.z] = hslToPoint(color, invertedLightness || false);
}

@@ -292,3 +306,6 @@ }

this.z = z;
this.color = pointToHSL([this.x, this.y, this.z]);
this.color = pointToHSL(
[this.x, this.y, this.z] as Vector3,
this._invertedLightness
);
}

@@ -302,3 +319,6 @@

this.color = [h, s, l];
[this.x, this.y, this.z] = hslToPoint(this.color);
[this.x, this.y, this.z] = hslToPoint(
this.color as Vector3,
this._invertedLightness
);
}

@@ -318,3 +338,6 @@

this.color[0] = (360 + (this.color[0] + angle)) % 360;
[this.x, this.y, this.z] = hslToPoint(this.color);
[this.x, this.y, this.z] = hslToPoint(
this.color as Vector3,
this._invertedLightness
);
}

@@ -330,3 +353,4 @@ }

positionFunctionZ?: (t: number, invert?: boolean) => number;
closedLoop: boolean;
invertedLightness?: boolean;
closedLoop?: boolean;
};

@@ -350,2 +374,4 @@ export class Poline {

private _invertedLightness = false;
constructor(

@@ -360,2 +386,3 @@ {

closedLoop,
invertedLightness,
}: PolineOptions = {

@@ -373,3 +400,3 @@ anchorColors: randomHSLPair(),

this._anchorPoints = anchorColors.map(
(point) => new ColorPoint({ color: point })
(point) => new ColorPoint({ color: point, invertedLightness })
);

@@ -386,4 +413,6 @@

this.connectLastAndFirstAnchor = closedLoop;
this.connectLastAndFirstAnchor = closedLoop || false;
this._invertedLightness = invertedLightness || false;
this.updateAnchorPairs();

@@ -510,3 +539,6 @@ }

this.positionFunctionZ
).map((p) => new ColorPoint({ xyz: p }));
).map(
(p) =>
new ColorPoint({ xyz: p, invertedLightness: this._invertedLightness })
);
});

@@ -520,3 +552,7 @@ }

}: ColorPointCollection & { insertAtIndex: number }): ColorPoint {
const newAnchor = new ColorPoint({ xyz, color });
const newAnchor = new ColorPoint({
xyz,
color,
invertedLightness: this._invertedLightness,
});
if (insertAtIndex) {

@@ -632,2 +668,11 @@ this.anchorPoints.splice(insertAtIndex, 0, newAnchor);

public set invertedLightness(newStatus: boolean) {
this._invertedLightness = newStatus;
this.updateAnchorPairs();
}
public get invertedLightness(): boolean {
return this._invertedLightness;
}
public get flattenedPoints() {

@@ -667,4 +712,2 @@ return this.points

//console.log(p5.color('red'))
const poline = new Poline();

@@ -675,4 +718,3 @@ p5.prototype.poline = poline;

poline.colors.map(
(c) =>
/*p5.Color(c)*/ `hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`
(c) => `hsl(${Math.round(c[0])},${c[1] * 100}%,${c[2] * 100}%)`
);

@@ -679,0 +721,0 @@ p5.prototype.polineColors = polineColors;

/**
* Poline Visual Editor
*
* This file is part of Poline.
* it is meant to be used with the Poline Library
* to visualize and edits its properties and settings.
*/
let svgscale = 100;
let uuid = 0;
const namespaceURI = "http://www.w3.org/2000/svg";
const $wheel = document.createElement("div");
const $huelabels = document.createElement("div");
$wheel.classList.add(`poline-picker-${uuid}`);
$huelabels.classList.add(`poline-picker-${uuid}__huelabels`);
const styles = `
.poline-picker-${uuid} {
--poline-diameter: 100%;
position: relative;
width: var(--poline-diameter);
aspect-ratio: 1;
}
`;
const $style = document.createElement("style");
$style.innerHTML = styles;
// creates the hue labels
const createLabel = (step: number, totalSteps: number): HTMLSpanElement => {
const $label = document.createElement("span");
$label.classList.add(`poline-picker-${uuid}__huelabel`);
if (step > 9 && step < 31) {
$label.classList.add(`poline-picker-${uuid}__huelabel--flipped`);
}
$label.setAttribute("data-huelabel", step.toString());
$label.style.setProperty("--i", (step / totalSteps).toString());
const $b = document.createElement("b");
$b.setAttribute("aria-label", `${step * 10}°`);
$b.innerText = `${step * 10}`;
$label.appendChild($b);
return $label;
};
// create a map of hue labels where the key is the hue value (step)
const huelabelsMap = new Map(
new Array(36).fill("").map((_, i) => [i, createLabel(i, 36)])
);
const createCSSRainbowGradient = (steps = 360 / 10) =>
new Array(steps)
.fill("")
.map(
(_, i) =>
`hsl(${
(i / (steps - 1)) * 360
}, calc(var(--s) * 100%), calc(var(--l,0) * 100%))`
)
.join(",");
const createSVG = (svgscale = 100) => {
const $svg = document.createElementNS(namespaceURI, "svg");
$svg.setAttribute("viewBox", `0 0 ${svgscale} ${svgscale}`);
return $svg;
};
const $svg = createSVG(svgscale);
function updateSVG() {
$huelabels.forEach(($huelabel, i) => {
$huelabel.classList.remove("wheel__huelabel--active");
// if the HUE label is within the range of the current anchor point
poline.anchorPoints.forEach((anchor) => {
const currentHue = anchor.color[0];
currentHue - hueSteps / 2 < i * 10 &&
currentHue + hueSteps / 2 > i * 10 &&
$huelabel.classList.add("wheel__huelabel--active");
});
});
$svg.innerHTML = "";
poline.anchorPoints.forEach((anchor) => {
const $circle = document.createElementNS(namespaceURI, "circle");
$circle.setAttribute("cx", anchor.x * svgscale);
$circle.setAttribute("cy", anchor.y * svgscale);
$circle.setAttribute("r", 2);
//anchor.hslCSS
$circle.classList.add("wheel__anchor");
$circle.style.setProperty("--s", anchor.color[1]);
$svg.appendChild($circle);
});
const $polylines = document.createElementNS(namespaceURI, "polyline");
$polylines.classList.add("wheel__line");
$polylines.setAttribute(
"points",
poline.flattenedPoints
.map((point) => `${point.x * svgscale},${point.y * svgscale}`)
.join(" ")
);
$svg.appendChild($polylines);
// calculate the length of the polyline
// set the stroke-dasharray and stroke-dashoffset to the length of the polyline
const length = $polylines.getTotalLength();
$polylines.style.setProperty("--length", length);
poline.flattenedPoints.forEach((point, i) => {
const $circle = document.createElementNS(namespaceURI, "circle");
$circle.setAttribute("cx", point.x * svgscale);
$circle.setAttribute("cy", point.y * svgscale);
const radius = 0.5 + point.color[1];
$circle.setAttribute("r", radius);
$circle.classList.add("wheel__point");
$circle.style.setProperty("--i", i);
$circle.style.setProperty("--circ", 2 * Math.PI * radius);
$circle.style.setProperty("--s", point.color[1]);
const c = formatHex({
mode: currentHueModel,
...currentModelFn(point.color),
});
$circle.style.setProperty("--c", c);
$svg.appendChild($circle);
});
let cssColors = [...poline.colorsCSS];
let colors = [...poline.colors].map((c) =>
formatHex({ mode: currentHueModel, ...currentModelFn(c) })
);
//colors = [...poline.colors].map(c => formatCss({ mode: 'p3', ...currentModelFn(c) }));
document.documentElement.style.setProperty(
"--prev",
colorArrToSteppedGradient(colors)
);
document.documentElement.style.setProperty("--prev-smooth", colors.join(","));
document.documentElement.style.setProperty("--c0", colors[colors.length - 1]);
document.documentElement.style.setProperty("--c1", colors[0]);
}
// create a webcompontent
class PolineEditor extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
[$style, $wheel, $huelabels, $svg].forEach(($el) => {
this.shadowRoot && this.shadowRoot.appendChild($el.cloneNode(true));
});
}
attributeChangedCallback(name, oldValue, newValue) {
console.log(`Value changed from ${oldValue} to ${newValue}`);
this.render();
}
connectedCallback() {
this.render();
}
get text() {
return this.getAttribute("title");
}
render() {
updateSVG();
}
}
customElements.define("poline-editor", PolineEditor, { extends: "div" });

Sorry, the diff of this file is too big to display