The Lab / Creative Coding

Creative CodingWeek 04-05

Oblivion is Freedom

Rest Energy, rebuilt in pure line. The code finds where two bodies face each other, pushes their edges inward, and laces them together in red.

Date
Sep 24, 2026
Course
Creative Coding · DM-GY 6063
Type
Generative

Design concept

Rest Energy projected in a dark gallery: Marina Abramović and Ulay hold a drawn bow, the arrow aimed at her heart
Marina Abramović and Ulay, Rest Energy, 1980. Image via Far Out Magazine

In Rest Energy (1980), Marina Abramović and Ulay lean away from each other, holding a drawn bow between them. The arrow points at her heart. Distance keeps the bow taut; trust keeps her alive.

I read this work against a pattern I see in my own generation: relationships that are physically close but emotionally half-present. Bodies close, trust withheld. The tension is the same; only the geometry has flipped.

So I rebuilt the performance in pure line, one question at a time: first read the bodies, then move their outlines, and finally tie the two people together.

Black silhouette of two figures holding a drawn bow between them
The silhouette the code reads. It never appears on the canvas.
The same two figures drawn as one continuous line
The one-line outline, drawn as the first layer
01

1. How does the code see a body?

Which pixels count as body?

I started from a silhouette of the performance: black figures on a white background. The sketch reads the image pixel by pixel. A pixel belongs to a body only if it is visible and dark. Anything faint or transparent is empty space.

function isBlackPixel(x, y) {
  let index = 4 * (x + y * img.width);
  let r = img.pixels[index];
  let g = img.pixels[index + 1];
  let b = img.pixels[index + 2];
  let a = img.pixels[index + 3];

  // Ignore the transparent background
  if (a < 50) return false;

  let brightness = (r + g + b) / 3;
  return brightness < 100;
}

Which edge matters?

Not the whole outline, only the two sides that face each other across the bow. Every 6 pixels down the image, the sketch scans one row and keeps her rightmost black pixel. A search limit keeps the scan inside the left 40% of the image, so the bow and his body never get mistaken for hers. His side does the same thing in reverse: it keeps his leftmost pixel inside the right 40%.

What comes out is no longer a shape. It is a column of points, one per row, waiting to be used.

let n = 6; // vertical gap between rows

function findGirlRightEdge() {
  girlRightEdge = [];

  for (let y = 0; y < img.height; y += n) {
    let rightX = -1; // -1 means nothing found yet

    // Scan left to right and keep the last black pixel: her right edge
    for (let x = 0; x < girlSearchLimit; x++) {
      if (isBlackPixel(x, y)) rightX = x;
    }

    if (rightX !== -1) girlRightEdge.push({ x: rightX, y: y });
  }
}
02

2. What if the two bodies don’t match?

Problem

They never do. His head sits higher than hers, so scanning both bodies on the same rows would give them different numbers of points, and some of his points would have no partner on her side.

Insight

The two bodies don’t need to share rows. They need to share a count. If each body is split into the same number of slices, point i on her side always has a point i on his.

Solution

The sketch first finds the top and bottom of his body. It then divides his height by her line count, so his rows are spaced evenly over his own body and he ends up with exactly as many points as she has. In draw(), min() is a final check: only rows where both edges have a point get drawn.

function findBoyLeftEdge() {
  boyLeftEdge = [];
  let boySearchStart = img.width - boySearchLimit;
  let lineCount = girlRightEdge.length;

  // 1. Find the top and bottom of his body
  let boyTopY = -1;
  let boyBottomY = -1;
  for (let y = 0; y < img.height; y++) {
    let hasBoyPixel = false;
    for (let x = img.width - 1; x >= boySearchStart; x--) {
      if (isBlackPixel(x, y)) { hasBoyPixel = true; break; }
    }
    if (hasBoyPixel) {
      if (boyTopY === -1) boyTopY = y;
      boyBottomY = y;
    }
  }

  // 2. Space his rows so he gets as many lines as she has
  let boyLineGap = (boyBottomY - boyTopY) / (lineCount - 1);

  for (let i = 0; i < lineCount; i++) {
    let y = round(boyTopY + i * boyLineGap);
    let leftX = -1;

    // Scan right to left and keep the last black pixel: his left edge
    for (let x = img.width - 1; x >= boySearchStart; x--) {
      if (isBlackPixel(x, y)) leftX = x;
    }
    if (leftX !== -1) boyLeftEdge.push({ x: leftX, y: y });
  }
}
03

3. How do you move an outline without drawing it?

Problem

I wanted each edge to feel pushed toward the other person. But drawing the silhouette and then a copy of it would only produce two filled shapes side by side.

Insight

An outline can exist only as the places where lines begin and end. If every row has a short line, the starting points trace the original edge and the end points trace the moved one. Neither edge has to be drawn.

Solution

Each edge point is moved inward in two steps: 10 pixels, then 50 more. Hers moves right, his moves left. The sketch draws one horizontal line from the original point straight to the final one. The silhouette is read but never shown. What sits under the lines is the one-line outline instead, so nothing of the original image reaches the canvas.

let move1 = 10;
let move2 = 50;

for (let i = 0; i < lineCount; i++) {
  let girl = girlRightEdge[i];
  let boy = boyLeftEdge[i];

  // Her edge moves right, his moves left
  let girlX3 = girl.x + move1 + move2;
  let boyX3 = boy.x - move1 - move2;

  line(girl.x, girl.y, girlX3, girl.y);
  line(boy.x, boy.y, boyX3, boy.y);
}
04

4. Where should two people connect?

Problem

The bow holds the two bodies apart. I wanted the space between them to do the opposite and bind them.

Insight

They shouldn’t connect at their original edges but at their moved ones, the two closest points across the gap. If the lines cross between rows instead of running straight across, they read as a thread pulled back and forth rather than a ladder.

Solution

Her moved point on row i connects to his moved point on row i + 1, and his to hers. Row after row, the crossings become a zigzag lace of X’s between them. Be a part, never apart.

stroke(255, 0, 0);

for (let i = 0; i < lineCount - 1; i++) {
  let girlCurrent = girlRightEdge[i];
  let girlNext = girlRightEdge[i + 1];
  let boyCurrent = boyLeftEdge[i];
  let boyNext = boyLeftEdge[i + 1];

  // Moved edges only
  let girlCurrentX3 = girlCurrent.x + move1 + move2;
  let girlNextX3 = girlNext.x + move1 + move2;
  let boyCurrentX3 = boyCurrent.x - move1 - move2;
  let boyNextX3 = boyNext.x - move1 - move2;

  // Her row i → his row i + 1
  line(girlCurrentX3, girlCurrent.y, boyNextX3, boyNext.y);
  // His row i → her row i + 1
  line(boyCurrentX3, boyCurrent.y, girlNextX3, girlNext.y);
}
05

5. How does it become physical?

Problem

A pen plotter draws one pen at a time. A single SVG with every line in it can only become a print in one color.

Insight

Each color needs its own file. The lacing should come out of the same sketch so it lands exactly where it belongs over the outline.

Solution

The canvas is an SVG canvas (p5.js-svg), and pressing S saves whatever is on it as a vector file. I keep a second version of draw() that renders only the red lacing, export each layer separately, and plot them one after the other on the same sheet.

function setup() {
  createCanvas(img.width, img.height, SVG);
  // ...
}

function keyPressed() {
  if (key === 's' || key === 'S') save("RestEnergy_lines.svg");
}

Pipeline: silhouette → pixel reading → edge detection → moved lines → cross connections → SVG (p5.js + p5.js-svg) → Inkscape → pen plotter