From 03fb52185143fd4088cf6eb8e52f4a0e8a9f65a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Clet?= Date: Mon, 19 Aug 2024 19:31:01 +0200 Subject: [PATCH] Reset color of selected slot by sending empty setcolor message --- code/tc.preset.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/code/tc.preset.js b/code/tc.preset.js index 69fea3c..5ea0aba 100644 --- a/code/tc.preset.js +++ b/code/tc.preset.js @@ -140,6 +140,10 @@ function slot(left, top, right, bottom, name, lock, interp, color_index, color_c this.name = null; this.lock = 0; this.interp = -1; + this.init_color(); + } + + this.init_color = function() { this.color_index = 0; this.color_custom = stored_slot_color; } @@ -574,7 +578,10 @@ function setcolor() { if (nb_args < 1 && nb_args > 5) { error("color: wrong number of arguments."); } else { - if (nb_args == 1) { + if (nb_args == 0) { + // Reset colors of selected slot to default values + slots[selected_slot].init_color(); + } else if (nb_args == 1) { // Set the color index of the currently selected slot (for when color_mode is 2) slots[selected_slot].color_index = Math.floor(args); } else if (nb_args == 2) {