TODO: add entries for centralizing licensing and authorship information and incorpora...
[Ale.git] / d2 / spixel.h
blob559e048c41914be558ae1e65e89120ed8286324c
1 // Copyright 2002 David Hilvert <dhilvert@auricle.dyndns.org>,
2 // <dhilvert@ugcs.caltech.edu>
4 /* This file is part of the Anti-Lamenessing Engine.
6 The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the Anti-Lamenessing Engine; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __spixel_h__
22 #define __spixel_h__
25 * Structure to describe a pixel to be used in storage.
28 #define HALF 3
30 #if ALE_COLORS != HALF
32 typedef pixel spixel;
34 #else
36 class spixel {
37 private:
38 ale_sreal x[3];
40 public:
41 spixel() {
42 x[0] = 0;
43 x[1] = 0;
44 x[2] = 0;
47 spixel(pixel p) {
48 x[0] = p[0];
49 x[1] = p[1];
50 x[2] = p[2];
53 spixel(ale_sreal x0, ale_sreal x1, ale_sreal x2) {
54 x[0] = x0;
55 x[1] = x1;
56 x[2] = x2;
59 operator pixel() const {
60 pixel result;
62 result[0] = x[0];
63 result[1] = x[1];
64 result[2] = x[2];
66 return result;
69 const ale_sreal &operator[](int i) const {
70 assert (i >= 0);
71 assert (i < 3);
73 return x[i];
76 ale_sreal &operator[](int i) {
77 assert (i >= 0);
78 assert (i < 3);
80 return x[i];
83 spixel operator+=(pixel p) {
84 return spixel(x[0] += p[0], x[1] += p[1], x[2] += p[2]);
87 spixel operator*=(pixel p) {
88 return spixel(x[0] *= p[0], x[1] *= p[1], x[2] *= p[2]);
91 spixel operator*=(ale_real d) {
92 return spixel(x[0] *= d, x[1] *= d, x[2] *= d);
95 spixel operator/=(pixel p) {
96 return spixel(x[0] /= p[0], x[1] /= p[1], x[2] /= p[2]);
99 spixel operator/=(ale_real d) {
100 return spixel(x[0] /= d, x[1] /= d, x[2] /= d);
104 #endif
106 #undef HALF
108 #endif