Skip to content

XOR lissajous

Inspired by S.G. Tatham's article on the XOR operation.

A Lissajous curve drawn and undrawn by XOR-ed lines

function setup() {
  setAttributes('antialias', false);
  createCanvas(400, 400, WEBGL);
  pixelDensity(1)
  strokeWeight(2)
  background(255);
  blendMode(EXCLUSION)
  stroke(255)
}

function draw() {
  let t1 = (frameCount - 36) / 40
  let t = frameCount / 40
  if (t1 > 0) {
    drawLine(t1)
  }
  drawLine(t)
  
}

function drawLine(t) {
  line(sin(t * 5) * 200, cos(t * 4) * 200, sin(t * 5+2) * 200, cos(t * 4+2) * 200)
}

(Originally seen at https://editor.p5js.org/bojidar-bg/sketches/whROy1ja4)

Experiments tagged p5 (29/85)

Experiments on this site (29/85)