double dist, dire; boolean mouseP; point p[] = new point[121]; double hx[] = new double[p.length]; double hy[] = new double[p.length]; Color col; double hCol, sCol, bCol; Polygon pl; double basehCol; double plushCol; //sample [setup, 600, 600]{ mouseP = false; for(int i = 0 ; i < p.length ; i++){ p[i] = point(0, 0); } for(int i = 0 ; i < p.length-1 ; i++){ p[i+1].x = p[i].x; p[i+1].y = p[i].y + (double)monitorHeight / (Math.sqrt(p.length)-1); if(monitorHeight < p[i+1].y){ p[i+1].x += (double)monitorWidth / (Math.sqrt(p.length)-1); p[i+1].y = 0; } } for(int i = 0; i < p.length; i ++){ hx[i] = p[i].x; hy[i] = p[i].y; } hCol = 0.0; sCol = 0.99; bCol = 0.99; basehCol = 0.0; plushCol = hCol + basehCol; } [paint]{ clearAll(); hCol = 0.0; sCol= 1.0; for(int i = 0; i < p.length - 12; i+=1){ if(hy[i] < monitorHeight){ plushCol = basehCol + hCol; if(1.0 < plushCol) plushCol = 1.0; if(plushCol < 0.0) plushCol = 0.0; col = Color.getHSBColor((float)plushCol, (float)sCol, (float)bCol); setColor(col); pl = new Polygon(); pl.addPoint((int)p[i].x, (int)p[i].y); pl.addPoint((int)p[i+1].x, (int)p[i+1].y); pl.addPoint((int)p[i+12].x, (int)p[i+12].y); pl.addPoint((int)p[i+11].x, (int)p[i+11].y); fillPolygon(pl); sCol -= 0.08; }else{ hCol += 0.02; sCol = 1.0; } } } [interval, 10]{ System.gc(); } [always]{ for(int i = 0 ; i < p.length ; i++){ dist = p[i].distanceTo(mouse); dire = p[i].directionTo(mouse); if(300 < dist) dist = 300; p[i].push((300-dist)/10., dire); } for(int i = 0 ; i < p.length ; i++){ dist = p[i].distanceTo(hx[i], hy[i]); dire = p[i].directionTo(hx[i], hy[i]); p[i].push(dist,dire); } if(mouseP == true){ basehCol = basehCol + (0.7 - basehCol)/7.0; }else{ basehCol = basehCol + (0.0 - basehCol)/7.0; } } [mousePressed]{ mouseP = true; } [mouseReleased]{ mouseP = false; }