@inv8der/ishihara
Advanced tools
Comparing version
import Color from 'colorjs.io' | ||
import { dotProduct } from '../utils' | ||
import { clamp, dotProduct } from '../utils' | ||
import type { Vector3D } from '../types' | ||
@@ -32,12 +32,12 @@ | ||
projection1: [ | ||
[0.1451, 1.20165, -0.34675], | ||
[0.10447, 0.85316, 0.04237], | ||
[0.00429, -0.00603, 1.00174], | ||
[0.1498, 1.19548, -0.34528], | ||
[0.10764, 0.84864, 0.04372], | ||
[0.00384, -0.0054, 1.00156], | ||
], | ||
projection2: [ | ||
[0.14115, 1.16782, -0.30897], | ||
[0.10495, 0.8573, 0.03776], | ||
[0.00431, -0.00586, 1.00155], | ||
[0.1457, 1.16172, -0.30742], | ||
[0.10816, 0.85291, 0.03892], | ||
[0.00386, -0.00524, 1.00139], | ||
], | ||
separationPlaneNormal: [0.00048, 0.00416, -0.00464], | ||
separationPlaneNormal: [0.00048, 0.00393, -0.00441], | ||
}, | ||
@@ -47,12 +47,12 @@ | ||
projection1: [ | ||
[0.36198, 0.86755, -0.22953], | ||
[0.26099, 0.64512, 0.09389], | ||
[-0.01975, 0.02686, 0.99289], | ||
[0.36477, 0.86381, -0.22858], | ||
[0.26294, 0.64245, 0.09462], | ||
[-0.02006, 0.02728, 0.99278], | ||
], | ||
projection2: [ | ||
[0.37009, 0.8854, -0.25549], | ||
[0.25767, 0.63782, 0.10451], | ||
[-0.0195, 0.02741, 0.99209], | ||
[0.37298, 0.88166, -0.25464], | ||
[0.25954, 0.63506, 0.1054], | ||
[-0.0198, 0.02784, 0.99196], | ||
], | ||
separationPlaneNormal: [-0.00293, -0.00645, 0.00938], | ||
separationPlaneNormal: [-0.00281, -0.00611, 0.00892], | ||
}, | ||
@@ -62,12 +62,12 @@ | ||
projection1: [ | ||
[1.01354, 0.14268, -0.15622], | ||
[-0.01181, 0.87561, 0.13619], | ||
[0.07707, 0.81208, 0.11085], | ||
[1.01277, 0.13548, -0.14826], | ||
[-0.01243, 0.86812, 0.14431], | ||
[0.07589, 0.805, 0.11911], | ||
], | ||
projection2: [ | ||
[0.93337, 0.19999, -0.13336], | ||
[0.05809, 0.82565, 0.11626], | ||
[-0.37923, 1.13825, 0.24098], | ||
[0.93678, 0.18979, -0.12657], | ||
[0.06154, 0.81526, 0.1232], | ||
[-0.37562, 1.12767, 0.24796], | ||
], | ||
separationPlaneNormal: [0.0396, -0.02831, -0.01129], | ||
separationPlaneNormal: [0.03901, -0.02788, -0.01113], | ||
}, | ||
@@ -87,3 +87,3 @@ } | ||
): ColorCoords { | ||
// Go from sRGB to linearRGB | ||
// Convert from sRGB to linearRGB | ||
const color = toColor(rgb) | ||
@@ -127,4 +127,6 @@ const linearRGB = color.to('srgb-linear').coords | ||
// Go back to sRGB | ||
return simulatedColor.to('srgb').coords | ||
// Convert back to sRGB, clamping any values not in gamut | ||
return simulatedColor | ||
.to('srgb') | ||
.coords.map((v) => clamp(v, 0, 1)) as ColorCoords | ||
} | ||
@@ -131,0 +133,0 @@ |
@@ -77,3 +77,4 @@ import Color from 'colorjs.io' | ||
export function generateConfusionLines( | ||
type: 'deutan' | 'protan' | 'tritan' | ||
type: 'deutan' | 'protan' | 'tritan', | ||
amount = 11 | ||
): ColorRange[] { | ||
@@ -148,10 +149,10 @@ const red = new Color('#ff0000').to('xyz') | ||
// Assuming bounds of [0, 1] and a step of 0.1, we'll end up with 11 lines | ||
// as we want to include both the lower and upper bounds | ||
const numLines = 11 | ||
// Assuming a bounds of [0, 1] and step of 0.1, we should end up with 11 lines | ||
// since both the lower and upper bounds are included. Therefore, to calculate | ||
// step we need divide by amount - 1, which in this example is 10 | ||
const confusionLines = [] | ||
const step = round((bounds[1] - bounds[0]) / (numLines - 1), 4) | ||
const step = round((bounds[1] - bounds[0]) / (amount - 1), 4) | ||
let percentage = bounds[0] | ||
for (let i = 0; i < numLines; i += 1) { | ||
for (let i = 0; i < amount; i += 1) { | ||
const startColor = startColorRange(percentage) | ||
@@ -158,0 +159,0 @@ confusionLines.push(createConfusionLine(startColor)) |
{ | ||
"name": "@inv8der/ishihara", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "files": [ |
23356987
027685
0.01%