Commit | Line | Data |
---|---|---|
3144ee8a AT |
1 | /* xscreensaver, Copyright (c) 1992-2013 Jamie Zawinski <jwz@jwz.org> |
2 | * | |
3 | * Permission to use, copy, modify, distribute, and sell this software and its | |
4 | * documentation for any purpose is hereby granted without fee, provided that | |
5 | * the above copyright notice appear in all copies and that both that | |
6 | * copyright notice and this permission notice appear in supporting | |
7 | * documentation. No representations are made about the suitability of this | |
8 | * software for any purpose. It is provided "as is" without express or | |
9 | * implied warranty. | |
10 | */ | |
11 | ||
12 | #ifndef __COLORS_H__ | |
13 | #define __COLORS_H__ | |
14 | ||
15 | /* Like XFreeColors, but works on `XColor *' instead of `unsigned long *' | |
16 | */ | |
17 | extern void free_colors (Screen *, Colormap, XColor *, int ncolors); | |
18 | ||
19 | ||
20 | /* Allocates writable, non-contiguous color cells. The number requested is | |
21 | passed in *ncolorsP, and the number actually allocated is returned there. | |
22 | (Unlike XAllocColorCells(), this will allocate as many as it can, instead | |
23 | of failing if they can't all be allocated.) | |
24 | */ | |
25 | extern void allocate_writable_colors (Screen *, Colormap, | |
26 | unsigned long *pixels, int *ncolorsP); | |
27 | ||
28 | ||
29 | /* Generates a sequence of colors evenly spaced between the given pair | |
30 | of HSV coordinates. | |
31 | ||
32 | If closed_p is true, the colors will go from the first point to the | |
33 | second then back to the first. | |
34 | ||
35 | If allocate_p is true, the colors will be allocated from the map; | |
36 | if enough colors can't be allocated, we will try for less, and the | |
37 | result will be returned to ncolorsP. | |
38 | ||
39 | If writable_p is true, writable color cells will be allocated; | |
40 | otherwise, read-only cells will be allocated. | |
41 | ||
42 | If allocate_p is false, screen and cmap are unused (OpenGL usage). | |
43 | */ | |
44 | extern void make_color_ramp (Screen *, Visual *, Colormap, | |
45 | int h1, double s1, double v1, | |
46 | int h2, double s2, double v2, | |
47 | XColor *colors, int *ncolorsP, | |
48 | Bool closed_p, | |
49 | Bool allocate_p, | |
50 | Bool *writable_pP); | |
51 | ||
52 | /* Generates a sequence of colors evenly spaced around the triangle | |
53 | indicated by the thee HSV coordinates. | |
54 | ||
55 | If allocate_p is true, the colors will be allocated from the map; | |
56 | if enough colors can't be allocated, we will try for less, and the | |
57 | result will be returned to ncolorsP. | |
58 | ||
59 | If writable_p is true, writable color cells will be allocated; | |
60 | otherwise, read-only cells will be allocated. | |
61 | ||
62 | If allocate_p is false, screen, visual and cmap are unused (OpenGL usage). | |
63 | */ | |
64 | extern void make_color_loop (Screen *, Visual *, Colormap, | |
65 | int h1, double s1, double v1, | |
66 | int h2, double s2, double v2, | |
67 | int h3, double s3, double v3, | |
68 | XColor *colors, int *ncolorsP, | |
69 | Bool allocate_p, | |
70 | Bool *writable_pP); | |
71 | ||
72 | ||
73 | /* Allocates a hopefully-interesting colormap, which will be a closed loop | |
74 | without any sudden transitions. | |
75 | ||
76 | If allocate_p is true, the colors will be allocated from the map; | |
77 | if enough colors can't be allocated, we will try for less, and the | |
78 | result will be returned to ncolorsP. An error message will be | |
79 | printed on stderr (if verbose_p). | |
80 | ||
81 | If *writable_pP is true, writable color cells will be allocated; | |
82 | otherwise, read-only cells will be allocated. If no writable cells | |
83 | cannot be allocated, we will try to allocate unwritable cells | |
84 | instead, and print a message on stderr to that effect (if verbose_p). | |
85 | ||
86 | If allocate_p is false, screen, visual and cmap are unused (OpenGL usage). | |
87 | */ | |
88 | extern void make_smooth_colormap (Screen *, Visual *, Colormap, | |
89 | XColor *colors, int *ncolorsP, | |
90 | Bool allocate_p, | |
91 | Bool *writable_pP, | |
92 | Bool verbose_p); | |
93 | ||
94 | /* Allocates a uniform colormap which touches each hue of the spectrum, | |
95 | evenly spaced. The saturation and intensity are chosen randomly, but | |
96 | will be high enough to be visible. | |
97 | ||
98 | If allocate_p is true, the colors will be allocated from the map; | |
99 | if enough colors can't be allocated, we will try for less, and the | |
100 | result will be returned to ncolorsP. An error message will be | |
101 | printed on stderr (if verbose_p). | |
102 | ||
103 | If *writable_pP is true, writable color cells will be allocated; | |
104 | otherwise, read-only cells will be allocated. If no writable cells | |
105 | cannot be allocated, we will try to allocate unwritable cells | |
106 | instead, and print a message on stderr to that effect (if verbose_p). | |
107 | ||
108 | If allocate_p is false, screen, visual and cmap are unused (OpenGL usage). | |
109 | */ | |
110 | extern void make_uniform_colormap (Screen *, Visual *, Colormap, | |
111 | XColor *colors, int *ncolorsP, | |
112 | Bool allocate_p, | |
113 | Bool *writable_pP, | |
114 | Bool verbose_p); | |
115 | ||
116 | /* Allocates a random colormap (the colors are unrelated to one another.) | |
117 | If `bright_p' is false, the colors will be completely random; if it is | |
118 | true, all of the colors will be bright enough to see on a black background. | |
119 | ||
120 | If allocate_p is true, the colors will be allocated from the map; | |
121 | if enough colors can't be allocated, we will try for less, and the | |
122 | result will be returned to ncolorsP. An error message will be | |
123 | printed on stderr (if verbose_p). | |
124 | ||
125 | If *writable_pP is true, writable color cells will be allocated; | |
126 | otherwise, read-only cells will be allocated. If no writable cells | |
127 | cannot be allocated, we will try to allocate unwritable cells | |
128 | instead, and print a message on stderr to that effect (if verbose_p). | |
129 | ||
130 | If allocate_p is false, screen, visual and cmap are unused (OpenGL usage). | |
131 | */ | |
132 | extern void make_random_colormap (Screen *, Visual *, Colormap, | |
133 | XColor *colors, int *ncolorsP, | |
134 | Bool bright_p, | |
135 | Bool allocate_p, | |
136 | Bool *writable_pP, | |
137 | Bool verbose_p); | |
138 | ||
139 | ||
140 | /* Assuming that the array of colors indicates the current state of a set | |
141 | of writable color cells, this rotates the contents of the array by | |
142 | `distance' steps, moving the colors of cell N to cell (N - distance). | |
143 | */ | |
144 | extern void rotate_colors (Screen *, Colormap, | |
145 | XColor *, int ncolors, int distance); | |
146 | ||
147 | #endif /* __COLORS_H__ */ |