Skip to content

Commit 5471ee5

Browse files
committed
Switch to rgb rather than hash colors, since they are much easier to read
1 parent 964a89c commit 5471ee5

3 files changed

Lines changed: 24 additions & 27 deletions

File tree

15_game.txt

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,11 @@ table look like the background we want:
443443

444444
[source,text/css]
445445
----
446-
.background { background: #34a6fb;
446+
.background { background: rgb(52, 166, 251);
447447
table-layout: fixed;
448448
border-spacing: 0; }
449449
.background td { padding: 0; }
450-
.lava { background: #ff6363; }
450+
.lava { background: rgb(255, 100, 100); }
451451
.wall { background: white; }
452452
----
453453

@@ -459,15 +459,12 @@ predictable variant (the way tables are laid out in HTML is a very
459459
complicated thing).
460460

461461
The `background` rules set background colors. CSS allows colors to be
462-
specified both as words (`white`) and with a rather cryptic `#RRGGBB`
463-
format, where the hash sign is followed by pairs of hexadecimal
464-
(base-16) digits giving first the red, then the green, and then the
465-
blue components of the color, as numbers between zero and `ff` (255).
466-
So in `#34a6fb` the the red component is hexadecimal `34` (3 × 16 + 4
467-
equals decimal 52), green is `a6` (166), and blue `fb` (251). Since
468-
the blue component is the largest, the resulting color will be
469-
blueish. You can see that in the `.lava` rule, the first part of the
470-
number (red) is the largest.
462+
specified both as words (`white`) and with a rather cryptic `rgb(R, G,
463+
B)` format, where the red, green, and blue components of the color are
464+
separated into three numbers from 0 to 255. So in `rgb(52, 166, 251)`
465+
the red component is 52, green is 166, and blue is 251. Since the blue
466+
component is the largest, the resulting color will be blueish. You can
467+
see that in the `.lava` rule, the first number (red) is the largest.
471468

472469
Drawing the actors is quite straightforward:
473470

@@ -501,8 +498,8 @@ squares, which we defined earlier):
501498
[source,text/css]
502499
----
503500
.actor { position: absolute; }
504-
.coin { background: #f1e559; }
505-
.player { background: #404040; }
501+
.coin { background: rgb(241, 229, 89); }
502+
.player { background: rgb(64, 64, 64); }
506503
----
507504

508505
To update the display when the world changes, the `drawFrame` method
@@ -536,7 +533,7 @@ convenient like that.)
536533
[source,text/css]
537534
----
538535
.lost .player {
539-
background: #a04040;
536+
background: rgb(160, 64, 64);
540537
}
541538
.won .player {
542539
box-shadow: -4px -7px 8px white, 4px -7px 8px white;

16_canvas.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,11 +883,11 @@ depending on whether the game is won (brighter) or lost (darker).
883883
----
884884
CanvasDisplay.prototype.clearDisplay = function() {
885885
if (this.level.status == "won")
886-
this.cx.fillStyle = "#44bfff";
886+
this.cx.fillStyle = "rgb(68, 191, 255)";
887887
else if (this.level.status == "lost")
888-
this.cx.fillStyle = "#2c88d6";
888+
this.cx.fillStyle = "rgb(44, 136, 214)";
889889
else
890-
this.cx.fillStyle = "#34a6fb";
890+
this.cx.fillStyle = "rgb(52, 166, 251)";
891891
this.cx.fillRect(0, 0,
892892
this.canvas.width, this.canvas.height);
893893
};

html/css/game.css

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
.background { background: #34a6fb;
1+
.background { background: rgb(52, 166, 251);
22
table-layout: fixed;
3-
border-spacing: 0; }
4-
.background td { padding: 0; }
5-
.lava { background: #ff6363; }
6-
.wall { background: white; }
3+
border-spacing: 0; }
4+
.background td { padding: 0; }
5+
.lava { background: rgb(255, 100, 100); }
6+
.wall { background: white; }
77

8-
.actor { position: absolute; }
9-
.coin { background: #f1e559; }
10-
.player { background: #404040; }
8+
.actor { position: absolute; }
9+
.coin { background: rgb(241, 229, 89); }
10+
.player { background: rgb(64, 64, 64); }
1111

1212
.game {
1313
overflow: hidden;
@@ -17,8 +17,8 @@
1717
}
1818

1919
.lost .player {
20-
background: #a04040;
20+
background: rgb(160, 64, 64);
2121
}
22-
.won .player {
22+
.won .player {
2323
box-shadow: -4px -7px 8px white, 4px -7px 8px white;
2424
}

0 commit comments

Comments
 (0)