-
Notifications
You must be signed in to change notification settings - Fork 116
/
mixbox.h
89 lines (77 loc) · 3.27 KB
/
mixbox.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// ==========================================================
// MIXBOX 2.0 (c) 2022 Secret Weapons. All rights reserved.
// License: Creative Commons Attribution-NonCommercial 4.0
// Authors: Sarka Sochorova and Ondrej Jamriska
// ==========================================================
//
// BASIC USAGE
//
// mixbox_lerp(r1, g1, b1, // 1st color
// r2, g2, b2, // 2nd color
// t, // mixing ratio
// &r, &g, &b); // result
//
// MULTI-COLOR MIXING
//
// mixbox_latent z1, z2, z3, z_mix;
// mixbox_rgb_to_latent(r1, g1, b1, z1);
// mixbox_rgb_to_latent(r2, g2, b2, z2);
// mixbox_rgb_to_latent(r3, g3, b3, z3);
//
// for (int i = 0; i < MIXBOX_LATENT_SIZE; i++) {
// // mix 30% of rgb1, 60% of rgb2, and 10% of rgb3
// z_mix[i] = 0.3f*z1[i] + 0.6f*z2[i] + 0.1f*z3[i];
// }
//
// mixbox_latent_to_rgb(z_mix, &r, &g, &b);
//
// PIGMENT COLORS
//
// Cadmium Yellow 254, 236, 0
// Hansa Yellow 252, 211, 0
// Cadmium Orange 255, 105, 0
// Cadmium Red 255, 39, 2
// Quinacridone Magenta 128, 2, 46
// Cobalt Violet 78, 0, 66
// Ultramarine Blue 25, 0, 89
// Cobalt Blue 0, 33, 133
// Phthalo Blue 13, 27, 68
// Phthalo Green 0, 60, 50
// Permanent Green 7, 109, 22
// Sap Green 107, 148, 4
// Burnt Sienna 123, 72, 0
//
// LICENSING
//
// If you want to obtain commercial license, please
// contact us at: [email protected]
//
#ifndef MIXBOX_H_
#define MIXBOX_H_
#ifdef __cplusplus
extern "C" {
#endif
#define MIXBOX_LATENT_SIZE 7
typedef float mixbox_latent[MIXBOX_LATENT_SIZE];
void mixbox_lerp(unsigned char r1, unsigned char g1, unsigned char b1,
unsigned char r2, unsigned char g2, unsigned char b2,
float t,
unsigned char* out_r, unsigned char* out_g, unsigned char* out_b);
void mixbox_lerp_float(float r1, float g1, float b1,
float r2, float g2, float b2,
float t,
float* out_r, float* out_g, float* out_b);
void mixbox_lerp_linear_float(float r1, float g1, float b1,
float r2, float g2, float b2,
float t,
float* out_r, float* out_g, float* out_b);
void mixbox_rgb_to_latent(unsigned char r, unsigned char g, unsigned char b, mixbox_latent out_latent);
void mixbox_latent_to_rgb(mixbox_latent latent, unsigned char* out_r, unsigned char* out_g, unsigned char* out_b);
void mixbox_float_rgb_to_latent(float r, float g, float b, mixbox_latent out_latent);
void mixbox_latent_to_float_rgb(mixbox_latent latent, float* out_r, float* out_g, float* out_b);
void mixbox_linear_float_rgb_to_latent(float r, float g, float b, mixbox_latent out_latent);
void mixbox_latent_to_linear_float_rgb(mixbox_latent latent, float* out_r, float* out_g, float* out_b);
#ifdef __cplusplus
}
#endif
#endif