point p[] = new point[150]; double v1x[] = new double[p.length]; double v1y[] = new double[p.length]; double v2x[] = new double[p.length]; double v2y[] = new double[p.length]; double hx[] = new double[p.length]; double hy[] = new double[p.length]; int pcur, vpcur; boolean mouseP; boolean moving; double dist, dire; //�T���v�� [setup, 600, 600]{ for(int i = 0; i < p.length; i++){ p[i] = point(-500, -500); hx[i] = p[i].x; hy[i] = p[i].y; v1x[i] = 0.; v1y[i] = 0.; v2x[i] = 0.; v2y[i] = 0.; } pcur = 0; vpcur = 0; mouseP = false; setBackColor(255, 255, 255); moving = false; } [paint]{ clearAll(); setColor(0, 0, 0); if(0 < pcur){ for(int i = 1; i < pcur; i ++){ drawBezierCurve(p[i-1].x, p[i-1].y, p[i-1].x + v2x[i-1], p[i-1].y + v2y[i-1], p[i].x + v1x[i], p[i].y + v1y[i], p[i].x, p[i].y); } } if(moving == false && mouseP == true){ for(int i = 0; i < pcur; i++){ drawOval(p[i].x-5, p[i].y-5, 10, 10); } for(int i = 0; i <= vpcur; i ++){ drawRect(p[i].x + v1x[i] - 5, p[i].y + v1y[i] - 5, 10, 10); drawRect(p[i].x + v2x[i] - 5, p[i].y + v2y[i] - 5, 10, 10); drawLine(p[i].x, p[i].y, p[i].x + v1x[i], p[i].y + v1y[i]); drawLine(p[i].x, p[i].y, p[i].x + v2x[i], p[i].y + v2y[i]); } } } [always]{ if(moving == false &&mouseP == true){ v2x[vpcur] = mouseX - p[vpcur].x; v2y[vpcur] = mouseY - p[vpcur].y; v1x[vpcur] = -v2x[vpcur]; v1y[vpcur] = -v2y[vpcur]; } if(moving == true){ for(int i = 0; i < pcur; 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){ dist = p[i].distanceTo(mouse); dire = p[i].directionTo(mouse); if(100 < dist) dist = 100; p[i].push(dist, dire); }else{ dist = mouse.distanceTo(p[i]); dire = mouse.directionTo(p[i]); if(600 < dist) dist = 600; p[i].push((600 - dist)/6., dire); } } } } [mousePressed]{ mouseP =true; if(moving == false && pcur < p.length){ p[pcur].x = mouseX; p[pcur].y = mouseY; hx[pcur] = p[pcur].x; hy[pcur] = p[pcur].y; v1x[pcur] =0.; v1y[pcur] =0.; v2x[pcur] =0.; v2y[pcur] =0.; pcur ++; } } [mouseReleased]{ mouseP = false; if(moving == false){ vpcur ++; } } [keyPressed]{ if(theKey == 's'){ if(moving ==false){ moving = true; }else{ moving = false; } } }