q5play
    Preparing search index...

    Function dist

    • 🧮 Calculates the distance between two points.

      This function also accepts two objects with x and y properties.

      Parameters

      • x1: number

        x-coordinate of the first point

      • y1: number

        y-coordinate of the first point

      • x2: number

        x-coordinate of the second point

      • y2: number

        y-coordinate of the second point

      Returns number

      distance between the points

      q5.draw = function () {
      background(0.8);
      line(0, 0, mouseX, mouseY);

      let d = dist(0, 0, mouseX, mouseY);
      text(round(d), -80, -80);
      };