00001
00002
00003
00004
00005 #ifndef shape_color_hpp
00006 #define shape_color_hpp
00007
00008 #include <iostream>
00009 #include <shape/shape.hpp>
00010 # define TMPL template<class K>
00011 # define SELF color<K>
00012 # define Shape geometric<K>
00013
00014 namespace mmx {
00015 namespace shape {
00016
00017
00018
00019 struct color_def {};
00020
00021 TMPL struct color;
00022
00023 template<> struct use<color_def>
00024 {
00025 typedef color<double> Color;
00026 };
00027
00028 TMPL struct color
00029 {
00030 float r,g,b;
00031 color(): r(0.314),g(0.979),b(1){}
00032 color(double x, double y, double z): r(x),g(y),b(z){}
00033 color(int x, int y, int z): r(x/255.),g(y/255.),b(z/255.){}
00034 color(const SELF& c): r(c.r),g(c.g),b(c.b){}
00035 color& operator= (const SELF & c)
00036 {
00037 r=c.r; g=c.g; b=c.b; return *this;
00038 }
00039 };
00040
00041 TMPL
00042 inline std::ostream& operator<<(std::ostream& os, const SELF & c)
00043 {
00044 os <<"Color("<<c.r<<","<<c.g<<","<<c.b<<")"; return os;
00045 }
00046
00047 }}
00048
00049 # undef TMPL
00050 # undef Shape
00051 # undef SELF
00052 # endif