diff -Nru blackbox-0.70.1.orig/lib/Image.cc blackbox-0.70.1/lib/Image.cc --- blackbox-0.70.1.orig/lib/Image.cc 2005-04-08 17:41:09.000000000 +0200 +++ blackbox-0.70.1/lib/Image.cc 2008-10-30 00:08:25.377434445 +0100 @@ -613,6 +613,8 @@ cdgradient(from, to, interlaced); else if (texture.texture() & bt::Texture::PipeCross) pcgradient(from, to, interlaced); + else if (texture.texture() & bt::Texture::SplitVertical) + svgradient(from, to, interlaced); if (texture.texture() & bt::Texture::Raised) raisedBevel(texture.borderWidth()); @@ -1412,6 +1414,164 @@ } } +void bt::Image::svgradient(const Color &from, const Color &to, + bool interlaced) { + // splitvertical gradient - based on openbox gradient_splitvertical + // http://icculus.org/openbox + // (badly) adapted from for Blackbox by Simone Rota + + double dry1, dgy1, dby1, dry2, dgy2, dby2, + dry3, dgy3, dby3, + yr1 = static_cast(from.red()+(from.red()>>2)), + yg1 = static_cast(from.green()+(from.green() >>2)), + yb1 = static_cast(from.blue()+(from.blue()>>2)), + yr2 = static_cast(from.red() ), + yg2 = static_cast(from.green()), + yb2 = static_cast(from.blue() ), + yr3 = static_cast(to.red() ), + yg3 = static_cast(to.green()), + yb3 = static_cast(to.blue() ), + yr3t = static_cast(to.red()+(to.red()>>4)), + yg3t = static_cast(to.green()+(to.green()>>4) ), + yb3t = static_cast(to.blue()+(to.blue()>>4)); + + if (yr1 > 0xFF) yr1 = 0xFF; + if (yg1 > 0xFF) yg1 = 0xFF; + if (yb1 > 0xFF) yb1 = 0xFF; + if (yr3t > 0xFF) yr3t = 0xFF; + if (yg3t > 0xFF) yg3t = 0xFF; + if (yb3t > 0xFF) yb3t = 0xFF; + + RGB *p = data; + unsigned int x, y, y1,y2,y3; + + + if (height <= 5) { + y1 = std::max((int)height/2, 0); + y2 = (height < 3 ? 0 : height % 2); + y3 = std::max((int)height/2, 1); + } else { + y1 = height/2 - (1 - (height % 2)); + y2 = 1; + y3 = height/2; + } + + dry1 = static_cast(from.red() - yr1); + dgy1 = static_cast(from.green() - yg1); + dby1 = static_cast(from.blue() - yb1); + dry2 = static_cast(to.red() - from.red() ); + dgy2 = static_cast(to.green() - from.green()); + dby2 = static_cast(to.blue() - from.blue() ); + dry3 = static_cast(yr3t - to.red()); + dgy3 = static_cast(yg3t - to.green()); + dby3 = static_cast(yb3t - to.blue()); + + dry1 /= y1; + dgy1 /= y1; + dby1 /= y1; + if (y2 > 0) { + dry2 /= (y2+2); + dgy2 /= (y2+2); + dby2 /= (y2+2); + yr2 += dry2; + yg2 += dgy2; + yb2 += dby2; + } + dry3 /= y3; + dgy3 /= y3; + dby3 /= y3; + + if (interlaced) { + // faked interlacing effect (feeling lazy - vertical gradient) + for (y = 0; y < height; ++y) { + const RGB rgb = { + static_cast((y & 1) ? (yr2 * 3. / 4.) : yr2), + static_cast((y & 1) ? (yg2 * 3. / 4.) : yg2), + static_cast((y & 1) ? (yb2 * 3. / 4.) : yb2), + 0 + }; + for (x = 0; x < width; ++x, ++p) + *p = rgb; + + yr2 += dry2; + yg2 += dgy2; + yb2 += dby2; + } + } else { + /* top half */ + for (y = y1-1; y > 0; --y) { + const RGB rgb = { + static_cast(yr1), + static_cast(yg1), + static_cast(yb1), + 0 + }; + for (x = 0; x < width; ++x, ++p) + *p = rgb; + + yr1 += dry1; + yg1 += dgy1; + yb1 += dby1; + } + const RGB rgb1 = { + static_cast(yr1), + static_cast(yg1), + static_cast(yb1), + 0 + }; + for (x = 0; x < width; ++x, ++p) + *p = rgb1; + + /* separator */ + for (y = y2-1; y > 0; --y) { + const RGB rgb = { + static_cast(yr2), + static_cast(yg2), + static_cast(yb2), + 0 + }; + for (x = 0; x < width; ++x, ++p) + *p = rgb; + + yr2 += dry2; + yg2 += dgy2; + yb2 += dby2; + } + const RGB rgb2 = { + static_cast(yr2), + static_cast(yg2), + static_cast(yb2), + 0 + }; + for (x = 0; x < width; ++x, ++p) + *p = rgb2; + + /* bottom half */ + for (y = y3-1; y > 0; --y) { + const RGB rgb = { + static_cast(yr3), + static_cast(yg3), + static_cast(yb3), + 0 + }; + for (x = 0; x < width; ++x, ++p) + *p = rgb; + + yr3 += dry3; + yg3 += dgy3; + yb3 += dby3; + } + const RGB rgb3 = { + static_cast(yr3), + static_cast(yg3), + static_cast(yb3), + 0 + }; + for (x = 0; x < width; ++x, ++p) + *p = rgb3; + + } +} void bt::Image::pgradient(const Color &from, const Color &to, bool interlaced) { diff -Nru blackbox-0.70.1.orig/lib/Image.hh blackbox-0.70.1/lib/Image.hh --- blackbox-0.70.1.orig/lib/Image.hh 2005-04-08 17:41:10.000000000 +0200 +++ blackbox-0.70.1/lib/Image.hh 2008-10-28 23:42:03.153031515 +0100 @@ -92,6 +92,7 @@ void vgradient(const Color &from, const Color &to, bool interlaced); void cdgradient(const Color &from, const Color &to, bool interlaced); void pcgradient(const Color &from, const Color &to, bool interlaced); + void svgradient(const Color &from, const Color &to, bool interlaced); static unsigned int global_maximumColors; static DitherMode global_ditherMode; diff -Nru blackbox-0.70.1.orig/lib/Texture.cc blackbox-0.70.1/lib/Texture.cc --- blackbox-0.70.1.orig/lib/Texture.cc 2005-03-15 08:01:36.000000000 +0100 +++ blackbox-0.70.1/lib/Texture.cc 2008-10-29 01:35:43.150776674 +0100 @@ -88,6 +88,8 @@ addTexture(bt::Texture::Elliptic); else if (descr.find("horizontal") != std::string::npos) addTexture(bt::Texture::Horizontal); + else if (descr.find("splitvertical") != std::string::npos) + addTexture(bt::Texture::SplitVertical); else if (descr.find("vertical") != std::string::npos) addTexture(bt::Texture::Vertical); else diff -Nru blackbox-0.70.1.orig/lib/Texture.hh blackbox-0.70.1/lib/Texture.hh --- blackbox-0.70.1.orig/lib/Texture.hh 2005-03-14 22:51:59.000000000 +0100 +++ blackbox-0.70.1/lib/Texture.hh 2008-10-28 23:30:32.111513673 +0100 @@ -92,7 +92,8 @@ // fake interlaced image Interlaced = (1l<<14), // border around image - Border = (1l<<15) + Border = (1l<<15), + SplitVertical = (1l<<16) }; inline Texture(void)