|
|
@@ -926,19 +926,35 @@ class SymjaConsole {
|
|
|
panel.innerHTML = '';
|
|
|
const c = document.createElement('canvas');
|
|
|
const dpr = window.devicePixelRatio || 1;
|
|
|
- c.width = (w || 600) * dpr;
|
|
|
- c.height = (h || 800) * dpr;
|
|
|
- c.style.width = (w || 600) + 'px';
|
|
|
- c.style.height = (h || 800) + 'px';
|
|
|
- c.style.maxWidth = '100%';
|
|
|
- c.style.maxHeight = '100%';
|
|
|
- c.style.objectFit = 'contain';
|
|
|
+ // 自适应:未指定尺寸则填满全屏面板
|
|
|
+ const cw = w || panel.clientWidth || window.innerWidth;
|
|
|
+ const ch = h || panel.clientHeight || window.innerHeight;
|
|
|
+ c.width = cw * dpr;
|
|
|
+ c.height = ch * dpr;
|
|
|
+ // CSS 精确填充
|
|
|
+ Object.assign(c.style, {
|
|
|
+ width: cw + 'px',
|
|
|
+ height: ch + 'px',
|
|
|
+ maxWidth: '100%',
|
|
|
+ maxHeight: '100%',
|
|
|
+ objectFit: 'contain',
|
|
|
+ position: 'absolute',
|
|
|
+ left: '50%',
|
|
|
+ top: '50%',
|
|
|
+ transform: 'translate(-50%, -50%)'
|
|
|
+ });
|
|
|
this._canvas = c;
|
|
|
this._ctx = c.getContext('2d');
|
|
|
this._ctx.scale(dpr, dpr);
|
|
|
+ this._logicalW = cw;
|
|
|
+ this._logicalH = ch;
|
|
|
panel.appendChild(c);
|
|
|
return this._ctx;
|
|
|
},
|
|
|
+ /** 获取逻辑画布宽度(供插件做自适应布局) */
|
|
|
+ width: function() { return this._logicalW || 600; },
|
|
|
+ /** 获取逻辑画布高度 */
|
|
|
+ height: function() { return this._logicalH || 800; },
|
|
|
getContext: function() { return this._ctx; },
|
|
|
getSize: function() {
|
|
|
const dpr = window.devicePixelRatio || 1;
|