Colourful lies you learned before high school
(January 12, 2018)
The primary colours cannot be mixed from other colours. This is one of the fundamental lessons from an elementary school art education. Did you know you can mix fire engine red using yellow and magenta?
Colour printers use cyan (sort of a powder blue), magenta, yellow and black ink, and they make scarlets and crimsons just fine. I knew this, but I was still surprised when I learned that red was a colour that could be derived from others. I’d never thought too hard about this contradiction between what I was taught as the truth about colour and my own observations of the world. Well, it turns out there's a rich history of humans struggling to find the primaries so I really don’t feel too bad.
In this (very long) webpage the author surveys 300 years of inaccurate or incomplete attempts at modelling colour, concluding that primaries would have to either be purely imaginary constructs or inadequate for creating the full spectrum of colour (this is because colour saturation goes down every time you mix paint or light colours). I am fascinated by both the human drive to figure it out, and the hubris of ignoring the pieces of reality that didn’t fit nicely into the model du jour.
So getting back to what I promised in the title: what other things did we learn about colour in school that aren’t quite right?
The different kinds of colour complements
Green is said to be the complement of red. Why does it clash so much, then? Middle school colour theory tends to conflate the visual complement of a colour and the mixing complement of a paint pigment or light.
The visual complement of a given colour is the colour against which it looks the most vibrant. Red’s visual complement is a blueish turquoise. You can see this for yourself by staring at a bright red object for 20 seconds, then looking at a white surface. What colour is the afterimage?
Other visual complement pairs (determined in the same way) are:
- egg yolk yellow and elementary school paint kit blue ("ultramarine")
- fuchsia pink and slightly blue greens like viridian
- eggplant purple and lime green
- sky blue and orange (Portal gun colours)
You can make some fun outfits based on these pairs, by the way. Using visual complement pairs is one way to create harmony in a colour scheme.
This is a colour wheel in which opposites along the wheel are visual complements of each other.
If you take a light mixing complement pair, then draw or paint densely packed dots alternating between the two colours on a piece of paper and then squint at it from far away, you should see a perfect neutral grey (if you get the proportion of one colour to the other correct). You are looking at the average between two different colours without mixing the physical paints. There will never be a neutral grey between red and yellow of course, but you won’t find one between red and green either.
Take a look at some of the middle colours in this gradient. It goes from green to reddish green to greenish red to red without going anywhere near grey! They are definitely not light mixing complements (and, against intuition and all manner of opponent process-based colour models, reddish green is a valid description of a colour).
Where did the idea of red being opposite to green come from, then? Red pigments mix with (blue-ish) green pigments to make neutral greys, so green and red are (near) paint mixing complements. There’s not much to say here. I think middle school got mixing complements mostly right. There are some interesting textural effects from interactions between heavy metal-based pigments and "smaller" and "lighter" synthetic pigments, but that's not really important unless you are Really Into Watercolour.
You don't need a perfect understanding of how brains and eyes process colour to make or appreciate good art. Look around and question any prescriptive rules about what colours do and do not go together. There are some great examples outside, because nature never got the memo about what should and shouldn't work :) And if you know a kid, mix a primary (or two) in front of them. That's cyan + magenta = blue, and yellow + magenta = red. Highly entertaining all around.
5 tons of flacs
(July 25, 2015)
Here are some things I learned and remembered on the way to writing a flac decoder in C++11. I actually wrote most of this up in April, but I found this post sitting here basically done, so out it goes.
It's convenient to use
bcfor base conversions and general arithmetic. Just enter
obase=16, type in any decimal number and
bcwill tell you what it is in hex.
ibase=16is also useful for the reverse conversion. Be careful if you're changing
ibase, because you'll have to enter the new
obasein the base specified by
hexdumpis cool! The
-Cflag is particularly useful since it lets you see bytes in hex and as chars (did you know the first four bytes of a valid flac file spell out 'fLaC'?)
flac --analyze file.flacdumps out flac information for you when you get tired of squinting at hexdump output and parsing files manually.
Flac encodes integers in big-endian format, except when they're encoded in unary format or encoded using an extrapolation of UTF-8 (this is a neat trick; it never occured to me that you could use the byte-saving powers of UTF-8 for something other than...well, unicode characters). Another exception is tags, which store little-endian integers to comply with the vorbis spec. Delightful.
Bitfields are not your friend. Especially when the architecture of your dev machine doesn't match with the endianness of the data. They look more idiot-proof than bitshifts and masking, but don't be fooled. Here Be Dragons.
STL bitsets are nice...when they're enough. They are frequently not enough, especially if you're trying to slice and dice bytes. They are really convenient for printing out numbers in binary, though. I learned this particular trick from Katy.
Gstreamer0.10 without Pulseaudio
(March 06, 2015)
You used to be able to configure gstreamer0.10-using applications to output
sound using OSSv4 via gconf; I had the following in
<?xml version="1.0"?> <gconf> <entry name="audiosrc" mtime="1390923248" type="string"> <stringvalue>osssrc</stringvalue> </entry> <entry name="videosrc" mtime="1390923248" type="string"> <stringvalue>v4l2src</stringvalue> </entry> <entry name="videosink" mtime="1390923248" type="string"> <stringvalue>autovideosink</stringvalue> </entry> <entry name="audiosink" mtime="1390923248" type="string"> <stringvalue>oss4sink</stringvalue> </entry> </gconf>
It wasn't working after I reinstalled Linux on a new SSD (I suspected my old
drive was starting to fail).
It appears gstreamer now uses GSettings/dconf, so instead I ran the following
in a bash prompt.
music-audiosink was the only one I needed to get audio working in luakit, but
I figured that setting the rest of them couldn't hurt.
gsettings set org.freedesktop.gstreamer-0.10.default-elements music-audiosink oss4sink gsettings set org.freedesktop.gstreamer-0.10.default-elements chat-audiosink oss4sink gsettings set org.freedesktop.gstreamer-0.10.default-elements sounds-audiosink oss4sink
If you're using plain old ALSA, you can replace that with the following.
gsettings set org.freedesktop.gstreamer-0.10.default-elements music-audiosink alsasink gsettings set org.freedesktop.gstreamer-0.10.default-elements chat-audiosink alsasink gsettings set org.freedesktop.gstreamer-0.10.default-elements sounds-audiosink alsasink
Also useful for exploration are
get, which are used in this
gsettings list-keys org.freedesktop.gstreamer-0.10.default-elements gsettings get org.freedesktop.gstreamer-0.10.default-elements music-audiosink
- Fun with Microphones - March 03, 2015
- Loading WebKit2Gtk Web Extensions - December 02, 2014
- Steinitz' theorem - September 28, 2013
- PMATH 351 Final Exam Definitions - December 04, 2012
- PMATH 351 Midterm Definitions - October 31, 2012
- L'Hopital's Rule - October 07, 2012
- Chicken thyme - September 13, 2012
- Some advice from Miss Havisham - September 05, 2012