Add colours to numbers

Fixes #24.
This commit is contained in:
Florine W. Dekker 2020-07-30 23:21:31 +02:00
parent 912f3410a4
commit de7b40c3c8
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "minesweeper",
"version": "0.0.32",
"version": "0.0.33",
"description": "Just Minesweeper!",
"author": "Felix W. Dekker",
"browser": "dist/bundle.js",

View File

@ -432,7 +432,7 @@ class Display {
const fillText = (text, font, color = "#000") => {
ctx.save();
ctx.fillStyle = color;
ctx.font = `${Math.floor(this.scale * 0.6)}px ${font}`;
ctx.font = `bold ${Math.floor(this.scale * 0.55)}px ${font}`;
ctx.textBaseline = "middle";
ctx.textAlign = "center";
ctx.fillText(text, Math.floor(this.scale / 2), Math.floor(this.scale / 2));
@ -459,10 +459,12 @@ class Display {
fillText("\uf1e2", "ForkAwesome");
fillText("\uf00d", "ForkAwesome", "#f00");
const digitColors =
["", "#0000ff", "#007b00", "#ff0000", "#00007b", "#7b0000", "#007b7b", "#000000", "#7b7b7b"];
this.digitSymbols = range(10).map(digit => {
const canvas = createCanvas(this.scale, this.scale);
ctx = canvas.getContext("2d");
if (digit !== 0) fillText("" + digit, "Courier New");
if (digit !== 0) fillText("" + digit, "Courier New", digitColors[digit]);
return canvas;
});