From 5e41f41a69c8890dcac35ac191ef6c93cb2828c6 Mon Sep 17 00:00:00 2001 From: Gabriele Cirulli Date: Wed, 5 Mar 2014 16:33:31 +0100 Subject: [PATCH] generate tile colors automatically --- index.html | 6 ++++++ style/main.css | 27 +++++++++++++++++++++++++++ style/main.scss | 23 +++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/index.html b/index.html index f098a34..74fa966 100644 --- a/index.html +++ b/index.html @@ -45,6 +45,12 @@
4
+
+ 512 +
+
+ 2048 +
diff --git a/style/main.css b/style/main.css index 0a5b1ec..e05c4fe 100644 --- a/style/main.css +++ b/style/main.css @@ -129,3 +129,30 @@ h1 { position: absolute; left: 363.75px; top: 363.75px; } + .tile.tile-2 { + background: #eee4da; } + .tile.tile-4 { + background: #ede0ca; } + .tile.tile-8 { + background: #edddba; } + .tile.tile-16 { + background: #eddaab; } + .tile.tile-32 { + background: #edd79b; } + .tile.tile-64 { + background: #edd48b; } + .tile.tile-128 { + background: #edd17c; + font-size: 45px; } + .tile.tile-256 { + background: #edce6c; + font-size: 45px; } + .tile.tile-512 { + background: #edcb5c; + font-size: 45px; } + .tile.tile-1024 { + background: #edc84d; + font-size: 35px; } + .tile.tile-2048 { + background: #edc53d; + font-size: 35px; } diff --git a/style/main.scss b/style/main.scss index 951f371..bae5889 100644 --- a/style/main.scss +++ b/style/main.scss @@ -1,3 +1,4 @@ +@import "helpers"; @import "fonts/clear-sans.css"; $field-width: 500px; @@ -7,6 +8,7 @@ $tile-size: ($field-width - $grid-spacing * ($grid-row-cells + 1)) / $grid-row-c $tile-border-radius: 3px; $tile-color: #eee4da; +$tile-gold-color: #edc22e; html, body { margin: 0; @@ -104,6 +106,27 @@ h1 { } } } + + $base: 2; + $exponent: 1; + $limit: 11; + + @while $exponent <= $limit { + $power: pow($base, $exponent); + $percent: (($exponent - 1) / $limit) * 100; + + &.tile-#{$power} { + background: mix($tile-gold-color, $tile-color, $percent); + + @if $power >= 100 and $power < 1000 { + font-size: 45px; + } @else if $power >= 1000 { + font-size: 35px; + } + } + + $exponent: $exponent + 1; + } } -- GitLab