Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index out of range: baseTriad[4] #109

Closed
Blaaznar opened this issue Sep 5, 2019 · 2 comments
Closed

Index out of range: baseTriad[4] #109

Blaaznar opened this issue Sep 5, 2019 · 2 comments

Comments

@Blaaznar
Copy link

Blaaznar commented Sep 5, 2019

Returns no errors but seems to be a bug:

var baseTriad = tinycolor(hex).tetrad();

This returns a zero based array 0-3:

["#500a28", "#4b500a", "#0a5032", "#0f0a50"]
    0: "#500a28"
    1: "#4b500a"
    2: "#0a5032"
    3: "#0f0a50"

baseTriad[4] is thus out of range and returns undefined.

@mbitson
Copy link
Owner

mbitson commented Apr 29, 2020

Hey there @Blaaznar !

Thank you for your report! This has recently been fixed in this PR: #105

I've got this deployed now to the tool, here: http://mcg.mbitson.com/

Please let me know if you notice anything else! Thanks again!

@micobarac
Copy link

Observing the latest source code, the issue is still present.
This piece of code shouldn't work at all:

case 'constantin':
var baseLight = tinycolor('#ffffff');
var baseDark = $scope.multiply(tinycolor(hex).toRgb(), tinycolor(hex).toRgb());
var baseTriad = tinycolor(hex).tetrad();
return [
	getColorObject(tinycolor.mix(baseLight, hex, 12), '50'),
	getColorObject(tinycolor.mix(baseLight, hex, 30), '100'),
	getColorObject(tinycolor.mix(baseLight, hex, 50), '200'),
	getColorObject(tinycolor.mix(baseLight, hex, 70), '300'),
	getColorObject(tinycolor.mix(baseLight, hex, 85), '400'),
	getColorObject(tinycolor.mix(baseLight, hex, 100), '500'),
	getColorObject(tinycolor.mix(baseDark, hex, 87), '600'),
	getColorObject(tinycolor.mix(baseDark, hex, 70), '700'),
	getColorObject(tinycolor.mix(baseDark, hex, 54), '800'),
	getColorObject(tinycolor.mix(baseDark, hex, 25), '900'),
	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')
];

var baseTriad = tinycolor(hex).tetrad(); // this variable should be renamed to baseTetrad.
baseTriad[4] is still out of bounds and returns undefined.

Still scratching my head how on earth does this work at all???

Btw, generated accent colors don't resemble much the default accent colors generated by Material algorithm (ie. red, indigo, blue...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants