简体   繁体   English

如何使用画布在图像上绘制覆盖图?

[英]How to draw overlay on image using canvas?

I want to draw shape(poly, rect, circle) on image JavaScript. 我想在图像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 例如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 我已经在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. 在覆盖画布上绘制将绘制一个半透明区域,该区域允许基础图像发光。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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