单击该图像时将图像添加到画布? [英] Adding image to canvas on click of that image?

查看:111
本文介绍了单击该图像时将图像添加到画布?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有cnavas设计,看起来像女孩的身体,当我点击任何图像,如(面料,衬衫),然后该图像将填充该设计。如果我点击面料然后它填充设计的袖子部分,如果我点击衬衫然后它填写身体部分。

这里的参考是链接

http://www.houseofblouse.com/design/u-neck-2 [ ^ ]

这里是我设计的女孩身体部位

I have cnavas design which looks like girl body,when i click on any image like (fabric,blouse) then that image will fill on that design. if i click fabric then it fill on sleeve part of design,if i click blouse then it fill in body part.
for reference here is link
http://www.houseofblouse.com/design/u-neck-2[^]
here is my design which is for girl body part

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
  </head>
  <body>
    <canvas id="myCanvas" width="700" height="800"></canvas>
    <script>
      var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');

      context.beginPath();
      context.moveTo(3, 20);
      context.lineTo(10, 200);
      context.stroke();
 context.beginPath();
      context.moveTo(155, 20);
      context.lineTo(150, 200);
      context.stroke();
context.beginPath();
      context.moveTo(10, 200);
      context.lineTo(150, 200);
      context.stroke();
context.beginPath();
      context.moveTo(3, 20);
      context.lineTo(45, 20);
      context.stroke();
context.beginPath();
      context.moveTo(155, 20);
      context.lineTo(110, 20);
      context.stroke();
context.beginPath();
      context.moveTo(45, 20);
      context.bezierCurveTo(48, 80, 110, 80, 110, 19);
      context.stroke();
    </script>
  </body>
</html>

推荐答案

您可以使用html drawImage 方法。

http://www.w3schools.com/tags/canvas_drawimage.asp [ ^ ]



要知道你的代码在做什么,请使用调试器,它将准确显示你的代码正在做什么和不做什么。

一步一步运行代码看看它是什么真的在做。

drawImage 功能上设置断点离子和调试器将在何时执行。
You can use the html drawImage method.
http://www.w3schools.com/tags/canvas_drawimage.asp[^]

To know what your code is doing, use the debugger which will show you exactly what your code is doing and don't.
Run your code step by step to see what it is really doing.
put a breakpoint on the drawImage function and the debugger will show you when it is executed.


这篇关于单击该图像时将图像添加到画布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