# Colour contrast

Because the [contact form](https://lucas-leprince.com/contact) has a favourite colour option I thought it would be a fun challenge to auto colour the confirmation emails people receive using their favourite colour

Feel free to play around and select different colours to see how it works

To visualize this the [webpage](https://lucas-leprince.com/web/default/bts/colour.html) version of this is ideal however I have done my best to translate it 

if you would prefer in it markdown please go to [https://lucas-leprince.com//bts/colour.md?colour=#EE0000](https://lucas-leprince.com//bts/colour.md?colour=#EE0000) to select a colour, the colour doesn't have to be #EE0000 it can be any hex colour

Finding the worst possible colour was an interesting goal and it took a couple attempts to get right

At first I pre calculated all possible values of each channel (which I have done here for [red](https://lucas-leprince.com//api/extras/hex/red), [green](https://lucas-leprince.com//api/extras/hex/green) [blue](https://lucas-leprince.com//api/extras/hex/blue) and [the value pre multiplication](https://lucas-leprince.com//api/extras/hex)).

I also used the contrast value from above and tried to find the three colours that were as dissimilar as possible.

The problem was that the algorythm was only optimizing one of the two goals at a time and I needed to try a different approach 


Instead of RGB I used hsl (hue, saturation, and lightness) this was much easier to work with because changing hue is how I got the "opposite" colour while lightness is how I gave them the same luminance

## Takeaways

1. contrast is exclusively a matter of how dark or light the colours are and nothing to do with their spot on the colour wheel

2. Blue is seen as a much darker colour than red and green so if you are trying to fix contrast tweak red and green first

3. Depending on whether you need a contrast ratio of 3:1 or 4.5:1 you can have up to 4 or 3 colours respectively before some of the colour combinations will be below the given threshold

[Return Home](https://lucas-leprince.com/index.md)

[Behind the scenes](https://lucas-leprince.com/bts.md)

[Dark Mode](https://lucas-leprince.com/bts/colour?mode=dark)

[Light Mode](https://lucas-leprince.com/bts/colour?mode=light)

[Rainbow Mode](https://lucas-leprince.com/bts/colour?mode=rainbow)

[Terminal Mode](https://lucas-leprince.com/bts/colour?mode=terminal)

[JSON](https://lucas-leprince.com/bts/colour.json)

[JWT](https://lucas-leprince.com/api/bts/colour/token)

[Database](https://lucas-leprince.com/database.md)

[get Progress](https://lucas-leprince.com/progress.md)

#### Social Media 

[GitHub](https://github.com/LePetitPrince-4)

[GitLab](https://gitlab.com/LePetitPrince4)

[LinkedIn](https://www.linkedin.com/in/lucas-leprince/)

[PGP key](https://lucas-leprince.com/pgp-key)

[RSS Feed](https://lucas-leprince.com/feed)

[Sitemap](https://lucas-leprince.com/sitemap.xml)

[permalink](https://lucas-leprince.com/permalink/v2/colours/md)