-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathborderColorPicker.h
60 lines (54 loc) · 1.93 KB
/
borderColorPicker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* @file borderColorPicker.h
* Definition of a border color picker.
*
*/
#ifndef BORDERCOLORPICKER_H
#define BORDERCOLORPICKER_H
#include "colorPicker.h"
/**
* borderColorPicker: a functor that determines the color that should be used
* given an x and a y coordinate. If the given position is near a border of
* the fill, then it should be colored with the given color. Otherwise, its color
* should not change.
*
* The following criteria should be used to determine if a position p is near
* a border: if p is within distance 3 of any cell that will be outside the
* fill, then the pixel at position p should be colored with the given color.
*
* You will use Euclidian distance to judge proximity. That means if p is at
* location (x,y), its distance to a point at location (a,b) is
* squareRoot([(x-a)^2 + (y-b)^2]). Note that you should not ever have to
* compute the square root to solve this problem.
*
**/
class borderColorPicker : public colorPicker
{
public:
/**
* Constructs a new borderColorPicker.
*
* @param fillColor Color for the border .
* @param tolerance used to determine the border of the fill.
* @param center the color used to determine whether or not a point is within
* the fill region.
*/
borderColorPicker(HSLAPixel fillColor,PNG & img, double tolerance,HSLAPixel center);
/**
* Picks the color for pixel (x, y). If the x or y coordinate is
* near the border of the fill, or the border of the image,
* the fillColor will be returned.
* Otherwise, the current color of (x,y) will be returned.
*
* @param x The x coordinate to pick a color for.
* @param y The y coordinat to pick a color for.
* @return The color chosen for (x, y).
*/
virtual HSLAPixel operator()(int x, int y);
private:
HSLAPixel color; /**< Color used for the grid border. */
PNG im;
double tol;
HSLAPixel ctr;
};
#endif