Changeset View
Changeset View
Standalone View
Standalone View
src/hsluv.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * HSLuv-C: Human-friendly HSL | ||||
3 | * <http://github.com/hsluv/hsluv-c> | ||||
4 | * <http://www.hsluv.org/> | ||||
5 | * | ||||
6 | * Copyright (c) 2015 Alexei Boronine (original idea, JavaScript implementation) | ||||
7 | * Copyright (c) 2015 Roger Tallada (Obj-C implementation) | ||||
8 | * Copyright (c) 2017 Martin Mitas (C implementation, based on Obj-C implementation) | ||||
9 | * | ||||
10 | * Permission is hereby granted, free of charge, to any person obtaining a | ||||
11 | * copy of this software and associated documentation files (the "Software"), | ||||
12 | * to deal in the Software without restriction, including without limitation | ||||
13 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||||
14 | * and/or sell copies of the Software, and to permit persons to whom the | ||||
15 | * Software is furnished to do so, subject to the following conditions: | ||||
16 | * | ||||
17 | * The above copyright notice and this permission notice shall be included in | ||||
18 | * all copies or substantial portions of the Software. | ||||
19 | * | ||||
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||||
21 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||||
25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||||
26 | * IN THE SOFTWARE. | ||||
27 | */ | ||||
28 | | ||||
29 | #ifndef HSLUV_H | ||||
30 | #define HSLUV_H | ||||
31 | | ||||
32 | #ifdef __cplusplus | ||||
33 | extern "C" { | ||||
34 | #endif | ||||
35 | | ||||
36 | | ||||
37 | /** | ||||
38 | * Convert HSLuv to RGB. | ||||
39 | * | ||||
40 | * @param h Hue. Between 0.0 and 360.0. | ||||
41 | * @param s Saturation. Between 0.0 and 100.0. | ||||
42 | * @param l Lightness. Between 0.0 and 100.0. | ||||
43 | * @param[out] pr Red component. Between 0.0 and 1.0. | ||||
44 | * @param[out] pr Green component. Between 0.0 and 1.0. | ||||
45 | * @param[out] pr Blue component. Between 0.0 and 1.0. | ||||
46 | */ | ||||
47 | void hsluv2rgb(double h, double s, double l, double* pr, double* pg, double* pb); | ||||
48 | | ||||
49 | /** | ||||
50 | * Convert RGB to HSLuv. | ||||
51 | * | ||||
52 | * @param r Red component. Between 0.0 and 1.0. | ||||
53 | * @param g Green component. Between 0.0 and 1.0. | ||||
54 | * @param b Blue component. Between 0.0 and 1.0. | ||||
55 | * @param[out] ph Hue. Between 0.0 and 360.0. | ||||
56 | * @param[out] ps Saturation. Between 0.0 and 100.0. | ||||
57 | * @param[out] pl Lightness. Between 0.0 and 100.0. | ||||
58 | */ | ||||
59 | void rgb2hsluv(double r, double g, double b, double* ph, double* ps, double* pl); | ||||
60 | | ||||
61 | /** | ||||
62 | * Convert HPLuv to RGB. | ||||
63 | * | ||||
64 | * @param h Hue. Between 0.0 and 360.0. | ||||
65 | * @param s Saturation. Between 0.0 and 100.0. | ||||
66 | * @param l Lightness. Between 0.0 and 100.0. | ||||
67 | * @param[out] pr Red component. Between 0.0 and 1.0. | ||||
68 | * @param[out] pg Green component. Between 0.0 and 1.0. | ||||
69 | * @param[out] pb Blue component. Between 0.0 and 1.0. | ||||
70 | */ | ||||
71 | void hpluv2rgb(double h, double s, double l, double* pr, double* pg, double* pb); | ||||
72 | | ||||
73 | /** | ||||
74 | * Convert RGB to HPLuv. | ||||
75 | * | ||||
76 | * @param r Red component. Between 0.0 and 1.0. | ||||
77 | * @param g Green component. Between 0.0 and 1.0. | ||||
78 | * @param b Blue component. Between 0.0 and 1.0. | ||||
79 | * @param[out] ph Hue. Between 0.0 and 360.0. | ||||
80 | * @param[out] ps Saturation. Between 0.0 and 100.0. | ||||
81 | * @param[out] pl Lightness. Between 0.0 and 100.0. | ||||
82 | */ | ||||
83 | void rgb2hpluv(double r, double g, double b, double* ph, double* ps, double* pl); | ||||
84 | | ||||
85 | | ||||
86 | #ifdef __cplusplus | ||||
87 | } | ||||
88 | #endif | ||||
89 | | ||||
90 | #endif /* HSLUV_H */ |