diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2013-02-06 07:53:59 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2013-02-06 07:54:09 (GMT) |
commit | 94fddc09c064555721dc521e3e94ed6f610653b9 (patch) | |
tree | ea3d83221c934ae177adfb9ebb2e48af05e9a1fb | |
parent | 0b41d0b908429053f3adcc1ce690ef6d1bfbcdf0 (diff) | |
download | fluxbox_pavel-94fddc09c064555721dc521e3e94ed6f610653b9.zip fluxbox_pavel-94fddc09c064555721dc521e3e94ed6f610653b9.tar.bz2 |
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.
-rw-r--r-- | src/FbTk/TextureRender.cc | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index df7a550..68b98df 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc | |||
@@ -570,31 +570,34 @@ void renderEllipticGradient(bool interlaced, | |||
570 | const FbTk::Color* from, const FbTk::Color* to, | 570 | const FbTk::Color* from, const FbTk::Color* to, |
571 | FbTk::ImageControl& imgctrl) { | 571 | FbTk::ImageControl& imgctrl) { |
572 | 572 | ||
573 | size_t i; | 573 | const double r = to->red(); |
574 | int x; | 574 | const double g = to->green(); |
575 | int y; | 575 | const double b = to->blue(); |
576 | 576 | ||
577 | const double dr = r - from->red(); | ||
578 | const double dg = g - from->green(); | ||
579 | const double db = b - from->blue(); | ||
577 | 580 | ||
578 | double r = to->red(); | 581 | const double w2 = width / 2.0; |
579 | double g = to->green(); | 582 | const double h2 = height / 2.0; |
580 | double b = to->blue(); | ||
581 | 583 | ||
582 | double dr = r - from->red(); | 584 | const double sw = 1.0 / (w2 * w2); |
583 | double dg = g - from->green(); | 585 | const double sh = 1.0 / (h2 * h2); |
584 | double db = b - from->blue(); | ||
585 | |||
586 | int w2 = width/2; | ||
587 | int h2 = height/2; | ||
588 | 586 | ||
587 | size_t i; | ||
588 | int x; | ||
589 | int y; | ||
590 | double _x; | ||
591 | double _y; | ||
589 | double d; | 592 | double d; |
590 | 593 | ||
591 | for (i = 0, y = -h2; y < h2; ++y) { | 594 | for (i = 0, y = 0; y < height; ++y) { |
592 | for (x = -w2; x < w2; ++x, ++i) { | 595 | for (x = 0; x < width; ++x, ++i) { |
593 | 596 | ||
594 | d = ((double)(x*x) / (double)(w2*w2)) | 597 | _x = x - w2; |
595 | + ((double)(y*y) / (double)(h2*h2)); | 598 | _y = y - h2; |
596 | 599 | ||
597 | d *= 0.5; | 600 | d = ((_x * _x * sw) + (_y * _y * sh)) / 2.0; |
598 | 601 | ||
599 | rgba[i].r = (unsigned char)(r - (d * dr)); | 602 | rgba[i].r = (unsigned char)(r - (d * dr)); |
600 | rgba[i].g = (unsigned char)(g - (d * dg)); | 603 | rgba[i].g = (unsigned char)(g - (d * dg)); |