1/*
2Open Tracker License
3
4Terms and Conditions
5
6Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy of
9this software and associated documentation files (the "Software"), to deal in
10the Software without restriction, including without limitation the rights to
11use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12of the Software, and to permit persons to whom the Software is furnished to do
13so, subject to the following conditions:
14
15The above copyright notice and this permission notice applies to all licensees
16and shall be included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25Except as contained in this notice, the name of Be Incorporated shall not be
26used in advertising or otherwise to promote the sale, use or other dealings in
27this Software without prior written authorization from Be Incorporated.
28
29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30of Be Incorporated in the United States and other countries. Other brand product
31names are registered trademarks or trademarks of their respective holders.
32All rights reserved.
33*/
34
35/*******************************************************************************
36/
37/	File:			ColorTools.h
38/
39/   Description:    Additional experimental color manipulation functions.
40/
41/	Copyright 2000, Be Incorporated, All Rights Reserved
42/
43*******************************************************************************/
44
45
46#ifndef _COLOR_TOOLS_H
47#define _COLOR_TOOLS_H
48
49#include <GraphicsDefs.h>
50
51#if B_BEOS_VERSION <= B_BEOS_VERSION_5
52
53namespace BExperimental {
54
55// Comparison operators.
56
57inline bool operator==(const rgb_color c1, const rgb_color c2)
58{
59	return (*((uint32*)&c1)) == (*((uint32*)&c2));
60}
61
62inline bool operator!=(const rgb_color c1, const rgb_color c2)
63{
64	return (*((uint32*)&c1)) != (*((uint32*)&c2));
65}
66
67#ifndef __HAIKU__
68// Color creation.
69
70inline rgb_color make_color(uint8 red, uint8 green, uint8 blue, uint8 alpha=255)
71{
72	rgb_color c;
73	c.red = red;
74	c.green = green;
75	c.blue = blue;
76	c.alpha = alpha;
77	return c;
78}
79#endif
80
81// Mix two colors together, ignoring their relative alpha channels.
82// If amount is 0, the result is color1; if 255, the result is color2;
83// if another value, it is somewhere in-between.  The resulting alpha
84// channel is mixed exactly like the other color channels.
85rgb_color mix_color(rgb_color color1, rgb_color color2, uint8 amount);
86
87// Blend two colors together, weighting by their relative alpha channels.
88// The resulting color is the same as mix_color(), except that the amount
89// used from color1 and color2's color channels is dependent on that color's
90// alpha channel.  For example, if color1.alpha is 0 and color2.alpha is
91// 255, the resulting red, green, and blue values will be the same as those
92// in color2, regardless of 'amount'.
93rgb_color blend_color(rgb_color color1, rgb_color color2, uint8 amount);
94
95// Return a color that is the disabled representation of 'color' when drawn
96// on a solid color 'background'.
97rgb_color disable_color(rgb_color color, rgb_color background);
98
99}	// namespace BExperimental
100
101using namespace BExperimental;
102
103#endif
104
105#endif
106