1秒毎に円を描いてx位置が500pixelを超えたら止まる。
timerTest.js
var x = 0;
var timer = new Timer(1, true);
timer.start();
timer.onExecute = function() {
document.createCircle(x, 100, 10);
if(x>500) {
timer.stop();
}
x+=10;
}
var x = 0;
var timer = new Timer(1, true);
timer.start();
timer.onExecute = function() {
document.createCircle(x, 100, 10);
if(x>500) {
timer.stop();
}
x+=10;
}
//A4 size
var w = 596;
var h = 842;
var back = document.createRectangle(new Rectangle(0, 0, w, h));
back.style.fill.color = new RGBColor(0, 0, 0);
var fl = 250;
var vpX = w/2;
var vpY = h/2;
var numBalls = 1000;
function drawBall(x, y, z, rad) {
if(z > -fl) {
var scale = fl / (fl+z);
x = vpX + x * scale;
y = vpY + y * scale;
rad = rad * scale;
}
var b = document.createCircle(x, y, rad);
b.style.fill.color = new RGBColor(255, 255, 255);
b.opacity = scale * 0.7 + 0.3;
}
for(var i=0; i < numBalls; i++) {
drawBall(Math.random() * w - w/2, Math.random() * h - h/2, numBalls - i, 10);
}
document.createCircle(x, y, radius);
var radius=10;
var xOff=250;
var yOff=450;
for(var i=0; i<10; i++) {
for(var j=0; j<10; j++) {
var circle = document.createCircle(xOff+i*radius*2, yOff+j*radius*2, radius);
circle.style.fill.color = new RGBColor(Math.random(),Math.random(),Math.random());
circle.style.stroke.color = new RGBColor(Math.random(),Math.random(),Math.random());
circle.style.stroke.width = (i+j)/2;
circle.opacity = (i+j)/20;
}
}
var p = new Path();
p.moveTo(0, 0);
p.lineTo(100, 100);
for(var i=0;i<100;i++) {
p.lineTo(i*5, Math.random()*100);
}