-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.cpp
More file actions
49 lines (42 loc) · 1.24 KB
/
tools.cpp
File metadata and controls
49 lines (42 loc) · 1.24 KB
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
#include <iostream>
#include <cmath>
#include <raylib.h>
#include "tools.h"
using namespace std;
Color RGB(double R, double G, double B) {
return (Color) { (unsigned char)(R*255),
(unsigned char)(G*255),
(unsigned char)(B*255),
255 };
}
Color HSB(double h, double s, double b) {
double R, G, B;
int i = int(h*6);
double f = h*6-i;
double p = b*(1-s);
double q = b*(1-f*s);
double t = b*(1-(1-f)*s);
switch (i % 6) {
case 0: R = b, G = t, B = p; break;
case 1: R = q, G = b, B = p; break;
case 2: R = p, G = b, B = t; break;
case 3: R = p, G = q, B = b; break;
case 4: R = t, G = p, B = b; break;
case 5: R = b, G = p, B = q; break;
}
return (Color) { (unsigned char)(R*255),
(unsigned char)(G*255),
(unsigned char)(B*255),
255 };
}
Color ColorMap1(double value) {
return HSB(0.7 - 0.5*value,
1,
1);
}
Color ColorMap2(double value) {
return HSB(0, 0, Sigmoid(value, 25, 0.5));
}
double Sigmoid(double x, double a, double b) {
return 1/(1+exp(-a*(x-b)));
}