start on text

This commit is contained in:
Dylan Pizzo
2025-01-05 10:12:27 -05:00
parent c196646955
commit 0da7c3ab23
3 changed files with 49 additions and 1 deletions

View File

@@ -88,6 +88,24 @@ export const drawCard = (
}
};
const drawText = (
context: CanvasRenderingContext2D,
text: string,
x: number,
y: number,
options?: {
maxWidth?: number;
maxHeight?: number;
allowWrap?: boolean;
font?: string;
color?: string;
}
) => {
const { maxWidth = undefined } = options ?? {};
context.font = "bold 48px serif";
context.fillText(text, x, y, maxWidth);
};
const drawStandardCard = async (
context: CanvasRenderingContext2D,
card: DominionCard
@@ -97,11 +115,13 @@ const drawStandardCard = async (
context.save();
// Draw the image
// Draw the card base
context.drawImage(colorImage(getImage("card-color-1"), "#ff9900"), 0, 0);
const color = "#ffffff"; // "#ffbc55";
context.drawImage(colorImage(getImage("card-color-1"), color), 0, 0);
context.drawImage(getImage("card-gray"), 0, 0);
context.drawImage(colorImage(getImage("card-brown"), "#ff9911"), 0, 0);
context.drawImage(getImage("card-description-focus"), 44, 1094);
// Draw the name
drawText(context, card.title, 300, 300);
// Draw the description
// Draw the types
// Draw the cost