MCPcopy Index your code
hub / github.com/anomalyco/opencode / oklab

Function oklab

packages/opencode/src/cli/cmd/run/theme.ts:226–240  ·  view source on GitHub ↗
(color: RGBA)

Source from the content-addressed store, hash-verified

224}
225
226function oklab(color: RGBA) {
227 const r = srgbToLinear(color.r)
228 const g = srgbToLinear(color.g)
229 const b = srgbToLinear(color.b)
230
231 const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)
232 const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)
233 const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)
234
235 return {
236 l: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
237 a: 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
238 b: 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
239 }
240}
241
242function nearestIndexed(indexed: RGBA[], rgba: RGBA): RGBA {
243 const target = oklab(rgba)

Callers 1

nearestIndexedFunction · 0.85

Calls 1

srgbToLinearFunction · 0.70

Tested by

no test coverage detected