Sort out some of the canvas CSS

This commit is contained in:
Gwilym Inzani 2023-07-05 10:27:52 +01:00 committed by Corwin
parent baab2582b5
commit ce75b15716
No known key found for this signature in database

View file

@ -1,6 +1,7 @@
import { FC, useEffect, useRef, useState } from "react";
import mGBA from "./vendor/mgba";
import { KeyBindings } from "./bindings";
import { styled } from "styled-components";
type Module = any;
@ -19,6 +20,14 @@ enum MgbaState {
const MGBA_ROM_DIRECTORY = "/data/games";
const MgbaCanvas = styled.canvas`
image-rendering: pixelated;
aspect-ratio: 240 / 160;
width: 100%;
object-fit: contain;
max-height: 100%;
`;
export const Mgba: FC<MgbaProps> = ({ gameUrl, volume, controls, paused }) => {
const canvas = useRef(null);
const mgbaModule = useRef<Module>({});
@ -107,7 +116,7 @@ export const Mgba: FC<MgbaProps> = ({ gameUrl, volume, controls, paused }) => {
return (
<>
<canvas ref={canvas}></canvas>
<MgbaCanvas ref={canvas} />
<button
onClick={() => {
if (state !== MgbaState.Initialised) return;