简体   繁体   English

访问简单形状的位置

[英]Accessing the position of simple shapes

I have a Rect assigned to a variable myrect: 我有一个Rect分配给变量myrect:

var myrect = new Rect (250,0,20,200);

I thought that writing: 我以为这样写:

console.log(myrect.x);

would output 250 but, it says " undefined ". 将输出250,但显示“ 未定义 ”。

I would like to know how I can redraw this rectangle by performing arithmetic on its x and y coordinates. 我想知道如何通过对x和y坐标进行算术来重绘此矩形。

The way to access the x and y properties is through the attr() method. 访问x和y属性的方法是通过attr()方法。

console.log(myrect.attr('x'));

See it in the documentation . 文档中看到它。 But I have to admit, the documentation isn't that beginner-friendly yet. 但是我不得不承认,文档还不适合初学者。

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

相关问题
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM