all repos — fluxbox @ 94fddc09c064555721dc521e3e94ed6f610653b9

custom fork of the fluxbox windowmanager

Fix bug in renderEllipticGradient()

For odd 'widths' and 'heigths' the texture would not be filled completely:
Given a 'width' of 5 we would render only 4 instances of x (-2, 1, 0, 1)
instead of the needed 5. This results in a texture which looks a bit cut off
to the bottom right side.
Mathias Gumz akira at fluxbox dot org
commit

94fddc09c064555721dc521e3e94ed6f610653b9

parent

0b41d0b908429053f3adcc1ce690ef6d1bfbcdf0

1 files changed, 20 insertions(+), 17 deletions(-)

jump to
M src/FbTk/TextureRender.ccsrc/FbTk/TextureRender.cc

@@ -570,31 +570,34 @@ FbTk::RGBA* rgba,

const FbTk::Color* from, const FbTk::Color* to, FbTk::ImageControl& imgctrl) { - size_t i; - int x; - int y; + const double r = to->red(); + const double g = to->green(); + const double b = to->blue(); + const double dr = r - from->red(); + const double dg = g - from->green(); + const double db = b - from->blue(); - double r = to->red(); - double g = to->green(); - double b = to->blue(); + const double w2 = width / 2.0; + const double h2 = height / 2.0; - double dr = r - from->red(); - double dg = g - from->green(); - double db = b - from->blue(); + const double sw = 1.0 / (w2 * w2); + const double sh = 1.0 / (h2 * h2); - int w2 = width/2; - int h2 = height/2; - + size_t i; + int x; + int y; + double _x; + double _y; double d; - for (i = 0, y = -h2; y < h2; ++y) { - for (x = -w2; x < w2; ++x, ++i) { + for (i = 0, y = 0; y < height; ++y) { + for (x = 0; x < width; ++x, ++i) { - d = ((double)(x*x) / (double)(w2*w2)) - + ((double)(y*y) / (double)(h2*h2)); + _x = x - w2; + _y = y - h2; - d *= 0.5; + d = ((_x * _x * sw) + (_y * _y * sh)) / 2.0; rgba[i].r = (unsigned char)(r - (d * dr)); rgba[i].g = (unsigned char)(g - (d * dg));