๐Ÿ’พ Archived View for anjune.lol โ€บ gmi โ€บ quab.gmi captured on 2023-01-29 at 02:42:39. Gemini links have been rewritten to link to archived content

View Raw

More Information

โžก๏ธ Next capture (2023-07-22)

-=-=-=-=-=-=-

โ†

monolalia โ†’ Mโ€™kay Computer โ†’ Quab (silly ASCII-to-Unicode-art converter)

Not a programmer, but I wrote a little helper script with the intention of decking my Gemini capsule out with Unicode art (โ€œQuabโ€ stands for โ€œquarter blocksโ€, allowing crude graphics with 2x2 โ€œpixelsโ€ per character). Was slightly proud of it for a little bit.

#!/usr/bin/env php
<?php

$ingrid = array();

$unich = array( "--  " => "โ”€", "| | " => "โ”‚",
                "  --" => "โ”€", " | |" => "โ”‚",
                "+ + " => "โ”ผ", "++  " => "โ”ผ",
                " + +" => "โ”ผ", "  ++" => "โ”ผ",
                "/-| " => "โ”Œ", "-\ |" => "โ”",
                "| \-" => "โ””", " |-/" => "โ”˜",
                "| --" => "โ”ด", "--| " => "โ”ฌ",
                "-+ |" => "โ”ค", "+-| " => "โ”œ",
                "/-|r" => "โ•ญ", "-\\r|" => "โ•ฎ",
                "|r\-" => "โ•ฐ", "r|-/" => "โ•ฏ",

                "..  " => "โ”ˆ", ". . " => "โ”Š",
                "  .." => "โ”ˆ", " . ." => "โ”Š",

                "----" => "โ•", "||||" => "โ•‘",
                "++++" => "โ•ฌ",
                "/-||" => "โ•”", "-\||" => "โ•—",
                "||\-" => "โ•š", "||-/" => "โ•",
                "||--" => "โ•ฉ", "--||" => "โ•ฆ",
                "-|-|" => "โ•ฃ", "|-|-" => "โ• ",

                "-- b" => "โ”", "| |b" => "โ”ƒ",
                "  -b" => "โ”", " | b" => "โ”ƒ",
                "+++b" => "โ•‹",
                "/-|b" => "โ”", "-\ b" => "โ”“", 
                "| \b" => "โ”—", " |-b" => "โ”›",
                "| -b" => "โ”ป", "--|b" => "โ”ณ", 
                "-+ b" => "โ”ซ", "+-|b" => "โ”ฃ", 

                ".. b" => "โ”‰", ". .b" => "โ”‹",
                "b .." => "โ”‰", " .b." => "โ”‹",
 
                "\//\\" => "โ•ณ",
                "\  \\" => "โ•ฒ",
                " // " => "โ•ฑ",

                "    " => " ",
                "#   " => "โ–˜", " #  " => "โ–", 
                "  # " => "โ––", "   #" => "โ–—",
                "##  " => "โ–€", "  ##" => "โ–„", 
                "# # " => "โ–Œ", " # #" => "โ–", 
                "#  #" => "โ–š", " ## " => "โ–ž",
                "### " => "โ–›", "## #" => "โ–œ", 
                "# ##" => "โ–™", " ###" => "โ–Ÿ",

                "####" => "โ–ˆ", "!!!!" => "โ–“", 
                "::::" => "โ–’", "...." => "โ–‘",

                " : :" => "๐Ÿฎ", ": : " => "๐ŸฎŒ",
                "::  " => "๐ŸฎŽ", "  ::" => "๐Ÿฎ",

                ":// " => "๐Ÿฎœ", "\: \\" => "๐Ÿฎ",
                " //:" => "๐Ÿฎž", "\ :\\" => "๐ŸฎŸ",

                "#// " => "โ—ค", "\# \\" => "โ—ฅ",
                " //#" => "โ—ข", "\ #\\" => "โ—ฃ",
                "\//v" => "๐Ÿฎš", "\//h" => "๐Ÿฎ›",
                
                "\ / " => "๐Ÿญฌ", "\/  " => "๐Ÿญญ",
                " / \\" => "๐Ÿญฎ", "  /\\" => "๐Ÿญฏ"
                
              );

