code: function (e) {
          // log current pixel color (debug mode)
          //var pixel = this.map.events.getMousePosition(e);
          //if (this.snapshot && this.snapshot.isReady()) {
          //    var r = this.snapshot.getPixelColor(Math.round(pixel.x), Math.round(pixel.y));
          //    console.log(r[0] + " " + r[1] + " " + r[2] + " " + r[3]);
          //}
          //return;
          if (this.allowDraw) {
              var pixel = this.map.events.getMousePosition(e);
              var x = Math.round(pixel.x);
              var y = Math.round(pixel.y);
              var px = this.downPoint.x;
              var py = this.downPoint.y;
              if (x != px || y != py)
              {
                  // color threshold calculation
                  var dx = x - px;
                  var dy = y - py;
                  var len = Math.sqrt(dx * dx + dy * dy);
                  var adx = Math.abs(dx);
                  var ady = Math.abs(dy);
                  var sign = adx > ady ? dx / adx : dy / ady;
                  sign = sign < 0 ? sign / 5 : sign / 3;
                  var thres = Math.min(Math.max(this.colorThreshold + Math.round(sign * len), 1), 255); // 1st method
                  //var thres = Math.min(Math.max(this.colorThreshold + dx / 2, 1), 255); // 2nd method
                  //var thres = Math.min(this.colorThreshold + Math.round(len / 3), 255); // 3rd method
                  if (thres != this.currentThreshold) {
                      this.currentThreshold = thres;
                      this.drawMask(px, py);
                  }
              }
          }
      }
docs: private