File: GriColor.hh

package info (click to toggle)
gri 2.4.2-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,540 kB
  • ctags: 1,966
  • sloc: cpp: 32,542; lisp: 3,243; perl: 806; makefile: 548; sh: 253
file content (47 lines) | stat: -rw-r--r-- 1,309 bytes parent folder | download
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
#ifndef _gricolor_h_
#define  _gricolor_h_

#include <string>
#include <stdio.h>
#include "types.hh"

class GriColor
{
public:
    enum type {rgb, hsv};
    GriColor() { t = rgb; a = b = c = 0.0;};
    GriColor(const GriColor& c);
    ~GriColor() {};
    GriColor& operator=(const GriColor& c);
    void setHSV(double H, double S, double V);
    void setRGB(double R, double G, double B);
    bool isRGB() const {return t == rgb;}
    void set_type(type tt) {t = tt;}
    type get_type() const {return t;}
    void getRGB(double *R, double *G, double *B) const;
    double getR() const {return a;}
    double getG() const {return b;}
    double getB() const {return c;}
    double getH() const {return a;}
    double getS() const {return b;}
    double getV() const {return c;}
protected:
    type t;
    double a;			// red, or hue
    double b;			// green, or saturation
    double c;			// blue, or brightness
};
class GriNamedColor : public GriColor
{
public:
    GriNamedColor();
    ~GriNamedColor();
    GriNamedColor(const char *n, double R, double G, double B);
    GriNamedColor(const GriNamedColor& C); 
    GriNamedColor& operator=(const GriNamedColor& C);
    void setNameRGB(const char *n, double R, double G, double B);
    char *getName() const {return name;}
private:
    char *name;
};
#endif