💾 Archived View for plot47.space › docs › generative-unicode-art.gmi captured on 2024-05-10 at 10:27:19. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-03-20)

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

Generative Unicode Art


The piece of art the program will produce can be specifed here:

machine03(4096)

and if it requires a random seed, then the below can be uncommneted, to use the current time as the seed, or a static value can be passed in to create the same piece over and over again.

srand()

Machine 01

Produces pieces like:

┼┴┼┼┼─┴┼┴┬┴┬┴┬┼┼┬┬─┬───┼─┴──┼─┬┼┬┴┬┬┴┼┴┼┬┼┴┼┴┴┼┼─┼┬──┬┼┴──┴──┼┼┼┴┬┴┼┬┬┬─┴┼┼┬┴┬┬┴┬─┴┼┼┴─┼┴┬┼┬┬┼┴┼┴┼┬┼┴─┼┼─┼┬┴┬┴┼┴┴──┴┬┴─┼──┴┼┼┼┬┴┬┴┴─┬──┬─┼─┬─┼─┬──┼┬┬┼┬┼──┬───┴┼┬┼──┼─┼─┼─┼──┼┬──┴┼┼┴┬┬┴┬─┬┼┴┼┬┼┬┬─┬┼┼┼┼┼┬┼┼┬┴─┼┼─┬─┬─┬┴┴──┬─┬┬┼┴┬┬─┴┬┼┴┴┼┴─┴┬┼─┬┴┴┴┬─┬─┴┬┬┬┴─┬┬┬┴┬─┼┬┬┴┬─┴┼┬──┴┬┬┬┴┼┴┴─┼─┼┴─┴┼┼┼┬─┬┴┼┼┼┼─┼┬┴┼┼┼┴┬─┴┼┴┴┼┴┴─┬┬─┬┴┼┬──┴──┴┴┼┼┬┼┼┴┴┴┬┬┴───┬┴┴┴─┴┼┬┴┬┼┴─┼┬┬─┬┴┼┴─┴┬┬┼┴┼─┴─┼┼┴─┼┬─┴┼┬─┴┼──┴┴┬┼───┴┼┬┴─┬┬┬┬┴┴┼┴─┬┬┬┬─┼──┼─┴─┼┴┴┼┴┼┬─┴┼┬┼┴──┬─┬┼┬─┴┴┴─┴┬─┬─┴┴┴┬┴┬┬┼┬┼┬┴┬─┬┼┬┬┬┴┴┬┼┬───┬─┬┬┬──┴┴┬┼─┴┬┼┬┴┼──┬┼┬┼─┴┬┼┬┬┼─┼┬┼┴┬┼┼┼┬┬┼┼┴┼┬┬┼┼┼┴┬┴─┼┼┼┬┴┬┬┬┬─┬─┬┬┼┬─┴┬─┼┴┬┴─┴─┴─┬┬┼┬┴┴┼──┬┬──┬┼┬┴┴┼┼┼┼┼┴┬─┴┼┴┼┼─┴┼┼┼┴┼┼┴┴┬┬┬─┴┴┬┼─┬┼─┴─┬┬┬┬─┬┬──┴─┼┬┼┼┼─┴┴┼┬┼─┴┼┴┼┬┴┴┼─┼┬┬┼─┴──┬───┼───┴┬┼─┬─┴┴┴┴─┼┬──┴┼┼┴┼─┬─┬┬┴┼┬┴─┼┼┬┬┼┴┼┴┼─┬─────┬─┼┼─┼┴┴┬─┬┴┼┼┬┬┬─┴┬┬─┼┴─┬┴┴┬┬┴┴┬┴─┼┴┬─┼┼┬┴┬┬┼┴┴─┬┼┬┬┼┼┬┴┴───┴┴┬┼┬┴──┴┼───┬┬─┼┼─┴┼┼─┬┬┬┼─┼┼─┴─┼─┬┴─┼┼─┼┼┴┬┴┴┬┴┬──┴─┬─┼┬─┬┬┴┼┼──┬┴─┴─┴┴─┬─┴─┼┼┬┼┼──┬─┼─┴┬┬┬┬┴┼┬┼─┼┴┴─┼┴┬┼┼┼┬┬┬┬┬┬┬─┼┬───┼┼┬─┬┴─┼─┴┴─┴

