~ubuntu-branches/ubuntu/breezy/garlic/breezy

« back to all changes in this revision

Viewing changes to prepare_color.c

  • Committer: Bazaar Package Importer
  • Author(s): zhaoway
  • Date: 2001-04-24 07:09:13 UTC
  • Revision ID: james.westby@ubuntu.com-20010424070913-uzpupnwdfhmliebz
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 Damir Zucic */
 
2
 
 
3
/*=============================================================================
 
4
 
 
5
                                prepare_color.c
 
6
 
 
7
Purpose:
 
8
        Prepare the color by mixing two colors, using the proper weighting.
 
9
 
 
10
Input:
 
11
        (1) Pointer to RGBS structure, with the first color.
 
12
        (2) Pointer to RGBS structure, with the second color.
 
13
        (3) Scale factor (double).
 
14
        (4) Pointer to GUIS structure.
 
15
 
 
16
Output:
 
17
        (1) Return value.
 
18
 
 
19
Return value:
 
20
        The pixel value for the new color.
 
21
 
 
22
 
 
23
=============================================================================*/
 
24
 
 
25
#include <stdio.h>
 
26
 
 
27
#include <X11/Xlib.h>
 
28
#include <X11/Xutil.h>
 
29
#include <X11/Xos.h>
 
30
#include <X11/Xatom.h>
 
31
 
 
32
#include "defines.h"
 
33
#include "typedefs.h"
 
34
 
 
35
/*======function prototypes:=================================================*/
 
36
 
 
37
unsigned long   PixelFromRGBS_ (RGBS *, GUIS *);
 
38
 
 
39
/*======mix two colors:======================================================*/
 
40
 
 
41
unsigned long PrepareColor_ (RGBS *rgb1SP, RGBS *rgb2SP,
 
42
                             double scale_factor, GUIS *guiSP)
 
43
{
 
44
unsigned long           colorID;
 
45
double                  color1, delta_color, color;
 
46
RGBS                    rgbS;
 
47
 
 
48
/* Red: */
 
49
color1  = (double) rgb1SP->red;
 
50
delta_color = (double) rgb2SP->red - (double) rgb1SP->red;
 
51
color = color1 + scale_factor * delta_color;
 
52
rgbS.red    = (unsigned short) color;
 
53
 
 
54
/* Green: */
 
55
color1  = (double) rgb1SP->green;
 
56
delta_color = (double) rgb2SP->green - (double) rgb1SP->green;
 
57
color = color1 + scale_factor * delta_color;
 
58
rgbS.green  = (unsigned short) color;
 
59
 
 
60
/* Blue: */
 
61
color1  = (double) rgb1SP->blue;
 
62
delta_color = (double) rgb2SP->blue - (double) rgb1SP->blue;
 
63
color = color1 + scale_factor * delta_color;
 
64
rgbS.blue   = (unsigned short) color;
 
65
 
 
66
/* Pixel value: */
 
67
colorID = PixelFromRGBS_ (&rgbS, guiSP);
 
68
 
 
69
/* Return the pixel value: */
 
70
return colorID;
 
71
}
 
72
 
 
73
/*===========================================================================*/
 
74
 
 
75