DEPARTMENT OF COMPUTING

CS 3005: Programming in C++

Color Table

Introduction

A color table is an array of colors. It is useful for translating a single number in a range (an index) into a color (RGB values), reliably and repeatedly.

We will use a color table to translate grid numbers into colors to create colorful images.

Assignment

The ppm_menu program needs to add a few new commands to allow the user to configure the color table, and to use it.

The new commands required are:

This functionality will be implemented by creating a class to store a single RGB Color, and a ColorTableclass to store a vector of Color objects.

Programming Requirements

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

Create ColorTable.{h,cpp}

These files will be used to declare and define both the Color and the ColorTable classes.

Color class

Data Members:

Methods:

Additional support functions for the Color class:

ColorTable class

Data Members:

Methods:

Creating a static Color object to return in error cases.

{
    static Color ec( -1, -1, -1 );
    static Color c( -1, -1, -1 );
    c = ec;
    return c;
}

Update NumberGrid.{h,cpp}

You will add a method to set a PPM object from the grid numbers, using a ColorTable instead of the built in table with 8 colors. Do not remove the previous method. Just add this one.

Add this method:

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

Table of New Commands

Command Name Function Name Description
set-color-table-size setColorTableSize Change the number of slots in the color table.
set-color setColor Set the RGB values for one slot in the color table.
set-random-color setRandomColor Randomly set the RGB values for one slot in the color table.
set-color-gradient setColorGradient Smoothly set the RGB values for a range of slots in the color table.
grid-apply-color-table applyGridColorTable Use the grid values to set colors in the output image using the color table.

Update ppm_menu.cpp

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 09/11/2023