简体   繁体   English

Javascript-如何选择图像的一部分以更改颜色

[英]Javascript - how to select part of an image to change color

I have an image that is completely white. 我的图像完全是白色的。 I want to select certain hexagonal sections to make them different colors, and then make the sections act like buttons that call different functions when they're clicked. 我想选择某些六边形截面以使其具有不同的颜色,然后使这些截面像单击按钮时一样调用不同功能的按钮。 I think I know how I would change the background color and make them clickable, but I don't know how to select a hexagonal section to change those things. 我想我知道如何更改背景颜色并使它们可单击,但是我不知道如何选择六角形截面来更改这些内容。 Can anyone help me? 谁能帮我? (without jQuery) (没有jQuery)

EDIT: I figured out how to change set apart the hexagonal sections, and how to make them clickable like a button, but I can't figure out how to change the color of each part. 编辑:我想出了如何更改设置分开的六角形部分,以及如何使它们像按钮一样可单击,但是我不知道如何更改每个部分的颜色。 How do you do that? 你是怎样做的?

You could try using an image map: 您可以尝试使用图片地图:

<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
  <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
  <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>

HTML < map> Tag HTML <map>标记

Here's a hexagon example: 这是一个六角形的例子:

HTML Color Picker HTML颜色选择器

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

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