MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / resize

Function resize

src/engine/ui.ts:360–388  ·  view source on GitHub ↗
(engine: VisualNovelEngine, _element: unknown, proportionWidth: number, proportionHeight: number)

Source from the content-addressed store, hash-verified

358// ============================================================================
359
360export function resize (engine: VisualNovelEngine, _element: unknown, proportionWidth: number, proportionHeight: number): void {
361 const parentElement = engine.parentElement();
362 if (!parentElement) return;
363
364 const mainWidth = parentElement.width();
365 const mainHeight = parentElement.height();
366
367 const h = Math.floor (mainWidth * (proportionHeight / proportionWidth));
368
369 let widthCss = '100%';
370 let heightCss = '100%';
371 let marginTopCss: string | number = 0;
372
373 if (h <= mainHeight) {
374 const marginTop = Math.floor ((mainHeight - h)/2);
375 marginTopCss = marginTop + 'px';
376 heightCss = h + 'px';
377
378 } else {
379 const w = Math.floor (mainHeight * (proportionWidth/proportionHeight));
380 widthCss = w + 'px';
381 }
382
383 $_('.forceAspectRatio').style ({
384 'width': widthCss,
385 'height': heightCss,
386 'margin-top': marginTopCss
387 });
388}
389
390export function goBack (engine: VisualNovelEngine, event: Event, selector: string): void {
391 if (!$_(`${selector} [data-screen="game"]`).isVisible ()) {

Callers

nothing calls this directly

Calls 3

parentElementMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80

Tested by

no test coverage detected