Back to index

kdeartwork  4.3.2
xs_colors.h
Go to the documentation of this file.
00001 /* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski <jwz@jwz.org>
00002  *
00003  * Permission to use, copy, modify, distribute, and sell this software and its
00004  * documentation for any purpose is hereby granted without fee, provided that
00005  * the above copyright notice appear in all copies and that both that
00006  * copyright notice and this permission notice appear in supporting
00007  * documentation.  No representations are made about the suitability of this
00008  * software for any purpose.  It is provided "as is" without express or 
00009  * implied warranty.
00010  */
00011 
00012 #ifndef __COLORS_H__
00013 #define __COLORS_H__
00014 
00015 /* Like XFreeColors, but works on `XColor *' instead of `unsigned long *'
00016  */
00017 extern void free_colors (Display *, Colormap, XColor *, int ncolors);
00018 
00019 
00020 /* Allocates writable, non-contiguous color cells.  The number requested is
00021    passed in *ncolorsP, and the number actually allocated is returned there.
00022    (Unlike XAllocColorCells(), this will allocate as many as it can, instead
00023    of failing if they can't all be allocated.)
00024  */
00025 extern void allocate_writable_colors (Display *dpy, Colormap cmap,
00026                                   unsigned long *pixels, int *ncolorsP);
00027 
00028 
00029 /* Generates a sequence of colors evenly spaced between the given pair
00030    of HSV coordinates.
00031 
00032    If closed_p is true, the colors will go from the first point to the
00033    second then back to the first.
00034 
00035    If allocate_p is true, the colors will be allocated from the map;
00036    if enough colors can't be allocated, we will try for less, and the
00037    result will be returned to ncolorsP.
00038 
00039    If writable_p is true, writable color cells will be allocated;
00040    otherwise, read-only cells will be allocated.
00041  */
00042 extern void make_color_ramp (Display *dpy, Colormap cmap,
00043                           int h1, double s1, double v1,
00044                           int h2, double s2, double v2,
00045                           XColor *colors, int *ncolorsP,
00046                           Bool closed_p,
00047                           Bool allocate_p,
00048                           Bool writable_p);
00049 
00050 /* Generates a sequence of colors evenly spaced around the triangle
00051    indicated by the thee HSV coordinates.
00052 
00053    If allocate_p is true, the colors will be allocated from the map;
00054    if enough colors can't be allocated, we will try for less, and the
00055    result will be returned to ncolorsP.
00056 
00057    If writable_p is true, writable color cells will be allocated;
00058    otherwise, read-only cells will be allocated.
00059  */
00060 extern void make_color_loop (Display *, Colormap,
00061                           int h1, double s1, double v1,
00062                           int h2, double s2, double v2,
00063                           int h3, double s3, double v3,
00064                           XColor *colors, int *ncolorsP,
00065                           Bool allocate_p,
00066                           Bool writable_p);
00067 
00068 
00069 /* Allocates a hopefully-interesting colormap, which will be a closed loop
00070    without any sudden transitions.
00071 
00072    If allocate_p is true, the colors will be allocated from the map;
00073    if enough colors can't be allocated, we will try for less, and the
00074    result will be returned to ncolorsP.  An error message will be
00075    printed on stderr (if verbose_p).
00076 
00077    If *writable_pP is true, writable color cells will be allocated;
00078    otherwise, read-only cells will be allocated.  If no writable cells
00079    cannot be allocated, we will try to allocate unwritable cells
00080    instead, and print a message on stderr to that effect (if verbose_p).
00081  */
00082 extern void make_smooth_colormap (Display *dpy, Visual *visual,
00083                               Colormap cmap,
00084                               XColor *colors, int *ncolorsP,
00085                               Bool allocate_p,
00086                               Bool *writable_pP,
00087                               Bool verbose_p);
00088 
00089 /* Allocates a uniform colormap which touches each hue of the spectrum,
00090    evenly spaced.  The saturation and intensity are chosen randomly, but
00091    will be high enough to be visible.
00092 
00093    If allocate_p is true, the colors will be allocated from the map;
00094    if enough colors can't be allocated, we will try for less, and the
00095    result will be returned to ncolorsP.  An error message will be
00096    printed on stderr (if verbose_p).
00097 
00098    If *writable_pP is true, writable color cells will be allocated;
00099    otherwise, read-only cells will be allocated.  If no writable cells
00100    cannot be allocated, we will try to allocate unwritable cells
00101    instead, and print a message on stderr to that effect (if verbose_p).
00102  */
00103 extern void make_uniform_colormap (Display *dpy, Visual *visual,
00104                                Colormap cmap,
00105                                XColor *colors, int *ncolorsP,
00106                                Bool allocate_p,
00107                                Bool *writable_pP,
00108                                Bool verbose_p);
00109 
00110 /* Allocates a random colormap (the colors are unrelated to one another.)
00111    If `bright_p' is false, the colors will be completely random; if it is
00112    true, all of the colors will be bright enough to see on a black background.
00113 
00114    If allocate_p is true, the colors will be allocated from the map;
00115    if enough colors can't be allocated, we will try for less, and the
00116    result will be returned to ncolorsP.  An error message will be
00117    printed on stderr (if verbose_p).
00118 
00119    If *writable_pP is true, writable color cells will be allocated;
00120    otherwise, read-only cells will be allocated.  If no writable cells
00121    cannot be allocated, we will try to allocate unwritable cells
00122    instead, and print a message on stderr to that effect (if verbose_p).
00123  */
00124 extern void make_random_colormap (Display *dpy, Visual *visual,
00125                               Colormap cmap,
00126                               XColor *colors, int *ncolorsP,
00127                               Bool bright_p,
00128                               Bool allocate_p,
00129                               Bool *writable_pP,
00130                               Bool verbose_p);
00131 
00132 
00133 /* Assuming that the array of colors indicates the current state of a set
00134    of writable color cells, this rotates the contents of the array by
00135    `distance' steps, moving the colors of cell N to cell (N - distance).
00136  */
00137 extern void rotate_colors (Display *, Colormap,
00138                         XColor *, int ncolors, int distance);
00139 
00140 #endif /* __COLORS_H__ */