This repository has been archived on 2026-04-25. You can view files and clone it, but cannot push or open issues or pull requests.
WordGame-JS/Snowman-Animated/scripts/thermometer.js

31 lines
691 B
JavaScript
Raw Permalink Normal View History

2024-05-08 12:41:16 -05:00
// Variables
var wantedHeight = 0;
var newHeight = 0;
var newPercent = 0;
// Functions
function _drawThermometer(){
// Setting stuff
let _percent = tries / 7;
wantedHeight = lerp(0,280, _percent);
newHeight = lerp(newHeight, wantedHeight, 0.2);
newPercent = lerp(newPercent, _percent, 0.2);
let yVal = Math.floor(lerp(0,255,newPercent));
let fillColour = "rgb(" + 0 + ", " + yVal + ", " + yVal + ")";
// Drawing
ctx.globalAlpha = 1;
ctx.beginPath();
ctx.fillStyle = fillColour;
ctx.fillRect(10,10,50,300);
ctx.fill();
ctx.beginPath();
ctx.fillStyle = "red";
ctx.fillRect(20,300,30,-newHeight);
ctx.fill();
}
// Events