Marcus Aurelius Meditations

Published by Tim on Sunday April 2, 2023

Last modified on January 25th, 2024 at 14:06

Since the beginning of the Corona crisis, I have been more and more interested in the history of ancient philosophy. The topic has grabbed me directly and no longer let go. And so I often spend my Sundays collecting second-hand books, reading and painting in them to make this abstract world a little more tangible to me.

I used to be very interested in psychology. And an interesting intersection between psychology and philisophy is represented by the philosophical schools of Hellenism. Stoicism in particular is very interesting in times of crisis. Books like the Meditations of Marcus Aurelius I have read and worked through several times. And I’ve always wondered how the knowledge from such books could be made available digitally in a useful way.

Ancient texts are almost all in the public domain, even in their translations, and so you can download them and work with them creatively. I have taken the Meditations of Marcus Aurelius, prepared the data cleanly and built a boilerplate for experiments with this work.

JSONArray json;

ArrayList<Verse> verses;

color black = #000000;
color white = #f1f1f1;
color grey = #AAAAAA;
color blue = #2700A2 ;
color green = #000000;

color FG1 = #0000FF;
color BG1 = #AAAAAA;

color FG2 = #AAAAAA;
color BG2 = #0000FF;

color FG, BG;

float offsetY = 0;
float padding = 10;

PFont font;
float txtSize = 150;

String txt, book, verse;
int verseAmount;

int selector = 0;

void setup() {

  size(1200, 900);

  offsetY = height;

  strokeCap(RECT);

  json = loadJSONArray("meditations.json");
  font = createFont("sans.otf", 1000);

  verses = new ArrayList<Verse>();

  for (int i = 0; i < json.size(); i++) {
    JSONObject item = json.getJSONObject(i);

    String txt = item.getString("english");
    String book = item.getString("book");
    String verse = item.getString("verse");
    Verse v = new Verse(txt, book, verse);
    verses.add(v);
  }
}

void draw() {
  background(BG);
  noStroke();

  verseAmount = json.size();

  Verse v = verses.get(selector);

  if (int(v.book) % 2 == 0) {
    FG = FG1;
    BG = BG1;
  } else {
    FG = FG2;
    BG = BG2;
  }

  drawProgressBar(v);
  v.display();


  offsetY -= 10;

  if (keyPressed) {
    if (keyCode == 37) {
      selector = selector - 1;
    } else if (keyCode == 39) {
      selector = selector + 1;
    }
    offsetY = height;
  }
}

class Verse {

  String txt;
  int book;
  int verse;

  Verse(String _txt, String _book, String _verse) {
    txt = _txt;
    book = int(_book);
    verse = int(_verse);
  }

  void display() {


    push();
    translate(padding, padding + offsetY);
    fill(BG);
    rect(0, 0, width, height*100-50);
    textFont(font);
    textSize(txtSize);
    textLeading(txtSize);
    textAlign(LEFT, TOP);
    if (book % 2 != 0) {
      fill(#F1F1f1);
    } else {
      fill(#000000);
    }
    text(txt, 0, 0, width - padding*2, height * 10);
    pop();
  }
}

void drawProgressBar(Verse v) {
  fill(FG);
  textFont(font);
  textSize(txtSize);
  textLeading(txtSize);
  textAlign(LEFT, TOP);
  text("marcus aurelius\nmeditations\nbook " + v.book + "\n" + "verse " + v.verse, 10, 10);
  
  float posX = map(selector, 0, verseAmount, 0, width);
  
  push();
  noStroke();
  fill(FG);
  rect(0, height-20, posX, 20);
  pop();
}

Related

Sam Griffith connects Creative Coding with Enviromentalism

In this post I’d like to introduce you to Sam Griffith, a talented graphic designer based in Detroit, to discuss […]

Throwback: My Talk at Demo Festival 2022

The next edition of the DEMO Festival is already approaching and I am currently developing a brand new talk for […]

Powers of Two – 128kb by Lena Weber

20 = 1 21 = 222 = 323 = 824 = 1625 = 3226 = 6427 = 128 … »In […]

p5.js Design Tools Directory

Hi! In this post I’ll collect case studies and direct links to tools that people have built with p5.js and […]

Omid Nemalhabib explores the intersection of Creative Coding and Perso-Arabic Typography

In 2022, I spontaneously posted a story on Instagram: If anyone out there is also in Rotterdam, I’d love to […]

The 128kb Framework and its Aesthetic Characteristics

One day in early 2024 I started to experiment with a new idea. I wrote down a set of rules […]

Lena Weber about her collaboration with A. G. Cook

Lena: This 10-minute visualiser for A. G. Cooks album teaser featuring my python archive generator, is one of my favourite […]

My new writing project “downgrade” is live

Hey folks, I hope you are doing great! You may have already read one or two of my essays that […]