1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /***************************************************************************
3  *            colour.h
4  *
5  *  Fri Oct 14 09:38:28 CEST 2011
6  *  Copyright 2011 Bent Bisballe Nyeng
7  *  deva@aasimon.org
8  ****************************************************************************/
9 
10 /*
11  *  This file is part of DrumGizmo.
12  *
13  *  DrumGizmo is free software; you can redistribute it and/or modify
14  *  it under the terms of the GNU Lesser General Public License as published by
15  *  the Free Software Foundation; either version 3 of the License, or
16  *  (at your option) any later version.
17  *
18  *  DrumGizmo is distributed in the hope that it will be useful,
19  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  *  GNU Lesser General Public License for more details.
22  *
23  *  You should have received a copy of the GNU Lesser General Public License
24  *  along with DrumGizmo; if not, write to the Free Software
25  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
26  */
27 #pragma once
28 
29 #include <array>
30 #include <cstdint>
31 
32 namespace GUI
33 {
34 
35 class Colour
36 {
37 public:
38 	Colour();
39 	Colour(float grey, float alpha = 1.0f);
40 	Colour(float red, float green, float blue, float alpha = 1.0f);
41 	Colour(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a);
42 	Colour(const Colour& other);
43 
44 	Colour& operator=(const Colour& other);
45 
46 	bool operator==(const Colour& other) const;
47 	bool operator!=(const Colour& other) const;
48 
red()49 	inline std::uint8_t red() const { return pixel[0]; }
green()50 	inline std::uint8_t green() const { return pixel[1]; }
blue()51 	inline std::uint8_t blue() const { return pixel[2]; }
alpha()52 	inline std::uint8_t alpha() const { return pixel[3]; }
53 
data()54 	std::uint8_t* data() { return pixel.data(); }
data()55 	const std::uint8_t* data() const { return pixel.data(); }
56 
57 private:
58 	std::array<std::uint8_t, 4> pixel{{255, 255, 255, 255}};
59 };
60 
61 } // GUI::
62