Skip to content

Brick wall graffiti

Move you mouse over the brick wall to paint it yellow.

A brick wall with thick yellow lines running across it.

function setup() {
  createCanvas(400, 400);
  
  background(220);
  
  randomSeed(1323)
  stroke("rgb(117,117,117)")
  strokeWeight(4)
  
  for (let j = 0; j < 6; j ++) {
    for (let i = 0; i < 9; i ++) {
      pickBrickColor()
      rect(10 + i * 40, 100 + j * 40, 40, 20)
    }
    pickBrickColor()
    rect(10 + 9 * 40, 100 + j * 40, 20, 20)
    rect(10, 120 + j * 40, 20, 20)
    for (let i = 0; i < 9; i ++) {
      pickBrickColor()
      rect(30 + i * 40, 120 + j * 40, 40, 20)
    }
  }
}

let lastX = -1, lastY = -1;

function draw() {
  strokeWeight(20)
  stroke("rgba(255,255,0,0.51)")
  noFill();
  if (mouseX > 10 && mouseY > 100 && mouseX < 30 + 9 * 40 && mouseY < 100 + 6 * 40) {
    if (lastY != -1) {
      line(lastX, lastY, mouseX, mouseY)
    }
    lastX = mouseX
    lastY = mouseY
  }
}
function pickBrickColor() {
  fill(random(["rgb(112,25,25)", "rgb(156,36,36)", "rgb(160,58,12)", "rgb(102,58,4)"]))
}

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

|← Experiments tagged p5 (1/85)

|← Experiments tagged interactive (1/26)

|← Experiments on this site (1/85)