home—info—labs—exams—hws
—D2L—MediaSamples/—breeze (snow day)—tutor/PIs
lab43
mixing images (conclusion)
Continuing on the idea of mixing images from last time:
Make a similar function mix, which is like mix1 except that
it makes a checkerboard pattern (bigger than a single-pixel square):
-
if our x,y position is exactly on a grid-outline, use black;
-
else if we're in an even grid-location (for grid of n x n pixels),
use the pixel from the first picture picture
-
else use the pixel from the second picture.
Use top-down design to write the above function,
inventing helper-functions (“the method of wishful thinking”);
then we can go back and complete those helper-functions later;
each helper-function will be a smaller/easier problem than the overall task.
Here is the solution.
home—info—labs—exams—hws
—D2L—MediaSamples/—breeze (snow day)—tutor/PIs