アットウィキロゴ

x34

var x = new Array();
var y = new Array();
var dir = new Array();
var number_dir = new Array();
var point = new Array();
var number_peak;
var peak = 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(t=1;t<26;t++){
    tx = 0;
dir[t] = new Array();
for(s1=-1;s1<2;s1++){
for(s2=-1;s2<2;s2++){
    x1 = x[t] + s1;
    y1 = y[t] + s2;
    sx = search(x1, y1);
  if(sx==t)sx=0;
    if (sx > 0) tx = tx + 1;
    if (sx > 0) dir[t][tx] = sx;
}}
number_dir[t] = tx;
}
 
for(s=1;s<26;s++){
n=25*Math.random();
point[s]=Math.floor(n)+1;    
}    
 
seek();    
 
paint();
 
 
}
function seek(){
 
tx=0;    
for(s=1;s<26;s++){
h=0;    
for(sx=1;sx<number_dir[s]+1;sx++){
s1=dir[s][sx];
if(point[s1]>point[s])h=100;    
}   
if(h<50)tx=tx+1;
if(h<50)peak[tx]=s;
}  
 
number_peak=tx;    
 
 
 
 
 
}
 
 
 
 
function paint(){
 
var sub=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">";
 
for(t=1;t<26;t++){
str=str+sub.rect(100*x[t]-100,100*y[t]-100,100,100,"red");  
}  
 
 
 for(t=1;t<number_peak+1;t++){
s=peak[t];     
str=str+sub.rect(100*x[s]-100,100*y[s]-100,100,100,"green");   
}  
 
 for(t=1;t<26;t++){  
str=str+sub.text(100*x[t]-50,100*y[t]-50,10,""+point[t]);
}  
 
str=str+"</svg>";
 
$("#memo").html(str);
 
}
 
 
 
function search(x1,y1){
 
    var s,sx,h;
    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年10月29日 14:33