February 2019
Intermediate to advanced
292 pages
6h 55m
English
A canvas is just a rectangular grid of pixels—much like your computer screen. Your implementation will allow its size to be configurable, so you can specify how wide and high the canvas ought to be.
Add the following test to your suite. It demonstrates how a canvas is created and shows every pixel in the canvas should be initialized to black (color(0, 0, 0)).
| | Scenario: Creating a canvas |
| | Given c ← canvas(10, 20) |
| | Then c.width = 10 |
| | And c.height = 20 |
| | And every pixel of c is color(0, 0, 0) |
Pixels are drawn to the canvas by specifying a position and a color. Write the following test, introducing a function called write_pixel(canvas, x, y, color) and showing how it is used.
Read now
Unlock full access