This Was Not An Easy Project
The Imitable QR Code
What is a QR Code?
- Think of those square black and white chunks of nonsense like a more complex bar code that you see on grocery store items. It contains information that can be decoded by a scanner, and even when damaged, it will still (likely) work.
- There are a variety of different formats for encoding
- Kanji (Japanese / Chinese script)
- Numeric (0-9)
- Alphanumeric (0-9, A-Z)
- Byte (8 bits of whatever!)
- There are a few more, but they are not widely supported, so I’ll just ignore them!
- What allows a QR Code to remain readable even after being damaged is because of error correction, more specifically the reed solomon error correction algorithm.
- Fixed patterns, such as the finder pattern allow for cameras to easily lock on to the code, help the decoder determine what version/format its using, etc. Mostly all metadata that is sometimes relevant to encoding, sometimes important for just taking the picture.
Why This Project Hill To Die On?
I’ve always wanted to do something with the rust programming language, but I couldn’t think of anything substantial until I started reading about how QR codes work. There’s nothing in particular that I absolutely needed to have in Rust that other languages couldn’t do - and after the fact, there wasn’t really anything fancy that I did in Rust to make this thing work. But what it did do was push me into thinking critically about the language, how I code, and in data structures. I made plenty of mistakes while working on this, some very expensive ones, but I am fortunate enough to have realized them.
There were many resources I used throughout the duration of the this project. This one in particular was crazy useful - but certainly not perfect. Because of how awesome WebAssembly is, I was able to figure out how to port my Rust program onto here - so similar to above, I used a canvas to map out how data gets encoded. I’ll go more in depth later, but this was just too much fun to not share now!