• <bdo id='tio77'></bdo><ul id='tio77'></ul>
      <tfoot id='tio77'></tfoot>
      <i id='tio77'><tr id='tio77'><dt id='tio77'><q id='tio77'><span id='tio77'><b id='tio77'><form id='tio77'><ins id='tio77'></ins><ul id='tio77'></ul><sub id='tio77'></sub></form><legend id='tio77'></legend><bdo id='tio77'><pre id='tio77'><center id='tio77'></center></pre></bdo></b><th id='tio77'></th></span></q></dt></tr></i><div id='tio77'><tfoot id='tio77'></tfoot><dl id='tio77'><fieldset id='tio77'></fieldset></dl></div>
    1. <legend id='tio77'><style id='tio77'><dir id='tio77'><q id='tio77'></q></dir></style></legend>

      <small id='tio77'></small><noframes id='tio77'>

        HTML5 将图像从工具栏拖放到画布

        HTML5 drag and drop images from a toolbar to a canvas(HTML5 将图像从工具栏拖放到画布)

          <small id='tkNe4'></small><noframes id='tkNe4'>

              <legend id='tkNe4'><style id='tkNe4'><dir id='tkNe4'><q id='tkNe4'></q></dir></style></legend>
                  <tbody id='tkNe4'></tbody>
                • <bdo id='tkNe4'></bdo><ul id='tkNe4'></ul>
                  <tfoot id='tkNe4'></tfoot>
                • <i id='tkNe4'><tr id='tkNe4'><dt id='tkNe4'><q id='tkNe4'><span id='tkNe4'><b id='tkNe4'><form id='tkNe4'><ins id='tkNe4'></ins><ul id='tkNe4'></ul><sub id='tkNe4'></sub></form><legend id='tkNe4'></legend><bdo id='tkNe4'><pre id='tkNe4'><center id='tkNe4'></center></pre></bdo></b><th id='tkNe4'></th></span></q></dt></tr></i><div id='tkNe4'><tfoot id='tkNe4'></tfoot><dl id='tkNe4'><fieldset id='tkNe4'></fieldset></dl></div>
                  本文介绍了HTML5 将图像从工具栏拖放到画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我进行了很多搜索,但找不到与我的需求相关的场景.我想将图像从工具栏拖放到画布,而不是从画布拖放到另一个画布.

                  I have searched a lot, but I could not find a scenario which is relevant to my need. I want to drag and drop images from a toolbar to a canvas, not from a canvas to another canvas.

                  请帮助我.提前致谢

                  推荐答案

                  演示:http://jsfiddle.net/m1erickson/2Us2S/

                  使用 jquery-ui 创建可拖动元素.

                  Use jquery-ui to create draggable elements.

                  $("#myToolbarImageElement").draggable();
                  

                  使用键值对的数据负载加载这些元素.

                  Load these elements with data payloads which are key-value pairs.

                  在您的情况下,这可能是您想要在画布上绘制的图像对象.

                  In your case this might be an image object that you want drawn on the canvas.

                  $("#myToolbarImageElement").data("image",myImageObject);
                  

                  将您的画布设置为拖放区:

                  Set your canvas as a drop zone:

                  $("#myCanvas").droppable({drop:myDropHandler});
                  

                  当您将元素放在画布上时,您可以读取数据(图像)并将该图像绘制到画布上.

                  When you drop the elements on canvas you can read the data (image) and drawImage that image to the canvas.

                  function myDropHandler(e,ui){
                      var x = ui.offset.left - $("#myCanvas").offset.left;
                      var y = ui.offset.top  - $("#myCanvas").offset.top;
                      var image = ui.draggable.data("image");
                      // draw on canvas
                      drawImage(image,x,y);
                  }
                  

                  这是一个很好的教程,关于使用 jquery-ui 的数据有效负载拖放元素:

                  Here's a nice tutorial on drag-drop elements with data payloads using jquery-ui:

                  http://www.elated.com/articles/drag-and-drop-with-jquery-your-essential-guide/

                  这篇关于HTML5 将图像从工具栏拖放到画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to make rooftext effect and valley text effect in HTML5 (or Fabric.js)(如何在 HTML5(或 Fabric.js)中制作屋顶文字效果和山谷文字效果)
                  Draw border around nontransparent part of image on canvas(在画布上的图像不透明部分周围绘制边框)
                  dragging and resizing an image on html5 canvas(在 html5 画布上拖动图像并调整其大小)
                  What#39;s the difference between a boolean as primitive and a boolean as property of an object?(作为原始对象的布尔值和作为对象属性的布尔值有什么区别?)
                  I want to do animation of an object along a particular path(我想沿特定路径对对象进行动画处理)
                  How to upload image into HTML5 canvas(如何将图像上传到 HTML5 画布中)

                      <bdo id='2uH8U'></bdo><ul id='2uH8U'></ul>
                    • <small id='2uH8U'></small><noframes id='2uH8U'>

                      <legend id='2uH8U'><style id='2uH8U'><dir id='2uH8U'><q id='2uH8U'></q></dir></style></legend>
                    • <i id='2uH8U'><tr id='2uH8U'><dt id='2uH8U'><q id='2uH8U'><span id='2uH8U'><b id='2uH8U'><form id='2uH8U'><ins id='2uH8U'></ins><ul id='2uH8U'></ul><sub id='2uH8U'></sub></form><legend id='2uH8U'></legend><bdo id='2uH8U'><pre id='2uH8U'><center id='2uH8U'></center></pre></bdo></b><th id='2uH8U'></th></span></q></dt></tr></i><div id='2uH8U'><tfoot id='2uH8U'></tfoot><dl id='2uH8U'><fieldset id='2uH8U'></fieldset></dl></div>

                            <tbody id='2uH8U'></tbody>

                          <tfoot id='2uH8U'></tfoot>