Malay Vasa Profile picture
Apr 14, 2022 12 tweets 5 min read Read on X
Color is probably the trickiest thing to master, especially using code. I wrote a thread breaking down color models and how to manipulate color in @p5xjs 🧵 1/n Image
There are several color models out there, you're probably already familiar with RGB - Red, Green, Blue. Each color is represented by three values ranging between 0 - 255 (256 Possibilities). Image
The problem with RGB is that it is meant to be machine-readable, your brain doesn't intuitively know why 212,24,118 is the color it is. It's meant to control the pixels on the screen and doesn't translate well to other uses, especially in making art.
To illustrate this further, here's the RGB value for bright orange, can you figure out how the values have to change to get a lighter shade of the same color? Your intuition says you need to add white, but how do you do that? Your mental model of color doesn't translate to RGB. Image
(It's 255, 137, 33 for those who're trying to figure it out)
To rescue us from this, there's HSB - Hue, Saturation, Brightness. Hue ranges between 0 - 360, and the other two are 0 - 100. It helps to think of the hue on a color wheel. Image
HSB unlocks so many possibilities because it allows you to control color programmatically, you can use loops to step through any of the parameters and get smooth transitions between colors. Here's an example where I step through the saturation. Image
Easily bump up the number of strips in the above example and get infinite shades. Doing this through RGB, if at all possible, would be an absolute nightmare. Image
HSB also allows you to implement color schemes, as they're all just some constant relationship between colors on the color wheel. This way you can easily generate more palettes that follow the same color scheme, a gold mine for generative art. Image
Here's an example that implements a complementary color scheme, where the colors are exactly opposite to each other on the color wheel. It's as simple as adding 180 to the hue of the first color. ( (h1+180)%360 is to map it back to 0-360 in case it exceeds) Image
That's all for this time, if you have any questions, feel free to drop them down below. Hope this thread gave you some confidence while working with color. Image

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Malay Vasa

Malay Vasa Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(