Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142591

How to detect transparent area click OR if user draw in transparent area in canvas?

$
0
0

I'm drawing an image onto a canvas using drawImage. It's a PNG that is surrounded by transparent pixels, like this:

How can I detect a drawing move path in the transparent part of that image on the canvas? I want to detect if a user draws in a transparent part.

var ctx = canvas.getContext('2d'),
    img = new Image;

img.onload = draw;
img.src = "http://i.stack.imgur.com/UFBxY.png";

function draw() {
  // draw original image in normal mode
  ctx.drawImage(img, 10, 10);
}
<canvas id=canvas width=500 height=500></canvas>

tack.imgur.com/b1FSF.png


Viewing all articles
Browse latest Browse all 142591

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>