Marcus Aurelius Meditations

Published by Tim on Sunday April 2, 2023

Last modified on October 3rd, 2024 at 14:36

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();
}

Enjoying the content?

I put a lot of love and effort into developing content on Creative Coding. Since 2018, I have published 209 interviews, case studies, and tutorials, along with over 272 lessons in 17 online courses – and there's more to come! If you'd like to support my work and help keep this platform evolving, please consider supporting me on Patreon. Thank you very much!

Speaking Image

Monthly Newsletter

Stay up to date and get new content circling around Creative Coding and Design within Limits, every 5th of the month, directly to your inbox.

Related

p5studio

A prototype for a browser-based design-application, built with p5.js and vue.js.

Building Tools with p5.js (Playlist)

Click here to login or connect!To view this content, you must be a member of Tim's Patreon at €7 or […]

DEMO 2025 – My Submissions

Limitations have always been playing a major role in my creative work; I was only able to develop my best […]

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 […]

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 […]

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 […]

Join the 128kb challenge!

Instagram, Twitter, TikTok… All the main platforms that technically have the required features to connect emerging communies for Creative Coding […]

A custom Mockup Tool, built with Processing (updated)

For my students at Elisava, I have created a new version of my mockup-tool. You need two different files for […]