The machine takes the following unicode box characters[1] "─,┴,┬,┼" and just randomly prints them in a long string to the screen. If the "Seed" has not been set, or is specified statically, it will always produce the same piece of art.

function machine01(size, _i, _CHAR) {
  _CHAR[0] = "─"
  _CHAR[1] = "┴"
  _CHAR[2] = "┬"
  _CHAR[3] = "┼"

  for (_i = 0; _i < size; _i++) {
    printf _CHAR[randint(3)]
  }

  print ""
}

[1] Unicode Block Drawing Characters

Machine 02

Produces pieces like:

╱╱╲╲╱╲╲╲╲╲╱╲╲╲╱╱╲╲╲╱╱╲╱╱╲╱╲╲╱╲╲╱╲╲╱╱╱╱╲╱╲╱╱╱╲╱╲╱╱╱╲╲╲╱╲╲╲╲╱╲╱╱╱╱╲╱╲╱╱╱╲╱╲╲╲╲╱╱╲╲╲╲╱╲╲╲╱╱╲╲╱╲╲╱╱╱╲╲╲╲╱╱╱╲╱╲╱╱╱╱╲╲╱╱╱╲╲╱╱╲╲╱╱╲╱╲╱╲╱╲╲╲╱╱╲╱╲╱╲╲╲╱╲╲╲╲╱╲╱╲╱╱╲╲╲╱╱╲╱╲╲╱╱╲╱╱╱╱╱╲╱╲╱╲╱╲╲╲╱╲╱╱╱╱╲╲╱╲╲╱╲╱╱╲╱╲╱╱╲╱╲╲╲╱╱╱╲╱╱╱╲╱╱╱╲╱╲╲╱╱╱╲╲╲╲╲╱╲╱╲╱╱╲╲╱╲╱╱╱╱╱╲╲╲╲╱╲╲╱╱╱╱╲╱╱╲╲╱╲╲╱╲╱╲╲╱╲╲╱╲╱╱╱╱╲╱╲╲╱╲╲╱╱╲╲╱╲╱╲╱╱╲╲╱╱╱╲╲╱╲╱╲╱╲╲╱╱╲╱╱╲╲╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╲╱╲╱╱╱╲╱╱╲╲╱╱╱╱╲╲╱╱╱╲╲╲╱╱╲╲╱╲╱╱╱╱╱╱╲╱╱╲╲╱╲╱╲╱╱╱╱╲╲╱╲╱╱╲╲╱╲╲╲╲╱╱╲╱╱╲╲╲╱╱╱╲╱╲╱╱╱╱╱╲╱╲╱╲╱╲╲╲╲╲╲╲╲╲╱╱╱╲╲╱╲╲╱╱╲╱╲╲╱╲╲╲╱╲╱╲╲╱╲╲╲╱╲╱╲╲╱╲╲╱╱╲╱╱╲╲╲╱╲╱╲╲╱╱╱╱╲╱╲╱╱╱╲╲╲╱╲╲╱╱╱╱╲╱╲╲╱╱╲╱╲╲╲╲╲╱╱╲╱╲╲╱╱╲╱╲╲╲╲╲╲╲╱╲╱╲╱╲╲╲╲╲╲╱╱╱╱╲╲╲╱╲╱╱╱╱╱╱╲╲╱╲╲╱╱╱╲╱╲╲╱╲╱╲╲╱╱╱╲╱╱╱╲╱╲╱╲╲╱╲╲╲╱╲╲╲╱╱╱╲╲╲╲╱╱╲╱╱╲╱╲╱╲╱╲╲╲╱╲╱╱╱╲╲╱╱╱╱╲╲╱╱╱╲╱╱╲╲╲╲╱╱╲╱╲╱╲╲╲╱╲╲╲╲╱╱╱╲╱╲╱╲╱╱╲╲╲╱╲╲╲╱╱╱╱╱╲╱╲╱╱╲╱╲╱╲╱╲╱╱╱╲╱╲╲╲╱╲╱╱╲╱╱╲╲╱╱╱╱╲╲╲╲╲╲╱╱╲╲╲╱╱╱╱╲╱╱╲╲╱╲╱╱╱╱╲╲╱╱╱╱╲╲╲╲╲╲╱╱╲╲╱╲╱╲╱╱╲╱╱╱╱╲╲╱╲╲╲╱╲╲╱╲╲╱╲╱╱╱╲╲╱╲╱╱╲╱╲╲╲╲╲╲╱╲╱╱╱╲╱╱╲╲╱╲╲╲╱╲╱╲╱╱╲╲╱╱╱╲╲╲╲╲╲╲╱╲╲╲╲╱╲╲╲╲╱╲╲╱╲╲╲╲╲╲╲╱╲╲╱╲╲╲╱╱╱╲╲╱╱╲╲╲╱╲╲╱╱╲╲╲╱╲╲╱╱╲╱╱╱╲╲╲╱╱╱╲╲╱╲╱╲╲╲╱╱╲╱╲╱╱╲╲╲╱╲╲╱╱╲╱╲

