text: // The Nature of Code
  // Daniel Shiffman
  // http://natureofcode.com
  
  // A rectangular box
  
  
  // Constructor
  class Box {
    constructor(x, y) {
      this.w = random(10, 40);
      this.h = random(10, 40);
  
      // this.boxColor = color(random(0, 360), random(10, 50), 100);
      this.boxColor = color(0);
  
      // Define a body
      let bd = new box2d.b2BodyDef();
      bd.type = box2d.b2BodyType.b2_dynamicBody;
      bd.position = scaleToWorld(x, y);
  
      // Define a fixture
      let fd = new box2d.b2FixtureDef();
      // Fixture holds shape
      fd.shape = new box2d.b2PolygonShape();
      fd.shape.SetAsBox(scaleToWorld(this.w / 2), scaleToWorld(this.h / 2));
  
      // Some physics
      fd.density = 1.0;
      fd.friction = 0.2;
      fd.restitution = 0.2;
  
      // Create the body
      this.body = world.CreateBody(bd);
      // Attach the fixture
      this.body.CreateFixture(fd);
  
      // Some additional stuff
      this.body.SetLinearVelocity(new box2d.b2Vec2(random(-5, 5), random(2, 5)));
      this.body.SetAngularVelocity(random(-5, 5));
    }
  
    // This function removes the particle from the box2d world
    killBody() {
      world.DestroyBody(this.body);
    }
  
    // Is the particle ready for deletion?
    done() {
      // Let's find the screen position of the particle
      let pos = scaleToPixels(this.body.GetPosition());
      // Is it off the bottom of the screen?
      if (pos.y > height + this.w * this.h) {
        this.killBody();
        return true;
      }
      return false;
    }
  
    mouseDone() {
      this.killBody();
    }
  
    // Drawing the box
    display() {
      // Get the body's position
      let pos = scaleToPixels(this.body.GetPosition());
      // Get its angle of rotation
      let a = this.body.GetAngleRadians();
  
      // Draw it!
      rectMode(CENTER);
      push();
      translate(pos.x, pos.y);
      rotate(a);
      fill(this.boxColor);
      stroke(this.boxColor);
      strokeWeight(2);
      rect(0, 0, this.w, this.h);
      pop();
    }
  }