アットウィキロゴ

pov

var x = new Array();
var y = new Array();
var a = new Array();
var dir = new Array();
var number_dir = new Array();
 
function sample(){
 
tx=0;
for(s=1;s<6;s++){
for(sx=1;sx<6;sx++){
tx=tx+1;
x[tx]=s;
y[tx]=sx;
}}
 
for(s=1;s<26;s++){
dir[s]=new Array();
}
 
for(s=1;s<26;s++){
a[s]=new Array();
}
 
for (s = 1; s < 26; s++) {
for (sx = 1; sx < 11; sx++) {
    a[s][sx] = s;
}}
 
for(s=1;s<26;s++){
t=0;    
for(s1=-1;s1<2;s1++){
for(s2=-1;s2<2;s2++){
tx=search(x[s]+s1,y[s]+s2);
if(tx==s)tx=0;  
if(tx>0)t=t+1;
if(tx>0)dir[s][t]=tx;    
}}
number_dir[s]=t;
}
 
var timer;
var delay = 1000;
 
var loop = function () {
 
    for (s = 1; s < 26; s++) {
        for (sx = 1; sx < 11; sx++) {
            move(s, sx);
        } 
    }
 
    paint();
 
    clearTimeout(timer);
    timer = setTimeout(loop, delay);
}
 
loop();
 
}
 
function paint(){
 
var sub=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">";
 
for(t=1;t<26;t++){
for(s=1;s<11;s++){
sx = a[t][s];
if(t==1)str=str+sub.rect(100*x[sx]-100,100*y[sx]-100,100,100,"blue");  
if(t==25)str=str+sub.rect(100*x[sx]-100,100*y[sx]-100,100,100,"red");  
}}
str=str+"</svg>";
 
$("#memo").html(str);
 
}
 
 
function move(s1,s2){
 
    t1 = a[s1][s2];
    n1 = number_dir[t1] * Math.random();
    n2 = Math.floor(n1) + 1;
    a[s1][s2] = dir[t1][n2];
}
 
 
 
 
 
function search(x1,y1){
 
    var s,sx;
    sx=0;
    for (s = 1; s < 26; s++) {
        h = 0;
        if (x[s] == x1) h = h + 1;
        if (y[s] == y1) h = h + 1;
        if (h == 2) sx = s;
    }
    return sx;
 
}
 
最終更新:2015年06月12日 05:38