Locally scoped buf

master
David Volovskiy 2025-05-03 15:19:32 -04:00
parent 9f0af38cb6
commit 5f837fbf0b
1 changed files with 14 additions and 11 deletions

View File

@ -435,10 +435,14 @@ function polyArray(start, end, max) {
return array;
}
buf = Graphics.createArrayBuffer(w, h, 2, { msb: true });
function drawRing(start, end, max) {
const edge = 4;
const thickness = 6;
// Create persistent `buf` inside the function scope
if (!drawRing._buf) {
drawRing._buf = Graphics.createArrayBuffer(w, h, 2, { msb: true });
}
const buf = drawRing._buf;
let img = { width: w, height: h, transparent: 0,
bpp: 2, palette: pal1, buffer: buf.buffer };
buf.clear();
@ -597,7 +601,6 @@ var drawTimeout;
function queueDraw() {
let now = Date.now();
let delay = settings.ring == 'Seconds' ? sec_update - (now % sec_update) : 60000 - (now % 60000);
print(delay);
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() {
drawTimeout = undefined;