function trim_lines(&$line) { $line = trim($line, "\n"); }

function pad_lines(&$line) { global $maxlen; $line = str_pad($line, $maxlen); }

/******************************************************************************/

$infile = file($argv[1]); // get an array of the lines in our input file

array_walk($infile, 'trim_lines'); // clean up newlines and tabs and whatnot

if ( (count($infile)/2) != (int)(count($infile)/2) ) // uneven line count?
    $infile[] = ""; // then add an empty line

// longest line a length not divisible by 4?
if (($maxlen = max(array_map('strlen', $infile)))/4 != (int)($maxlen/4) ) 
    $maxlen += 4 - ($maxlen % 4); // then adjust target length

array_walk($infile, 'pad_lines'); // pad infile's strings to target length

// massage $ingrid into an y,x grid of chars, each line space-padded to $maxlen

while ($line = array_shift($infile)) {
    $linearray = str_split($line);

    if (count($linearray) < $maxlen) 
        $linearray = array_pad($linearray, $maxlen, " ");

    $ingrid[] = $linearray;
}

for ($y=0; $y<count($ingrid); $y+=2) { 
    for ($x=0; $x<$maxlen; $x+=2) {
        $searchkey =  $ingrid[$y][$x]   . $ingrid[$y][$x+1] 
                    . $ingrid[$y+1][$x] . $ingrid[$y+1][$x+1];
        // print("[".$searchkey."][");
        if (array_key_exists($searchkey, $unich))
            print($unich[$searchkey]);
        else
            print($searchkey[0]);
       // print("]");
    }
    print "\n";
}

?>

Example inputs:

                                                  \/\  /
                                                  /\ \/
                                              \  /\/ / / /\/
                                               \/ /\/ / / /\
                                        \  /\ \/\/\/\/\/\/\/ / /
                                         \/  \/\/\/\/\/\/\/\/ /
                                    \   \/\/\ \/\/\/\/\/\/\/\/\/\  /
                                     \  /\/\ \/\/\/\/\/\/\/\/\/\ \/
                                  \/\ \/\/\/\/\/\/\/\/  \/\/\/\/\/\ \/
                                  /\ \/\/\/\/\/\/\/\/\##/\/\/\/\/\ \/\      ##
  .................................................. #  # ................ #  # ......................
  .................................................. #  # ................ #  # ......................
