拉斐尔 JS 问题

发布于 2024-09-25 16:59:23 字数 278 浏览 0 评论 0原文

我正在关注 netuts 的有关 raphael js 的教程,但我不明白其中一个示例,有人可以用更简单的英语向我解释一下吗?我知道我应该首先了解更多有关 javascript 的知识。

for(var i = 0; i < 5; i+=1) {
     var multiplier = i*5;
     paper.circle(250 + (2*multiplier), 100 + multiplier, 50 - multiplier); }

谢谢!非常

I am following a tutorial from netuts about raphael js and I dont understand one of the examples, could some one possibly explain this to me in plainer english. I know I should learn more about javascript first.

for(var i = 0; i < 5; i+=1) {
     var multiplier = i*5;
     paper.circle(250 + (2*multiplier), 100 + multiplier, 50 - multiplier); }

Thanks! Very Much

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对你的占有欲 2024-10-02 16:59:23

该代码将

for(var i = 0; i < 5; i+=1) { // loop five times => create five circles
    var multiplier = i*5;     // multiply i to increase the effect in the next lines
    paper.circle( 250 + (2*multiplier), // the x coordinate of the new circle
                  100 + multiplier, // the y coordinate
                  50 - multiplier); // the radius
}

在此 SVG 元素中创建五个圆圈结果:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="556" height="109">
<desc>Created with Raphaël</desc>
<defs/>
    <circle cx="250" cy="100" r="50" fill="none" stroke="#000"/>
    <circle cx="260" cy="105" r="45" fill="none" stroke="#000"/>
    <circle cx="270" cy="110" r="40" fill="none" stroke="#000"/>
    <circle cx="280" cy="115" r="35" fill="none" stroke="#000"/>
    <circle cx="290" cy="120" r="30" fill="none" stroke="#000"/>
</svg>

The code will create five circles

for(var i = 0; i < 5; i+=1) { // loop five times => create five circles
    var multiplier = i*5;     // multiply i to increase the effect in the next lines
    paper.circle( 250 + (2*multiplier), // the x coordinate of the new circle
                  100 + multiplier, // the y coordinate
                  50 - multiplier); // the radius
}

Results in this SVG element:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="556" height="109">
<desc>Created with Raphaël</desc>
<defs/>
    <circle cx="250" cy="100" r="50" fill="none" stroke="#000"/>
    <circle cx="260" cy="105" r="45" fill="none" stroke="#000"/>
    <circle cx="270" cy="110" r="40" fill="none" stroke="#000"/>
    <circle cx="280" cy="115" r="35" fill="none" stroke="#000"/>
    <circle cx="290" cy="120" r="30" fill="none" stroke="#000"/>
</svg>
瑾兮 2024-10-02 16:59:23
for(var i = 0; i < 5; i+=1) {

迭代5次。将到目前为止迭代的次数存储在变量 i 中。 “{”开始循环。

var multiplier = i * 5;

将 i 乘以 5 并存储在称为 multiplier 的变量中。

paper.circle(250 + (2*multiplier), 100 + multiplier, 50 - multiplier);

绘制一个圆,其 x 坐标为 250 加两倍乘数,y 坐标为 100 加乘数,半径为 50 减去乘数。 (本质上是一种获得不同圆圈的奇特方法。)

}

结束循环。

for(var i = 0; i < 5; i+=1) {

Iterate 5 times. Store the number of times iterated so far in the variable i. The "{" begins the loop.

var multiplier = i * 5;

Multiply i by 5 and store in a variable called multiplier.

paper.circle(250 + (2*multiplier), 100 + multiplier, 50 - multiplier);

Draw a circle with an x coordinate at 250 plus twice the multiplier, a y coordinate at 100 plus the multiplier and with a radius of 50 minus the multiplier. (Essentially a fancy way of getting distinct circles.)

}

End the loop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文