2
我正在努力随机在屏幕周围浮动一些形状。最终他们将互相交流,并具有onclick功能。我可以让圈子在屏幕上呈现,但我无法让他们有动作。看起来.animate()函数不是我在这里需要的。使用拉斐尔JS浮动屏幕周围的形状
有谁知道我会怎么做呢?
以下是我有:
jQuery(function ($) {
// Global Vars
var items = 30,
width = window.innerWidth,
height = window.innerHeight,
paper = Raphael("galaxy", width, height),
frameRate = 100,
i,
galaxy = [],
star = [],
stars = [];
// Do some variants for each item
for (i = 0; i<items; i++) {
stars[i] = {
x : Math.random() * width,
y : Math.random() * height,
r : Math.random()*255,
g : Math.random()*255,
b : Math.random()*255,
size : Math.random() * 20
}
}
// Creates canvas 320 × 200 at 10, 50
// Creates circle at x = 50, y = 40, with radius 10
for (i = 0; i<items; i++) {
star[i] = paper.circle(stars[i].x, stars[i].y, stars[i].size);
star[i].attr("fill", "rgb("+stars[i].r+", "+stars[i].g+", "+stars[i].b+")");
star[i].attr("stroke", "none");
}//end for
});
哇,这是完美的。我曾尝试过使用setTimeout的不同组合,但我永远无法理解它。谢谢! – 2009-08-28 17:23:12