var x=new Array();
var mode;
function sample() {
var msg = new SpeechSynthesisUtterance('Hello World');
var msg2 = new SpeechSynthesisUtterance('Hi YOKO');
mode=4;
for(s=1;s<5;s++){
x[s]=1;
}
var timer;
var delay = 1000;
var loop = function () {
mode=mode+1;
if(mode>4)mode=1;
n1=6*Math.random();
n2=Math.floor(n1)+1;
x[mode]=x[mode]+n2;
if(x[mode]>40)x[mode]=x[mode]-40;
if(n2>3)window.speechSynthesis.speak(msg);
if(n2<3)window.speechSynthesis.speak(msg2);
paint();
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"500\" height=\"500\">";
str=str+sub.rect(10*x[1],100,10,10,"blue");
str=str+sub.rect(10*x[2],200,10,10,"red");
str=str+sub.rect(10*x[3],300,10,10,"green");
str=str+sub.rect(10*x[4],400,10,10,"yellow");
str=str+"</svg>";
$("#memo").html(str);
}
最終更新:2016年06月10日 14:03