Core Graphics, Chapter 1. The Oracle Method for Drawing
A bitmap as an answer key, and the byte that would not round.
A bitmap as an answer key, and the byte that would not round.
You will be able to describe a bitmap as nothing more than a long block of bytes with a few numbers that say how to read it.
You will be able to say what premultiplied alpha is, in words a child could follow, and compute the stored byte for any color byte and alpha byte, exactly, by hand.
A shape is a list of five kinds of step, and the rules for walking it.
Four points, a handful of straight pieces, and the match that got worse when the cut got finer.
Why an edge pixel has the value it has, and how the context decides what is inside.
You will be able to say, for a line of any width at any position, which pixel rows it lights and with what bytes, and work the answer out by hand.
You will be able to read the six numbers of a transform as three arrows on a sheet of graph paper, and say, for any list of translate, scale and rotate calls, which order they happen in and which six numbers they leave behind.
You will be able to say what a clip is, as a byte for every pixel, and work out the edge pixel of a rectangle clip, of a fill, and of the two together, by hand, to the last byte.
You will be able to say what a gradient is, in words a child could follow: some colors pinned at some places, and a rule for the color in between.
You will be able to say what a blend mode is: for the twelve separable modes, a function of the source pixel and the backdrop pixel, on premultiplied bytes, with one piece that depends on the mode and two that do not.
You will be able to say how drawing an image into a rectangle becomes one question per destination pixel: where in the picture is the center of this pixel, and what color is there.
A rectangle, a stroke, a curve, a gradient and a shadow, written three ways, and a playbook for the whole book.