<tfoot id='7HGCQ'></tfoot>
    • <bdo id='7HGCQ'></bdo><ul id='7HGCQ'></ul>
      <legend id='7HGCQ'><style id='7HGCQ'><dir id='7HGCQ'><q id='7HGCQ'></q></dir></style></legend>
    1. <small id='7HGCQ'></small><noframes id='7HGCQ'>

        <i id='7HGCQ'><tr id='7HGCQ'><dt id='7HGCQ'><q id='7HGCQ'><span id='7HGCQ'><b id='7HGCQ'><form id='7HGCQ'><ins id='7HGCQ'></ins><ul id='7HGCQ'></ul><sub id='7HGCQ'></sub></form><legend id='7HGCQ'></legend><bdo id='7HGCQ'><pre id='7HGCQ'><center id='7HGCQ'></center></pre></bdo></b><th id='7HGCQ'></th></span></q></dt></tr></i><div id='7HGCQ'><tfoot id='7HGCQ'></tfoot><dl id='7HGCQ'><fieldset id='7HGCQ'></fieldset></dl></div>
      1. 如何在 HTML Canvas 中获取旧生成元素的引用?

        How do I get reference of old generated elements in HTML Canvas?(如何在 HTML Canvas 中获取旧生成元素的引用?)
        <legend id='bS3sl'><style id='bS3sl'><dir id='bS3sl'><q id='bS3sl'></q></dir></style></legend>
            <bdo id='bS3sl'></bdo><ul id='bS3sl'></ul>

                <tbody id='bS3sl'></tbody>
                <tfoot id='bS3sl'></tfoot>

                1. <i id='bS3sl'><tr id='bS3sl'><dt id='bS3sl'><q id='bS3sl'><span id='bS3sl'><b id='bS3sl'><form id='bS3sl'><ins id='bS3sl'></ins><ul id='bS3sl'></ul><sub id='bS3sl'></sub></form><legend id='bS3sl'></legend><bdo id='bS3sl'><pre id='bS3sl'><center id='bS3sl'></center></pre></bdo></b><th id='bS3sl'></th></span></q></dt></tr></i><div id='bS3sl'><tfoot id='bS3sl'></tfoot><dl id='bS3sl'><fieldset id='bS3sl'></fieldset></dl></div>
                2. <small id='bS3sl'></small><noframes id='bS3sl'>

                  本文介绍了如何在 HTML Canvas 中获取旧生成元素的引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  看看这个例子:

                    var c=document.getElementById("myCanvas");
                     var ctx=c.getContext("2d");
                  
                      // First rectangle created    
                      ctx.fillRect(20,20,150,100);
                  
                      // Second rectangle created    
                      ctx.fillRect(20,150,150,100);
                  
                      // Third rectangle created    
                      ctx.fillRect(20,300,150,100);
                  

                  我在这里创建了三个矩形.创建第三个矩形后,我想旋转第一个矩形.我现在如何获得第一个矩形的参考?

                  I created three rectangles here. After creating third rectangle I want to rotate first rectangle. How do i get reference of first rectangle now?

                  推荐答案

                  画布只是一个愚蠢的像素网格.它不明白上面画了什么形状.您的代码(或您的代码使用的库)必须跟踪您绘制的形状.

                  A canvas is just a dumb grid of pixels. It doesn't understand what shapes have been drawn on it. Your code (or a library that your code uses) must keep track of the shapes that you've drawn.

                  相反,听起来您想要一个库来创建 场景图,例如 EaselJS, Paper.js 或 KineticJS.这些库将维护一个数据结构,用于跟踪在画布上绘制了哪些形状,然后在您想要操作这些形状时重新绘制它们.

                  Instead, it sounds like you want a library to create a scene graph, like EaselJS, Paper.js, or KineticJS. These libraries will maintain a data structure that tracks what shapes have been drawn on the canvas, and they will then redraw them when you want to manipulate those shapes.

                  这篇关于如何在 HTML Canvas 中获取旧生成元素的引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 画布中)
                3. <small id='FII9P'></small><noframes id='FII9P'>

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

                              <tbody id='FII9P'></tbody>