Refactor GUI rendering and align RTA axis

This commit is contained in:
Mikei386
2026-07-22 11:35:51 +02:00
parent 2e868bfa3a
commit 890a47a272
16 changed files with 1199 additions and 1415 deletions
+2 -20
View File
@@ -1,22 +1,4 @@
const CAN_USE_OFFSCREEN = typeof OffscreenCanvas === 'function';
function createSurface(width, height) {
const w = Math.max(1, Math.ceil(width));
const h = Math.max(1, Math.ceil(height));
if (CAN_USE_OFFSCREEN) {
const canvas = new OffscreenCanvas(w, h);
const ctx = canvas.getContext('2d');
if (ctx) return { canvas, ctx, width: w, height: h };
}
if (typeof document !== 'undefined') {
const canvas = document.createElement('canvas');
canvas.width = w;
canvas.height = h;
const ctx = canvas.getContext('2d');
if (ctx) return { canvas, ctx, width: w, height: h };
}
return null;
}
import { createCanvasSurface } from '../core/canvas_surface.js';
export function drawCachedStaticLayer(targetCtx, shared, layerId, key, x, y, width, height, build) {
if (!targetCtx || !shared || typeof build !== 'function') return false;
@@ -30,7 +12,7 @@ export function drawCachedStaticLayer(targetCtx, shared, layerId, key, x, y, wid
|| layer.height !== h;
if (needsRebuild) {
layer = createSurface(w, h);
layer = createCanvasSurface(w, h);
if (!layer) return false;
layer.key = key;
layer.ctx.save();