Continuous Lines / 連続線

マウスをクリックしてドラッグし、線を描きます。

mouseDragged line drawing
Drawing Interaction

View Source Code

/*
 * @name Continuous Lines
 * @arialabel Thin white line draws on a dark grey background as the user clicks and drags their mouse
 * @description Click and drag the mouse to draw a line.
 */
function setup() {
  // createCanvas(710, 400);
  createCanvas(windowWidth, windowHeight);
  background(102);
}

function draw() {
  stroke(255);
  if (mouseIsPressed === true) {
    line(mouseX, mouseY, pmouseX, pmouseY);
  }
}

License

Source code is available on GitHub p5.js website legacy.

All examples are licensed under CC BY-NC-SA 4.0.