File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ vec4 hex2rgba(const(char)[] input) {
137
137
/**
138
138
Parses a hex string to a RGBA color
139
139
140
- Returns the color as 8 bit RGB(A)
140
+ Returns the color as a static 8 bit RGB(A) array.
141
141
*/
142
142
ubyte [4 ] hex2rgbau (const (char )[] input) {
143
143
import core.stdc.stdio : printf;
@@ -199,4 +199,27 @@ unittest {
199
199
string col6 = " #FF" ;
200
200
ubyte [4 ] col6u = [255 , 0 , 0 , 0 ];
201
201
assert (hex2rgbau(col6) == col6u);
202
+ }
203
+
204
+ /**
205
+ Returns RGBA color from 0..1 from colors in range 0..255
206
+ */
207
+ vec4 rgbau2rgba (ubyte [4 ] colors) {
208
+ return vec4 (
209
+ cast (float )colors[0 ]/ 255.0 ,
210
+ cast (float )colors[1 ]/ 255.0 ,
211
+ cast (float )colors[2 ]/ 255.0 ,
212
+ cast (float )colors[3 ]/ 255.0 ,
213
+ );
214
+ }
215
+
216
+ /**
217
+ Returns RGB color from 0..1 from colors in range 0..255
218
+ */
219
+ vec3 rgbu2rgb (ubyte [3 ] colors) {
220
+ return vec3 (
221
+ cast (float )colors[0 ]/ 255.0 ,
222
+ cast (float )colors[1 ]/ 255.0 ,
223
+ cast (float )colors[2 ]/ 255.0 ,
224
+ );
202
225
}
You can’t perform that action at this time.
0 commit comments