summaryrefslogtreecommitdiff
path: root/hyp2mat/lib/palette.h
blob: 146e358da9bddf7dc5fe6dea0bbbf5373e104a34 (plain)
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
/*
 * hyp2mat - convert hyperlynx files to matlab scripts
 * Copyright 2012 Koen De Vleeschauwer.
 *
 * This file is part of hyp2mat.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * Generate a palette of colors, given hue, saturation and value (brightness).
 * The number of colors needed may be specified, but does not need to be known in advance.
 * After Martin Ankerl "How to Generate Random Colors Programmatically"
 */

#ifndef PALETTE_H
#define PALETTE_H

struct PaletteColor {
  double red;
  double green;
  double blue;
  };

class Palette {
public:
  Palette();
  /* hue, saturation and value (brightness) are double, in range 0..1. (HSV color model) */
  void SetPalette(double hue, double saturation, double value); /* HSV model */
  /* Set the number of colors in the palette. If the number of colors is not known in advance, choose 0 */
  void SetNumberOfColors(unsigned int number_of_colors);
  /* Return palette color */
  PaletteColor Color(int color);

private:
  double palette_hue;
  double palette_saturation;
  double palette_value;
  double step;
  };

#endif

/* not truncated */