Sub topic 1
What a colour model is and why there is more than one
Prerequisites
This chapter assumes you have:
- Basic familiarity with digital images or design software, such as choosing a fill colour in an editor.
- Comfort with simple arithmetic and base-10 numbers.
- Optionally, some CSS or scripting experience for the code samples. You can skip the code and still follow the chapter.
What a colour model is
A colour model is a rule for describing a colour with numbers. You give it a small set of values, called channels, and it tells you which colour those values mean. RGB uses three channels: red, green and blue. CMYK uses four: cyan, magenta, yellow and black.
A colour model is not the same as a colour. It is a way of writing colours down. The same orange can be written in several models, and each one uses a different recipe to reach it.
The CSS below writes one orange in two ways:
.button {
background-color: #ff8800;
border-color: rgb(255 136 0);
color: #fff;
}The hex value #ff8800 and rgb(255 136 0) name the same colour. The shorthand #fff expands to #ffffff, which is white. All three values use the RGB model. Only the notation differs.
Why there is more than one model
Colour is made in different physical ways, and no single recipe suits all of them. A screen starts dark and makes colour by emitting light. A printed page starts as white paper and makes colour by absorbing some of the light that falls on it. These are opposite processes, so each needs its own set of channels.
| Situation | What the device does | Natural model |
|---|---|---|
| Monitor, phone, projector | Emits red, green and blue light | RGB |
| Inkjet, offset press | Lays ink that absorbs light | CMYK |
| Web page styling | Describes screen colour as text | Hex or `rgb()` notation, both RGB |
Each model fits its medium. RGB channels match the three kinds of light sources in a display. CMYK channels match the inks a press can lay down. Using the wrong model for a medium gives you values the device cannot use directly.
Two ideas to keep apart
Learners often mix up two things:
- The model, which is the set of channels and the rule for combining them.
- The notation, which is how you write the numbers down.
Hex is a notation. It writes RGB values in base 16, and it does not introduce a new model. Chapter 5 covers this in detail. RGB and CMYK are models. They differ in how they build colour, and that difference is what the rest of this tutorial explains.
A third idea comes later. Even inside one model, two devices may show the same numbers differently. That is the job of a colour space, which you will meet in a later chapter.
How the models fit together
The diagram shows why a design file may need more than one set of numbers. A brand orange used on a website is written in RGB. The same orange on a printed brochure needs CMYK values. The two sets of numbers describe the same intent, but they are not identical, and moving from one to the other is a conversion, not a simple relabelling.
A first look at the numbers
You can see that a model is just numbers by converting between two notations in code. This JavaScript turns a hex string into three channel values and back:
function hexToRgb(hex) {
const m = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex);
if (!m) throw new Error("Invalid hex colour: " + hex);
return m.slice(1).map((h) => parseInt(h, 16));
}
function rgbToHex(r, g, b) {
return "#" + [r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("");
}
console.log(hexToRgb("#ff8800")); // [255, 136, 0]
console.log(rgbToHex(255, 136, 0)); // "#ff8800"The conversion works because hex and RGB are the same model in two notations. Each pair of hex digits is one channel. Going from RGB to CMYK is harder, because the two models work differently. A later chapter shows why.
Common mistakes at this stage
- Calling hex a separate colour model. It is a way of writing RGB.
- Assuming one set of numbers looks the same on every device. The model gives the recipe, but the device decides how it looks.
- Picking a model by habit instead of by destination. Choose it by where the work will be shown.
Exercise
A client gives you the brand colour as #ff8800 and asks for it on a website and on a printed flyer. Which colour model describes the hex value, and why will the flyer need different numbers?
Show answer
The hex value is written in the RGB model, because hex is only a notation for RGB channel values. The flyer is printed with ink, which uses the CMYK model, so the colour must be converted to CMYK values. The conversion is needed because screens emit light and ink absorbs it.
Exercise
Is rgb(255 136 0) a different colour model from #ff8800?
Show answer
No. Both use the RGB model and describe the same colour. They are two notations for the same three channel values.