From e4a10ebf30c8e9ceb634f3797dfaaee9a22f65c9 Mon Sep 17 00:00:00 2001 From: "A.Olokhtonov" Date: Sat, 20 Apr 2024 23:10:55 +0300 Subject: [PATCH] Make color picker actually change the active color --- README.txt | 2 +- client/index.js | 1 + client/webgl_listeners.js | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.txt b/README.txt index cb6655d..8e8197f 100644 --- a/README.txt +++ b/README.txt @@ -34,7 +34,7 @@ Release: + Player list + Follow player + Color picker (or at the very least an Open Color color pallete) - - EYE DROPPER! + + EYE DROPPER! - Dynamic svg cursor to represent the brush - Eraser - Line drawing diff --git a/client/index.js b/client/index.js index 931cd97..5d7a3d9 100644 --- a/client/index.js +++ b/client/index.js @@ -220,6 +220,7 @@ async function main() { 'stats': {}, 'following_player': null, + 'color_picked': null, 'wasm': {}, }; diff --git a/client/webgl_listeners.js b/client/webgl_listeners.js index 33a82c8..7ff0d18 100644 --- a/client/webgl_listeners.js +++ b/client/webgl_listeners.js @@ -179,6 +179,13 @@ function mousedown(e, state, context) { return; } + if (state.colorpicking) { + const color_u32 = color_to_u32(state.color_picked.substring(1)); + state.players[state.me].color = color_u32; + fire_event(state, color_event(color_u32)); + return; + } + if (context.active_image) { // Move selected image with left click const image_event = image_at(state, canvasp.x, canvasp.y); @@ -224,6 +231,8 @@ function update_color_picker_color(state, context, canvasp) { } document.querySelector('.picker-preview-inner').style.background = color_under_cursor; + + state.color_picked = color_under_cursor; } function mousemove(e, state, context) {