rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / x11 / xcolor / src / XCrHsbCmap.c
blob5da95d5d143a0e41b09f1fb6493a0a9825d7750a
1 /*-
2 * XCrHsbCmap.c - X11 library routine to create an HSB ramp colormaps.
4 * Copyright (c) 1991, 2011, Oracle and/or its affiliates. All rights reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
25 * Author: Patrick J. Naughton
26 * naughton@sun.com
29 #include <X11/X.h>
30 #include <X11/Xos.h>
31 #include <X11/Xlib.h>
32 #include "xcolor.h"
34 Status
35 XCreateHSBColormap(
36 Display *dsp,
37 int screen,
38 Colormap *cmap, /* colormap return value */
39 int count, /* number of entries to use */
40 double h1, /* starting hue */
41 double s1, /* starting saturation */
42 double b1, /* starting brightness */
43 double h2, /* ending hue */
44 double s2, /* ending saturation */
45 double b2, /* ending brightness */
46 int bw, /* Boolean: True = save black and white */
47 Visual **visual)
49 u_char red[256];
50 u_char green[256];
51 u_char blue[256];
52 unsigned long pixel;
53 Status status;
54 XColor xcolors[256];
56 if (count > 256)
57 return BadValue;
59 HSBramp(h1, s1, b1, h2, s2, b2, 0, count - 1, red, green, blue);
61 if (bw) {
62 pixel = WhitePixel(dsp, screen);
63 if (pixel < 256)
64 red[pixel] = green[pixel] = blue[pixel] = 0xff;
66 pixel = BlackPixel(dsp, screen);
67 if (pixel < 256)
68 red[pixel] = green[pixel] = blue[pixel] = 0;
70 status = XCreateDynamicColormap(dsp, screen, cmap, visual, xcolors,
71 count, red, green, blue);
73 return status;