mbitson / mcg

Material Design Palette/Theme Generator - AngularJS, React, Ember, Vue, Android, Flutter & More!
http://mcg.mbitson.com/
MIT License
630 stars 96 forks source link

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

Open KlausHans opened 3 years ago

KlausHans commented 3 years ago

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' ;)

KlausHans commented 3 years ago

Just found https://github.com/mbitson/mcg/issues/109 According to this it should be fixed, but it's not.

micobarac commented 8 months ago

Still an issue :(