.... ###  ### .... ###### .... ###### .... ###### .. #  # ...... ###### .. #  # .... #### .. ###### ....
....#   ##   #....#      #....#      #....#      #.. #  # ......#      #.. #  # .... #  # ..#      #....
.. #..  ..  ..#  #.. ## ..#  #.. ## ..#  #.. ## ..#  #..# .... #.. ## ..#  #..# .... #..#  #.. ## ..# ..
.. #..# .. #..#  #..#  #..#  #..#  #..#  #..#  #..#  #..# .... #..#  #..#  #..# .... #..#  #..#  #..# ..
.. #::# :: #::#  #::#  #::#  #::#  #::#  #::#  #::#  #::# .... ####  #::#  #::# .... #::#  ####  #::# ..
.. #::# :: #::#  #::#  #::#  #::#  #::#  #::#  #::#  #::# ....       #::#  #::# .... #::#        #::# ..
.. #!!# ## #!!#  #!!#  #!!#  #!!#  #!!#  #!!#  #!!#  #!!# ...... #####!!#  #!!# .... #!!# .. #####!!# ..
.. #!!#    #!!#  #!!#  #!!#  #!!#  #!!#  #!!#  #!!#  #!!# ......#     !!#  #!!# .... #!!# ..#     !!# ..
.. #::# .. #::#  #::#  #::#  #::#  #::#  #::#  #::#  #::#  ### #:: ###::#  #::#  ### #::#  #:: ###::# ..
.. #::# .. #::#  #::#  #::#  #::#  #::#  #::#  #::#  #::#  # # #::#  #::#  #::#  # # #::#  #::#  #::# ..
.. #..# .. #..#  #..#  #..#  #..#  #..#  #..#  #..#  #..#  # # #..#  #..#  #..#  # # #..#  #..#  #..# ..
.. #..# .. #..#  #.. ## ..#  #..#  #..#  #.. ## ..#  #.. ##  # #.. ###..#  #.. ##  # #..#  #.. ###..# ..
.. #  # .. #  # ..#      #.. #  #  #  # ..#      #....#     # ..#       # ..#     #  #  # ..#       # ..
..  ##  ..  ##  .. ###### ..  ##    ##  .. ###### .... #####  .. #######  .. #####   #### .. #######  ..
  ....................................................................................................  
  ....................................................................................................  
                        \/\/\/   /\/\/ /\/\/\/\/\/\/\/\/   /\ \/\/\/\/\/\/\/\/\/\/
                        /\/\/\  / /\/\/ /\/\/\/\/\/\/\/\  /  \/\/\/\/\/\/\/\/\/\/\
                           /\/\/   / /\/\/\/\/\/\/  \ \/\/  \ \ \ \/\/\/\/\/\/\
                          / /\/\  / / /\/\/\/\/\/\   \/\/\   \ \ \/\/\/\/\/\/\ \
                              \/ /\/\/\/\/\/\/\          /\/\ \/\/\/\/\/ /\
                              /\/ /\/\/\/\/\/\ \        / /\ \/\/\/\/\/\/  \
                              
  ##                   ##                                                                              
 #####      ####       ##        ####       ##  ##      ##       ####       ##        ####       ##### 
  ##       ##  ##      ##       ##  ##      ##  ##      ##      ##          ##       ##  ##      ##  ##
  ##       ######      ##       ######       ####       ##       ####       ##       ##  ##      ##  ##
   ##       ##          ##       ##           ##         ##         ##       ##       ####       ##  ## 

Example outputs:

                         โ•ณโ•ฒโ•ฑ                                        
                       โ•ฒโ•ฑโ•ณโ•ฑโ•ฑโ•ฑโ•ณ                                      
                    โ•ฒโ•ฑโ•ฒโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ฑโ•ฑ                                    
                  โ•ฒ โ•ณโ•ณโ•ฒโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ฒโ•ฑ                                  
                 โ•ณโ•ฒโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ–„โ•ณโ•ณโ•ณโ•ณโ•ณโ•ฒโ•ณ   โ–„                             
 โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ– โ–Œโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ– โ–Œโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘                 