The machine takes the following unicode box characters[1] "╱,╲" and just randomly prints them in a long string to the screen. If the "Seed" has not been set, or is specified statically, it will always produce the same piece of art.

function machine02(size, _i, _CHAR) {
  _CHAR[0] = "╱"
  _CHAR[1] = "╲"

  for (_i = 0; _i < size; _i++) {
    printf _CHAR[randint(1)]
  }

  print ""
}

[1] Unicode Block Drawing Characters

Machine 03

Produces pieces like:

╭╭╮╰╯╭╭╮╮╯╮╯╰╰╮╮╭╰╮╰╯╯╭╭╭╮╭╮╯╰╰╰╰╭╰╯╭╭╭╯╯╮╮╯╭╯╰╮╯╮╮╭╰╮╮╭╰╯╮╯╯╮╮╯╮╭╭╯╭╮╭╰╯╯╯╰╮╯╭╰╰╯╭╰╭╯╰╰╭╮╮╯╯╯╭╰╰╮╮╭╰╯╰╮╭╯╮╯╭╮╯╰╰╯╯╰╮╮╰╮╰╮╭╮╭╮╭╰╰╯╭╯╭╭╭╮╯╮╰╯╰╮╯╰╭╭╰╮╯╯╰╮╭╭╯╭╯╰╰╮╮╰╭╯╰╭╭╯╯╰╭╯╮╰╮╮╭╮╰╯╭╰╭╭╰╰╭╯╰╭╰╭╭╭╰╭╮╰╯╰╰╰╯╭╯╰╯╯╮╯╮╮╯╯╮╮╮╯╰╭╯╰╮╯╭╮╰╮╭╮╮╭╮╰╮╰╰╭╯╭╯╰╮╭╯╰╯╰╮╯╭╰╯╯╯╯╰╮╰╭╰╭╮╭╭╯╭╰╯╯╭╮╯╯╯╭╮╭╭╯╰╮╯╮╰╮╰╰╰╰╭╯╭╮╰╮╭╰╮╯╮╮╭╭╰╯╮╭╰╮╰╯╰╯╭╰╰╭╰╯╰╰╮╭╮╭╮╮╰╯╭╮╭╮╯╰╰╰╭╯╮╰╮╭╯╮╰╮╮╯╭╮╯╮╯╭╮╰╯╮╯╯╯╯╰╮╯╰╭╯╯╮╯╰╮╭╭╮╯╯╭╯╭╯╭╯╯╯╯╭╰╮╰╯╰╰╰╯╯╭╭╭╯╯╭╭╰╮╮╮╰╮╭╭╭╮╰╯╰╮╰╰╰╯╯╰╯╯╮╮╯╮╯╭╭╯╭╰╰╯╮╰╭╮╭╭╰╰╯╯╮╯╯╭╮╭╰╰╰╭╭╯╯╰╰╯╮╭╯╮╯╰╮╯╮╮╰╭╭╯╰╮╭╯╯╮╰╮╮╯╯╮╮╭╮╭╰╯╭╮╭╰╮╮╯╰╯╮╭╰╰╭╭╭╯╯╮╮╭╯╭╯╭╮╰╮╮╯╭╯╭╭╮╯╯╭╮╭╯╮╭╮╯╮╯╭╰╰╮╭╯╮╰╰╯╯╭╭╮╮╯╮╯╭╭╭╭╮╮╯╰╮╭╮╯╯╯╯╯╰╯╮╮╮╭╰╭╮╭╮╯╯╰╭╯╰╭╰╮╯╯╮╰╰╰╯╯╮╭╮╮╰╯╯╮╯╯╮╭╯╰╰╮╰╰╭╯╭╰╭╯╯╯╯╮╮╭╰╰╮╮╭╭╰╰╮╯╮╰╯╭╰╮╮╯╮╮╮╯╮╮╭╰╰╰╮╮╰╮╭╮╯╮╮╮╭╰╭╮╰╰╮╯╮╰╭╯╭╮╭╮╰╮╮╯╮╯╭╮╭╭╯╯╮╭╭╮╰╮╰╰╭╮╮╮╭╯╭╮╭╮╰╰╯╭╯╭╰╯╮╰╰╰╯╮╰╰╯╰╭╯╯╭╭╭╮╮╯╯╯╯╰╮╯╯╯╭╯╯╰╰╯╯╰╭╰╰╭╯╯╭╮╭╭╮╭╯╯╰╮╮╯╭╰╭╯╯╮╭╭╭╭╰╰╰╭╯╯╭╮╮╭╯╯╮╭╰╭╯╯╮╭╭╮╰╮╭╯╯╭╰╰╮╯╯╭╯╮╰╯╯╮╰╭╰╭╭╯╮╰╭╯╭╮╭╭╰╭╯╯╮╮╮╯╰╭╰╯╮╰╮╰╭╭╭╰╮╮╮╰╭╯╮╭╭╯╭╰╯╰╮╭╭╰╯╭╰╯╯╭╮╰╭╮╭╭╮╯╮╯╮╯╮╰╰╮╮

