Skip to content

Commit

Permalink
refactor: rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tychota committed Dec 14, 2023
1 parent 4d7f8f0 commit a33b2bc
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/gamut/rgb/oklab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ abstract class OkLabGamutMapping extends ToRGBColorspaceVisitor {

rgbVisitor = new ToRGBColorspaceVisitor();

private static COLOR_EPSILON = 0.0001;
protected static GAMUT_EPSILON = 0.00001;
private static CLAMP_OR_GAMUT_BREAKPOINT = 0.0001;
protected static MINIMAL_CHROMA_EPSILON = 0.00001;

public visitRGBColor(color: InstanceType<typeof Color.RGB>) {
// benchmark.recordMark("[Naive Interpolation] TargetSpace -> RGB (end)");
if (
color.r < 0 - OkLabGamutMapping.COLOR_EPSILON ||
color.r > 1 + OkLabGamutMapping.COLOR_EPSILON ||
color.g < 0 - OkLabGamutMapping.COLOR_EPSILON ||
color.g > 1 + OkLabGamutMapping.COLOR_EPSILON ||
color.b < 0 - OkLabGamutMapping.COLOR_EPSILON ||
color.b > 1 + OkLabGamutMapping.COLOR_EPSILON
color.r < 0 - OkLabGamutMapping.CLAMP_OR_GAMUT_BREAKPOINT ||
color.r > 1 + OkLabGamutMapping.CLAMP_OR_GAMUT_BREAKPOINT ||
color.g < 0 - OkLabGamutMapping.CLAMP_OR_GAMUT_BREAKPOINT ||
color.g > 1 + OkLabGamutMapping.CLAMP_OR_GAMUT_BREAKPOINT ||
color.b < 0 - OkLabGamutMapping.CLAMP_OR_GAMUT_BREAKPOINT ||
color.b > 1 + OkLabGamutMapping.CLAMP_OR_GAMUT_BREAKPOINT
) {
const okLabColorspace = new ToOkLabColorspaceVisitor();
// benchmark.recordMark("[Gamut oklab] RGB -> TargetSpace (start)");
Expand Down Expand Up @@ -308,7 +308,7 @@ export class OkLabGamutClipPreserveChroma extends OkLabInterpolateGamutMapping {
gamutMap(color: InstanceType<typeof Color.OkLab>): InstanceType<typeof Color.OkLab> {
const oklab = color;
const l = oklab.l;
const c = Math.max(OkLabGamutMapping.GAMUT_EPSILON, Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b));
const c = Math.max(OkLabGamutMapping.MINIMAL_CHROMA_EPSILON, Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b));

const a_norm = oklab.a / c;
const b_norm = oklab.b / c;
Expand All @@ -328,7 +328,7 @@ export class OkLabGamutClipProjectTo05 extends OkLabInterpolateGamutMapping {
gamutMap(color: InstanceType<typeof Color.OkLab>): InstanceType<typeof Color.OkLab> {
const oklab = color;
const l = oklab.l;
const c = Math.max(OkLabGamutMapping.GAMUT_EPSILON, Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b));
const c = Math.max(OkLabGamutMapping.MINIMAL_CHROMA_EPSILON, Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b));

const a_norm = oklab.a / c;
const b_norm = oklab.b / c;
Expand All @@ -349,7 +349,7 @@ export class OkLabGamutClipProjectToLCusp extends OkLabInterpolateGamutMapping {
gamutMap(color: InstanceType<typeof Color.OkLab>): InstanceType<typeof Color.OkLab> {
const oklab = color;
const l = oklab.l;
const c = Math.max(OkLabGamutMapping.GAMUT_EPSILON, Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b));
const c = Math.max(OkLabGamutMapping.MINIMAL_CHROMA_EPSILON, Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b));

const a_norm = oklab.a / c;
const b_norm = oklab.b / c;
Expand All @@ -375,7 +375,7 @@ export class OkLabGamutClipAdaptativeL05 extends OkLabInterpolateGamutMapping {
gamutMap(color: InstanceType<typeof Color.OkLab>): InstanceType<typeof Color.OkLab> {
const oklab = color;
const l = oklab.l;
const c = Math.max(OkLabGamutMapping.GAMUT_EPSILON, Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b));
const c = Math.max(OkLabGamutMapping.MINIMAL_CHROMA_EPSILON, Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b));

const a_norm = oklab.a / c;
const b_norm = oklab.b / c;
Expand All @@ -401,7 +401,7 @@ export class OkLabGamutClipAdaptativeLcusp extends OkLabInterpolateGamutMapping
gamutMap(color: InstanceType<typeof Color.OkLab>): InstanceType<typeof Color.OkLab> {
const oklab = color;
const l = oklab.l;
const c = Math.max(OkLabGamutMapping.GAMUT_EPSILON, Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b));
const c = Math.max(OkLabGamutMapping.MINIMAL_CHROMA_EPSILON, Math.sqrt(oklab.a * oklab.a + oklab.b * oklab.b));

const a_norm = oklab.a / c;
const b_norm = oklab.b / c;
Expand Down

0 comments on commit a33b2bc

Please sign in to comment.