From d6d384aefa2f262ec68f1bac12de539c1bc16942 Mon Sep 17 00:00:00 2001 From: TheJoeCoder <joe@radialbog9.uk> Date: Mon, 5 Aug 2024 12:55:25 +0100 Subject: [PATCH] Add velocity debug --- static/js/background_anim.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/static/js/background_anim.js b/static/js/background_anim.js index 1d06adf..f835fdb 100644 --- a/static/js/background_anim.js +++ b/static/js/background_anim.js @@ -17,6 +17,8 @@ const LINE_COLOUR = "#777"; const VELOCITY_SLOWDOWN_MULTIPLIER = 0.998; const VELOCITY_PUSH_MULTIPLIER = 1.8; +const SHOW_VELOCITIES = true; + // ---- // Sort-of constants (change with window size) @@ -188,6 +190,15 @@ const drawConnectingLines = () => { ctx.closePath(); }; +const drawDebugText = () => { + for(let dot of dots) { + ctx.beginPath(); + ctx.font = "15px Arial"; + ctx.fillText(`${dot.vx}/${dot.vy}`,dot.x,dot.y); + ctx.closePath(); + } +}; + const draw = () => { // Clear the screen ctx.clearRect(0, 0, canvas.width, canvas.height); @@ -201,6 +212,11 @@ const draw = () => { // Draw connecting lines drawConnectingLines(); + + // Draw velocity text + if(SHOW_VELOCITIES) { + drawDebugText(); + } }; const physics = () => { -- GitLab