28 lines
637 B
TypeScript
Raw Normal View History

2025-01-04 22:32:17 -05:00
import { drawCard, loadImages } from "../draw.ts";
2024-12-29 23:00:38 -05:00
import { DominionCard } from "../types.ts";
const sizeMap = {
card: {
width: 1403,
height: 2151,
},
landscape: {
width: 2151,
height: 1403,
}
}
export const Card = (props: {card: DominionCard}) => {
const {card} = props;
const {width, height} = sizeMap[card.orientation];
2025-01-04 22:32:17 -05:00
return <canvas style={{width: "2.5in"}} width={width} height={height} ref={async (canvasElement) => {
2024-12-29 23:00:38 -05:00
if (canvasElement) {
const context = canvasElement.getContext("2d");
if (context) {
2025-01-05 23:55:22 -05:00
await loadImages();
// await loadFonts();
2024-12-29 23:00:38 -05:00
drawCard(context, card);
}
}
}}></canvas>
}