The machine takes the following unicode box characters[1] "╭,╮,╯,╰" and just randomly prints them in a long string to the screen. If the "Seed" has not been set, or is specified statically, it will always produce the same piece of art.

function machine03(size, _i, _CHAR) {
  _CHAR[0] = "╭"
  _CHAR[1] = "╮"
  _CHAR[2] = "╯"
  _CHAR[3] = "╰"

  for (_i = 0; _i < size; _i++) {
    printf _CHAR[randint(3)]
  }

  print ""
}

[1] Unicode Block Drawing Characters

Machine 04

Programmer [aemkei] Tweeted the formula "(x ^ y) % 9" alongside code for more “alien art”. But how can a formula as simple as "(x ^ y) % 9" result in a complex design? The combination of Bitwise XOR (^) and Modulo (%) generate a repeating pattern that’s still complex enough to satisfy the eye[1].

[1] Alien art drawn with surprisingly simple math

The Program Structure

Header
Begin
Seed
Art
End
Random Integer
Machine 01
Machine 02
Machine 03

The Header

The header is just the bit of the file that tells the shell what to run it with. It goes at the very start of the file.

#!/usr/bin/awk -f

The program

It consists of a BEGIN wrapper around a function (the art function):

BEGIN {

{The art program goes here}

}

Helper functions

The "randint" helper function creates a random number between 0 and n. It will always produce the same set of number unless initialised with a seed using the "srand(x)" function, before running it the first time. If "x" is not supplied it will use the current time.

function randint(n) {
  return int((n + 1) * rand())
}