@mathigon/core
Advanced tools
Comparing version 1.1.9 to 1.1.10
@@ -6,2 +6,7 @@ "use strict"; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __knownSymbol = (name, symbol) => { | ||
if (symbol = Symbol[name]) | ||
return symbol; | ||
throw Error("Symbol." + name + " is not defined"); | ||
}; | ||
var __export = (target, all) => { | ||
@@ -20,2 +25,39 @@ for (var name in all) | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var __await = function(promise, isYieldStar) { | ||
this[0] = promise; | ||
this[1] = isYieldStar; | ||
}; | ||
var __yieldStar = (value) => { | ||
var obj = value[__knownSymbol("asyncIterator")]; | ||
var isAwait = false; | ||
var method; | ||
var it = {}; | ||
if (obj == null) { | ||
obj = value[__knownSymbol("iterator")](); | ||
method = (k) => it[k] = (x) => obj[k](x); | ||
} else { | ||
obj = obj.call(value); | ||
method = (k) => it[k] = (v) => { | ||
if (isAwait) { | ||
isAwait = false; | ||
if (k === "throw") | ||
throw v; | ||
return v; | ||
} | ||
isAwait = true; | ||
return { | ||
done: false, | ||
value: new __await(new Promise((resolve) => { | ||
var x = obj[k](v); | ||
if (!(x instanceof Object)) | ||
throw TypeError("Object expected"); | ||
resolve(x); | ||
}), 1) | ||
}; | ||
}; | ||
} | ||
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => { | ||
throw x; | ||
}, "return" in obj && method("return"), it; | ||
}; | ||
@@ -483,3 +525,3 @@ // src/index.ts | ||
} | ||
var Color = class { | ||
var Color = class _Color { | ||
constructor(r, g, b, a = 1) { | ||
@@ -532,3 +574,3 @@ this.r = r; | ||
copy() { | ||
return new Color(this.r, this.g, this.b, this.a); | ||
return new _Color(this.r, this.g, this.b, this.a); | ||
} | ||
@@ -539,3 +581,3 @@ // --------------------------------------------------------------------------- | ||
return color; | ||
return color.startsWith("#") ? Color.fromHex(color) : Color.fromRgb(color); | ||
return color.startsWith("#") ? _Color.fromHex(color) : _Color.fromRgb(color); | ||
} | ||
@@ -545,5 +587,5 @@ static fromRgb(color) { | ||
if (!match) | ||
return new Color(0, 0, 0); | ||
return new _Color(0, 0, 0); | ||
const a = match[4] ? +match[5] || 0 : 1; | ||
return new Color(+match[1], +match[2], +match[3], a); | ||
return new _Color(+match[1], +match[2], +match[3], a); | ||
} | ||
@@ -555,4 +597,4 @@ /** Creates a Color instance from a hex string. */ | ||
if (!rgbParts) | ||
return new Color(0, 0, 0); | ||
return new Color( | ||
return new _Color(0, 0, 0); | ||
return new _Color( | ||
parseInt(rgbParts[1], 16), | ||
@@ -570,3 +612,3 @@ parseInt(rgbParts[2], 16), | ||
const l1 = Math.round(l * 255); | ||
return new Color(l1, l1, l1); | ||
return new _Color(l1, l1, l1); | ||
} | ||
@@ -578,3 +620,3 @@ const q = l < 0.5 ? l * (1 + s) : l + s - l * s; | ||
const b = hue2rgb(p, q, h - 1 / 3); | ||
return new Color(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)); | ||
return new _Color(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)); | ||
} | ||
@@ -590,11 +632,11 @@ /** Generates a rainbow gradient with a given number of steps. */ | ||
static shades(color, steps, range = 0.5) { | ||
const light = Color.mix("#fff", color, range); | ||
const dark = Color.mix("#000", color, range); | ||
return Color.gradient([light, color, dark], steps); | ||
const light = _Color.mix("#fff", color, range); | ||
const dark = _Color.mix("#000", color, range); | ||
return _Color.gradient([light, color, dark], steps); | ||
} | ||
/** Linearly interpolates two colors or hex strings. */ | ||
static mix(c1, c2, p = 0.5) { | ||
c1 = Color.from(c1); | ||
c2 = Color.from(c2); | ||
return new Color( | ||
c1 = _Color.from(c1); | ||
c2 = _Color.from(c2); | ||
return new _Color( | ||
p * c1.r + (1 - p) * c2.r, | ||
@@ -622,3 +664,3 @@ p * c1.g + (1 - p) * c2.g, | ||
const l = total(hsl.map((c, i) => weights[i] * c[2])) / weight; | ||
return Color.fromHsl(h, s, l); | ||
return _Color.fromHsl(h, s, l); | ||
} | ||
@@ -677,3 +719,3 @@ }; | ||
for (const set of sets) | ||
yield* set; | ||
yield* __yieldStar(set); | ||
} | ||
@@ -680,0 +722,0 @@ function every(set, callback) { |
@@ -0,1 +1,44 @@ | ||
var __knownSymbol = (name, symbol) => { | ||
if (symbol = Symbol[name]) | ||
return symbol; | ||
throw Error("Symbol." + name + " is not defined"); | ||
}; | ||
var __await = function(promise, isYieldStar) { | ||
this[0] = promise; | ||
this[1] = isYieldStar; | ||
}; | ||
var __yieldStar = (value) => { | ||
var obj = value[__knownSymbol("asyncIterator")]; | ||
var isAwait = false; | ||
var method; | ||
var it = {}; | ||
if (obj == null) { | ||
obj = value[__knownSymbol("iterator")](); | ||
method = (k) => it[k] = (x) => obj[k](x); | ||
} else { | ||
obj = obj.call(value); | ||
method = (k) => it[k] = (v) => { | ||
if (isAwait) { | ||
isAwait = false; | ||
if (k === "throw") | ||
throw v; | ||
return v; | ||
} | ||
isAwait = true; | ||
return { | ||
done: false, | ||
value: new __await(new Promise((resolve) => { | ||
var x = obj[k](v); | ||
if (!(x instanceof Object)) | ||
throw TypeError("Object expected"); | ||
resolve(x); | ||
}), 1) | ||
}; | ||
}; | ||
} | ||
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => { | ||
throw x; | ||
}, "return" in obj && method("return"), it; | ||
}; | ||
// src/utilities.ts | ||
@@ -405,3 +448,3 @@ function uid(n = 10) { | ||
} | ||
var Color = class { | ||
var Color = class _Color { | ||
constructor(r, g, b, a = 1) { | ||
@@ -454,3 +497,3 @@ this.r = r; | ||
copy() { | ||
return new Color(this.r, this.g, this.b, this.a); | ||
return new _Color(this.r, this.g, this.b, this.a); | ||
} | ||
@@ -461,3 +504,3 @@ // --------------------------------------------------------------------------- | ||
return color; | ||
return color.startsWith("#") ? Color.fromHex(color) : Color.fromRgb(color); | ||
return color.startsWith("#") ? _Color.fromHex(color) : _Color.fromRgb(color); | ||
} | ||
@@ -467,5 +510,5 @@ static fromRgb(color) { | ||
if (!match) | ||
return new Color(0, 0, 0); | ||
return new _Color(0, 0, 0); | ||
const a = match[4] ? +match[5] || 0 : 1; | ||
return new Color(+match[1], +match[2], +match[3], a); | ||
return new _Color(+match[1], +match[2], +match[3], a); | ||
} | ||
@@ -477,4 +520,4 @@ /** Creates a Color instance from a hex string. */ | ||
if (!rgbParts) | ||
return new Color(0, 0, 0); | ||
return new Color( | ||
return new _Color(0, 0, 0); | ||
return new _Color( | ||
parseInt(rgbParts[1], 16), | ||
@@ -492,3 +535,3 @@ parseInt(rgbParts[2], 16), | ||
const l1 = Math.round(l * 255); | ||
return new Color(l1, l1, l1); | ||
return new _Color(l1, l1, l1); | ||
} | ||
@@ -500,3 +543,3 @@ const q = l < 0.5 ? l * (1 + s) : l + s - l * s; | ||
const b = hue2rgb(p, q, h - 1 / 3); | ||
return new Color(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)); | ||
return new _Color(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)); | ||
} | ||
@@ -512,11 +555,11 @@ /** Generates a rainbow gradient with a given number of steps. */ | ||
static shades(color, steps, range = 0.5) { | ||
const light = Color.mix("#fff", color, range); | ||
const dark = Color.mix("#000", color, range); | ||
return Color.gradient([light, color, dark], steps); | ||
const light = _Color.mix("#fff", color, range); | ||
const dark = _Color.mix("#000", color, range); | ||
return _Color.gradient([light, color, dark], steps); | ||
} | ||
/** Linearly interpolates two colors or hex strings. */ | ||
static mix(c1, c2, p = 0.5) { | ||
c1 = Color.from(c1); | ||
c2 = Color.from(c2); | ||
return new Color( | ||
c1 = _Color.from(c1); | ||
c2 = _Color.from(c2); | ||
return new _Color( | ||
p * c1.r + (1 - p) * c2.r, | ||
@@ -544,3 +587,3 @@ p * c1.g + (1 - p) * c2.g, | ||
const l = total(hsl.map((c, i) => weights[i] * c[2])) / weight; | ||
return Color.fromHsl(h, s, l); | ||
return _Color.fromHsl(h, s, l); | ||
} | ||
@@ -599,3 +642,3 @@ }; | ||
for (const set of sets) | ||
yield* set; | ||
yield* __yieldStar(set); | ||
} | ||
@@ -602,0 +645,0 @@ function every(set, callback) { |
{ | ||
"name": "@mathigon/core", | ||
"version": "1.1.9", | ||
"version": "1.1.10", | ||
"license": "MIT", | ||
@@ -36,12 +36,12 @@ "homepage": "https://mathigon.io/core", | ||
"@types/tape": "5.6.0", | ||
"@typescript-eslint/eslint-plugin": "5.59.8", | ||
"@typescript-eslint/parser": "5.59.8", | ||
"esbuild": "0.17.19", | ||
"eslint": "8.42.0", | ||
"@typescript-eslint/eslint-plugin": "5.61.0", | ||
"@typescript-eslint/parser": "5.61.0", | ||
"esbuild": "0.18.11", | ||
"eslint": "8.44.0", | ||
"eslint-plugin-import": "2.27.5", | ||
"tape": "5.6.3", | ||
"tape": "5.6.4", | ||
"ts-node": "10.9.1", | ||
"tslib": "2.5.3", | ||
"typescript": "5.1.3" | ||
"tslib": "2.6.0", | ||
"typescript": "5.1.6" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174477
2662