mp_traversals
Terrible Traversals
GradientColorPicker Class Reference

A color picker class using gradient color picking algorithm. More...

#include <GradientColorPicker.h>

Inheritance diagram for GradientColorPicker:
[legend]
Collaboration diagram for GradientColorPicker:
[legend]

Public Member Functions

 GradientColorPicker (HSLAPixel color1, HSLAPixel color2, Point center, unsigned radius)
 GradientColorPicker constructor. More...
 
HSLAPixel getColor (unsigned x, unsigned y)
 Picks the color for pixel (x, y). More...
 
- Public Member Functions inherited from ColorPicker
virtual ~ColorPicker ()
 Class destructor. More...
 

Detailed Description

A color picker class using gradient color picking algorithm.

Constructor & Destructor Documentation

◆ GradientColorPicker()

GradientColorPicker::GradientColorPicker ( HSLAPixel  color1,
HSLAPixel  color2,
Point  center,
unsigned  radius 
)

GradientColorPicker constructor.

Member Function Documentation

◆ getColor()

HSLAPixel GradientColorPicker::getColor ( unsigned  x,
unsigned  y 
)
virtual

Picks the color for pixel (x, y).

The first color fades into the second color as you move from the initial fill point, the center, to the radius. Beyond the radius, all pixels should be just color2.

You should calculate the distance between two points using the standard euclidean distance formula.

Then, scale each of the three channels (H, S, and L) from color1 to color2 linearly from d = 0 to d = radius.

Parameters
xThe x coordinate to pick a color for.
yThe y coordinate to pick a color for.
Returns
The color selected for (x, y).

Implements ColorPicker.


The documentation for this class was generated from the following files: