Ollin

Current

A board of black lines that run from top to bottom and undulate, after Riley's Current (1964).

Run
swift run --package-path Examples Example-Recreations-BridgetRiley-Current
Source
Examples/Recreations/BridgetRiley/Current/Sketch.swift
//  Recreation after Bridget Riley - Current (1964), synthetic polymer paint on
//  board, 148.1 x 149.3 cm, The Museum of Modern Art, New York (Philip Johnson
//  Fund). A homage, not a reproduction, and not affiliated with or endorsed by
//  the artist or the museum.
//  https://www.moma.org/collection/works/79998
//  https://bridget-riley.publications.britishart.yale.edu/catalogue/10/
//  https://www.tate.org.uk/research/tate-papers/39/a-technical-study-into-bridget-rileys-paintings-fall-and-hesitate
//
//  An original Ollin interpretation, written from two pictures of the
//  painting (one in the Yale Center for British Art's catalog, one in Tate's
//  technical study) and from that study's account of Fall (1963), which names
//  Current as a similar work. For Fall she drew one curve by hand and had it
//  cut as a template. She traced it again and again across the board and
//  painted alternate bands black. The pictures of Current measure the same
//  way: every row is cut by the same 117 or so black lines at one constant
//  step. The curve's swing, its four waves, and the heights where the waves
//  tighten are measured from those pictures. Her curve was drawn by hand, and
//  here a formula with six numbers stands in for it. Nothing was ported: the
//  work is paint on board.

import Foundation
import Ollin

/// *Current* (Bridget Riley, 1964): a board filled from edge to edge with
/// black lines that run from top to bottom and undulate.
///
/// The whole painting is one curve. It is repeated across the board at a
/// constant sideways step, and every other gap between two copies is painted
/// black. So a black line is always half a step wide when measured straight
/// across, and it looks thinner wherever it leans.
///
/// The curve is a wave that leaves the top edge leaning left. It swings the
/// same distance to each side all the way down, about four steps. Only its
/// length changes. It makes `waves` whole waves from the top edge to the
/// bottom. They are long near both edges and `tightening` times shorter
/// inside a band. The band's middle sits at `band`, a little above the
/// middle of the board. The waves shorten quickly as a line comes into the
/// band from above (`onset`) and lengthen slowly as it leaves below
/// (`release`). The eye reads that lopsided squeeze as a ripple pressed into
/// the surface.
///
/// The painting is still and seems to move. Here the waves travel down the
/// lines, slowly through the band and fast near the edges. One lap of
/// `seconds` carries each wave to where the next one began.
///
/// Try it: set `tightening` to 1 for plain even waves. Move `band` to slide
/// the squeeze up and down the board. Make `release` equal to `onset` and
/// the band loses its lean. `--export-svg` writes each black line as one
/// closed outline.
@main
final class Current: Sketch {
    /// The black lines counted across the board.
    @Param(40 ... 160, icon: "line.3.horizontal") var lines = 117
    /// How far a line swings to each side, in steps from one line to the next.
    @Param(0 ... 8, icon: "arrow.left.and.right") var swing = 4.1
    /// Whole waves a line makes from the top edge to the bottom edge.
    @Param(1 ... 8, icon: "water.waves") var waves = 4.0
    /// Where the middle of the tight band sits: 0 is the top edge, 1 the bottom.
    @Param(0.2 ... 0.8, icon: "arrow.up.and.down") var band = 0.442
    /// The height of the tight band, as a share of the board's height.
    @Param(0 ... 0.4, icon: "rectangle.compress.vertical") var bandHeight = 0.105
    /// How many times shorter the waves are inside the band than at the edges.
    @Param(1 ... 12, icon: "arrow.down.right.and.arrow.up.left") var tightening = 6.7
    /// How soon the waves shorten above the band, as a share of the height.
    /// Small is abrupt.
    @Param(0.005 ... 0.2, icon: "arrow.up.to.line") var onset = 0.026
    /// How slowly the waves lengthen again below the band, as a share of the
    /// height. Large is gradual.
    @Param(0.005 ... 0.2, icon: "arrow.down.to.line") var release = 0.07
    /// Seconds for one lap: each wave travels down to where the next began.
    @Param(4 ... 30, icon: "clock") var seconds = 16.0

    override var loopDuration: Double? { seconds }

    /// The painting's black and its white, sampled from the catalog's picture.
    private let ink = Color(hex: 0x161616)
    private let ground = Color(hex: 0xFEFEFE)

    override func setup() {
        noStroke()
    }

    /// How many waves a line packs into a unit of height at `v`, where 0 is
    /// the top edge and 1 the bottom. It is 1 far from the band and
    /// `tightening` inside it. Above and below the band it falls away along
    /// a bell-shaped shoulder, `onset` wide above and `release` wide below.
    private func rate(at v: Double) -> Double {
        let fromMiddle = v - band
        let outside = max(0, abs(fromMiddle) - bandHeight / 2)
        let shoulder = fromMiddle < 0 ? onset : release
        let bump = 1 / (1 + (outside / shoulder) * (outside / shoulder))
        return 1 + (tightening - 1) * bump
    }

    override func draw() {
        background(ground)
        fill(ink)

        // One sample every two pixels down the board is finer than the
        // tightest wave needs, so the outline reads as a smooth curve.
        let rows = max(8, Int(height / 2))
        let step = 1.0 / Double(rows)

        // The wave's phase at each sample: the running sum of the rate, scaled
        // so that the whole height holds exactly `waves` waves.
        var phase = [Double](repeating: 0, count: rows + 1)
        var previous = rate(at: 0)
        for i in 1 ... rows {
            let here = rate(at: Double(i) * step)
            phase[i] = phase[i - 1] + (previous + here) / 2 * step
            previous = here
        }
        let whole = phase[rows]
        let turn = waves * .tau / whole

        // The lap moves every wave down by one whole wave, so the last frame
        // meets the first.
        let travel = loopProgress(over: seconds) * .tau

        let pitch = width / Double(lines)
        let reach = swing * pitch

        // One black line: down its left edge, then back up its right edge,
        // which is the same curve half a step to the right.
        var outline: [Vector2] = []
        outline.reserveCapacity(2 * (rows + 1))
        for i in 0 ... rows {
            // The minus sign is the painting's: a line leaves the top edge
            // leaning to the left.
            let x = -reach * sin(phase[i] * turn - travel)
            outline.append(Vector2(x, Double(i) * step * height))
        }
        for i in stride(from: rows, through: 0, by: -1) {
            outline.append(Vector2(outline[i].x + pitch / 2, outline[i].y))
        }
        let line = Shape(outline, closed: true)

        // The same line at every step across the board. A few extra copies on
        // each side cover the edges, where a line swings in from outside.
        let spare = Int(swing.rounded(.up)) + 1
        for k in -spare ..< lines + spare {
            withState {
                translate(Double(k) * pitch, 0)
                drawShape(line)
            }
        }
    }
}

↑↓ move ↩ open