DEPARTMENT OF COMPUTING

CS 3005: Programming in C++

Paint By Numbers (NumberGrid)

A two-dimensional grid of values can be represented in several different ways in software. One way is to use a one-dimensional array and use a function to translate from the two-dimensional coordinates to the one-dimensional index. This is like the way you have been storing three-dimensional data in the PPM class.

Assignment

This assignment will extend the previous menu based program to allow the user to “paint by numbers”. The user will store a single number per location in a grid. Your program will create an image with the same height and width as the grid, and translate the numbers into colors for the pixels.

For example, every place the user stores the number 3 in the grid will have the same pixel color values in the image.

Our implementation will require a class to store and manage a two dimensional grid of integers. The number grid will use a height and width to manage the dimensions of the data. When a value is read or written, a row and a column must be specified to uniquely identify the value. Values may only be in the range 0 through a maximum configured value. The maximum configured value can be any integer in the range 0 to 2^31 - 1 (roughly 2 billion).

The ppm_menu program will have a few new commands:

Programming Requirements

The following files must be updated or created and stored in the src directory of your repository.

Create NumberGrid.{h,cpp}

Declare the NumberGrid class in the header file, and implement its methods in the implementation file. Descriptions of the data members and methods follow. This class will be used to store a rectangular grid of numbers. The numbers will be used to select colors to assign to pixels in an image.

Data Members:

Methods:

Number in Grid Color (R, G, B)
0 (0, 0, 0)
maximum value allowed in the grid (63, 31, 31)
number % 8 == 0 (63, 63, 63)
number % 8 == 1 (63, 31, 31)
number % 8 == 2 (63, 63, 31)
number % 8 == 3 (31, 63, 31)
number % 8 == 4 (0, 0, 0)
number % 8 == 5 (31, 63, 63)
number % 8 == 6 (31, 31, 63)
number % 8 == 7 (63, 31, 63)

Updates to ActionData.{h,cpp}

Additional Data Members:

Updated Methods:

Additional Methods:

Update image_menu.h and image_drawing.cpp

The follow functions must be declared and implemented.

Update controllers.cpp

The following functions will require updates to their implementations.

Table of New Commands

Command Name Function Name Description
grid configureGrid Configure the grid.
grid-set setGrid Set a single value in the grid.
grid-apply applyGrid Use the grid values to set colors in the output image.

Update Makefile

The following commands should work correctly.

Additional Documentation

Show Off Your Work

To receive credit for this assignment, you must

Additionally, the program must build, run and give correct output.

Extra Challenges (Not Required)

Last Updated 10/13/2023