1
0
Fork 0

SliderInput: precalculate static rectangles

also remove unneeded variable 'levelHeight'
master
thyttan 2023-08-26 20:06:17 +02:00
parent ead101bb90
commit afa7fd91ec
1 changed files with 6 additions and 5 deletions

View File

@ -31,12 +31,14 @@ if (ROTATE) {
// Initialize the level
let level;
let prevLevel = conf.currLevel || STEPS/2;
let levelHeight;
let firstRun = true;
let ebLast = 0;
let exFirst;
const borderRect = {x:X_START,y:Y_START,w:WIDTH+8,y2:Y_START+HEIGHT+5,r:0};
const hollowRect = {x:X_START+2,y:Y_START+2,w:WIDTH+4,y2:Y_START+HEIGHT+2,r:0};
let wasOnIndicator = (exFirst)=>{
"ram";
if (!ROTATE) return exFirst>X_START-OVERSIZE_L*WIDTH && exFirst<X_START+WIDTH+OVERSIZE_R*WIDTH;
@ -98,17 +100,16 @@ let draw = (level)=>{
// Pauses and resets the time out when interacted with.
if (firstRun || !LAZY) {
g.setColor(COL_FG).fillRect({x:X_START,y:Y_START,w:WIDTH+8,y2:Y_START+HEIGHT+5,r:0}); // To get outer border...
g.setColor(COL_FG).fillRect(borderRect); // To get outer border...
}
if (level == prevLevel) {if (!firstRun) return; if (firstRun) firstRun = false;}
levelHeight = level*STEP_SIZE; //level==0?WIDTH:level*STEP_SIZE; // Math.max(level*STEP_SIZE,STEP_SIZE);
prevLevel = level;
g.setColor(COL_BG).
fillRect({x:X_START+2,y:Y_START+2,w:WIDTH+4,y2:Y_START+HEIGHT+2,r:0}). // ... and here it's made hollow.
fillRect(hollowRect). // ... and here it's made hollow.
setColor(0==level?COL_BG:COL_FG).
fillRect(updateBar(levelHeight)); // Here the bar is drawn.
fillRect(updateBar(level*STEP_SIZE)); // Here the bar is drawn.
//print(level);
//print(process.memory().usage);