WordGame-JS/Snowman-Animated/scripts/thermometer.js
2024-05-08 13:41:16 -04:00

31 lines
No EOL
691 B
JavaScript
Executable file

// 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