1

我有一个 KineticJs 项目,我正在创建几个带有循环的矩形。我不会给他们任何类型的 PII。但是使用拖动组件,我可以单独拖动它们。我们在开发者工具中看不到任何东西的画布幕后发生了什么。我希望能够看到发生了什么,比如我在屏幕上拥有的所有东西的坐标x和坐标。y

<canvas width="1578" style="width: 1578px; height: 1200px; position: absolute;" height="1200"></canvas>

这就是开发人员工具中显示的所有内容,用于具有 10 个矩形的画布。

4

2 回答 2

0

A <canvas> does not keep a reference to 'shapes' drawn onto it. It really is just a drawing surface so its up to the script (or library) which is doing the drawing to do the logic and keep reference to any drawn shapes.

If you want something with that kind of native functionality you should have a look at the <svg> element. There you would be able to see (and reference) <rect> elements

More information about svg here: https://developer.mozilla.org/en/docs/SVG

于 2012-12-27T19:48:24.917 回答
0

画布只是一个位图绘图表面。与 MS Paint(或现实生活中的画布)一样,绘图表面不记得您在其上绘制的内容。它所能做的就是告诉你当前的像素。

KineticJS 或者您需要跟踪您想要记住的每个相关对象。

在 KineticJS 中,您有一个包含图层的舞台对象,这些图层具有组和形状。

您有兴趣获取给定图层中的所有形状。

您需要在 KineticJS 教程和文档中查找。

在继续之前,您应该阅读以下内容:

https://github.com/ericdrowell/KineticJS/wiki

http://kineticjs.com/docs/

于 2012-12-27T21:53:30.730 回答