xxxxxxxxxx
var NUMSINES = 6;
var sines = new Array(NUMSINES);
var rad;
var i;
var fund = 0.05;
var ratio = 2;
var trace = false;
var bgm;
var a,b,c;
function preload(){
bgm = loadSound("bgm.wav");
}
function setup()
{
createCanvas(windowWidth, windowHeight);
bgm.setVolume(0.1);
bgm.loop();
rad = height/4;
background(255);
b = min(width, height);
a = b / 1; //
colorMode(HSB, 255);
for (i = 0; i<sines.length; i++)
{
sines[i] = PI;
}
}
function draw()
{
if (!trace) {
background(0);
strokeWeight(3);
stroke("white");
noFill();
ellipse (720, 380, 600,600);
//pulse
c = a + sin(frameCount / (a / 160) + HALF_PI) * a / 1;
stroke(100 + c / 13, 255, 255);
strokeWeight(3);
circle(width / 2, height / 2, c);
textSize(25);
text('3', width/2, height/6);
text('10', width/2, (height/6)*5);
text('4', width/3, height/2);
text('7', (width/3)*2, height/2);
}
// game
push();
translate(width/2, height/2);
for (i = 0; i<sines.length; i++)
{
if (trace) {
stroke(0, 0, 255*(float(i)/sines.length), alpha);
fill(0, 0, 255,52);
erad = (5.0*2.0-float(i)/sines.length);
}
var radius = rad/(i+3);
var rot = -sines[i/6];
rotate(rot);
if (!trace) ellipse(1, 0, radius*1, radius*1);
push();
translate(0, radius);
stroke(255);
if (!trace) ellipse(0, 0, 5, 5);
fill(random(255), random(255), 255);
if (trace) ellipse(0, 0, erad, erad);
pop();
translate(0, radius);
sines[i] = (sines[i]+(fund))%TWO_PI;
}
pop();
}
function keyReleased()
{
if (key==' ') {
trace = !trace;
background(255);
}
}