โ–‘โ–‘โ–žโ–€โ–„โ–€โ–šโ–‘โ–‘โ–žโ–€โ–€โ–šโ–‘โ–‘โ–žโ–€โ–€โ–šโ–‘โ–‘โ–žโ–€โ–€โ–šโ–‘โ– โ–Œโ–‘โ–‘โ–‘โ–žโ–€โ–€โ–šโ–‘โ– โ–Œโ–‘โ–‘โ–โ–€โ–Œโ–‘โ–žโ–€โ–€โ–šโ–‘โ–‘                
โ–‘โ–โ–‘โ––โ–‘โ–—โ–‘โ–Œโ–โ–‘โ–žโ–šโ–‘โ–Œโ–โ–‘โ–žโ–šโ–‘โ–Œโ–โ–‘โ–žโ–šโ–‘โ–Œโ–โ–‘โ–Œโ–‘โ–‘โ–โ–‘โ–žโ–šโ–‘โ–Œโ–โ–‘โ–Œโ–‘โ–‘โ–โ–‘โ–Œโ–โ–‘โ–žโ–šโ–‘โ–Œโ–‘                
โ–‘โ–โ–’โ–Œโ–’โ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–‘โ–‘โ–โ–€โ–˜โ–โ–’โ–Œโ–โ–’โ–Œโ–‘โ–‘โ–โ–’โ–Œโ–โ–€โ–˜โ–โ–’โ–Œโ–‘                
โ–‘โ–โ–“โ–Œโ–€โ–โ–“โ–Œโ–โ–“โ–Œโ–โ–“โ–Œโ–โ–“โ–Œโ–โ–“โ–Œโ–โ–“โ–Œโ–โ–“โ–Œโ–โ–“โ–Œโ–‘โ–‘โ–‘โ–žโ–€โ–€โ–“โ–Œโ–โ–“โ–Œโ–‘โ–‘โ–โ–“โ–Œโ–‘โ–žโ–€โ–€โ–“โ–Œโ–‘                
โ–‘โ–โ–’โ–Œโ–‘โ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–’โ–Œโ–โ–œโ–โ–’โ–žโ–œโ–’โ–Œโ–โ–’โ–Œโ–โ–œโ–โ–’โ–Œโ–โ–’โ–žโ–œโ–’โ–Œโ–‘                
โ–‘โ–โ–‘โ–Œโ–‘โ–โ–‘โ–Œโ–โ–‘โ–šโ–žโ–‘โ–Œโ–โ–‘โ–Œโ–โ–‘โ–Œโ–โ–‘โ–šโ–žโ–‘โ–Œโ–โ–‘โ–šโ–žโ–โ–โ–‘โ–šโ–Ÿโ–‘โ–Œโ–โ–‘โ–šโ–žโ–โ–โ–‘โ–Œโ–โ–‘โ–šโ–Ÿโ–‘โ–Œโ–‘                
โ–‘โ–โ–„โ–˜โ–‘โ–โ–„โ–˜โ–‘โ–šโ–„โ–„โ–žโ–‘โ–โ–„โ–˜โ–โ–„โ–˜โ–‘โ–šโ–„โ–„โ–žโ–‘โ–‘โ–šโ–„โ–„โ–˜โ–‘โ–šโ–„โ–„โ–„โ–˜โ–‘โ–šโ–„โ–„โ–˜โ–โ–„โ–Œโ–‘โ–šโ–„โ–„โ–„โ–˜โ–‘                
 โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘                 
            โ•ณโ•ณโ•ณ โ•ฑโ•ณโ•ณโ•ฑโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณ โ•ฑโ•ฒโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณ                           
             โ•ฑโ•ณโ•ณ โ•ฑโ•ฑโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณ โ•ฒโ•ณโ•ณ โ•ฒโ•ฒโ•ฒโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ฒ                            
               โ•ณโ•ฑโ•ณโ•ณโ•ณโ•ณโ•ณโ•ณโ•ฒ    โ•ฑโ•ณโ•ฒโ•ณโ•ณโ•ณโ•ณโ•ณโ•ฑโ•ฒ                              
 โ–„         โ–—โ––                                                       
โ–โ–ˆโ–€  โ–—โ–›โ–œโ––  โ–โ–Œ   โ–Ÿโ–€โ–™   โ–ˆ โ–ˆ   โ–ˆ   โ–Ÿโ–€โ–˜   โ–ˆ   โ–—โ–›โ–œโ––  โ–โ–›โ–œโ––                
 โ–œโ––  โ–โ–ˆโ–€โ–˜  โ–โ–™   โ–œโ–›โ–€   โ–โ–ˆโ–˜   โ–œโ––  โ–โ–€โ–™   โ–œโ––  โ–โ–™โ–Ÿโ–˜  โ–โ–Œโ–โ–Œ 

Displays best if your terminal has its own line- and block-drawing characters rather than using the fontโ€™s (Konsole and Kitty both do this admirably fwiw)โ€ฆ