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,
25 * Revision 1.1 2000/12/03 18:58:41 id
26 * initiate plugins branch
28 * Revision 1.1.1.1 1999/02/21 17:16:47 gloth
39 RImage
*waves(int argc
, char **argv
, int width
, int height
, int relief
)
42 int i
, j
, k
, done
, sine
[256];
43 int from
[3] = { 0x00, 0x00, 0x00 };
44 int to
[3] = { 0xff, 0xff, 0xff };
45 int layers
, range
, dx
[1000], dy
[1000];
53 for (done
= 0; !done
;) {
54 static struct option long_options
[] = {
60 c
= getopt_long(argc
, argv
, "f:t:", long_options
, &option_index
);
67 if (!parse_color(optarg
, from
)) {
68 error("invalid color: %s\n", optarg
);
73 if (!parse_color(optarg
, to
)) {
74 error("invalid color: %s\n", optarg
);
87 if (!start_image("waves", argc
, 2, 3, width
, height
, &image
)) {
91 layers
= atoi(argv
[0]);
92 range
= atoi(argv
[1]);
105 for (i
= 0; i
< 256; i
++) {
106 sine
[i
] = (int)(127.0 * sin(2.0 * M_PI
* i
/ 256)) + 128;
111 for (i
= 0; i
< layers
; i
++) {
112 dx
[i
] = random_int(range
) - range
/ 2;
113 dy
[i
] = random_int(range
) - range
/ 2;
117 for (i
= 0; i
< height
; i
++) {
118 for (j
= 0; j
< width
; j
++) {
119 int output
[3], value
= 0;
120 for (k
= 0; k
< layers
; k
++) {
121 value
+= sine
[(j
* dx
[k
] + i
* dy
[k
]) & 255];
123 interpolate_color(output
, from
, to
, value
/ layers
);
127 if (RRGBAFormat
== image
->format
)