#!/usr/bin/perl

use strict;
use warnings;

my $symbols = [
  { "pos" => 200,   "sym" => "->" },
  { "pos" => 400,   "sym" => "=>" },
  { "pos" => 600,   "sym" => "~>" },
  { "pos" => 800,   "sym" => "<>" },
  { "pos" => 1000,  "sym" => "=~" },
  { "pos" => 1200,  "sym" => "<\$>" },
  { "pos" => 1400,  "sym" => "<*>" },
  { "pos" => 1600,  "sym" => ">>=" },
];

my $fonts = [
  { "pos" => 100, "name" => "Cascadia-Mono-Regular" },
  { "pos" => 200, "name" => "Source-Code-Pro-Regular" },
  { "pos" => 300, "name" => "Dejavu-Sans-Mono" },
  { "pos" => 400, "name" => "JetBrains-Mono-Regular" },
  { "pos" => 500, "name" => "Iosevka" },
  { "pos" => 600, "name" => "Ubuntu-Mono" },
  { "pos" => 700, "name" => "Fira-Mono-Regular" },
  { "pos" => 800, "name" => "Liberation-Mono" },
  { "pos" => 900, "name" => "Roboto-Mono-Regular" }
];

sub f {
  my ($x, $s, $c, $a) = @_;
  return join(" ",
    "-pointsize 64",
    "-fill " . $c . " ",
    (map { "-font \"$_->{name}\" -annotate +$x+$_->{pos} \"$s\"" } $fonts->@*),
    "-fill " . $a . " -font \"Myna-Regular\" -annotate +@{[$x + 10]}+1000 \"$s\"",
  );
}

system (join(" ",
    "magick",
    "-size 2000x1200 xc:black",
    "-gravity northwest",
    join (' ', map { f($_->{pos}, $_->{sym}, "white", "cyan") } $symbols->@*),
    quotemeta($ARGV[0])
));

system (join(" ",
    "magick",
    "-size 2000x1200 xc:white",
    "-gravity northwest",
    join (' ', map { f($_->{pos}, $_->{sym}, "black", "crimson") } $symbols->@*),
    quotemeta($ARGV[1])
));
