Reflection
The floating triangle of the 1980s and its reflection.
- Run
swift run --package-path Examples Example-Recreations-NasreenMohamedi-Reflection- Source
- Examples/Recreations/NasreenMohamedi/Reflection/Sketch.swift
// Recreation after Nasreen Mohamedi - an untitled drawing of her last
// decade: Untitled, ca. 1980s, ink and graphite on paper on board, 11 x 14
// in., Talwar Gallery TG 3812, read beside a sheet of the same size and
// figure that was shown in "Lines among Lines" at the Drawing Center, New
// York, in 2005 (Untitled, ca. 1980s, ink and graphite on paper, 11 x 14
// in.). Every work of hers is untitled, so nothing here is named after one.
// A homage, not a reproduction, and not affiliated with or endorsed by the
// artist or her estate.
// https://www.talwargallery.com/artists/nasreen-mohamedi
// https://www.talwargallery.com/exhibitions/nasreen-mohamedi4
// https://www.talwargallery.com/news/the-new-york-times25
//
// An original Ollin interpretation. No statement of a rule for these
// sheets was found, hers or anyone's: the figure and its proportions were
// read off the gallery's pictures of them by measuring, and the order the
// lines are ruled in is this sketch's own guess. Nothing was ported: the
// work is a ruling pen and a pencil on paper.
import Foundation
import Ollin
/// The floating triangle and its reflection (Nasreen Mohamedi, the 1980s).
/// The sheets of her last years are small and nearly empty. Holland Cotter,
/// reviewing her retrospective in 2016, wrote: "Her last drawings, which must
/// have demanded superhuman control, are of tiny spaceshiplike chevrons
/// shooting into deep space." An illness of the nervous system was taking
/// the steadiness of her hands by then.
///
/// On this sheet one figure hovers at the middle of the paper, about half as
/// wide as the sheet. It is a triangle with its point down, so flat that it
/// is nineteen times wider than it is deep. Its two lower edges are ink,
/// drawn heavy. They are widest at the point and thin to a quarter of that
/// at the tips, the way a ruling pen runs out. Its top edge is a hairline,
/// and level hairlines fill it at one even pitch. Each stops at the heavy
/// edges, so each is shorter than the one above. On the top edge stands a
/// second triangle, upright, which this sketch calls the roof: two hairlines
/// that meet in a corner a little wider than a right angle. Then, in
/// graphite and much paler, the whole figure is drawn again upside down, as
/// if it stood on still water.
///
/// Measuring the gallery's picture gives the numbers this sketch uses. The
/// mirror line is level and sits at the middle of the sheet's height, to a
/// quarter of one percent. Each of the figure's six hairlines has a twin the
/// same distance below that line, and the pairs agree to one part in 1,300
/// of the figure's width. The heavy point comes down to the mirror line and
/// the reflection's point comes up to meet it, a hair apart. Her hand shows
/// in one place: the roof's twin is about four percent deeper than the roof.
/// This sketch draws it as an exact twin.
///
/// The sheet shown in 2005 is the same figure said more briefly, and the
/// parameters carry most of the differences between the two. There the
/// triangle holds nine hairlines (`hatching` 9). The roof is smaller and
/// floats above the top edge (`roof` 0.096, `lift` 0.065). The point rests
/// on the mirror line (`gap` 0), and only the heavy edges are reflected
/// (`whole` off), as two graphite lines that cross at the point. Two
/// differences are left out: there the point stands 57 percent of the way
/// down the sheet, and the roof is ink.
///
/// Nothing on the sheet is left to chance, so every seed draws the same
/// figure. What moves is the ruling. A lap opens on the finished sheet,
/// clears it, and rules it again one line at a time, at a steady pace. The
/// top edge comes first, then the hairlines below it, the two heavy edges
/// from the point outward, and the roof. The reflection follows in the same
/// order.
///
/// Try it: `seconds` is the lap and the export loop. `hatching`, `roof`,
/// `lift`, `gap` and `whole` are the differences between the two sheets, so
/// the numbers above turn one nearly into the other. The hairlines export as lines
/// and the heavy edges as the outline of the region their stroke covers, so
/// `--export-svg` keeps the thinning for a pen.
@main
final class Reflection: Sketch {
/// How many level hairlines fill the triangle, counting its top edge.
/// They divide its depth evenly. The measured sheet has 6, the sheet
/// shown in 2005 has 9.
@Param(2 ... 14, icon: "line.3.horizontal") var hatching = 6
/// The height of the roof, the upright triangle, as a share of the
/// figure's width. 0 leaves it out. Measured: 0.158, and 0.096 on the
/// 2005 sheet.
@Param(0 ... 0.22, icon: "triangle") var roof = 0.158
/// How far the roof floats above the top edge, as a share of the
/// figure's width. Measured: 0, and 0.065 on the 2005 sheet.
@Param(0 ... 0.12, icon: "arrow.up") var lift = 0.0
/// How far the middle of the heavy point stops short of the mirror
/// line, as a share of the figure's width. Measured: 0.0035, and 0 on
/// the 2005 sheet.
@Param(0 ... 0.03, icon: "arrow.up.and.down") var gap = 0.0035
/// The reflection shows the whole figure. Off, it shows the two heavy
/// edges only, as on the 2005 sheet.
@Param(icon: "square.on.square") var whole = true
/// Seconds for one lap: the finished sheet, a clean one, and the ruling.
/// It is also the export loop.
@Param(8 ... 30, icon: "clock") var seconds = 24.0
override var canvasSize: CanvasSize { .size(1400, 1100) }
override var loopDuration: Double? { seconds }
// The figure's proportions, measured on the gallery's picture of the
// sheet. Lengths are shares of the figure's width unless a name says
// otherwise.
/// The figure's width, as a share of the sheet's width.
private let span = 0.519
/// The flat triangle's depth, from its top edge to its point.
private let depth = 0.052
/// The heavy edges' width at the point, and the share of it left at a tip.
private let heavy = 0.0083
private let tip = 0.25
/// The slope of the roof's sides, as rise over run. Measured 0.88 on one
/// sheet and 0.94 on the other.
private let pitchOfRoof = 0.9
private let paper = Color(hex: 0xEFEEEB)
private let ink = Color(hex: 0x272120)
/// The hairlines of the figure: thin and brownish on the sheet.
private let hair = Color(hex: 0xB5AAA0)
/// The roof's two lines: gray, and a little paler.
private let roofGray = Color(hex: 0xC3C2BF)
/// The reflection, paler again. On the sheet it reads as graphite.
private let graphite = Color(hex: 0xCFCECB)
/// The width of every hairline, in canvas pixels.
private let fine = 0.6
/// One stroke of the pen or the pencil, in the order it is ruled.
private struct Ruled {
/// The points the stroke runs through, from where the pen is set down.
var points: [Vector2]
var color: Color
var weight: Double
/// A heavy edge thins as it goes: full width at its first point.
var isHeavy = false
}
/// Where the lap is: how much of the ruling is done (0 to 1) and how
/// much ink the sheet carries. The lap opens on the finished sheet,
/// clears it, and rules it again.
private func stage(at lap: Double) -> (ruled: Double, ink: Double) {
let hold = 0.14, clear = 0.2, done = 0.96
if lap < hold { return (1, 1) }
if lap < clear {
let gone = (lap - hold) / (clear - hold)
return (1, 1 - gone * gone * (3 - 2 * gone))
}
return (min(1, (lap - clear) / (done - clear)), 1)
}
override func draw() {
background(paper)
noFill()
strokeCap(.butt)
strokeJoin(.miter)
// 1. The figure, from its measured proportions. The mirror line is
// the middle of the sheet.
let across = width * span
let mirror = height / 2
let middle = width / 2
let point = Vector2(middle, mirror - gap * across)
let top = point.y - depth * across
let left = Vector2(middle - across / 2, top), right = Vector2(middle + across / 2, top)
let feet = top - lift * across
let rise = roof * across
let run = rise / pitchOfRoof
var figure: [Ruled] = []
// The top edge and the hairlines under it, each from the left heavy
// edge to the right one.
for index in 0 ..< hatching {
let share = Double(index) / Double(hatching)
let y = top + depth * across * share
let half = across / 2 * (1 - share)
figure.append(Ruled(points: [Vector2(middle - half, y), Vector2(middle + half, y)],
color: hair, weight: fine))
}
// The heavy edges, each from the point outward.
figure.append(Ruled(points: [point, left], color: ink, weight: heavy * across, isHeavy: true))
figure.append(Ruled(points: [point, right], color: ink, weight: heavy * across, isHeavy: true))
// The roof, one stroke over its tip.
if rise > 0.5 {
figure.append(Ruled(points: [Vector2(middle - run, feet), Vector2(middle, feet - rise),
Vector2(middle + run, feet)],
color: roofGray, weight: fine))
}
// 2. The reflection: every stroke again, the same distance below the
// mirror line as it stands above it, in graphite.
var marks = figure
for mark in figure where whole || mark.isHeavy {
marks.append(Ruled(points: mark.points.map { Vector2($0.x, 2 * mirror - $0.y) },
color: graphite, weight: fine))
}
// 3. How far the ruling has come. The pen moves at one pace, and
// lifting it to the next line costs as much as a short stroke.
let now = stage(at: loopProgress(over: seconds))
let lifting = across * 0.12
let lengths = marks.map { length(of: $0.points) }
let all = lengths.reduce(0) { $0 + $1 + lifting }
var owed = now.ruled * all
// 4. Draw what is ruled so far. The two heavy edges are one stroke
// with a sharp corner at the point, so they wait for each other.
var heavyReach: [Double] = []
for (index, mark) in marks.enumerated() {
let share = now.ruled >= 1 ? 1 : max(0, min(1, owed / lengths[index]))
owed -= lengths[index] + lifting
if mark.isHeavy {
heavyReach.append(share)
continue
}
guard share > 0 else { continue }
stroke(mark.color.withAlpha(now.ink))
strokeWeight(mark.weight)
let drawn = cut(mark.points, at: share)
if drawn.count == 2 { drawLine(drawn[0], drawn[1]) } else { drawPolyline(drawn) }
}
if heavyReach.count == 2, heavyReach[0] > 0 {
let toLeft = heavyReach[0], toRight = heavyReach[1]
let a = point + (left - point) * toLeft, b = point + (right - point) * toRight
let widthAtA = 1 - (1 - tip) * toLeft, widthAtB = 1 - (1 - tip) * toRight
stroke(ink.withAlpha(now.ink))
strokeWeight(heavy * across)
if toRight > 0 {
strokeProfile(.values([widthAtA, 1, widthAtB], at: [0, toLeft / (toLeft + toRight), 1]))
drawPolyline([a, point, b])
} else {
strokeProfile(.values([widthAtA, 1], at: [0, 1]))
drawPolyline([a, point])
}
noStrokeProfile()
}
}
/// The length of a bent line.
private func length(of points: [Vector2]) -> Double {
var total = 0.0
for index in 1 ..< points.count {
total += hypot(points[index].x - points[index - 1].x, points[index].y - points[index - 1].y)
}
return total
}
/// The first `share` of a bent line, by length.
private func cut(_ points: [Vector2], at share: Double) -> [Vector2] {
guard share < 1 else { return points }
var remaining = length(of: points) * share
var kept = [points[0]]
for index in 1 ..< points.count {
let piece = hypot(points[index].x - points[index - 1].x, points[index].y - points[index - 1].y)
if piece >= remaining {
kept.append(points[index - 1] + (points[index] - points[index - 1]) * (remaining / max(piece, 1e-9)))
return kept
}
kept.append(points[index])
remaining -= piece
}
return kept
}
}