docs: function createBorderForBlur(mask, radius, visited) {
  
          var x, i, j, y, k, k1, k2,
              w = mask.width,
              h = mask.height,
              data = mask.data,
              visitedData = new Uint8Array(data),
              minX = mask.bounds.minX,
              maxX = mask.bounds.maxX,
              minY = mask.bounds.minY,
              maxY = mask.bounds.maxY,
              len = w * h,
              temp = new Uint8Array(len), // auxiliary array to check uniqueness
              border = [], // only border points
              x0 = Math.max(minX, 1),
              x1 = Math.min(maxX, w - 2),
              y0 = Math.max(minY, 1),
              y1 = Math.min(maxY, h - 2);
  
          if (visited && visited.length > 0) {
              // copy visited points (only "black")
              for (k = 0; k < len; k++) {
                  if (visited[k] === 1) visitedData[k] = 1;
              }
          }
  
          // walk through inner values except points on the boundary of the image
          for (y = y0; y < y1 + 1; y++)
              for (x = x0; x < x1 + 1; x++) {
                  k = y * w + x;
                  if (data[k] === 0) continue; // "white" point isn't the border
                  k1 = k + w; // y + 1
                  k2 = k - w; // y - 1
                  // check if any neighbor with a "white" color
                  if (visitedData[k + 1] === 0 || visitedData[k - 1] === 0 ||
                      visitedData[k1] === 0 || visitedData[k1 + 1] === 0 || visitedData[k1 - 1] === 0 ||
                      visitedData[k2] === 0 || visitedData[k2 + 1] === 0 || visitedData[k2 - 1] === 0) {
                      //if (visitedData[k + 1] + visitedData[k - 1] + 
                      //    visitedData[k1] + visitedData[k1 + 1] + visitedData[k1 - 1] +
                      //    visitedData[k2] + visitedData[k2 + 1] + visitedData[k2 - 1] == 8) continue;
                      border.push(k);
                  }
              }
  
          // walk through points on the boundary of the image if necessary
          // if the "black" point is adjacent to the boundary of the image, it is a border point
          if (minX == 0)
              for (y = minY; y < maxY + 1; y++)
                  if (data[y * w] === 1)
                      border.push(y * w);
  
          if (maxX == w - 1)
              for (y = minY; y < maxY + 1; y++)
                  if (data[y * w + maxX] === 1)
                      border.push(y * w + maxX);
  
          if (minY == 0)
              for (x = minX; x < maxX + 1; x++)
                  if (data[x] === 1)
                      border.push(x);
  
          if (maxY == h - 1)
              for (x = minX; x < maxX + 1; x++)
                  if (data[maxY * w + x] === 1)
                      border.push(maxY * w + x);
  
          var result = [], // border points with radius-neighbors
              start, end,
              endX = radius + w,
              endY = radius + h,
              n = radius * 2 + 1; // size of the pattern for radius-neighbors (from -r to +r with the center point)
  
          len = border.length;
          // walk through radius-neighbors of border points and add them to the result array
          for (j = 0; j < len; j++) {
              k = border[j]; // index of the border point
              temp[k] = 1; // mark border point
              result.push(k); // save the border point
              x = k % w; // calc x by index
              y = (k - x) / w; // calc y by index
              start = radius - x > 0 ? radius - x : 0;
              end = endX - x < n ? endX - x : n; // Math.min((((w - 1) - x) + radius) + 1, n);
              k1 = k - radius;
              // walk through x-neighbors
              for (i = start; i < end; i++) {
                  k2 = k1 + i;
                  if (temp[k2] === 0) { // check the uniqueness
                      temp[k2] = 1;
                      result.push(k2);
                  }
              }
              start = radius - y > 0 ? radius - y : 0;
              end = endY - y < n ? endY - y : n; // Math.min((((h - 1) - y) + radius) + 1, n);
              k1 = k - radius * w;
              // walk through y-neighbors
              for (i = start; i < end; i++) {
                  k2 = k1 + i * w;
                  if (temp[k2] === 0) { // check the uniqueness
                      temp[k2] = 1;
                      result.push(k2);
                  }
              }
          }
  
          return result;
      }