From Typewriters to Pixels: A Journey with CMYK, RGB, and Building a Color Visualizer
When I was a kid, I published a fanzine about comics. This was long before I had a computer—it was created using a typewriter, paper, and scissors!
The fanzine was initially in black and white, photocopied at my school. Over time, as it gained more success, I was able to afford offset printing with color covers!
However, managing those colors was quite challenging. Each cover had to be printed four times, once for each color: cyan, magenta, yellow, and key (black) — abbreviated as CMYK.
This meant I had to provide four separate sheets, each printed in black ink, but corresponding to a specific color.
Here’s one of the issues I published:
All the yellow you see in the image above was hand-painted by me using black ink on the “yellow” sheet. For the skin tones, I used something called “raster dots.” These were sheets you could buy with black dots of varying densities. You would cut out the dots and apply them — in this case, to the “red” sheet.
I worked on a light table — a glass-topped drawing table with built-in lighting — so I could see through the various sheets while aligning them correctly.
It was very time-consuming, but it sparked a lifelong interest in understanding colors — and the huge difference between print- and screen colors!
While CMYK is limited to four colors, it’s still relatively easy to grasp. We’ve all used colored pencils on paper and have an intuitive sense of how colors mix. CMYK is a subtractive color model. You start with a white sheet of paper, and as you add more ink, you’re actually subtracting light. Combining all colors moves you toward black. If you don’t apply any ink, the paper stays white because it reflects all light.
When I got my first computer, I had to understand RGB, which is very different from CMYK. RGB is an additive color model used for digital screens. Here, you’re mixing light itself — adding more light makes the colors brighter and moves you toward white. Turn off all the RGB lights (R=0, G=0, B=0), and the screen goes black because there’s no light emitted.
As a graphic designer back then, you had to calibrate your screen because the colors you saw on the screen and those you saw in print were often very different!
Visualizing RGB
RGB represents three light sources: red, green, and blue. When a light is off, its value is 0; when it’s fully on, its value is 255. When these lights overlap, they create different colors.
To better understand how RGB works, let’s build a small tool:
HTML
<fieldset class="rgb"> <label class="r"> R:<input type="number" name="r" min="0" max="255" value="255" /></label> <label class="g"> G:<input type="number" name="g" min="0" max="255" value="255" /></label> <label class="b"> B:<input type="number" name="b" min="0" max="255" value="255" /></label> <output class="rg">R+G</output> <output class="rb">R+B</output> <output class="gb">G+B</output> </fieldset>
Styles
First, let’s create a 9x8 grid:
.rgb { all: unset; aspect-ratio: 9 / 8; container-type: inline-size; display: grid; font-size: 1.75cqi; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; }
It’s an unusual size, but that's because our R, G and B circles are 5x5 and overlap:
.r, .g, .b { aspect-ratio: 1 / 1; border-radius: 50%; display: grid; font-size: 5cqi; mix-blend-mode: difference; }
The CSS for .r, .g and .b is:
.r { background-color: rgb(var(--r), 0, 0); grid-area: 1 / 3 / 6 / 8; } .g { background-color: rgb(0, var(--g), 0); grid-area: 4 / 1 / 9 / 6; } .b { background-color: rgb(0, 0, var(--b)); grid-area: 4 / 5 / 9 / 10; }
I’ve used grid-area a lot lately. It lets you place a grid item at a very specific location:
row-start / col-start / row-end / col-end
It’s easier to visualize this if you enable Dev Tools’ grid visualizer:
Did you notice the three CSS Custom Properties, --r, --g and --b? We’ll update these in a small JS snippet:
const rgb = document.querySelector('.rgb'); rgb.addEventListener('input', e => { const N = e.target; document.body.style.setProperty(`--${N.name}`, N.value); })
And that’s basically it. I’ve added some
mix-blend-mode: difference
Read about it here — it’s great fun to loop through all the modes.
Demo
Here’s a Codepen. Click and edit the numbers below R, G and B, and notice how the page background and the overlapping parts of all three circles change.
以上是From Typewriters to Pixels: A Journey with CMYK, RGB, and Building a Color Visualizer的详细内容。更多信息请关注PHP中文网其他相关文章!

在这篇文章中,布莱克·莫里(Blackle Mori)向您展示了一些骇客,同时试图推动同位HTML支持的极限。如果您敢于使用这些,以免您也被标记为CSS罪犯。

具有CSS的自定义光标很棒,但是我们可以将JavaScript提升到一个新的水平。使用JavaScript,我们可以在光标状态之间过渡,将动态文本放置在光标中,应用复杂的动画并应用过滤器。

互动CSS动画和元素相互启动的元素在2025年似乎更合理。虽然不需要在CSS中实施乒乓球,但CSS的灵活性和力量的增加,可以怀疑Lee&Aver Lee&Aver Lee有一天将是一场

有关利用CSS背景滤波器属性来样式用户界面的提示和技巧。您将学习如何在多个元素之间进行背景过滤器,并将它们与其他CSS图形效果集成在一起以创建精心设计的设计。

好吧,事实证明,SVG的内置动画功能从未按计划进行弃用。当然,CSS和JavaScript具有承载负载的能力,但是很高兴知道Smil并没有像以前那样死在水中

是的,让#039;跳上文字包装:Safari Technology Preview In Pretty Landing!但是请注意,它与在铬浏览器中的工作方式不同。

此CSS-tricks更新了,重点介绍了年鉴,最近的播客出现,新的CSS计数器指南以及增加了几位新作者,这些新作者贡献了有价值的内容。

在大多数情况下,人们展示了@Apply的@Apply功能,其中包括Tailwind的单个property实用程序之一(会改变单个CSS声明)。当以这种方式展示时,@Apply听起来似乎很有希望。如此明显


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

Atom编辑器mac版下载
最流行的的开源编辑器

WebStorm Mac版
好用的JavaScript开发工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能