X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fcolor.qh;h=3a3a61fe33731b1ad0116acce5ba5ac2982d826c;hb=3cc71b21056619026df243c7888d0ff151600a02;hp=d1fdc2c3bcf39d82b3249c9c10f457b395e02a7a;hpb=eac60648c4017e495060dd3ba9e50ac4bad5000a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/color.qh b/qcsrc/lib/color.qh index d1fdc2c3b..3a3a61fe3 100644 --- a/qcsrc/lib/color.qh +++ b/qcsrc/lib/color.qh @@ -3,10 +3,17 @@ #include "string.qh" #define colormapPaletteColor(c, isPants) colormapPaletteColor_(c, isPants, time) +ERASEABLE vector colormapPaletteColor_(int c, bool isPants, float t) { + // these colors are defined in gfx/colormap_palette.pl + // to generate them run: perl gfx/colormap_palette.pl > gfx/colormap_palette.lmp + // it will save them to gfx/colormap_palette.lmp (in the lmp format) + // and prints the cases of the following switch so they can be copy-pasted here + switch (c) { + // generated by gfx/colormap_palette.pl case 0: return '1.000000 1.000000 1.000000'; case 1: return '1.000000 0.333333 0.000000'; case 2: return '0.000000 1.000000 0.501961'; @@ -24,17 +31,18 @@ vector colormapPaletteColor_(int c, bool isPants, float t) case 14: return '1.000000 0.666667 0.000000'; case 15: if (isPants) - return '1 0 0' * (0.502 + 0.498 * sin(t / 2.7182818285 + 0.0000000000)) - + '0 1 0' * (0.502 + 0.498 * sin(t / 2.7182818285 + 2.0943951024)) - + '0 0 1' * (0.502 + 0.498 * sin(t / 2.7182818285 + 4.1887902048)); + return '1 0 0' * (0.502 + 0.498 * sin(t / M_E + 0)) + + '0 1 0' * (0.502 + 0.498 * sin(t / M_E + M_PI * 2 / 3)) + + '0 0 1' * (0.502 + 0.498 * sin(t / M_E + M_PI * 4 / 3)); else - return '1 0 0' * (0.502 + 0.498 * sin(t / 3.1415926536 + 5.2359877560)) - + '0 1 0' * (0.502 + 0.498 * sin(t / 3.1415926536 + 3.1415926536)) - + '0 0 1' * (0.502 + 0.498 * sin(t / 3.1415926536 + 1.0471975512)); + return '1 0 0' * (0.502 + 0.498 * sin(t / M_PI + M_PI * 5 / 3)) + + '0 1 0' * (0.502 + 0.498 * sin(t / M_PI + M_PI)) + + '0 0 1' * (0.502 + 0.498 * sin(t / M_PI + M_PI * 1 / 3)); default: return '0.000 0.000 0.000'; } } +ERASEABLE float rgb_mi_ma_to_hue(vector rgb, float mi, float ma) { if (mi == ma) @@ -56,6 +64,7 @@ float rgb_mi_ma_to_hue(vector rgb, float mi, float ma) } } +ERASEABLE vector hue_mi_ma_to_rgb(float hue, float mi, float ma) { vector rgb; @@ -110,6 +119,7 @@ vector hue_mi_ma_to_rgb(float hue, float mi, float ma) return rgb; } +ERASEABLE vector rgb_to_hsv(vector rgb) { float mi, ma; @@ -127,11 +137,13 @@ vector rgb_to_hsv(vector rgb) return hsv; } +ERASEABLE vector hsv_to_rgb(vector hsv) { return hue_mi_ma_to_rgb(hsv.x, hsv.z * (1 - hsv.y), hsv.z); } +ERASEABLE vector rgb_to_hsl(vector rgb) { float mi, ma; @@ -151,6 +163,7 @@ vector rgb_to_hsl(vector rgb) return hsl; } +ERASEABLE vector hsl_to_rgb(vector hsl) { float mi, ma, maminusmi; @@ -166,6 +179,7 @@ vector hsl_to_rgb(vector hsl) return hue_mi_ma_to_rgb(hsl.x, mi, ma); } +ERASEABLE string rgb_to_hexcolor(vector rgb) { return strcat(