summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/bling/default.nix
blob: 8d6207f658fb14ec9855081a42c9b5a327bf83bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{ imagemagick, runCommand, ... }:

with import <stockholm/lib>;

let
  krebs-v2 = [
    "                "
    "                "
    " x x         x x"
    "xx x  xx xx xx x"
    "xx x  xx xx xx x"
    " xxx   x  x  xxx"
    " xxx  xxxxx  xxx"
    "  x  xxxxxxx  x "
    "  xxxxxxxxxxxxx "
    "     xxxxxxx    "
    "   xxxxxxxxxxx  "
    "   x   xxx   x  "
    "  x  x x x x  x "
    "  x  x x x x  x "
    "  x xx x x xx x "
    "                "
  ];

  chars-per-pixel = 1;
  colors = 2;
  columns = foldl' max 0 (map stringLength krebs-v2);
  rows = length krebs-v2;

  png-geometry = "1692x1692";

  txt = concatMapStrings (s: "${s}\n") krebs-v2;

  xpm = ''
    static char *krebs_v2[] = {
      ${toC (toString [columns rows colors chars-per-pixel])},
      "  c None",
      "x c #E4002B",
      ${concatMapStringsSep ",\n  " toC krebs-v2}
    };
  '';
in

runCommand "bling"
  {
    inherit xpm;
    passAsFile = ["xpm"];
  }
  ''
    mkdir -p $out
    cd $out

    cp $xpmPath krebs-v2.xpm
    ${imagemagick}/bin/convert krebs-v2.xpm krebs-v2.ico
    ${imagemagick}/bin/convert krebs-v2.xpm -scale ${png-geometry} krebs-v2.png
  ''