Debian Codegraph @

src/cdogs/color.h

raw symbols SCIP
1 /*
2 C-Dogs SDL
3 A port of the legendary (and fun) action/arcade cdogs.
4
5 Copyright (c) 2013-2017, 2024 Cong Xu
6 All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10
11 Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
13 Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28 */
29 #pragma once
30
31 #include "sys_specifics.h"
32
33 #include <stdbool.h>
34 #include <stdint.h>
35
36 typedef struct
37 {
38 uint8_t r;
39 uint8_t g;
40 uint8_t b;
41 uint8_t a;
42 } color_t;
43 extern color_t colorWhite;
44 extern color_t colorRed;
45 extern color_t colorGreen;
46 extern color_t colorBlue;
47 extern color_t colorPoison;
48 extern color_t colorBlack;
49 extern color_t colorDarker;
50 extern color_t colorPurple;
51 extern color_t colorGray;
52 extern color_t colorDarkGray;
53 extern color_t colorYellow;
54 extern color_t colorMagenta;
55 extern color_t colorCyan;
56 extern color_t colorFog;
57 extern color_t colorOrange;
58 extern color_t colorTransparent;
59
60 extern color_t colorMaroon;
61 extern color_t colorLonestar;
62 extern color_t colorRusticRed;
63 extern color_t colorOfficeGreen;
64 extern color_t colorPakistanGreen;
65 extern color_t colorDarkFern;
66 extern color_t colorNavyBlue;
67 extern color_t colorArapawa;
68 extern color_t colorStratos;
69 extern color_t colorPatriarch;
70 extern color_t colorPompadour;
71 extern color_t colorLoulou;
72 extern color_t colorBattleshipGrey;
73 extern color_t colorDoveGray;
74 extern color_t colorGravel;
75 extern color_t colorComet;
76 extern color_t colorFiord;
77 extern color_t colorTuna;
78 extern color_t colorHacienda;
79 extern color_t colorKumera;
80 extern color_t colorHimalaya;
81 extern color_t colorChocolate;
82 extern color_t colorNutmeg;
83 extern color_t colorBracken;
84 extern color_t colorTeal;
85 extern color_t colorSkobeloff;
86 extern color_t colorDeepJungleGreen;
87
88 extern color_t colorSkin;
89 extern color_t colorDarkSkin;
90 extern color_t colorAsianSkin;
91
92 extern color_t colorLightBlue;
93 extern color_t colorSelectedBG;
94
95 color_t ColorMult(color_t c, color_t m);
96 color_t ColorAlphaBlend(color_t a, color_t b);
97
98 typedef struct
99 {
100 double h, s, v;
101 } HSV;
102 extern HSV tintNone;
103 extern HSV tintRed;
104 extern HSV tintYellow;
105 extern HSV tintGreen;
106 extern HSV tintCyan;
107 extern HSV tintPoison;
108 extern HSV tintGray;
109 extern HSV tintPurple;
110 extern HSV tintDarker;
111 // Multiply by HSV components; used for tinting
112 // h: hue, if >= 0 then the hue is forced to be this value
113 // s: saturation, where all RGB components are shifted towards the average value
114 // v: scale factor on the final components
115 color_t ColorTint(color_t c, HSV hsv);
116
117 bool ColorEquals(const color_t a, const color_t b);
118 bool HSVEquals(const HSV a, const HSV b);
119
120 // Convert hex string to color
121 color_t StrColor(const char *s);
122 // Convert colour to hex string
123 void ColorStr(char *s, const color_t c);
124 #define COLOR_STR_BUF 9