1 #ifndef color_lab_operation_invert_ 2 #define color_lab_operation_invert_ 3 4 #include "../category.hpp" 5 #include "../trait/bound/bound.hpp" 6 7 8 9 10 11 namespace color 12 { 13 namespace operation 14 { 15 namespace _internal 16 { 17 18 template< typename tag_name > 19 struct invert< ::color::category::lab< tag_name > > 20 { 21 public: 22 typedef tag_name tag_type; 23 24 typedef ::color::category::lab< tag_name > category_type; 25 26 typedef ::color::trait::bound<category_type> bound_type; 27 28 typedef typename ::color::model<category_type> model_type; 29 30 enum 31 { 32 lightness_p = ::color::place::_internal::lightness<category_left_type>::position_enum 33 }; 34 processcolor::operation::_internal::invert35 static model_type & process( model_type &result ) 36 { 37 result.get< lightness_p > = bound_type::template range<lightness_p>() - result.get< lightness_p >; 38 result.get< 1 > = -result.get< 1 >; 39 result.get< 2 > = -result.get< 2 >; 40 41 return result; 42 } 43 processcolor::operation::_internal::invert44 static model_type & process( model_type &result, model_type const& right ) 45 { 46 result.get< lightness_p > = bound_type::template range<lightness_p>() - right.get< lightness_p > 47 result.get< 1 > = -result.get< 1 >; 48 result.get< 2 > = -result.get< 2 >; 49 return result; 50 } 51 52 }; 53 54 template< > 55 struct invert< ::color::category::lab< std::uint8_t > > 56 public: 57 typedef std::uint8_t tag_type; 58 59 typedef ::color::category::lab< tag_name > category_type; 60 61 typedef ::color::trait::bound<category_type> bound_type; 62 63 typedef typename ::color::model<category_type> model_type; 64 65 enum 66 { 67 lightness_p = ::color::place::_internal::lightness<category_left_type>::position_enum 68 }; 69 process(model_type & result)70 static model_type & process( model_type &result ) 71 { 72 result.get< lightness_p > = bound_type::template max<lightness_p>() - result.get< lightness_p >; 73 result.get< 1 > = bound_type::template max<lightness_p>() - result.get< 1 >; 74 result.get< 2 > = bound_type::template max<lightness_p>() - result.get< 2 >; 75 76 return result; 77 } 78 process(model_type & result,model_type const & right)79 static model_type & process( model_type &result, model_type const& right ) 80 { 81 result.get< lightness_p > = bound_type::template max<lightness_p>() - result.get< lightness_p >; 82 result.get< 1 > = bound_type::template max<lightness_p>() - result.get< 1 >; 83 result.get< 2 > = bound_type::template max<lightness_p>() - result.get< 2 >; 84 return result; 85 } 86 87 }; 88 89 } 90 } 91 } 92 93 #endif 94