-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7df94a9
Showing
43 changed files
with
34,230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = { | ||
"env": { | ||
"browser": true, | ||
"es2022": true, | ||
"node": true | ||
}, | ||
"extends": "standard-with-typescript", | ||
"overrides": [ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"files": [ | ||
".eslintrc.{js,cjs}" | ||
], | ||
"parserOptions": { | ||
"sourceType": "script" | ||
} | ||
} | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"@typescript-eslint/strict-boolean-expressions": "off", | ||
}, | ||
"ignorePatterns": [ | ||
"dist", | ||
"node_modules", | ||
"coverage", | ||
"scripts", | ||
"src/data" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.vscode | ||
.idea | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>browser/umd</title> | ||
</head> | ||
<body> | ||
view source and open the console | ||
|
||
<!-- | ||
it is assumed that a global instance of chroma is | ||
available in the browser. Chroma is not bundled | ||
with the umd build of the library! | ||
--> | ||
<script src="node_modules/chroma-js/chroma.js"></script> | ||
<script src="node_modules/@mtillmann/colors/dist/umd/colors.js"></script> | ||
|
||
<script> | ||
const r = async (url) => | ||
await fetch(`node_modules/@mtillmann/colors/dist/data/${url}`); | ||
const text = async (url) => { | ||
const resp = await r(url); | ||
return await resp.text(); | ||
}; | ||
const json = async (url) => { | ||
const resp = await r(url); | ||
return await resp.json(); | ||
}; | ||
|
||
document.addEventListener("DOMContentLoaded", async () => { | ||
|
||
// collect the data you need to initialize the lookup classes | ||
// this may be done in a build step in a real application and not | ||
// necessarily in the browser via fetch | ||
const binaryLookup = await text("binaryLookup.bin"); | ||
const colorMap = await json("colorMap.json"); | ||
const lookupCube = await json("lookupCube.json"); | ||
const { byteToShadeOffset } = await json("binaryLookupMaps.json"); | ||
|
||
const colorLookup = new Colors.ColorLookup(lookupCube, colorMap); | ||
const altShadeLookup = new Colors.AltShadeLookup(); | ||
const shadeLookup = new Colors.ShadeLookup( | ||
binaryLookup, | ||
byteToShadeOffset | ||
); | ||
|
||
console.group("colorLookup"); | ||
console.info(colorLookup.lookupByRGB(11, 44, 99)); | ||
console.groupEnd(); | ||
|
||
console.group("altShadeLookup"); | ||
console.info(altShadeLookup.shadeByRGB(11, 44, 99)); | ||
console.info(altShadeLookup.shadeByRGB(11, 44, 99, true)); | ||
console.groupEnd(); | ||
|
||
console.group("shadeLookup"); | ||
console.info(shadeLookup.shadeByRGB(11, 44, 99)); | ||
console.groupEnd(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.