TuttleOFX
1
|
00001 // Copyright Tom Brinkman 2008. Distributed under the Boost 00002 // Software License, Version 1.0. (See accompanying 00003 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00004 00005 #ifndef _border_hpp_ 00006 #define _border_hpp_ 00007 00008 #include <boost/gil/gil_all.hpp> 00009 00010 namespace layer 00011 { 00012 00013 template <typename view_t> 00014 struct border 00015 { 00016 typedef typename view_t::value_type color_t; 00017 color_t clr; 00018 00019 border(color_t clr) : clr(clr) {} 00020 00021 void operator()(view_t& view) 00022 { 00023 using namespace boost::gil; 00024 00025 for (int x = 0; x < view.width(); ++x) 00026 { 00027 view(x,0) = clr; 00028 view(x,view.height()-1) = clr; 00029 } 00030 00031 for (int y = 0; y < view.height(); ++y) 00032 { 00033 view(0,y) = clr; 00034 view(view.width()-1,y) = clr; 00035 } 00036 } 00037 }; 00038 00039 template <typename view_t> 00040 struct raised_border 00041 { 00042 typedef typename view_t::value_type color_t; 00043 color_t dark,light; 00044 00045 raised_border(color_t light, color_t dark) : dark(dark), light(light) {} 00046 00047 void operator()(view_t& view) 00048 { 00049 using namespace boost::gil; 00050 00051 for (int x = 0; x < view.width(); ++x) 00052 view(x,0) = light; 00053 00054 for (int y = 0; y < view.height(); ++y) 00055 view(0,y) = light; 00056 00057 for (int y = 1; y < view.height(); ++y) 00058 view(view.width()-1,y) = dark; 00059 00060 for (int x = 0; x < view.width(); ++x) 00061 view(x,view.height()-1) = dark; 00062 } 00063 }; 00064 00065 } 00066 00067 #endif