{"version":3,"file":"isTransparent.min.mjs","names":[],"sources":["../../../../src/util/misc/isTransparent.ts"],"sourcesContent":["/**\n * Returns true if context has transparent pixel\n * at specified location (taking tolerance into account)\n * @param {CanvasRenderingContext2D} ctx context\n * @param {Number} x x coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} y y coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} tolerance Tolerance pixels around the point, not alpha tolerance, integer\n * @return {boolean} true if transparent\n */\nexport const isTransparent = (\n  ctx: CanvasRenderingContext2D,\n  x: number,\n  y: number,\n  tolerance: number,\n): boolean => {\n  tolerance = Math.round(tolerance);\n  const size = tolerance * 2 + 1;\n  const { data } = ctx.getImageData(x - tolerance, y - tolerance, size, size);\n\n  // Split image data - for tolerance > 1, pixelDataSize = 4;\n  for (let i = 3; i < data.length; i += 4) {\n    const alphaChannel = data[i];\n    if (alphaChannel > 0) {\n      return false;\n    }\n  }\n  return true;\n};\n"],"mappings":"AASA,MAAa,GACX,EACA,EACA,EACA,IAAA,CAGA,IAAM,EAAmB,GADzB,EAAY,KAAK,MAAM,EAAA,EACM,EAAA,CACvB,KAAE,GAAS,EAAI,aAAa,EAAI,EAAW,EAAI,EAAW,EAAM,EAAA,CAGtE,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,OAAQ,GAAK,EAEpC,GADqB,EAAK,GACP,EACjB,MAAA,CAAO,EAGX,MAAA,CAAO,GAAA,OAAA,KAAA"}