File: rgbhsl.h

package info (click to toggle)
rss-glx 0.7.5-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 10,184 kB
  • ctags: 1,561
  • sloc: cpp: 11,577; ansic: 4,233; sh: 3,315; asm: 1,312; xml: 552; makefile: 194; perl: 49
file content (41 lines) | stat: -rw-r--r-- 1,839 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * Copyright (C) 2002  Terence M. Welsh
 * Ported to Linux by Tugrul Galatali <tugrul@galatali.com>
 *
 * Rgbhsl is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as 
 * published by the Free Software Foundation.
 *
 * Rgbhsl is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

// This library converts between colors defined with RGB values and HSL
// values.  It also finds in-between colors by moving linearly through
// HSL space.
// All functions take values for r, g, b, h, s, and l between 0.0 and 1.0
// (RGB = red, green, blue;  HSL = hue, saturation, luminosity)

#ifndef RGBHSL_H
#define RGBHSL_H

void rgb2hsl (float r, float g, float b, float &h, float &s, float &l);

void hsl2rgb (float h, float s, float l, float &r, float &g, float &b);

// For these 'tween functions, a tween value of 0.0 will output the first
// color while a tween value of 1.0 will output the second color.
// A value of 0 for direction indicates a positive progression around
// the color wheel (i.e. red -> yellow -> green -> cyan...).  A value of
// 1 does the opposite.
void hslTween (float h1, float s1, float l1, float h2, float s2, float l2, float tween, int direction, float &outh, float &outs, float &outl);

void rgbTween (float r1, float g1, float b1, float r2, float g2, float b2, float tween, int direction, float &outr, float &outg, float &outb);

#endif // RGBHSL_H