Fractal zoom with text

I was wondering if its possible to create a fractal zoom with text instead of shapes or lines.
If so, can someone please point me in the right direction.
I’m currently learning Processing for my Major Project and this would be a great addition to my animation!

Fractal is a broad thing

Probably it’s not possible in a mathematical sense

But you could like fake it

Eg when you have the word Text and when you zoom in the lines of the T are again made by the word Text (so T = one horizontal „Text“ for the upper line and one vertical „Text“ for the vertical line).

And when you zoom in those texts are again made of „Text“

Hey, and welcome to the forum!

Great to have you here!!

Hi @M.Payne
I’ve played a bit with fractal zooming, and I’m curious about what you have in mind. Do you mean taking the contours of a bolded letter and then applying the line divisions of that contour similar to a Koch curve?

You might be able to fake it with the Chaos Game.

Disclaimer: this has been on my mind, so I am biased. Also, I have not tried to make a zooming function.

int T = 4000;

float px = 0;
float py = 0;
float prevx = 0;
float prevy = 0;
int nowc = 0;
float DETAIL = 0.5;
PGraphics msk;

int S = 220;

void setup() {
  msk = createGraphics(512,512,P2D);

void draw() {
  // Seems this used to work within setup()...?
  // Could load an image instead
  msk.text("TEXT", -15, 0);
  for (int i=0; i<T; i++) {
    int t = (int)random(4);
    float tx = 0;
    float ty = 0;
    int to = 0;
    switch(t) {
      case 0:
        tx = width;
        ty = 0;
        to = color(0, 0, 0);
      case 1:
        tx = width;
        ty = height;
        to = color(0, 255, 0);
      case 2:
        tx = 0;
        ty = height;
        to = color(255, 0, 0);
        tx = 0;
        ty = 0;
        to = color(0, 0, 255);
    // From wiki: "A point inside a square repeatedly jumps half of the distance towards a randomly chosen vertex. No fractal appears."
    // Myself: Assign colors to each vertex.
    //         Even without the text, an exclusive-or-like pattern (XOR of x and y coordinates) will appear betwen colors. :P
    nowc = lerpColor(nowc, to, DETAIL);
    px = px + (tx - px)/2.0;
    py = py + (ty - py)/2.0;
    if ((px < width) && (px >= 0) && (py < height) && (py >= 0)) {
      if ((msk.pixels[ int(py) * width + int(px)] & 0xFF) == 0)
        prevx = px;
        prevy = py;
        px = prevx;
        py = prevy;

Hey, thanks for the warm welcome and quick responses.
@Chrisir that sounds exactly like what I would like to do, how would this be coded?

@noahbuddy I tried your coding and although it produced something very colourful and looks great, it’s not quite what I’m looking for!


I’ve uploaded a simple sketch which I’m hoping explains what I’m hoping to achieve a bit better.


I can point to one of them (as always, probably more ways to do it than one…).

One way is to make the text as an IFS (Iterated Function System - IE an ordered fractal. Same type as a Sierpinski triangle and lots of others). I’ve pointed to this listing of Electronics & Wireless World magazines in another post (freely downloadable). There, the August 1990 issue have a really good article on ordered fractals. Unfortunately, the link doesn’t work atm (probably temporary?). In the mean time, I re-uploaded the issue here, in case you like to give it a read (Page 703. Don’t worry, the page numbering in that issue begins at 647 ish).

As an example, the author shows a collage of the letters “ME”:

(I made a Visual Basic program years ago based on that article btw. I’ve been meaning to re-write for Processing, but haven’t gotten around to it)