]> git.sesse.net Git - remoteglot/commitdiff
Better imbalance pieces in dark mode.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 20 Oct 2022 17:55:26 +0000 (19:55 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 20 Oct 2022 17:55:26 +0000 (19:55 +0200)
Simply use the pieces of the opposite color and invert them;
they are made for a light background.

www/css/remoteglot.css
www/js/remoteglot.js

index 42bf1b9c0b88105721aabbd73127978d9813bb1d..672e583d7032d80049b90cad9d112f923cb387f6 100644 (file)
@@ -203,6 +203,11 @@ a.move:hover {
        color: #555;
 }
 
+.imbalance-inverted-piece {
+       display: none;
+       filter: invert(1);
+}
+
 @media (prefers-color-scheme: dark) {
 
 :root {
@@ -221,5 +226,9 @@ a.move, a.move:link {
 a:link {
        color: rgb(128,128,238);
 }
-
+.imbalance-piece {
+       display: none;
+}
+.imbalance-inverted-piece {
+       display: initial;
 }
index dc0e6307cce2f1e61f341f105e215bf73eb84b9a..3a95204e20bc7692a38d2fb3fdc36ed5b7e61eab 100644 (file)
@@ -1751,10 +1751,12 @@ var update_imbalance = function(fen) {
        var black_imbalance = '';
        for (var piece in imbalance) {
                for (var i = 0; i < imbalance[piece]; ++i) {
-                       white_imbalance += '<img src="' + svg_pieces['w' + piece.toUpperCase()] + '" alt="" style="width: 15px;height: 15px;">';
+                       white_imbalance += '<img src="' + svg_pieces['w' + piece.toUpperCase()] + '" alt="" style="width: 15px;height: 15px;" class="imbalance-piece">';
+                       white_imbalance += '<img src="' + svg_pieces['b' + piece.toUpperCase()] + '" alt="" style="width: 15px;height: 15px;" class="imbalance-inverted-piece">';
                }
                for (var i = 0; i < -imbalance[piece]; ++i) {
-                       black_imbalance += '<img src="' + svg_pieces['b' + piece.toUpperCase()] + '" alt="" style="width: 15px;height: 15px;">';
+                       black_imbalance += '<img src="' + svg_pieces['b' + piece.toUpperCase()] + '" alt="" style="width: 15px;height: 15px;" class="imbalance-piece">';
+                       black_imbalance += '<img src="' + svg_pieces['w' + piece.toUpperCase()] + '" alt="" style="width: 15px;height: 15px;" class="imbalance-inverted-piece">';
                }
        }
        $('#whiteimbalance').html(white_imbalance);