2 * libwmfun - WindowMaker texture function library
3 * Copyright (C) 1999 Tobias Gloth
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 RImage *fade(int argc, char **argv, int width, int height, int relief)
31 int from[3] = { 0x00, 0x00, 0x00 };
32 int to[3] = { 0xff, 0xff, 0xff };
39 int c, done, option_index = 0;
42 for (done = 0; !done;) {
43 static struct option long_options[] = {
49 c = getopt_long(argc, argv, "f:t:", long_options, &option_index);
56 if (!parse_color(optarg, from)) {
57 error("invalid color: %s\n", optarg);
62 if (!parse_color(optarg, to)) {
63 error("invalid color: %s\n", optarg);
76 if (!start_image("fade", argc, 0, 1, width, height, &image)) {
80 this = (int *)malloc(width * sizeof(int));
81 last = (int *)malloc(width * sizeof(int));
89 for (i = 0; i < width; i++) {
93 factor = pow(0.2, 1.0 / height);
94 delta = (factor < 0.5) ? 2.0 * factor : 2.0 * (1.0 - factor);
99 for (j = 0; j < height; j++) {
100 memcpy(last, this, width * sizeof(int));
101 for (i = 0; i < width; i++) {
103 int k = i + random_int(3) - 1;
104 double f = factor + random_double(delta) - delta / 2.0;
113 this[i] = (int)(f * last[k]);
114 interpolate_color(output, from, to, this[i]);
118 if (RRGBAFormat == image->format)