简体   繁体   中英

How to draw overlay on image using canvas?

I want to draw shape(poly, rect, circle) on image JavaScript. and want to generate Hotspot using selected shape, bellow is example link what I want. And How do I draw overlay an canvas over the image?

eg https://google-developers.appspot.com/maps/documentation/javascript/examples/drawing-tools http://www.maschek.hu/imagemap/imgmap

I've implemented something like this on http://jsbin.com/acuvom/5

Basically it will draw a transparent canvas on the same position with the same width and height as the original image. In my example I moved the image also into a canvas in order to extract the selected area of the image, but you could omit this part.

Drawing on the overlay canvas will draw a semi-transparent area which allows the underlying image to shine through.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM