X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fcolor.qh;h=6f7a7326de41f5cce1953dc26a5ac27aa933296d;hb=f6eba5d1edfbdbb4a6f1578d904ae8d38ddf6dbe;hp=442d8ee89ea762ce8459981487b9a4631ef745a6;hpb=43eba8ca70f00458db385630f86009f6d7fa849a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/color.qh b/qcsrc/lib/color.qh index 442d8ee89..6f7a7326d 100644 --- a/qcsrc/lib/color.qh +++ b/qcsrc/lib/color.qh @@ -1,9 +1,9 @@ -#ifndef COLOR_H -#define COLOR_H +#pragma once #include "string.qh" #define colormapPaletteColor(c, isPants) colormapPaletteColor_(c, isPants, time) +ERASEABLE vector colormapPaletteColor_(int c, bool isPants, float t) { switch (c) @@ -25,17 +25,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) @@ -57,6 +58,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; @@ -111,6 +113,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; @@ -128,11 +131,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; @@ -152,6 +157,7 @@ vector rgb_to_hsl(vector rgb) return hsl; } +ERASEABLE vector hsl_to_rgb(vector hsl) { float mi, ma, maminusmi; @@ -167,6 +173,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( @@ -176,5 +183,3 @@ string rgb_to_hexcolor(vector rgb) DEC_TO_HEXDIGIT(floor(rgb.z * 15 + 0.5)) ); } - -#endif