From dc2d2c0c6de71f38cac2da984139fa6be8e19b96 Mon Sep 17 00:00:00 2001 From: Passthem <514827965@qq.com> Date: Mon, 14 Apr 2025 16:14:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E5=97=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 ++- include/shader.h | 6 ++++++ src/shader.c | 9 ++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d41d68c..42bb310 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,8 @@ "*.py": "python", "app.h": "c", "time.h": "c", - "math.h": "c" + "math.h": "c", + "color_utils.h": "c" }, "C_Cpp.errorSquiggles": "enabled", "C_Cpp.default.includePath": [ diff --git a/include/shader.h b/include/shader.h index 96999c7..32fa36c 100644 --- a/include/shader.h +++ b/include/shader.h @@ -3,9 +3,15 @@ #include "color_utils.h" +typedef enum LightMode { + LIGHT_MODE_RAINBOW, + LIGHT_MODE_WHITE, +} LightMode; + typedef struct { int index; double time; + LightMode mode; } Status; void init_status(Status* status); diff --git a/src/shader.c b/src/shader.c index 55d3813..f047ee3 100644 --- a/src/shader.c +++ b/src/shader.c @@ -3,6 +3,7 @@ void init_status(Status* status) { status->index = 0; status->time = 0; + status->mode = LIGHT_MODE_WHITE; } Color shader(Status* status) { @@ -10,5 +11,11 @@ Color shader(Status* status) { return hex_to_color(0xFFFFFF); } - return hsv_to_color(status->time * 120 + status->index * 6, 1, 1); + switch (status->mode) { + case LIGHT_MODE_RAINBOW: + return hsv_to_color(status->time * 120 + status->index * 6, 1, 1); + + default: + return hex_to_color(0xFFFFFF); + } } \ No newline at end of file