惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
Lohrmann on Cybersecurity
Martin Fowler
Martin Fowler
Engineering at Meta
Engineering at Meta
腾讯CDC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
TaoSecurity Blog
TaoSecurity Blog
博客园_首页
Vercel News
Vercel News
Hugging Face - Blog
Hugging Face - Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Last Week in AI
Last Week in AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
The Exploit Database - CXSecurity.com
量子位
Project Zero
Project Zero
A
Arctic Wolf
小众软件
小众软件
NISL@THU
NISL@THU
C
CERT Recently Published Vulnerability Notes
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Troy Hunt's Blog
P
Privacy & Cybersecurity Law Blog
Security Latest
Security Latest
B
Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
D
DataBreaches.Net
Schneier on Security
Schneier on Security
The Hacker News
The Hacker News
K
Kaspersky official blog
C
Check Point Blog
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Webroot Blog
Webroot Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
人人都是产品经理
人人都是产品经理
AI
AI
Cisco Talos Blog
Cisco Talos Blog
MyScale Blog
MyScale Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
S
Schneier on Security
P
Palo Alto Networks Blog

oida.dev | TypeScript, Rust

TypeScript's `erasableSyntaxOnly` Flag Unsafe for work Tokio: Macros Tokio: Channels Tokio: Getting Started Network Applications on the Tokio Stack Remake, Remodel, Reduce. The `never` type and error handling in TypeScript 5 Inconvenient Truths about TypeScript Refactoring in Rust: Introducing Traits Refactoring in Rust: Abstraction with the Newtype Pattern Announcing the TypeScript Cookbook TypeScript: Iterating over objects The road to universal JavaScript 10 years of oida.dev Rust: Tiny little traits The TypeScript converging point How not to learn TypeScript Getting started with Rust Introducing Slides and Coverage TypeScript: The humble function overload TypeScript + React: Children types are broken TypeScript: In defense of any Rust: Enums to wrap multiple errors Dissecting Deno Error handling in Rust TypeScript: Unexpected intersections Upgrading Node.js dependencies after a yarn audit TypeScript: Array.includes on narrow types TypeScript + React: Typing Generic forwardRefs shared, util, core: Schroedinger's module names Learning Rust and Go TypeScript: Narrow types in catch clauses TypeScript: Low maintenance types Tidy TypeScript: Name your generics Tidy TypeScript: Avoid traditional OOP patterns Tidy TypeScript: Prefer type aliases over interfaces Tidy TypeScript: Prefer union types over enums My new book: TypeScript in 50 Lessons Go Preact! ❤️ this in JavaScript and TypeScript TypeScript and ECMAScript Modules TypeScript + React: Why I don't use React.FC TypeScript + React: Component patterns TypeScript: Augmenting global and lib.dom.d.ts Vite with Preact and TypeScript TypeScript: Union to intersection type 11ty: Generate Twitter cards automatically Are large node module dependencies an issue? TypeScript: Variadic Tuple Types Preview TypeScript: Improving Object.keys Remake, Remodel. Part 4. TypeScript + React: Typing custom hooks with tuple types TypeScript: Assertion signatures and Object.defineProperty TypeScript: Check for object properties and narrow down type Boolean in JavaScript and TypeScript void in JavaScript and TypeScript Symbols in JavaScript and TypeScript Why I use TypeScript TypeScript + React: Extending JSX Elements TypeScript: Validate mapped types and const context TypeScript: Match the exact object shape TypeScript: The constructor interface pattern Streaming your Meetup - Part 4: Directing and Streaming with OBS Streaming your Meetup - Part 3: Speaker audio Streaming your Meetup - Part 2: Speaker video Streaming your Meetup - Part 1: Basics and Projector TypeScript and React Guide: Added a new styles chapter TypeScript and React Guide: Added a new render props chapter TypeScript and React: Styles and CSS TypeScript and React TypeScript and React Guide: Added a new prop types chapter TypeScript without TypeScript -- JSDoc superpowers TypeScript: Mapped types for type maps JAMStack vs serverless web apps The Unsung Benefits of JAMStack Sites TypeScript: Ambient modules for Webpack loaders My most favourite talks in 2018 TypeScript and React Guide: Added a new context chapter TypeScript: Built-in generic types TypeScript: Type predicates JSX is syntactic sugar TypeScript and React Guide: Added a new hooks chapter Getting your CfP application right FAQ on our Angular Connect Talk: Automating UI development TypeScript and Substitutability Debugging Node.js apps in TypeScript with Visual Studio Code From Medium: Deconfusing Pre- and Post-processing From Medium: PostCSS misconceptions Saving and scraping a website with Puppeteer Cutting the mustard - 2018 edition Wordpress as CMS for your JAMStack sites My most favourite podcast episodes in 2017 My most favourite talks in 2017 My most favourite books in 2017 The Best Request Is No Request, Revisited Not so hidden figures - Organizing ScriptConf My podcast journey to ScriptCast Grid layout, grid layout everywhere! #scriptconf and #devone
CSS levels up: the HWB colour model
2014-07-13 · via oida.dev | TypeScript, Rust

