Trama
Two ruled rectangles woven with one family of circles, after Mac Entyre's Tramas (1961 to 1964) and Pintura Generativa: Trama General por Circunferencias (1964).
- Run
swift run --package-path Examples Example-Recreations-MacEntyreVidal-Trama- Source
- Examples/Recreations/MacEntyreVidal/Trama/Sketch.swift
// Recreation after Eduardo Mac Entyre - the Tramas of the early 1960s,
// weaves of concentric circles and ruled lines, read from Pintura
// Generativa: Trama General por Circunferencias (1964, oil on canvas, 169 x
// 77 cm) in the Art Museum of the Americas of the Organization of American
// States, Washington, from Tramas (1961 to 1964, oil on canvas, 135 x 63.5
// cm) in the Museo Nacional de Bellas Artes, Buenos Aires, and from the
// detail pictures of Vibraciones sobre rojo (1964, oil on canvas, 75 x 60
// cm) published by the Museo de Arte Moderno de Buenos Aires. A homage, not
// a reproduction, and not affiliated with or endorsed by the artist or his
// estate.
// https://artsandculture.google.com/asset/pintura-generativa-trama-general-por-circunferencias/5QGxj5vNXePyDQ
// https://www.bellasartes.gob.ar/coleccion/obra/7275/
// https://coleccion.museomoderno.org/index.php/Detail/works/16186
//
// An original Ollin interpretation. The Washington museum's note on its
// canvas, by Mark Andrew White, states the rule: "the intersection of a
// fragmentary series of concentric circles with two rectangular grids, each
// composed of precise horizontal lines". The note on Tramas by María Amalia
// García, for the Museo Nacional de Bellas Artes, reads that canvas the same
// way: two rectangles, each a weave of straight horizontal lines with a
// weave of circular lines laid over it. The proportions are measured off
// the Washington museum's picture of its canvas. How the lines are spaced
// is read off pictures, since no account gives it. In the details of
// Vibraciones sobre rojo, the closest pictures there are, the circles keep
// one step. One ruling keeps one gap, a little wider than that step. The
// other starts at a quarter of the step and opens by a little more at every
// line. The Washington picture is too small to count lines in. The default
// ruling here, a little wider than the step at the inner edge and closing
// toward the outer one, is chosen because it gives forms like the ones
// that picture shows. Nothing was ported: the canvases were ruled and drawn
// by hand. The ranges, the looks, and the motion are this sketch's own.
import Foundation
import Ollin
/// Trama (Eduardo Mac Entyre, Buenos Aires, 1961 to 1964). A trama is a
/// weave. In the first half of the 1960s he laid two plain families of lines
/// over each other and painted what they made together. One family is a set
/// of circles about a single center, each a constant step larger than the
/// last. The other is a set of straight horizontal lines. Neither is much to
/// look at alone. Where they cross, the eye joins the crossings into large
/// soft curves that are painted nowhere: a moiré, the pattern two regular
/// patterns make when they overlap. The canvases in Washington and in the
/// Museo Nacional de Bellas Artes each hold two rectangles of ruled lines,
/// one above the other. One set of circles is centered between them, so each
/// rectangle shows only a piece of it.
///
/// The lines are not always evenly ruled. In his *Vibraciones sobre rojo*
/// of 1964 one ruling starts with a gap a quarter of the circles' step. Each
/// gap after it is a little wider, until the lines are as far apart as the
/// circles. So the two families fall in and out of step down the canvas. The
/// soft curves gather where the gap comes equal to the step. They gather as
/// rings when the gap is widening there, and as a waist between two fans of
/// arches when it is narrowing.
///
/// Here the circles are `step` apart and stop where the largest touches the
/// outer edge of the rectangles. Each rectangle is ruled from its inner edge
/// outward. The gap at the inner edge is `inner` steps and the gap at the
/// outer edge is about `outer` steps. Every gap between differs from the one
/// before by one constant amount, so the last line lands exactly on the
/// outer edge. The seed moves each rectangle's two gaps by up to a tenth, as
/// two rulings by one hand differ, and a press deals the next pair. Over one
/// cycle of `seconds` every circle grows by one step and the outermost fades
/// out. So the soft curves flow, and the picture comes back to itself.
///
/// Try it: `inner` at 0.25 and `outer` at 1 is the opening ruling measured
/// off *Vibraciones sobre rojo*, and both at 1.12 is its even one. `look`
/// picks the paints of one of the three canvases, on the proportions of the
/// Washington one. A larger `step` shows the two families plainly.
/// `--export-svg` gives every ruled line as a line and every piece of a
/// circle as one stroke, so the steps can be read from the file.
@main
final class Trama: Sketch {
/// The ground and the paints, after three of the canvases.
enum Look: String, CaseIterable, ParamOption {
/// Washington: magenta lines and blue circles on vermilion.
case bermellon
/// Museo Nacional de Bellas Artes: red circles on blue, over pink
/// lines in the upper rectangle and green lines in the lower.
case azul
/// Museo de Arte Moderno: green lines and blue circles on crimson.
case carmin
}
/// The ground and the paints.
@Param(icon: "paintpalette") var look = Look.bermellon
/// The distance from one circle to the next, in canvas pixels.
@Param(3.5 ... 16, icon: "circle.circle") var step = 5.0
/// The gap between ruled lines at a rectangle's inner edge, in steps.
@Param(0.2 ... 1.6, icon: "arrow.down.to.line") var inner = 1.1
/// The gap between ruled lines at a rectangle's outer edge, in steps.
@Param(0.2 ... 1.6, icon: "arrow.up.to.line") var outer = 0.7
/// Seconds for every circle to grow into the next one's place.
@Param(4 ... 30, icon: "clock") var seconds = 12.0
/// The Washington canvas is 77 wide by 169 high.
override var canvasSize: CanvasSize { .size(656, 1440) }
override var loopDuration: Double? { seconds }
/// One ruled rectangle: its lines, as distances from its inner edge.
struct Grid {
/// -1 for the rectangle above the middle, 1 for the one below.
var side: Double
/// How far each line is from the rectangle's inner edge.
var lines: [Double]
}
private struct Dealt: Equatable { var step: Double; var inner: Double; var outer: Double; var seed: Int }
private var dealtFor: Dealt?
private var grids: [Grid] = []
private var pressed = false
// The proportions of the Washington canvas, measured off its picture.
private var middle: Vector2 { Vector2(width / 2, height / 2) }
/// Half the width of both rectangles.
private var halfWidth: Double { 0.346 * width }
/// From the middle to a rectangle's inner edge.
private var near: Double { 0.029 * height }
/// From the middle to a rectangle's outer edge.
private var far: Double { 0.438 * height }
override func mousePressed() {
pressed = true
}
override func draw() {
if pressed {
pressed = false
seed(variation + 1)
}
let wanted = Dealt(step: step, inner: inner, outer: outer, seed: variation)
if dealtFor != wanted {
dealtFor = wanted
deal()
}
let phase = loopProgress(over: max(1, seconds))
// The ground, the lines of the upper and the lower rectangle, and
// the circles.
let ground: Color, linePaints: [Color], circlePaint: Color
switch look {
case .bermellon:
ground = Color(hex: 0xCB5123)
linePaints = [Color(hex: 0x8B3679), Color(hex: 0x8B3679)]
circlePaint = Color(hex: 0x2F6F9A)
case .azul:
ground = Color(hex: 0x295F97)
linePaints = [Color(hex: 0xBE8FAE), Color(hex: 0x2E5B40)]
circlePaint = Color(hex: 0x843A36)
case .carmin:
ground = Color(hex: 0x6E2436)
linePaints = [Color(hex: 0x2E7A4A), Color(hex: 0x2E7A4A)]
circlePaint = Color(hex: 0x2F62AE)
}
background(ground)
noFill()
strokeCap(.butt)
// Both families are painted about a sixth of the circles' step wide,
// as in the Buenos Aires details.
strokeWeight(max(0.7, step * 0.17))
// The note on the Museo Nacional de Bellas Artes canvas has the
// circles laid over the lines. In the details of *Vibraciones sobre
// rojo* the lines lie over the circles, and the Washington look
// follows those.
if look == .azul {
drawLines(in: linePaints)
drawCircles(in: circlePaint, phase: phase)
} else {
drawCircles(in: circlePaint, phase: phase)
drawLines(in: linePaints)
}
}
/// The circles: one family about the middle, one step apart. Only the
/// piece of each that falls inside a rectangle is drawn. Each grows by one
/// step over the cycle, so the picture at the end of the cycle is the
/// picture at its start with the circles renumbered.
private func drawCircles(in paint: Color, phase: Double) {
let m = middle
let count = Int(far / step)
for k in 0 ..< count {
let along = Double(k) + phase
let radius = along * step
guard radius > near else { continue }
// The circle leaving at the outer edge fades over its last step,
// so the count holds and nothing pops.
let fade = min(1, Double(count) - along)
stroke(paint.withAlpha(fade))
// How far the piece opens either side of straight up or down:
// until it meets the inner edge or a side, whichever is nearer.
var half = acos(near / radius)
if radius > halfWidth { half = min(half, asin(halfWidth / radius)) }
for grid in grids {
let toward = grid.side * .pi / 2
drawArc(center: m, radiusX: radius, radiusY: radius,
start: toward - half, stop: toward + half)
}
}
}
/// The ruled lines of the upper and the lower rectangle.
private func drawLines(in paints: [Color]) {
let m = middle
for (grid, paint) in zip(grids, paints) {
stroke(paint)
for distance in grid.lines {
let y = m.y + grid.side * (near + distance)
drawLine(m.x - halfWidth, y, m.x + halfWidth, y)
}
}
}
/// Rules the two rectangles. Each is ruled from its inner edge outward.
/// The first gap is `inner` steps and the last about `outer` steps, each
/// moved by the seed by up to a tenth. Every gap in between is the one
/// before plus one constant amount, chosen so the last line lands exactly
/// on the outer edge.
private func deal() {
randomSeed(variation)
grids = []
let depth = far - near
for side in [-1.0, 1.0] {
let first = step * inner * random(0.9, 1.1)
let last = step * outer * random(0.9, 1.1)
// As many gaps as fit at the mean of the first and the last.
let gaps = max(2, Int((2 * depth / (first + last)).rounded()))
// Line j sits at j * first + change * j * (j - 1) / 2, and line
// `gaps` has to sit at `depth`.
let change = 2 * (depth - Double(gaps) * first) / (Double(gaps) * Double(gaps - 1))
var lines: [Double] = []
for j in 0 ... gaps {
lines.append(Double(j) * first + change * Double(j) * Double(j - 1) / 2)
}
grids.append(Grid(side: side, lines: lines))
}
}
}