1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Interpolate (calculate) additional color, using two old colors.
11
(1) The first input color.
12
(2) The second input color.
13
(3) Pointer to GUIS structure.
19
The pixel value calculated.
22
=============================================================================*/
27
#include <X11/Xutil.h>
29
#include <X11/Xatom.h>
34
/*======interpolate color:===================================================*/
36
unsigned long InterpolateColor_ (unsigned long color1ID,
37
unsigned long color2ID,
40
unsigned long colorID;
41
unsigned long red_mask, green_mask, blue_mask;
42
unsigned long red1, red2, red;
43
unsigned long green1, green2, green;
44
unsigned long blue1, blue2, blue;
45
double r1, r2, g1, g2, b1, b2;
50
red_mask = guiSP->visual_infoS.red_mask;
51
green_mask = guiSP->visual_infoS.green_mask;
52
blue_mask = guiSP->visual_infoS.blue_mask;
54
/* Extract input color components: */
55
red1 = color1ID & red_mask;
56
red2 = color2ID & red_mask;
57
green1 = color1ID & green_mask;
58
green2 = color2ID & green_mask;
59
blue1 = color1ID & blue_mask;
60
blue2 = color2ID & blue_mask;
62
/* Convert to doubles: */
70
/* Calculate new color components: */
74
red = ((unsigned long) r) & red_mask;
75
green = ((unsigned long) g) & green_mask;
76
blue = ((unsigned long) b) & blue_mask;
78
/* Combine new color components: */
79
colorID = red | green | blue;
81
/* Return the pixel value: */
85
/*===========================================================================*/