double dist, dire, ddist, ddire; point p[] = new point[80]; double hx[] = new double[p.length]; double hy[] = new double[p.length]; String stst[] = new String[p.length]; String st = new String("Hello.This is Motion Express Language."); int i; Font f = new Font("Helvetica", Font.PLAIN, 12); int w; FontMetrics fm; //sample [setup, 600, 300]{ i = 0; for(int ii = 0; ii < p.length; ii++){ p[ii] = point(200, 150); hx[ii] = p[ii].x; hy[ii] = p[ii].y; stst[ii] = new String(""); } w = getFontMetrics(f).stringWidth(st); p[0].x = monitorWidth / 2. - w/2.; hx[0] = monitorWidth / 2. - w/2.; } [paint]{ clearAll(); setColor(0, 0, 0); setFont(f); for(int ii = 0; ii < i; ii++){ drawString(stst[ii], p[ii].x, p[ii].y); } } [interval, 0.05]{ if(i < st.length()){ i +=1; } } [interval, 0, 17]{ i = 0; for(int ii = 0; ii < p.length; ii ++){ stst[ii] = ""; } st = "Hello.This is Motion Express Language."; w = getFontMetrics(f).stringWidth(st); p[0].x = monitorWidth / 2. - w/2.; hx[0] = monitorWidth / 2. - w/2.; } [interval, 5, 17]{ i = 0; for(int ii = 0; ii < p.length; ii ++){ stst[ii] = ""; } st = "If you wish, you can generate the object which carries out a dynamic motion."; w = getFontMetrics(f).stringWidth(st); p[0].x = monitorWidth / 2. - w/2.; hx[0] = monitorWidth / 2. - w/2.; } [interval, 12, 17]{ i = 0; for(int ii = 0; ii < stst.length; ii ++){ stst[ii] = ""; } st = "Let's enjoy dynamic world !!"; w = getFontMetrics(f).stringWidth(st); p[0].x = monitorWidth / 2. - w/2.; hx[0] = monitorWidth / 2. - w/2.; } [always]{ dist = distance(preMouseX, preMouseY, mouseX, mouseY); dire = direction(preMouseX, preMouseY, mouseX, mouseY); for(int ii = 0; ii < i; ii ++){ stst[ii] = st.substring(ii, ii+1); if(0 < ii){ w = getFontMetrics(f).stringWidth(stst[ii-1]); p[ii].x = p[ii-1].x + w; hx[ii] = hx[ii-1] + w; } ddist = p[ii].distanceTo(hx[ii], hy[ii]); ddire = p[ii].directionTo(hx[ii], hy[ii]); p[ii].push(ddist, ddire); ddist = p[ii].distanceTo(mouse)/50.; p[ii].push(dist / ddist , dire); } }