Skip to content

Why does baseTriad[4] work? This is out of bounds. #121

Open
@KlausHans

Description

@KlausHans

In ColorGeneratorCtrl.js is the following code for the constantin algorithm:

var baseTriad = tinycolor(hex).tetrad();
[...]
getColorObject(tinycolor.mix(baseDark, baseTriad[4], 15).saturate(80).lighten(65), 'A100'),
getColorObject(tinycolor.mix(baseDark, baseTriad[4], 15).saturate(80).lighten(55), 'A200'),
getColorObject(tinycolor.mix(baseDark, baseTriad[4], 15).saturate(100).lighten(45), 'A400'),
getColorObject(tinycolor.mix(baseDark, baseTriad[4], 15).saturate(100).lighten(40), 'A700')

baseTriad is an array with a length of 4, so index 4 should not exist, only 0 to 3.
I've played around here:
https://stackblitz.com/edit/angular-w2jbiq?file=src%2Fapp%2Fapp.component.ts
To my surprise it actually mades a difference in comparison to e.g. baseTriad[2]. Why is that so? It looks like unintended behavior or a bug to me.
Edit: Ok, of course it's simply undefined, so the whole tetrad thing is unnecessary.

Thanks!

Off topic: The var should be named 'baseTetrad' ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions