   var leftClick=16, alt=8;
   var pencilWidth=1;

   macro "Pencil Tool - C037L494fL4990L90b0Lc1c3L82a4Lb58bL7c4fDb4L5a5dL6b6cD7b" {
        getCursorLoc(x, y, z, flags);
        if (flags&alt!=0)
           setColor(getValue("color.background"));
        draw(pencilWidth);
   }
 
  macro 'Pencil Tool Options...' {
       pencilWidth = getNumber("Pencil Width (pixels):", pencilWidth);
  }

   function draw(width) {
        setupUndo();
        getCursorLoc(x, y, z, flags);
        setLineWidth(width);
        moveTo(x,y);
        x2=-1; y2=-1;
        while (true) {
            getCursorLoc(x, y, z, flags);
            if (flags&leftClick==0) exit();
            if (x!=x2 || y!=y2)
                lineTo(x,y);
            x2=x; y2 =y;
            wait(10);
        }
   }
