Dan Hollick Profile picture
Sep 14, 2022 17 tweets 6 min read Read on X
Ever wondered how a QR code works?
No, me neither but it's low-key fascinating.

(Warning, there is some extremely nerdy shit here.👇 ) Image
The Quick Response code was invented by a subsidiary of Toyota to track parts across the manufacturing process.

Barcodes were proving inadequate - they can only be read at certain angles and didn't store much data relative to their size

The QR code solves those issues and more Image
The most distinctive thing about a QR code are these cube shapes, called Finder Patterns, that help your reader detect the code.

The smaller fourth cube, the Alignment Pattern, orientates the code so it can be at any angle and the reader will still know which way is up. Image
You've probably never noticed but every QR code has these alternating black and white dots called the Timing Pattern.

These tell the reader how big a single module is and how big the whole QR code is - known as the version.

Version 1: Smallest
Version 40: Biggest ImageImage
Information about the format is stored in these two strips near the Finder patterns.

It's stored twice so its readable even when QR code is partially obscured. (You'll notice that this is a recurring theme.) Image
This stores three crucial pieces of information:

- Mask.
- Error correction level
- Error correction format.

I know these sound super fucking boring but they are actually pretty interesting. Image
First, error correction - what is it?

Essentially, it dictates how much redundant information is stored in the code to ensure it remains readable even when part of it is missing. Image
This is pretty amazing - If your code is outdoors you can choose a higher redundancy level to make sure it still functions when obscured.

(try it) Image
Second, the mask - what's that?

Well, QR readers work best when there are the same amount of white and black areas.

But the data might not play ball so a mask is used to even things out. Image
When a mask is applied to the code anything that falls under the dark part of the mask is inverted.

A white area becomes black and black area becomes white.
There are 8 standard patterns which are applied one by one.

The pattern that achieves the best result is used and that info is stored so the reader can unapply the mask. Image
Finally we get to the actual data.

Weirdly, the data starts at the bottom-right corner and winds back up like pictured.

It almost doesn't matter where it starts because it can be read at any angle. Image
The first chunk of information here tells the reader what mode the data was encoded in and the second tells it the length.

In our case each character takes up 8 bit chunks, otherwise known as bytes, and there are 24 of them. Image
There is still a bunch of left over space after our data.

This is where the error correction information is stored so that it can be read if partially obscured. The way this works is actually really really complex so I'll leave that out.

That's basically it! Image
For the absolute nerds who made it here, a fun fact:

Perhaps the coolest thing about QR codes is that Denso Wave, the company that invented them, never exercised their patent and released the technology for free!

denso-wave.com/en/technology/…
Apparently, to maximise engagement, I'm supposed to link the original tweet here and encourage you to retweet it.
You can check out the unrolled version here:
typefully.com/DanHollick/qr-…

• • •

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

Keep Current with Dan Hollick

Dan Hollick 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!

More from @DanHollick

Oct 27, 2025
Before we all mute the word 'dithering' I thought I'd explain a little bit about why we needed to dither digital images in the first place.

Although it's an aesthetic now, we used to need dithering to trick our eyes into seeing more colors than were actually there. 👇 Image
So in the early days of computing, memory was scarce and we couldn't store a lot of color detail.

To get around this we used limited palettes with lookup tables or really low bit depth colors, to reduce the number of colors in an image, also called quantization. Image
The problem with quantization is it creates hard steps where there should be gradual gradients - we don't have a color in between these.

This is where dithering comes in. We can approximate this gradient by adding some noise with the two neighbouring colors. Image
Read 13 tweets
Jun 8, 2023
Excited to finally share what I've been working on.

Introducing Detax, a comprehensive suite of automated tax avoidance and money laundering tools. Our goal is to revolutionise the financial fraud industry by bringing it into the 21st century.

detax.framer.website
Historically, avoiding tax has been a manual, labor intensive task which has put it out of the reach of most small businesses.

We're here to change that and open up a world of financial fraud to businesses of any size.
This is, of course, not real.

This is actually the site we're going to build in my advanced @framer course.

You can join the waitlist at advancedframer.com . Beta access in July.
Read 4 tweets
Apr 13, 2023
How does a Large Language Model like ChatGPT actually work?

Well, they are both amazingly simple and exceedingly complex at the same time.

Hold on to your butts, this is a deep dive ↓
You can think of a model as calculating the probabilities of an output based on some input.

In language models, this means that given a sequences of words they calculate the probabilities for the next word in the sequence.

Like a fancy autocomplete. Image
To understand where these probabilities come from, we need to talk about something called a neural network.

This is a network like structure where numbers are fed into one side and probabilities are spat out the other.

They are simpler than you might think.
Read 26 tweets
Mar 16, 2023
Why are some typefaces harder to read than others at the same font-size?

Well, it has a lot to do with x-height but of course it's a bit more complicated than that: ↓
You probably know this already but the x-height of a typeface is the difference between the baseline and the height of the lowercase letters.

We can also think of x-height as a ratio of the total cap height or body height.
Typically we use the letter x to determine this, hence the name.

Interestingly, curved lowercase letters like a, c, and e are often slightly taller than the x-height. They purposefully overshoot so that they appear the same visual height as x, v, w, and z.

Anyway...
Read 13 tweets
Feb 1, 2023
Why is making a dark mode greyscale so hard to get right?

Well, of course it has to do with the weird way humans perceive colour and contrast. 👇
The main issue is we we perceive contrast as higher between lighter colours.

Even though these two sets of colours have the same mathematical contrast we perceive the left as having more contrast than the right. Image
So in designs that use a lot of subtle light greys (containers, borders etc) it isn't as simple as just inverting the colour scale.

The contrast between darker greys will be lower as you can see below.
Read 16 tweets
Dec 15, 2022
Ever heard of a shader but too afraid to ask what it even means at this point?

Lets fuck around and find out 👇
First, we need to understand the difference between a CPU and GPU and why we need a separate unit just to draw graphics anyway.

(Don't worry, it's not going to be too technical.)
The thing that makes a CPU great is that it can perform a wide variety of tasks relatively quickly.

But the limitation is that each CPU core is optimised to do one thing at a time and so tasks are largely performed sequentially.
Read 19 tweets

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!

:(