HWB is short for “Hue, Whiteness, Blackness” and is a new colour space format, which is now proposed in the current CSS Colours Module Level 4 working draft.

It was invented in 1996 by the same guy who invented HSL to address some of its problems, trying to make it even more intuitive for humans to understand and use. Spoiler: It is.

Some notes: First of all, this colour model isn’t implemented anywhere. It’s an early working draft after all. It might be subject to change and even not get implemented anywhere at all (though I doubt it, it rocks). The samples here are mostly for fun, but do provide you with an RGB code you can use. Also, if you want an HWB to RGB conversion code, check out my GitHub repo for colour demos. And if you are into scientific reading, check out Alvy Ray Smith’s original paper.

The colour model - How it works #

Hue #

If you are familiar with HSL, you know what to expect from the first parameter, the H (Hue). The hue follows the colours of a rainbow, starting at red, going over orange, yellow, green, blue and indigo to violet. The hue tells us where we are on that spectrum. From violet it goes back to red, giving us a colour cycle that spans all 360 degrees.

The colour cycle by Newton in 1700s

The hue specifies the angle on that cycle, starting with red at 0 degrees. If you want an easy way to remember the order of the primary colours, just think of the old guy Roy G. Biv. Each letter of “his” name stands for one of the main colours in that cycle.

The Hue goes from red over orange, yellow, green, blue and indigo to violet. Then returning to red. Source: http://en.wikipedia.org/wiki/File:HueScale.svg

This part is identical to all the other H-related colour models. But from here, we go different ways.

Whiteness and Blackness #

In other models (especially HSL), the other parameters need to be set to some initial values. If you want to have pure red, saturation needs to be at 100% while lightness should be 50%. That’s ok and very understandable. Too light it would be white, too dark it’s black. In the middle you get exactly what you want.

HWB gives you the pure colour by just specifying the hue and leaving the other two parameters to zero. Now we add white and/or black.

Imagine you have your pure red as a liquid. Now add as much white as you have. The more you add, the more white it gets, resulting in pure white at the end.

Same goes for black. The more black colour you add, the darker your colour gets, resulting at some point in pure black.

Whiteness and Blackness for the color red

If you add as much white as you add black, you get grey in the end, the original colour disappearing completely. That’s why the bottom right half of that certain hue is always the same, no matter what you original hue was.

In CSS #

The CSS syntax for it is really easy and straigthforward, you do it in the same way as with RGB or HSL: hwb(0, 0, 0) results in red. You specify the first parameter in degs, the second and third in percent or a decimal number from 0 to 1. hwb(120deg, 20%, 20%); results in a slightly greyish green.

Here’s a little demo, just edit the three values of HWB:

Oddities and notes #

If you add 100% black, you’ll always get black. Same goes for 100% white.

If you add at the same amount of black and white, and they are at least 50%, you’ll always get rgb(127, 127, 127). This is because the sum of both colours can’t go over 100%, so if you got more, both values will be normalised.

Once HWB comes, HWBA will come too. The A is – naturally – an additional alpha channel that goes from 0 to 1, describing the color’s opacity.

Bottom line #

Chances are, you’ve already used the intuitive way of HWB colour selection once. Ubuntu used this model in their old colour picker (see below), and several other operating systems or programs used this form of colour selection.

Ubuntu Color Picker

Other than being really easy to understand and use, it is also really easy to describe in code. Adding black and white to a base colour feels like mixing paints, and I guess we’ve all done this at some point.

I’m really looking forward to it and will start using it now. A Sass function is available on GitHub and via bower

Image credits #

Further reading #

Related Articles