Subject: ?Gradient implementation in menus and titles

From: Dominik Vogt <[email-masked]>
Date: Fri, 20 Aug 1999 13:37:59 +0200

Tim, yesterday I tried to port the gradient styles from
Graphics.c for TitleStyle and consorts. But with the current
code I have to do this:

  - Create a pixmap with the gradient
  - Stretch the pixmap in X direction to the required width
    (creates a new Pixmap)
  - Stretch the pixmap in Y direction to the required height
    (creates a new Pixmap)
  - Copy the contents of the pixmap into the window title.
  - free all pixmaps

This is ***slow***. There are two ways to solve the problem.
We can either try to write code that handles pixmap background
for titles (which won't work well with the current ...Style code
because of the stacking of styles). Or we need gradient drawing
functions that allow to draw the gradients directly into a
drawable of a given size. What do you think about it? I'd prefer
the second approach, but I'm unwilling to duplicate the gradient
drawing code.

BTW, shouldn't the CreateStretchPixmap function work in a single
step instead of calling CreateX/YStretchPixmap? I think it will be
more efficient but not much more code.

Bye

Dominik ^_^

-- 
Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/14-4596, fax: 07031/14-3883, [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Tim Phipps <[email-masked]>
Date: Fri, 20 Aug 1999 15:08:20 +0100

> the second approach, but I'm unwilling to duplicate the gradient
I think it's possible by adding another 3 inputs to
CreateGradientPixmap(). The extra inputs would be the pixmap to draw
into (or NULL) and the size of the pixmap. CreateGradientPixmap()
assumes the pixmap size suits the gradient type so the code to put the
pixel values into the image would have to be scaled by
width/pixmap_width etc.  The image would have to be created to match the
pixmap size so the final XPutImage works properly.

The HGradient code would be

    case H_GRADIENT:
      for (i = 0; i < pixmap_width; i++) {
        register Pixel p = pixels[i * width / pixmap_width];
        for (j = 0; j < pixmap_height; j++)
          XPutPixel(image, i, j, p);
      }
      break;

where pixmap_width is the width of the input pixmap and "width" is the
width given by CalculateGradientDimensions(). I think this might also
fix the Tetris effect when making gradients with just a few colors.

> more efficient but not much more code.
Yes, just laziness on my part.

Cheers,
Tim.