edelstone / material-palette-generator

🎨 Get perfect Material Design palettes from any hex color.
https://materialpalettes.com
213 stars 25 forks source link

Change URL once primary and/or secondary colors have been selected #1

Open edelstone opened 5 years ago

edelstone commented 5 years ago

Adding the colors to a specialized URL would allow the link to be shared and bookmarked easily.

Got this via email:

Thanks for the handy Material Design Palette Generator. It would be great if we could bookmark it with the primary/secondary colors in the URL, like https://materialpalettes.com/?primary=#2f5597. Is that something you would consider implementing?

vkottler commented 3 years ago

Hmm, honestly what would be awesome would be some kind of hosted API that accepts "hex color(s)" (maybe "primary", "secondary") and sends back some JSON data with the palette(s) in RGB-hex. I'm working on an offline generator for this, but I wish Google had the source for this in one of their material components. The "theme" component is not very sophisticated and requires manual entry for the actual colors.

Got as far as looking through "Color Tool" source to find that in the end they're literally just calling chroma.js lighten and darken (since that tool doesn't do the palette generator...).

Anyway, stumbled upon this project on this quest. Thanks for hosting it!

JorensM commented 7 months ago

So I tinkered around with the code, and I'm not sure what's going on exactly, but it looks like the function U() in main.js, which supposedly takes in a hsl value, doesn't seem to be accurate. in the place where we set the primary color, if I replace the U function's arguments with 0, 1 and 0.5, this is the color I get:

same-hsl-on-app

While actually the color with HSL values 0, 1 and 0.5 looks like this:

actual-red-hsl

So yeah, I'm not sure why that's happening.

edelstone commented 7 months ago

@JorensM Yeah me either. You may have read in the README that it's all Google's obfuscated code doing the color calculations. Likely not something we should attempt to change but feel free to work around it.

JorensM commented 7 months ago

@edelstone I guess I'll pass this one since I don't want to break something somewhere else haha. Maybe someone braver than me will come along and give it a go!

edelstone commented 7 months ago

@JorensM not a problem. Thanks for looking!