00001 #ifndef __data_h__
00002 #define __data_h__
00003
00007 struct rgba {
00008 unsigned char r,
00009 g,
00010 b,
00011 a;
00012 };
00013
00014
00018 struct rgb {
00019 unsigned char r,
00020 g,
00021 b;
00022 rgb &operator=(rgba right) {
00023 r = right.r; g = right.g; b = right.b;
00024 return *this;
00025 }
00026
00027 rgb &operator+=(rgb right) {
00028 if ((int)r+(int)right.r > 255) r = 255;
00029 else r += right.r;
00030 if ((int)g+(int)right.g > 255) g = 255;
00031 else g += right.g;
00032 if ((int)b+(int)right.b > 255) b = 255;
00033 else b += right.b;
00034 return *this;
00035 }
00036
00037 rgb &operator*=(rgb right) {
00038 if ((int)r*(int)right.r > 255) r = 255;
00039 else r *= right.r;
00040 if ((int)g*(int)right.g > 255) g = 255;
00041 else g *= right.g;
00042 if ((int)b*(int)right.b > 255) b = 255;
00043 else b *= right.b;
00044 return *this;
00045 }
00046
00047 rgb &operator*=(double right) {
00048 if ((double)r*right > 255) r = 255;
00049 else r *= right;
00050 if ((double)g*right > 255) g = 255;
00051 else g *= right;
00052 if ((double)b*right > 255) b = 255;
00053 else b *= right;
00054 return *this;
00055 }
00056
00057 rgb operator*(rgb right) {
00058 rgb res;
00059 if ((int)r*(int)right.r > 255) res.r = 255;
00060 else res.r = r*right.r;
00061 if ((int)g*(int)right.g > 255) res.g = 255;
00062 else res.g = g*right.g;
00063 if ((int)b*(int)right.b > 255) res.b = 255;
00064 else res.b = b*right.b;
00065 return res;
00066 }
00067
00068 rgb operator*(double right) {
00069 rgb res;
00070 if ((double)r*right > 255) res.r = 255;
00071 else res.r = r*right;
00072 if ((double)g*right > 255) res.g = 255;
00073 else res.g = g*right;
00074 if ((double)b*right > 255) res.b = 255;
00075 else res.b = b*right;
00076 return res;
00077 }
00078
00079 };
00080
00084 struct vertex {
00085 float x,
00086 y,
00087 z;
00088 };
00089
00090 #endif