- (00-341192D)
def R(s,x,y)
if distance(x,y,s/2,s/2)<=(s/20)
0
else if distance(x,y,3*s/2,3*s/2) <=(s/20)
0
else if distance(x,y,s/2,s/2)<=(s/2)
0.8*((s/2)-distance(x,y,s/2,s/2))/(s/2)
else if distance(x,y,1.5*s,1.5*s)<=(s/2)
0.8*((s/2)-distance(x,y,1.5*s,1.5*s))/(s/2)
else
if distance(x,y,s,s)>=s
2*(distance(x,y,s,s)-s)/s
else
if distance(x,y,s/2,1.5*s)<=(s/8)&&(y-x)>s
1
else if distance(x,y,s/2,1.5*s)<=(s/3.5)&&(y-x)>s
0
else
rand(1.0/99)#((s)-distance(x,y,s,s))/(s)
end
end
end
end
end
end
end
end
def G(s,x,y)
if (x-y)<=(s/10)&&(x-y)>=(-s/10)&&(x>=2*(sqrt(2)-1)*s && (x<=2*s-(2*(sqrt(2)-1)*s)))
&& (y>=2*(sqrt(2)-1)*s && (y<=2*s-(2*(sqrt(2)-1)*s)))
1
else if distance(x,y,s/2,s/2)<=(s/20)
0
else if distance(x,y,3*s/2,3*s/2) <=(s/20)
0
else if distance(x,y,s/2,s/2)<=(s/2)
((s/2)-distance(x,y,s/2,s/2))/(s/2)
else
if distance(x,y,1.5*s,1.5*s)<=(s/2)
((s/2)-distance(x,y,1.5*s,1.5*s))/(s/2)
else
if distance(x,y,s,s)>=s
2*(distance(x,y,s,s)-s)/s
else
if distance(x,y,s/2,1.5*s)<=(s/3.5)&&(y-x)>s
&& distance(x,y,s/2,1.5*s)>=(s/8.0)
((s/2)-distance(x,y,s/2,1.5*s))/(s/2)
else
0
end
end
end
end
end
end
end
end
def B(s,x,y)
if distance(x,y,s/2,s/2)<=(s/20)
0
else if distance(x,y,3*s/2,3*s/2) <=(s/20)
0
else if distance(x,y,s/2,s/2)<=(s/2)
0.1*((s/2)-distance(x,y,s/2,s/2))/(s/2)
else if distance(x,y,1.5*s,1.5*s)<=(s/2)
0.1*((s/2)-distance(x,y,1.5*s,1.5*s))/(s/2)
else
if distance(x,y,s,s)>=s
0
else
if distance(x,y,s/2,1.5*s)<=(s/3.5)&&(y-x)>s
&& distance(x,y,s/2,1.5*s)>=(s/8.0)
((s/2)-distance(x,y,s/2,1.5*s))/(s/2)
else
((s)-distance(x,y,s,s))/(s)
end
end
end
end
end
end
end
def nerd(s)
image = make2d(2*s,2*s)
for y in 0..(2*s-1)
for x in 0..(2*s-1)
image[y][x] = [R(s,x,y),G(s,x,y),B(s,x,y)]
end
end
image
end
- ( 00-340234F )
def malon
[[[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,1,1],
[1,1,1],[1,1,1],[1,1,1],[1,1,1]],
[[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],
[1,0.5,0.28],[1,1,1],[1,1,1],[1,1,1],[1,1,1]],
[[1,1,1],[1,1,1],[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],
[1,0.5,0.28],[1,0.5,0.28],[1,1,1],[1,1,1],[1,1,1]],
[[1,1,1],[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],
[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,1,1],[1,1,1]],
[[1,1,1],[1,0.5,0.28],[0,0,0],[0,0,0],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],
[1,0.5,0.28],[0,0,0],[0,0,0],[1,0.5,0.28],[1,1,1]],
[[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,1,1],[0,0,0],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],
[0,0,0],[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,1,1]],
[[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,1,1],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[1,1,1],
[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28]],
[[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,1,1],[0,0,0],[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,1,1],[0,0,0],
[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28]],
[[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,1,1],[1,1,1],[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,1,1],[1,1,1],
[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28]],
[[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],
[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28]],
[[1,1,1],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],
[1,0.9,0.1],[1,0.9,0.1],[1,0.5,0.28],[1,0.5,0.28],[1,0.5,0.28],[1,1,1]],
[[1,1,1],[1,1,1],[1,1,1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],
[1,0.9,0.1],[1,0.9,0.1],[1,1,1],[1,1,1],[1,1,1]],
[[1,1,1],[0,0,0],[0,0,0],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],
[1,0.9,0.1],[1,0.9,0.1],[1,1,1],[1,1,1],[1,1,1]],
[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],
[0,0,0],[0,0,0],[0,0,0],[1,1,1]],
[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[1,0.9,0.1],[0,0,0],[0,0,0],
[0,0,0],[0,0,0],[1,1,1]],
[[1,1,1],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[1,1,1],[1,1,1],[1,1,1],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[1,1,1],
[1,1,1]]]
end
show(malon)
- (00-340233C )
def circle(x,y,c,d,p)
if distance(x,y,p/2,p/2)>=c && distance(x,y,p/2,p/2)<=d
-1
else
0
end
end
def line1(x,y,p)
if x>=p/5.0 && x<=p*4.0/5.0 && y>=p/3.0-p/100.0 && y<=p/3.0+p/100.0
-1
else
0
end
end
def line2(x,y,p)
if x>=p/5.0 && x<=p*4.0/5.0 && y>=p*2.0/3.0-p/100.0 && y<=p*2.0/3.0+p/100.0
-1
else
0
end
end
def line3(x,y,p)
if y>=p/6.0 && y<=p*2.0/3.0 && p-5.0/3.0*x+p/60.0>=y && p-5.0/3.0*x-p/60.0<=y
-1
else
0
end
end
def line4(x,y,p)
if y>=p/6.0 && y<=p/3.0*2.0 && -2.0/3.0*p+5.0/3.0*x+p/60.0>=y && -2.0/3.0*p+5.0/3.0*x-p/60.0<=y
-1
else
0
end
end
def line5(x,y,p)
if y>=p/3.0 && y<=5.0/6.0*p && 5.0/3.0*x+p/60.0>=y && 5.0/3.0*x-p/60.0<=y
-1
else
0
end
end
def line6(x,y,p)
if y>=p/3.0 && y<=5.0/6.0*p && 5.0/3.0*p-5.0/3.0*x+p/60.0>=y && 5.0/3.0*p-5.0/3.0*x-p/60.0<=y
-1
else
0
end
end
def a(p,x,y)
if y==p/2
0
else
sin(16*asin((y-p/2.0)/distance(x,y,p/2.0,p/2.0)))
end
end
def r(x,y,p)
0.5+0.47*(line1(x,y,p)+line2(x,y,p)+line3(x,y,p)+line4(x,y,p)+line5(x,y,p)+
line6(x,y,p)+circle(x,y,p/3.0+p/100.0,p/3.0+p/50.0,p)+
circle(x,y,7.0*p/15.0+p/100.0,7.0*p/15.0+p/50.0,p))+
0.4*sin(0.4*distance(x,y,p/2.0,p/6.0))
end
def g(x,y,p)
0.5+0.47*(line1(x,y,p)+line2(x,y,p)+line3(x,y,p)+line4(x,y,p)+line5(x,y,p)+
line6(x,y,p)+circle(x,y,p/3.0+p/100.0,p/3.0+p/50.0,p)+
circle(x,y,7.0*p/15.0+p/100.0,7.0*p/15.0+p/50.0,p))+
0.4*sin(0.2*distance(x,y,p/2,p/6.0*5.0))
end
def b(x,y,p)
0.5+0.47*(line1(x,y,p)+line2(x,y,p)+line3(x,y,p)+line4(x,y,p)+line5(x,y,p)+
line6(x,y,p)+circle(x,y,p/3.0+p/100.0,p/3.0+p/50.0,p)+
circle(x,y,7.0*p/15.0+p/100.0,7.0*p/15.0+p/50.0,p))+0.5*a(p,x,y)
end
def mahou(p)
image=make2d(p,p)
for y in 0..(p-1)
for x in 0..(p-1)
image[y][x]=[r(x,y,p),g(x,y,p),b(x,y,p)]
end
end
image
end
- ( 00-340541G )
def a(s,x,y)
if y == s/3.0
0
else
sin((x-s/4.0)/(y-s/3.0)*5)/2.0+0.5
end
end
def b(s,x,y)
if distance(x,y,s/2,s/2)
b=(cos(0.3*(x-y))*(0.9-distance(x,y,s/2,s/2)/sqrt(0.5*s**2))+(0.9-
distance(x,y,s/2,s/2)/sqrt(0.5*s**2))*cos(0.3*(x+y)))*0.8
else
b=0.8
end
end
def kadai1(s)
image=make2d(500,500)
for y in 0..499
for x in 0..499
image[y][x]=[(998-(x+y))/998.0,b(s,x,y),a(s,x,y)]
end
end
image
end
- ( 00-340077C )
def heart(s,x,y)
r = s/2.0
t = -1.5*((x-r)/r)
u = -1.5*((y-r)/r)
320*(-((t)**2)*((u)**3)+((t)**2+(u)**2-1)**3)+t**2
end
def kadai(s)
image = make2d(s,s)
for x in 0..s-1
for y in 0..s-1
if heart(s,x,y)<0
image[y][x] = [255/255.0,192/255.0,203/255.0]
else
image[y][x] = [255/255.0,255/255.0,240/255.0]
end
end
end
image
end
- ( 00-340531F )
def ulam(n,m)
img=make2d(2*n+1,2*n+1)
img[n][n]=prime(m) ? 1 : 0
for i in (1..n)
c=4*i*i+m
for k in (0..2*i)
img[n+i-k][n-i]=prime(c-4*i+k) ? 1 : 0
img[n-i][n-i+k]=prime(c-2*i+k) ? 1 : 0
img[n-i+k][n+i]=prime(c+k) ? 1 : 0
img[n+i][n+i-k]=prime(c+2*i+k) ? 1 : 0
end
end
show(img)
end
def max(a)
r=a[0]
l=a.length
for i in (1..(l-1))
if ra[i]
r=a[i]
end
end
r
end
def f(a,x)
r=0
l=a.length
for i in(0..(l-1))
r=r+a[i]*(x**i)
end
r
end
def fshow(a)
d=0.001
l=200
g=make2d(2*l,2*l)
t=[0,(l-f(a,-d*l)/d+0.5).to_i()]
for i in(0..(2*l-1))
k=l-(f(a,d*(i-l+0.5))/d).to_i()
if k>=0 && k<2*l
g[k][i]=1
end
t[0]=t[1]
t[1]=(l-f(a,d*(i-l+1))/d+0.5).to_i()
m=[max([min(t),0]),min([max(t),2*l-1])]
for j in(m[0]..m[1])
g[j][i]=1
end
end
show(g)
end
def imp_f(a,x,y)
r=0
k=a.length
l=a[0].length
for i in (0..k-1)
for j in (0..l-1)
r=r+a[i][j]*(y**i)*(x**j)
end
end
r
end
def implicit(a)
d=0.01
l=200
g=make2d(2*l,2*l)
for i in (0..(2*l-1))
for j in (0..(2*l-1))
t=[imp_f(a,d*(j-l),-d*(i-l+0.5)),imp_f(a,d*(j-l+1),-d*(i-l+0.5))]
if (t[0]>=0 && t[1]<=0) || (t[0]<=0 && t[1]>=0)
g[i][j]=1
else
t[0]=imp_f(a,d*(j-l+0.5),-d*(i-l))
t[1]=imp_f(a,d*(j-l+0.5),-d*(i-l+1))
if (t[0]>=0 && t[1]<=0) || (t[0]<=0 && t[1]>=0)
g[i][j]=1
end
end
end
end
show(g)
end
implicit([[0,0,0,1],[0,-3,0,0],[0,0,0,0],[1,0,0,0]])
implicit([[0,-3,0,4],[-5,0,0,0],[0,0,0,0],[20,0,0,0],[0,0,0,0],[-16,0,0,0]])
- ( 00-340530C )
def show_color_picture()
a=make2d(50,50)
for y in 0..49
for x in 0..49
a[y][x]=[rand(),rand(),rand()]
end
end
show(a)
end
- ( 00-340529I )
def sky(n)
sora=make2d(n,n)
for y in 0..n-1
for x in 0..n-1
if distance(n/2.0,n-1,y,x)<46.0*n/55
if distance(n/2.0,n-1,y,x)<44.0*n/55
if distance(n/2.0,n-1,y,x)<42.0*n/55
if distance(n/2.0,n-1,y,x)<40.0*n/55
if distance(n/2.0,n-1,y,x)<38.0*n/55
if distance(n/2.0,n-1,y,x)<36.0*n/55
if distance(n/2.0,n-1,y,x)<34.0*n/55
if distance(n/2.0,n-1,y,x)<32.0*n/55
sora[x][y]=[0,0.796875,1]
else
sora[x][y]=[0.652,0.339,0.656]
end
else
sora[x][y]=[0.136,0.277,0.578]
end
else
sora[x][y]=[0,0.402,0.746]
end
else
sora[x][y]=[0,0.5,0]
end
else
sora[x][y]=[1,0.828,0]
end
else
sora[x][y]=[1,0.714,0.296]
end
else
sora[x][y]=[0.925,0.101,0.238]
end
else
sora[x][y]=[0,0.796875,1]
end
end
end
show(sora)
end
- ( 00-340539J )
def key
k=make2d(450,450)
for b in 0..14
for a in 0..14
w=29
h=29
for x in 10..(w-10)
for y in 10..(h-10)
k[30*a+x][30*b+y]=[1,1,1]
end
end
for x in 0..9
for y in 10..(h-10)
k[30*a+x][30*b+y]=[(9-x)/9.0,(9-x)/9.0-a/14.0+b/14.0,1-(9-x)/9.0]
end
end
for x in (w-9)..w
for y in 10..(h-10)
k[30*a+x][30*b+y]=[(x-w+9)/9.0+a/14.0-b/14.0,(x-w+9)/9.0,1-(x-w+9)/9.0]
end
end
for x in 10..(w-10)
for y in 0..9
k[30*a+x][30*b+y]=[(9-y)/9.0,(9-y)/9.0-a/14.0+b/14.0,1-(9-y)/9.0]
end
end
for x in 10..(w-10)
for y in (h-9)..h
k[30*a+x][30*b+y]=[(y-h+9)/9.0,(y-h+9)/9.0+a/14.0-b/14.0,1-(y-h+9)/9.0]
end
end
for x in 0..9
for y in 0..9
if y==x
k[30*a+x][30*b+y]=[0,0,0]
else if y>x
k[30*a+x][30*b+y]=[(9-x)/9.0,(9-x)/9.0,1-(9-x)/9.0]
else
k[30*a+x][30*b+y]=[(9-y)/9.0,(9-y)/9.0,1-(9-y)/9.0]
end
end
end
end
for x in (w-9)..w
for y in 0..9
if y==-(x-w+9)+9
k[30*a+x][30*b+y]=[0,0,0]
else if y>-(x-w+9)+9
k[30*a+x][30*b+y]=[(x-w+9)/9.0,(x-w+9)/9.0,1-(x-w+9)/9.0]
else
k[30*a+x][30*b+y]=[(9-y)/9.0,(9-y)/9.0,1-(9-y)/9.0]
end
end
end
end
for x in 0..9
for y in (h-9)..h
if y==-x+h
k[30*a+x][30*b+y]=[0,0,0]
else if y>-x+h
k[30*a+x][30*b+y]=[(y-h+9)/9.0,(y-h+9)/9.0,1-(y-h+9)/9.0]
else
k[30*a+x][30*b+y]=[(9-x)/9.0,(9-x)/9.0,1-(9-x)/9.0]
end
end
end
end
for x in (w-9)..w
for y in (h-9)..h
if y==(x-w+9)+(h-9)
k[30*a+x][30*b+y]=[0,0,0]
else if y>(x-w+9)+(h-9)
k[30*a+x][30*b+y]=[(y-h+9)/9.0,(y-h+9)/9.0,1-(y-h+9)/9.0]
else
k[30*a+x][30*b+y]=[(x-w+9)/9.0,(x-w+9)/9.0,1-(x-w+9)/9.0]
end
end
end
end
end
end
k
end
- (00-340249B )
def funcpict(x,y)
b=make2d(x,y)
b[0][0]=[1,1,1]
b[0][x-1]=[0,0,1]
b[y-1][0]=[1,0,0]
b[y-1][x-1]=[0,1,0]
for i in 1..(x-2)
b[0][i]=[((x-1-i)*b[0][0][0]+i*b[0][x-1][0]).to_f/(x-1).to_f,
((x-1-i)*b[0][0][1]+i*b[0][x-1][1]).to_f/(x-1).to_f,
((x-1-i)*b[0][0][2]+i*b[0][x-1][2]).to_f/(x-1).to_f]
b[y-1][i]=[((x-1-i)*b[y-1][0][0]+i*b[y-1][x-1][0]).to_f/(x-1).to_f,
((x-1-i)*b[y-1][0][1]+i*b[y-1][x-1][1]).to_f/(x-1).to_f,
((x-1-i)*b[y-1][0][2]+i*b[y-1][x-1][2]).to_f/(x-1).to_f]
end
for i in 1..(y-2)
b[i][0]=[((y-1-i)*b[0][0][0]+i*b[y-1][0][0]).to_f/(y-1).to_f,
((y-1-i)*b[0][0][1]+i*b[y-1][0][1]).to_f/(y-1).to_f,
((y-1-i)*b[0][0][2]+i*b[y-1][0][2]).to_f/(y-1).to_f]
b[i][x-1]=[((y-1-i)*b[0][x-1][0]+i*b[y-1][x-1][0]).to_f/(y-1).to_f,
((y-1-i)*b[0][x-1][1]+i*b[y-1][x-1][1]).to_f/(y-1).to_f,
((y-1-i)*b[0][x-1][2]+i*b[y-1][x-1][2]).to_f/(y-1).to_f]
end
for i in 1 .. y-2
for j in 1.. x-2
b[i][j]=[((x-1-j)*b[i][0][0]+j*b[i][x-1][0]+(y-1-i)*b[0][j][0]+i*b[y-1][j][0]).to_f/(x+y-2).to_f,
((x-1-j)*b[i][0][1]+j*b[i][x-1][1]+(y-1-i)*b[0][j][1]+i*b[y-1][j][1]).to_f/(x+y-2).to_f,
((x-1-j)*b[i][0][2]+j*b[i][x-1][2]+(y-1-i)*b[0][j][2]+i*b[y-1][j][2]).to_f/(x+y-2).to_f]
end
end
show(b)
def dow()
a=make2d(300,500)
for j in 0..299
for i in 0..499
a[j][i]=[0,0,0]
end
end
for j in 0 .. 299
for i in 0 .. 499
a[0][i]=[1,1,1]
a[299][i]=[1,1,1]
if i%120==0
a[j][i]=[0.3,0.3,0.3]
end
if ((j+1)%60==0)&&i!=299
a[j][i]=[0.3,0.3,0.3]
end
end
end
st=150
chaos=0
for i in 0 .. 499
a[st][i]=[1,1,1]
for j in st+1..299
a[j][i]=[0,0,(299-j).to_f/(299-st-1)]
end
if chaos==0
if rand(50)==0
chaos=9
st=st+rand(8)
else if rand(50)==1
chaos=-10
st=st-rand(8)
else
chaos=0
st=st+rand(3)-rand(3)
end
end
else if chaos>0
st=st+rand(8)
chaos=chaos-1
else
st=st-rand(8)
chaos=chaos+1
end
end
while (st>299)||(st<0)
st=st+rand(3)-rand(3)+1
end
end
show(a)
end
- (00-340262C )
def italia()
[[[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],
[1,0,0]],
[[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],
[1,0,0]],
[[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],
[1,0,0]],
[[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],
[1,0,0]],
[[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],
[1,0,0]],
[[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],
[1,0,0]],
[[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],
[1,0,0]],
[[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],
[1,0,0]],
[[0,1,0],[0,1,0],[0,1,0],[0,1,0],[0,1,0],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,1,1],[1,0,0],[1,0,0],[1,0,0],[1,0,0],
[1,0,0]]]
end
- (00-340534E )
#(田中注): 以下のプログラムは掲示板の注釈モードに変換されたため,不完全なものになっています.
def R(s,x,y)
r=s/2
if distance(x,y,r,r)< r/5.to_f()
abs(sin*1
else
if distance(x,y,r,r)< r/3
abs*2
else
if distance(x,y,r,r)< r
abs(cos*3
else
(sqrt(2)*r-distance(x,y,r,r))/(sqrt(2)-1)*r
end
end
end
end
def g(s,x,y)
r=s/2
if distance(x,y,r,r)< r/4.to_f()
abs(sin*4
else
if distance(x,y,r,r)< r/2
abs*5
else
if distance(x,y,r,r)< r
abs(cos*6
else
(sqrt(2)*r-distance(x,y,r,r))/(sqrt(2)-1)*r
end
end
end
end
def b(s,x,y)
r=s/2
if distance(x,y,r,r)<2*r/9.to_f()
abs(sin*7
else
if distance(x,y,r,r)<3*r/5
abs*8
else
if distance(x,y,r,r)< r
abs(cos*9
else
(sqrt(2)*r-distance(x,y,r,r))/(sqrt(2)-1)*r
end
end
end
end
def gazou(s)
image=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x]=[R(s,x,y),g(s,x,y),b(s,x,y)]
end
end
image
end
- (00-340065F )
$Square = 256
def message(str)
if str.length == 0
return
end
give_seed(str) # make random seed
# set background color
fbgr = Math.sin(Math::PI / 2.0 * rand() + Math::PI / 4.0) ** 1.4
fbgb = Math.sin(Math::PI / 2.0 * rand() + Math::PI / 4.0) ** 1.4
fbgg = Math.sin(Math::PI / 2.0 * rand() + Math::PI / 4.0) ** 1.4
tbgr = Math.sin(Math::PI / 2.0 * rand() + Math::PI / 4.0) ** 0.8
tbgb = Math.sin(Math::PI / 2.0 * rand() + Math::PI / 4.0) ** 0.8
tbgg = Math.sin(Math::PI / 2.0 * rand() + Math::PI / 4.0) ** 0.8
pattern = rand(4)
# set circles and lines data
circles = circlesprovide(str) # to make circles
lines = linesprovide(str) # to make lines
# make white data
array = Array.new($Square)
for i in 0...$Square
array[i] = Array.new($Square)
for j in 0...$Square
array[i][j] = bg_gradation(j,i,[fbgr, fbgg, fbgb],[tbgr, tbgg, tbgb],pattern)
end
end
# draw circles
for i in 0...circles.length()
drawcircle(circles[i], array)
end
# draw lines
for i in 0...lines.length()
drawline(lines[i], array)
end
array
end
# Give random seed from given string
def give_seed(str)
seedtimes = 1 # you can change seeds by changing this
sum = 0
for i in 0..(str.length - 2)
sum += (str[i] * Math.log(str[i+1])).to_i
end
sum *= seedtimes
srand sum
end
# Make circles data
# array content format is [x, y, r, [a,r,g,b]]
def circlesprovide(str)
maxradius = 80
minradius = 10
numbers = rand(str.length() * (str.length() % 4 + 1))
data = Array.new(numbers)
for i in 0...numbers
s = rand(str.length())
if printable(str[s])
x = rand($Square)
y = rand($Square)
r = (( (str[s]-31) * (maxradius - minradius) / (127-31) ) + minradius) * rand()
ca = rand()
cr = rand()
cg = rand()
cb = rand()
data[i] = [x,y,r,[ca,cr,cg,cb]]
end
end
data.compact
end
# Make lines data
# array content format is [x0(y0), x1(y1), x(0) or y(1), [a,r,g,b]]
def linesprovide(str)
numbers = rand(str.length() * 1.5)
data = Array.new(numbers)
for i in 0...numbers
s = rand(str.length())
if printable(str[s])
x0 = rand($Square)
x1 = Square - 1 - rand(Square)
xory = str[s] % 2
ca = rand()
cr = rand()
cg = rand()
cb = rand()
data[i] = [x0, x1, xory, [ca,cr,cg,cb]]
end
end
data.compact
end
# from 32 to 126 (in decimal): printable characters
def printable(i)
i > 31 && i < 127
end
# Draw a circle by given data and array
# This method destructionally changes given array
def drawcircle(data, array)
antialias = 6
x = data[0]
y = data[1]
r = data[2]
ca = data[3][0]
cr = data[3][1]
cg = data[3][2]
cb = data[3][3]
for i in 0...array.length()
for j in 0...array[i].length()
if ((i - y)**2 + (j - x)**2) < r**2
array[i][j][0] = array[i][j][0] * ca + cr * (1-ca)
array[i][j][1] = array[i][j][1] * ca + cg * (1-ca)
array[i][j][2] = array[i][j][2] * ca + cb * (1-ca)
else
dis = Math.sqrt(((i - y)**2 + (j - x)**2) - r**2)
if dis < antialias
cca = ca + (1 - ca) * dis / antialias
array[i][j][0] = array[i][j][0] * cca + cr * (1-cca)
array[i][j][1] = array[i][j][1] * cca + cg * (1-cca)
array[i][j][2] = array[i][j][2] * cca + cb * (1-cca)
end
end
end
end
end
# Draw a line by given data and array
# This method destructionally changes given array
def drawline(data, array)
linealias = 0.5
x0 = data[0]
x1 = data[1]
xory = data[2]
ca = data[3][0]
cr = data[3][1]
cg = data[3][2]
cb = data[3][3]
cca = ca + (1-ca)/2
if xory == 0 # vertically
for i in 0...$Square
point = (x0 + (x1 - x0) * ((i + 0.0) / $Square)).round
upalias = ((x0 + (x1 - x0) * ((i + 0.0) / $Square)) - linealias).round
downalias = ((x0 + (x1 - x0) * ((i + 0.0) / $Square)) + linealias).round
array[i][downalias][0] = array[i][downalias][0] * cca + cr * (1-cca)
array[i][downalias][1] = array[i][downalias][1] * cca + cg * (1-cca)
array[i][downalias][2] = array[i][downalias][2] * cca + cb * (1-cca)
array[i][upalias][0] = array[i][upalias][0] * cca + cr * (1-cca)
array[i][upalias][1] = array[i][upalias][1] * cca + cg * (1-cca)
array[i][upalias][2] = array[i][upalias][2] * cca + cb * (1-cca)
array[i][point][0] = array[i][point][0] * ca + cr * (1-ca)
array[i][point][1] = array[i][point][1] * ca + cg * (1-ca)
array[i][point][2] = array[i][point][2] * ca + cb * (1-ca)
end
else # horizonally
for i in 0...$Square
point = (x0 + (x1 - x0) * ((i + 0.0) / $Square)).round
upalias = ((x0 + (x1 - x0) * ((i + 0.0) / $Square)) - linealias).round
downalias = ((x0 + (x1 - x0) * ((i + 0.0) / $Square)) + linealias).round
array[downalias][i][0] = array[downalias][i][0] * cca + cr * (1-cca)
array[downalias][i][1] = array[downalias][i][1] * cca + cg * (1-cca)
array[downalias][i][2] = array[downalias][i][2] * cca + cb * (1-cca)
array[upalias][i][0] = array[upalias][i][0] * cca + cr * (1-cca)
array[upalias][i][1] = array[upalias][i][1] * cca + cg * (1-cca)
array[upalias][i][2] = array[upalias][i][2] * cca + cb * (1-cca)
array[point][i][0] = array[point][i][0] * ca + cr * (1-ca)
array[point][i][1] = array[point][i][1] * ca + cg * (1-ca)
array[point][i][2] = array[point][i][2] * ca + cb * (1-ca)
end
end
array
end
# This provides background gradation "color" from leftup to rightdown
def bg_gradation(x,y,from,to,pattern)
max = 2 * ($Square - 1)
grad = 0
case pattern
when 0 then
grad = 1 - (x+y+0.0) / max
when 1 then
grad = 1 - (x+($Square-y)+0.0) / max
when 2 then
grad = 1 - (($Square-x)+y+0.0) / max
when 3 then
grad = 1 - (($Square-x)+($Square-y)+0.0) / max
end
r = from[0] * grad + to[0] * (1-grad)
g = from[1] * grad + to[1] * (1-grad)
b = from[2] * grad + to[2] * (1-grad)
[r,g,b]
end
- ( 00-340237E )
g=[0.15,0.63,0.05]
r=[1,0,0]
w=[1,1,1]
e=[[g,w,r],[g,w,r]]
show(e)
- ( 00-340528F )
def d(x,y,u,v)
sqrt((x-u)**2+(y-v)**2)
end
def show_color_picture()
a=make2d(100,100)
for y in 0..99
for x in 0..99
if d(x,y,50,50)<20
a[y][x]=[1.0,0,0]
else
a[y][x]=[1.0,1.0,1.0]
end
end
end
show(a)
end
- (00-340243D )
def picture()
a=make2d(100,100)
for y in 0..99
for x in 0..99
a[y][x]=[x/100.0,y/100.0,(x+y)/200.0]
end
end
show(a)
end
- (00-340075G)
def soften(arr)
ret=make2d(arr.length,arr.length)
for i in 0..(arr.length-1)
for j in 0..(arr.length-1)
ret[i][j]=make1d(3)
for k in 0..2
ret[i][j][k]=arr[i][j][k]
end
end
end
for i in 1..(arr.length-2)
for j in 1..(arr.length-2)
for k in 0..2
ret[i][j][k]=0.4*arr[i][j][k]+0.1*arr[i-1][j][k]+0.1*arr[i+1][j][k]+
0.1*arr[i][j-1][k]+0.1*arr[i][j+1][k]+0.05*arr[i+1][j+1][k]+
0.05*arr[i+1][j-1][k]+0.05*arr[i-1][j+1][k]+0.05*arr[i-1][j-1][k]
end
end
end
for i in 1..(arr.length-2)
for k in 0..2
ret[i][0][k]=0.6*arr[i][0][k]+0.1*arr[i-1][0][k]+0.1*arr[i+1][0][k]+
0.1*arr[i][1][k]+0.05*arr[i+1][1][k]+0.05*arr[i-1][1][k]
ret[i][arr.length-1][k]=0.6*arr[i][arr.length-1][k]+0.1*arr[i-1][arr.length-1][k]+
0.1*arr[i+1][arr.length-1][k]+0.1*arr[i][arr.length-2][k]+
0.05*arr[i+1][arr.length-2][k]+0.05*arr[i-1][arr.length-2][k]
end
end
for j in 1..(arr.length-2)
for k in 0..2
ret[0][j][k]=0.6*arr[0][j][k]+0.1*arr[1][j][k]+0.1*arr[0][j-1][k]+0.1*arr[0][j+1][k]+
0.05*arr[1][j+1][k]+0.05*arr[1][j-1][k]
ret[arr.length-1][j][k]=0.6*arr[arr.length-1][j][k]+0.1*arr[arr.length-2][j][k]+
0.1*arr[arr.length-1][j-1][k]+0.1*arr[arr.length-1][j+1][k]+
0.05*arr[arr.length-2][j+1][k]+0.05*arr[arr.length-2][j-1][k]
end
end
for k in 0..2
ret[0][0][k]=0.5*arr[0][0][k]+0.2*arr[1][0][k]+0.2*arr[0][1][k]+0.1*arr[1][1][k]
ret[0][arr.length-1][k]=0.5*arr[0][arr.length-1][k]+0.2*arr[1][arr.length-1][k]+
0.2*arr[0][arr.length-2][k]+0.1*arr[1][arr.length-2][k]
ret[arr.length-1][0][k]=0.5*arr[arr.length-1][0][k]+0.2*arr[arr.length-2][0][k]+
0.2*arr[arr.length-1][1][k]+0.1*arr[arr.length-2][1][k]
ret[arr.length-1][arr.length-1][k]=0.5*arr[arr.length-1][arr.length-1][k]+
0.2*arr[arr.length-2][arr.length-1][k]+
0.2*arr[arr.length-1][arr.length-2][k]+
0.1*arr[arr.length-2][arr.length-2][k]
end
return ret
end
# 1 RとGを座標の対数で取り座標の和の対数が整数にある程度近い場合にBが1になる図形
def generatePicture2(size)
r=make2d(size,size)
for y in 0..(size-1)
for x in 0..(size-1)
r[y][x]=[Math::log(x+1)/Math::log(size), Math::log(y+1)/Math::log(size), Math::log(x+y+2)%1<=0.4 ? 1 : 0]
end
end
return r
end
# 3 一定間隔で縦横にランダムな色の線を引いた図形
def generatePicture4()
ret=make2d(200,200)
for i in 0..199
for j in 0..199
ret[i][j]=[0.5,0.5,0.5]
end
end
for i in 0..39
r1=rand()
r2=rand()
r3=rand()
for j in 0..199
ret[i*5][j]=[r1,r2,r3]
end
end
for i in 0..39
r1=rand()
r2=rand()
r3=rand()
for j in 0..199
ret[j][i*5]=[r1,r2,r3]
end
end
return ret
end
- (00-340067B)
def pic(n)
image = make2d(n,n)
for s in (0..n-1)
for t in (0..n-1)
image[s][t]=[0,0,0]
end
end
m = n*45
for k in 0..m-1
r = n/2.0
t = 1.0*PI*k/(n-1)
x = t*cos(t) -r
y = t*sin(t) -r
image[y][x] = [1.0*k/m,0,0]
x = t*cos(t) -r+1
y = t*sin(t) -r+1
image[y][x] = [0,1.0*k/m,0]
x = t*cos(t) -r-1
y = t*sin(t) -r-1
image[y][x] = [0,0,1.0*k/m]
x = t*cos(t) -r-2
y = t*sin(t) -r-2
image[y][x] = [0,1.0*k/m,0]
x = t*cos(t) -r+2
y = t*sin(t) -r+2
image[y][x] = [0,0,1.0*k/m]
end
image
end
- (00-340617E )
def a
[0.678,1,0.184]
end
def b
[0.133,0.545,0.133]
end
def c
[1,0.843,0]
end
def d
[0.933,0.773,0.569]
end
def e
[1,0.894,0.769]
end
def f
[0.827,0.827,0.827]
end
def g
[0.902,0.902,0.980]
end
def h
[0,0,0]
end
def i
[0.310,0.310,0.310]
end
def j
[0.263, 0.184,0.184]
end
def k
[0.565,0.404,0.243]
end
def l
[0.537,0.494,0.345]
end
def m
[1,1,1]
end
def one
[m,m,m,m,m,m,m,m,j,j,j,j,j,j,m,m,m,m,m,m,m,m]
end
def two
[m,m,m,m,m,m,j,j,k,l,l,l,l,k,j,j,m,m,m,m,m,m]
end
def three
[m,m,m,m,m,h,k,l,l,l,j,j,l,l,l,k,h,m,m,m,m,m]
end
def four
[m,m,m,m,h,j,l,l,l,l,k,k,l,l,l,l,j,h,m,m,m,m]
end
def five
[m,m,m,m,h,j,l,l,l,l,l,l,l,l,l,l,j,h,m,m,m,m]
end
def six
[m,m,m,h,j,j,k,l,l,l,l,l,l,l,l,k,j,j,h,m,m,m]
end
def seven
[m,m,m,h,j,j,j,k,f,g,g,g,g,f,k,j,j,j,h,m,m,m]
end
def eight
[m,m,i,h,j,j,k,f,g,g,g,g,g,g,f,k,j,j,h,i,m,m]
end
def nine
[m,i,a,i,i,j,k,f,g,g,g,g,g,g,f,k,j,i,i,a,i,m]
end
def ten
[i,a,a,b,i,i,i,k,g,g,g,g,g,g,k,i,i,i,b,a,a,i]
end
def eleven
[m,i,b,a,h,i,i,i,i,i,i,i,i,i,i,i,i,h,a,b,i,m]
end
def twelve
[m,m,i,a,b,h,j,k,l,l,l,l,l,l,k,j,h,b,a,i,m,m]
end
def thirteen
[m,m,i,h,d,b,h,h,l,l,l,l,l,l,h,h,b,d,h,i,m,m]
end
def fourteen
[m,m,m,h,l,b,d,f,i,i,i,i,i,i,f,d,b,l,h,m,m,m]
end
def fifteen
[m,m,m,m,i,b,d,f,h,d,b,a,d,h,f,d,b,i,m,m,m,m]
end
def sixteen
[m,m,m,m,i,a,b,d,e,e,e,e,e,e,d,b,a,i,m,m,m,m]
end
def seventeen
[m,m,m,m,m,i,b,h,d,e,d,d,e,d,h,b,i,m,m,m,m,m]
end
def eighteen
[m,m,m,m,m,m,h,f,h,h,j,j,h,h,f,h,m,m,m,m,m,m]
end
def ninteen
[m,m,m,m,m,h,g,f,g,j,h,h,j,g,f,g,h,m,m,m,m,m]
end
def twenty
[m,m,m,m,h,g,g,g,i,g,j,j,g,i,g,g,g,h,m,m,m,m]
end
def twentyone
[m,m,m,h,i,j,g,h,f,i,f,f,i,h,g,j,h,c,h,m,m,m]
end
def twentytwo
[m,m,i,e,j,i,h,j,f,f,h,c,f,f,j,h,i,h,e,i,m,m]
end
def twentythree
[m,m,i,d,d,h,m,j,j,f,f,f,f,j,c,c,h,d,d,i,m,m]
end
def twentyfour
[m,m,m,h,h,m,m,h,l,j,j,j,j,g,c,c,g,h,h,m,m,m]
end
def twentyfive
[m,m,m,m,m,m,h,k,d,d,k,k,d,d,k,h,m,m,m,m,m,m]
end
def twentysix
[m,m,m,m,m,m,h,d,d,k,h,h,k,d,d,h,m,m,m,m,m,m]
end
def twentyseven
[m,m,m,m,m,m,k,i,k,h,m,m,h,k,i,k,m,m,m,m,m,m]
end
def twentyeight
[m,m,m,m,m,m,h,b,b,h,m,m,h,b,b,h,m,m,m,m,m,m]
end
def twentynine
[m,m,m,m,m,m,m,h,h,m,m,m,m,h,h,m,m,m,m,m,m,m]
end
show([one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,
seventeen,eighteen,ninteen,twenty,twentyone,twentytwo,twentythree,twentyfour,twentyfive,twentysix,
twentyseven,twentyeight,twentynine])
- ( 00-340610D )
class Fire
def initialize(style = [0, 1, 2], w = 500, h = 300, unit = 100)
@style = style
@w = w
@h = h
@unit = unit.to_f
@pxs = Array.new(h).map { Array.new(w, 0.0) }
seed
end
def seed
for i in 0 .. (@w - 1)
r = rand(4)
@pxs[0][i] = @unit * rand(2) * 3
end
end
def reseed
for i in 1 .. (@w - 2)
if @pxs[0][i] != @pxs[0][i+1] && rand(4) <= 1
@pxs[0][i] = @unit * 3 - @pxs[0][i]
@pxs[0][i+1] = @unit * 3 - @pxs[0][i+1]
end
end
end
def grow
for i in 1 .. (@h - 1)
c = 0
for j in 1 .. (@w - 2)
@pxs[i][j] = ((@pxs[i-1][j-1] + @pxs[i-1][j] + @pxs[i-1][j+1] + @pxs[i][j]) / 4.0).to_i
c += @pxs[i][j]
end
if c <= 0.01
break
end
end
end
def print
@pxs.map {|col|
col.map {|p|
c = [0, 0, 0]
for i in 0..2
if p <= (i + 1) * @unit
c[@style[i]] = (p - i * @unit) / @unit
break
else
c[@style[i]] = 1
end
end
c
}
}.drop(1).reverse #種の列は見栄えが悪いので消す
end
end
load("fire.rb")
fire = Fire.new()
100.times {
fire.grow
fire.reseed
}
show(fire.print)
load("fire.rb")
fire = Fire.new()
10.times {
fire.grow
fire.reseed
}
show(fire.print)
load("fire.rb")
fire = Fire.new([2,1,0])
100.times {
fire.grow
fire.reseed
}
show(fire.print)
- ( 00-340070B )
imagea=make2d(200,200)
for i in 0..199
for j in 0..199
imagea[i][j]=[sin(sin(i)),cos(3.8*j)*0.8,distance(i,j,100,100)/200]
end
end
for i in 0..199
for j in 0..199
for q in 0..2
if imagea[i][j][q]<=0.2
imagea[i][j][q]=0.5
end
end
end
end
show(imagea)
- ( 00-340049F )
def mandelbrot(a,b,n,li)
t=0
re=0.0
im=0.0
for i in (0..n-1)
re1=re
im1=im
re=re1*re1-im1*im1+a
im=2*re1*im1+b
if re*re+im*im > li
t=1
break
end
end
return t
end
def drawmandelbrot(ylen,xlen,n,li)
ar = make2d(ylen,xlen)
for y in (0..ylen-1)
for x in (0..xlen-1)
m = mandelbrot((-ylen/2.0+y)/ylen*4,(-xlen/2.0+x)/ylen*4,n,li)
if m == 1
ar[y][x] = 1
end
end
end
return ar
end
def isrbprac2()
show(drawmandelbrot(500,300,20,2))
end
def line2(ar,y1,x1,y2,x2)
for i in (0..100)
ar[y1+(y2-y1)*i/100][x1+(x2-x1)*i/100]=1
end
end
def frac2(ar,y1,x1,y2,x2,depth,depthmax)
if depth <= depthmax
d1x=(x2+2*x1)/3
d1y=(y2+2*y1)/3
d2x = (x1/2+x2/2+0.28867513*(y1-y2)).round
d2y = (y1/2+y2/2+0.28867513*(x2-x1)).round
d3x=(2*x2+x1)/3
d3y=(2*y2+y1)/3
d=line2(ar,y1,x1,y2,x2)
d=frac2(ar,y1,x1,d1y,d1x,depth+1,depthmax)
d=frac2(ar,d3y,d3x,y2,x2,depth+1,depthmax)
d=line2(ar,d1y,d1x,d2y,d2x)
d=line2(ar,d2y,d2x,d3y,d3x)
d=frac2(ar,d1y,d1x,d2y,d2x,depth+1,depthmax)
d=frac2(ar,d2y,d2x,d3y,d3x,depth+1,depthmax)
end
end
def isrbprac3()
ar = make2d(300,600)
frac2(ar,0,0,0,599,1,5)
show(ar)
end
def make3d(height,width,z)
a = make2d(width,height)
for j in (0..height-1)
for i in (0..width-1)
a[i][j] = make1d(z)
end
end
a
end
def mono2color(ar)
ymax = ar.length
xmax = ar[0].length
ar_=make3d(ymax,xmax,3)
for y in (0..ymax-1)
for x in (0..xmax-1)
aaa = ar[y][x]
ar_[y][x][0]=aaa
ar_[y][x][1]=aaa
ar_[y][x][2]=aaa
end
end
return ar_
end
def mosaic(ar,ydiv,xdiv)
ylen = ar.length
xlen = ar[0].length
ar_=make3d(ylen,xlen,3)
for j in (0..ydiv-1)
for i in (0..xdiv-1)
y1 = (1.0*ylen/ydiv*j).round
y2 = (1.0*ylen/ydiv*(j+1)).round-1
x1 = (1.0*xlen/xdiv*i).round
x2 = (1.0*xlen/xdiv*(i+1)).round-1
filr = 0.0
filg = 0.0
filb = 0.0
for y in (y1..y2)
for x in (x1..x2)
filr = filr + ar[y][x][0]
filg = filg + ar[y][x][1]
filb = filb + ar[y][x][2]
end
end
filr = filr/(y2-y1+1)/(x2-x1+1)
filg = filg/(y2-y1+1)/(x2-x1+1)
filb = filb/(y2-y1+1)/(x2-x1+1)
for y in (y1..y2)
for x in (x1..x2)
ar_[y][x][0] = filr
ar_[y][x][1] = filg
ar_[y][x][2] = filb
end
end
end
end
return ar_
end
def isrbprac4()
show(mosaic(mono2color(sphere(100)),15,17))
end
- ( 00-340054B )
def f(a,x)
a*(1-x)*x
end
def logistic(s,p,q)
image = make2d(4*s+1,4*s+1) #4s四方の下地をつくる
for b in 0..4*s
a=b*1.0/s
x=0.1
for i in 1..p #極限に近づけるためにp回までの計算を捨てる
x=f(a,x)
end
for i in 1..q #グラフに代入していく
x=f(a,x)
y=(4*s*x).round
image[4*s-y][b]=1
end
end
show(image)
end
- (00-340607D )
def happinesses()
#white
w=make2d(3,3)
for i in 0..2
#red
w[i][0]=[1,0,0]
#green
w[i][1]=[0,1,0]
#blue
w[i][2]=[0,0,1]
end
#black
b=make2d(3,3)
for i in 0..2
#red
b[i][0]=[0.1,0,0]
#green
b[i][1]=[0,0.1,0]
#blue
b[i][2]=[0,0,0.1]
end
h=[[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,b,w,w,w,w,w,w,w],
[w,w,w,b,b,b,b,b,b,b,b,b,w,w,w],
[w,w,w,w,w,w,w,b,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,b,w,w,w,w,w,w,w],
[w,b,b,b,b,b,b,b,b,b,b,b,b,b,w],
[w,w,w,w,b,w,w,w,w,w,b,w,w,w,w],
[w,w,w,w,w,b,w,w,w,w,b,w,w,w,w],
[w,w,w,w,w,b,w,w,w,b,w,w,w,w,w],
[w,b,b,b,b,b,b,b,b,b,b,b,b,b,w],
[w,w,w,w,w,w,w,b,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,b,w,w,w,w,w,w,w],
[w,w,w,b,b,b,b,b,b,b,b,b,w,w,w],
[w,w,w,w,w,w,w,b,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,b,w,w,w,w,w,w,w]]
hp=make2d(45,45)
for y in 0..44
for x in 0..44
hp[y][x]=h[y/3][x/3][y%3][x%3]
end
end
hps=[[hp,hp,hp],
[hp,hp,hp],
[hp,hp,hp],
[hp,hp,hp],
[hp,hp,hp],
[hp,hp,hp]]
hpss=make2d(270,135)
for y in 0..269
for x in 0..134
hpss[y][x]=hps[y/45][x/45][y%45][x%45]
end
end
hpss
end
def white_black()
#white
w=make2d(3,3)
for i in 0..2
#red
w[i][0]=[1,0,0]
#green
w[i][1]=[0,1,0]
#blue
w[i][2]=[0,0,1]
end
#black
b=make2d(3,3)
for i in 0..2
#red
b[i][0]=[0.1,0,0]
#green
b[i][1]=[0,0.1,0]
#blue
b[i][2]=[0,0,0.1]
end
wb=make2d(90,45)
for j in 0..89
for i in 0..44
if j<20*sin(i*4*PI/90)+45 #白と黒の境目いじる
wb[j][i]=w
else
wb[j][i]=b
end
end
end
white_black=make2d(270,135)
for y in 0..269
for x in 0..134
white_black[y][x]=wb[y/3][x/3][y%3][x%3]
end
end
white_black
end
def pict()
pic=[[white_black,happinesses]]
pict=make2d(270,270)
for y in 0..269
for x in 0..269
pict[y][x]=pic[y/270][x/135][y%270][x%135]
end
end
show(pict)
end
- ( 00-340248I )
def picture(r)
a = make2d(r,r)
for y in 0..(r-1)
for x in 0..(r-1)
a[y][x]=[sin(x)*sin(y),0.0,cos(x)*cos(y)]
end
end
show(a)
end
- (00-340968B )
def b(s,x,y)
r=s/2.0
if distance(x,y,r,r)<= r
(r-distance(x,y,r,r))/(r)
else
1
end
end
def picture(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
if x+y<=s
image[y][x] =[sin(1.0*y*y*y/(s*s)*b(s,x,y))*1.0*y*y*y/(s*s)*b(s,x,y),1.0*(x*x)*(y*y)/(s*s*s)*b(s,x,y),
cos(1.0*x*x*x/(s*s)*b(s,x,y))*1.0*x*x*x/(s*s)*b(s,x,y)]
else
image[y][x] =[cos(1-1.0*(s-1-y)*(s-1-y)*(s-1-y)/(s*s)*b(s,x,y))*(1-1.0*(s-1-y)*(s-1-y)*(s-1-y)/(s*s)*b(s,x,y)),
1-1.0*(s-1-x)*(s-1-x)*(s-1-y)*(s-1-y)/(s*s*s)*b(s,x,y),
sin(1-1.0*(s-1-x)*(s-1-x)*(s-1-x)/(s*s)*b(s,x,y))*(1-1.0*(s-1-x)*(s-1-x)*(s-1-x)/(s*s)*b(s,x,y))]
end
end
end
image
end
def b(s,x,y)
r=s/2.0
if distance(x,y,r,r)<= r
(r-distance(x,y,r,r))/(r)
else
1
end
end
def picture(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
if x+y<=s
image[y][x] =[1.0*y*y*y/(s*s)*b(s,x,y),1.0*(x*x)*(y*y)/(s*s*s)*b(s,x,y),1.0*x*x*x/(s*s)*b(s,x,y)]
else
image[y][x] =[1-1.0*(s-1-y)*(s-1-y)*(s-1-y)/(s*s)*b(s,x,y),
1-1.0*(s-1-x)*(s-1-x)*(s-1-y)*(s-1-y)/(s*s*s)*b(s,x,y),
1-1.0*(s-1-x)*(s-1-x)*(s-1-x)/(s*s)*b(s,x,y)]
end
end
end
image
end
- (00-340525G )
def rainbow(s)
a=make2d(s,s)
r=s/2
for y in 0..s-1
for x in 0..s-1
if distance(x,y,r,r)r*19/21
a[y][x]=[1,(r-distance(x,y,r,r))*21/(2.0*r),0]
elsif distance(x,y,r,r)>r*18/21
a[y][x]=[(distance(x,y,r,r)-18*r/21.0)*21/(r*1.0),1,0]
elsif distance(x,y,r,r)>r*16/21
a[y][x]=[0,(distance(x,y,r,r)-16*r/21)*21/(2.0*r),1]
elsif distance(x,y,r,r)>r*15/21
a[y][x]=[(16*r/21-distance(x,y,r,r))*21/(2.0*r),0,1]
else a[y][x]=[0,0.8,1]
end
else a[y][x]=[0,0.8,1]
end
end
end
show(a)
end
- ( 00-340232J )
def ia(s,t,g)
a=make2d(s,s)
b=1.0/(t^(1/2))
c=1.0/b-1.0
for x in 0..(s-1)
for y in 0..(s-1)
p=(x+1).to_f/s.to_f
q=(y+1).to_f/s.to_f
r=distance(p,q,0,0)
l=atan(q/p)
a[x][y]=[1,1,1]
for k in 1..g
if (1.0-b)**2+b**2+2*(1.0-b)*b*cos(l)*cos(c*l)-2*(1.0-b)*b*sin(l)*sin(c*l)-0.05<(r*r*k) &&
(r*r*k)<(1.0-b)**2+b**2+2*(1.0-b)*b*cos(l)*cos(c*l)-2*(1.0-b)*b*sin(l)*sin(c*l)+0.05
a[x][y]=[(k*(g.to_f))/(g+1.0),0,0]
else
#a[x][y]=[1,1,1]
end
end
end
end
show(a)
end
- ( 00-340961A )
def bs(ns)
r = [ns.clone]
up = true
sMin = -1
sMax = ns.length
while sMax - sMin >= 2
range = if up then (sMin+1).upto(sMax-2) else (sMax-2).downto(sMin+1) end
for i in range
if ns[i] > ns[i+1]
w = ns[i]
ns[i] = ns[i+1]
ns[i+1] = w
end
r << ns.clone
end
if up then sMax-=1 else sMin+=1 end
up = !up
end
return r
end
N = 40
rorig = (0..N).to_a.map{|x| x / N.to_f}.shuffle
gorig = (0..N).to_a.map{|x| x / N.to_f}.shuffle
borig = (0..N).to_a.map{|x| x / N.to_f}.shuffle
rs = bs(rorig)
gs = bs(gorig)
bs = bs(borig)
rgb = []
for i in 0 .. rs.length - 1
rgb[i] = []
for j in 0 .. rs[i].length - 1
rgb[i] << [rs[i][j], gs[i][j], bs[i][j]]
end
end
show(rgb)
# バブルソートの様子を図示しました それだけです
そーす長くなってしまったのでこちらに
https://gist.github.com/anonymous/5ec0dac4c004fb807b26
このソースからは、2番目の画像ができます
1番目の画像も、一部(453-469行目)をちょろっといじればでてきます
Values = 2
LEFT = -1
RIGHT = 1
HALT = 0
def transition(state, value)
return [value, RIGHT, state]
end
class Transition
def initialize(cases)
@cases = cases
end
def transition(state, value)
for set in @cases
if [state, value] == set[0,2] then
return set[2,3]
end
end
raise "no match"
end
end
class Machine
def initialize(trans)
@position = 0
@positive = []
@negative = []
@state = 1
@trans = trans
@history = []
end
def read()
arr = if @position >= 0 then @positive else @negative end
ix = @position.abs
if arr[ix] == nil then arr[ix] = 0 end
return arr[ix]
end
def write(value)
arr = if @position >= 0 then @positive else @negative end
ix = @position.abs
arr[ix] = value
end
def step()
r = @trans.transition(@state, read())
val = r[0]
dir = r[1]
st = r[2]
write(val)
@position += dir
@state = st
write(read())
end
def run()
@history << [@position, @state, @positive.clone, @negative.clone]
while (@state != 0)
step()
@history << [@position, @state, @positive.clone, @negative.clone]
end
end
def history() @history end
end
def finalPosLen(machine)
machine.history.last[2].length
end
def finalNegLen(machine)
machine.history.last[3].length
end
def adoptLength(n, val, arr)
if arr.length < n then
arr += [val] * (n - arr.length)
end
return arr
end
#busy beaver winners
x = [
[1, 0, 1, RIGHT, 2],
[1, 1, 1, LEFT, 2],
[2, 0, 1, LEFT, 1],
[2, 1, 1, RIGHT, HALT]
]
y = [
[1, 0, 1, RIGHT, 2],
[1, 1, 1, RIGHT, HALT],
[2, 0, 0, RIGHT, 3],
[2, 1, 1, RIGHT, 2],
[3, 0, 1, LEFT, 3],
[3, 1, 1, LEFT, 1]
]
z = [
[1, 0, 1, RIGHT, 2],
[1, 1, 1, LEFT, 2],
[2, 0, 1, LEFT, 1],
[2, 1, 0, LEFT, 3],
[3, 0, 1, RIGHT, HALT],
[3, 1, 1, LEFT, 4],
[4, 0, 1, RIGHT, 4],
[4, 1, 0, RIGHT, 1]
]
tr = Transition.new(z)
m = Machine.new(tr)
m.run()
history = m.history
posLen = finalPosLen(m)
negLen = finalNegLen(m)
for set in history
pos = adoptLength(posLen, 0, set[2])
neg = adoptLength(negLen, 0, set[3]).drop(1)
set[0] += negLen - 1
set[2] = neg.reverse + pos
set.pop
end
def valueColor(val)
x = 1 - val.to_f / (Values - 1)
return [x, x, x]
end
def stateColor(state)
if state == 0 then return [0, 0, 0] end
x = state.hash % 100
y = state.hash.hash % 100
z = state.hash.hash.hash % 100
return [x,y,z].map{|v| v / 200.0 + 0.5}
end
def describeMemory(position, mem)
line = []
for v in mem
line << valueColor(v)
line << valueColor(v)
line << valueColor(v)
line << [0.9,0.9,0.9]
end
blank = [[0.9,0.9,0.9]] * (4 * mem.length)
cursor = [[0.85,0.85,0.85]] * (4 * mem.length)
cursor[position*4, 3] = [[1,0,0]] * 3
return [line] * 3 + [cursor, blank]
end
bitmap = []
for h in history
lines = describeMemory(h[0], h[2])
state = [stateColor(h[1])] * 2 + [[0.8,0.8,0.8]]
lines = lines.map{|l|
state + l
}
bitmap += lines
end
show(bitmap)
#チューリングマシンの動作過程を画像にしました
#画像になっているのは4状態ビジービーバーゲームの最優秀マシンです
#白黒の四角形がセルの値、セルの下にある赤いバーが「現在位置」、左端にある色のつい
#たラインが現在のマシン状態を表しています
- ( 00-340543C )
def e(n)
a=make2d(2*n,2*n)
for i in 0..2*n-1
for j in 0..2*n-1
a[i][j]=[i*j*j*1.0/(4*n*n),(2*n-i)*(2*n-j)*(2*n-j)*(2*n-i)*1.0/(4*n*n*n*n),i*i*j*1.0/(4*n*n)]
end
a
end
a
end
show(e(100))
- (00-340240E )
def kadai(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x]=[cos(x*0.03141592),cos(y*0.03141592),cos((x*y)*0.03141592)]
end
end
image
end
show(kadai(200))
- (00-340978C )
def mark(s)
a=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
if distance(x,y,s/2,s/2)>=11*s/30
if (x%35==0 && y%45==0) || (x%67==0 && y%54==0)
b=rand()
a[y][x]=[b,b,0]
else
a[y][x]=[0,0,(0.3)*(distance(x,y,(s-1),(s-1))+distance((s-1),(s-1),(s-1)*(s-1-2*y+2*x)/(2*(s-0.999999999)-2*y),0))/(2*s*sqrt(2))]
end
elsif distance(x,y,s/2,s/2)>=s/3 && distance(x,y,s/2,s/2)<11*s/30
if y>=x
a[y][x]=[1,1,1-((y-x)*3)/(2*(sqrt(2)*(sqrt(2)*s/2)))]
else y< x
a[y][x]=[1,1,1-((x-y)*3)/(2*(sqrt(2)*(sqrt(2)*s/2)))]
end
else
if (distance(x,y,5*s/6,s/2)<=s/3 && distance(x,y,s/3,(3+sqrt(3))*s/6)<=s/3 && y>=sqrt(3)*x+s*(1-
sqrt(3))/2) || (distance(x,y,2*s/3,(3+sqrt(3))*s/6)<=s/3 && distance(x,y,2*s/3,(3-sqrt(3))*s/6)<=s/3 &&
y>=s/2) || (distance(x,y,5*s/6,s/2)<=s/3 && distance(x,y,s/3,(3-sqrt(3))*s/6)<=s/3 && y>=-
sqrt(3)*x+s*(1+sqrt(3))/2) || (distance(x,y,s/6,s/2)<=s/3 && distance(x,y,2*s/3,(3-sqrt(3))*s/6)<=s/3
&& y<=sqrt(3)*x+s*(1-sqrt(3))/2) || (distance(x,y,s/3,(3+sqrt(3))*s/6)<=s/3 && distance(x,y,s/3,(3-
sqrt(3))*s/6)<=s/3 && y<=s/2) || (distance(x,y,s/6,s/2)<=s/3 && distance(x,y,2*s/3,(3+sqrt(3))*s/6)
<=s/3 && y<=-sqrt(3)*x+s*(1+sqrt(3))/2)
a[y][x]=[1,0.2,0]
elsif (distance(x,y,5*s/6,s/2)<=s/3 && distance(x,y,s/3,(3+sqrt(3))*s/6)<=s/3 && y(1-sqrt(3))/2) || (distance(x,y,2*s/3,(3+sqrt(3))*s/6)<=s/3 && distance(x,y,2*s/3,(3-sqrt(3))*s/6)<=s/3
&& y< s/2) || (distance(x,y,5*s/6,s/2)<=s/3 && distance(x,y,s/3,(3-sqrt(3))*s/6)<=s/3 && y< -sqrt(3)*x+s*(1+sqrt(3))/2) || (distance(x,y,s/6,s/2)<=s/3 && distance(x,y,2*s/3,(3-sqrt(3))*s/6)<=s/3
&& y>sqrt(3)*x+s*(1-sqrt(3))/2) || (distance(x,y,s/3,(3+sqrt(3))*s/6)<=s/3 && distance(x,y,s/3,(3-
sqrt(3))*s/6)<=s/3 && y>s/2) || (distance(x,y,s/6,s/2)<=s/3 && distance(x,y,2*s/3,(3+sqrt(3))*s/6)
<=s/3 && y>-sqrt(3)*x+s*(1+sqrt(3))/2)
a[y][x]=[1,0.4,0]
else
if distance(x,y,s/2,s/2)>=9*s/30 && distance(x,y,s/2,s/2)
if y>=x
a[y][x]=[0.8,0.8,0.8-(y-x)/(sqrt(2)*(sqrt(2)*s/2))]
else y< x
a[y][x]=[0.8,0.8,0.8-(x-y)/(sqrt(2)*(sqrt(2)*s/2))]
end
elsif x%2==1 || y%2==1
a[y][x]=[0,0,rand()]
else
a[y][x]=[0,rand(),0]
end
end
end
end
end
a
end
- ( 00-340263F )
def b(s,x,y)
r=s/2.0
if distance(x,y,r,r)<=r
(r-distance(x,y,r,r))/r
else
1
end
end
def sphere(s)
image=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x]=[1,b(s,x,y),1-b(s,x,y)]
end
end
image
end
- (00-340242A )
def distance(x,y,u,v)
((x-u)**2+(y-v)**2)**0.5
end
def kadai(s)
image = make2d(s,s)
for x in (0..(s/16))
for y in (0..(s-1))
if y-s/8>(s/16-x)**1.5/7.0
image[y][x] = 0.2+(y/(2*s).to_f())
else
image[y][x] = 0.7+(y/(5*s).to_f())
end
end
end
for x in ((s/16+1)..(5*s/16))
for y in (0..(s-1))
if y-s/8>(x-s/16)**1.5/7.0
image[y][x] = 0.2+(y/(2*s).to_f())
else
image[y][x] = 0.7+(y/(5*s).to_f())
end
end
end
for x in ((25*s/16+1)..(9*s/16))
for y in (0..(s-1))
if y-s/6>(9*s/16-x)**1.5/7.0
image[y][x] = 0.2+(y/(2*s).to_f())
else
image[y][x] = 0.7+(y/(5*s).to_f())
end
end
end
for x in (9*s/16+1)..(13*s/16)
for y in 0..(s-1)
if y-s/6>(x-9*s/16)**1.5/7.0
image[y][x] = 0.2+(y/(2*s).to_f())
else
if distance(x,y,9*s/13,3*s/13)>s/8
image[y][x] = 0.7+(y/(5*s).to_f())
else
image[y][x] = 0.9
end
end
end
end
for x in (13*s/16+1)..(s-1)
for y in 0..(s-1)
if y-s/5>(17*s/16-x)**1.5/7.0
image[y][x] = 0.2+(y/(2*s).to_f())
else
if distance(x,y,9*s/13,3*s/13)>s/8
image[y][x] = 0.7+(y/(5*s).to_f())
else
image[y][x] = 0.9
end
end
end
end
image
end
show(kadai(500))
- (00-340618H)
# 1から100までの素数が白い正方形で表されています(1は便宜上素数ということにしています)。
# 2、3、5、7(10以下)の倍数だけをふるえばよいので、プログラムは
def show_furui()
a=make2d(10,10)
for y in 0..9
for x in 0..9
a[0][0]=1
a[0][1]=1
a[0][2]=1
a[0][4]=1
a[0][6]=1
if ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%5.0==0
&& ((x+1)+y*10.0)%7.0==0
a[y][x]=0.2*0.3*0.5*0.7
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%5.0==0
a[y][x]=0.2*0.3*0.5
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.2*0.3*0.7
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%5.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.2*0.5*0.7
elsif ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%5.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.3*0.5*0.7
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%3.0==0
a[y][x]=0.2*0.3
elsif ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%5.0==0
a[y][x]=0.3*0.5
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%5.0==0
a[y][x]=0.2*0.5
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.2*0.7
elsif ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.3*0.7
elsif ((x+1)+y*10.0)%5.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.5*0.7
elsif ((x+1)+y*10.0)%2.0==0
a[y][x]=0.2
elsif ((x+1)+y*10.0)%3.0==0
a[y][x]=0.3
elsif ((x+1)+y*10.0)%5.0==0
a[y][x]=0.5
elsif ((x+1)+y*10.0)%7.0==0
a[y][x]=0.7
else
a[y][x]=1
end
end
end
show(a)
end
# としました。
# 各数で素因数の0.1倍を互いにかけあわせているので、色が濃いと素因数が多くなっています。
def show_furui120()
a=make2d(12,10)
for y in 0..11
for x in 0..9
a[0][0]=1
a[0][1]=1
a[0][2]=1
a[0][4]=1
a[0][6]=1
if ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%5.0==0
&& ((x+1)+y*10.0)%7.0==0
a[y][x]=0.2*0.3*0.5*0.7
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%5.0==0
a[y][x]=0.2*0.3*0.5
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.2*0.3*0.7
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%5.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.2*0.5*0.7
elsif ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%5.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.3*0.5*0.7
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%3.0==0
a[y][x]=0.2*0.3
elsif ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%5.0==0
a[y][x]=0.3*0.5
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%5.0==0
a[y][x]=0.2*0.5
elsif ((x+1)+y*10.0)%2.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.2*0.7
elsif ((x+1)+y*10.0)%3.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.3*0.7
elsif ((x+1)+y*10.0)%5.0==0 && ((x+1)+y*10.0)%7.0==0
a[y][x]=0.5*0.7
elsif ((x+1)+y*10.0)%2.0==0
a[y][x]=0.2
elsif ((x+1)+y*10.0)%3.0==0
a[y][x]=0.3
elsif ((x+1)+y*10.0)%5.0==0
a[y][x]=0.5
elsif ((x+1)+y*10.0)%7.0==0
a[y][x]=0.7
else
a[y][x]=1
end
end
end
show(a)
end
- ( 00-340547E )
def dora(s)
image=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
r=sin(sqrt(x**2+y**2)*0.015708)
g=cos(x*y*0.015708/s)
b=(sin((x+y)*0.015708))**2
image[y][x]=[r,g,b]
end
end
image
end
- ( 00-340073A )
def original1(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
r = ((y-s/2.00)**2+0.5)/((s/2)**2) #red
g = ((x-s/2.00)**2+0.5)/((s/2)**2) #green
b = (x+y)/200.00 #blue
image[y][x] = [r,g,b]
end
end
- (00-340230D)
def R(s,x,y)
r=s/2.0
if distance(x,y,r,r)<=r/2.0
0
else
1
end
end
def B(s,x,y)
r=s/2.0
if distance(x,y,r,r)<=r/2.0
(r-distance(x,y,r,r))/r
else
1
end
end
def G(s,x,y)
r=s/2.0
if distance(x,y,r,r)<=r
1-(r-distance(x,y,r,r))/r
else
1
end
end
def colorsphere(s)
image = make2d(s, s)
for y in 0..(s -1)
for x in 0..(s -1)
image[y][x] = [R(s,x,y), B(s,x,y), G(s,x,y) ]
end
end
image
end
- (00-340629B )
#まず、序盤に作成したdistance関数および, 配列作成に必要なmake2d関数をロードします.
def b(s,x,y,u,v)
r=s/2.0
if distance(x,y,u,v)<=r
1
else
0
end
end
# 直径s, 中心(x,y)となるような円を作成するための関数bを定義しました.
def spheres(s)
xr=rand(s)
yr=rand(s)
xg=rand(s)
yg=rand(s)
xb=rand(s)
yb=rand(s)
rr=rand(s)
rg=rand(s)
rb=rand(s)
#赤, 緑, 青の円の直径および中心座標をランダムに決定します.
r=s/2.0
if rr <= r
rr = s-rr
end
if rg <= r
rg = s-rg
end
if rb <= r
rb = s-rb
end
# 半径が非常に小さくなるのを避ける意味で, 直径がs/2より小さくなるようなときは
# 直径を新たに s-(元の直径)になるようにしました.
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
p = (x+y)/(2*s-2.0)
image[y][x]=[p*b(rr,x,y,xr,yr),p*b(rg,x,y,xg,yg),p*b(rb,x,y,xb,yb)]
end
end
image
end
# それぞれの円が重なるところは, その色同士が重なるようにしてみました.
# また, 左上から右下にかけてだんだん明るくなるようなグラデーションをかけるためにpを設定しました.
- (00-340235I)
def kadai(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x]=[sin((x+y)*0.02718281828),cos((x-y)*0.02718281828),rand(200)/200.0]
end
end
image
end
show(kadai(200))
- (00-340264I)
def a(s,t,x,y)
r=s/2.0
5*sin(t*asin((y-3.0/2.0*r)/(distance(x,y,3.0/2.0*r,3.0/2.0*r)+0.01)))
end
def b(s,x,y)
r=s/2.0
if r*sin((x-r)/(r/12.0))/((x-r)/(r/12.0))+rx
[0.7*sin(y/(r/15))+0.5*sin(y/(r/30)),0.5*sin(y/(r/30)),sin(x/(r/23.0))]
elsif r*sin((x-r)/(r/12.0))/((x-r)/(r/12.0))+r>y &&
r*sin((y-r)/(r/12.0))/((y-r)/(r/12.0))+ry &&
r*sin((y-r)/(r/12.0))/((y-r)/(r/12.0))+r>x
[2.0*x*y/(s+1)**2.0,x/(y+1.0),y/(x+1.0)]
else
[0,0,0]
end
end
def abc(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x] = b(s,x,y)
end
end
image
end
def panda()
[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]
end
- (00-340266E )
def f(s,x,y)
if distance(x,y,s/4,s/4) < s/8
if distance(x,y,s/4,s/4) < s/16
[rand(),0,0]
else
[1,1,0]
end
elsif distance(x,y,3*s/4,s/4) < s/8
if distance(x,y,3*s/4,s/4) < s/16
[rand(),0,0]
else
[1,1,0]
end
elsif distance(x,y,s/2,s/2) < s/16
[0.8,0,0]
elsif y > (x-(s/2))**2/5+11*s/16
if y < (x-(s/2))**2/5+13*s/16
[0.5,0,0]
else
[rand(x)/100.0,rand(y)/100.0,rand(x+y)/100.0]
end
else
[rand(x)/100.0,rand(y)/100.0,rand(x+y)/100.0]
end
end
def g(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x] = f(s,x,y)
end
end
image
end
show(g(300))
- (00-340979F )
def bizzare()
a=make2d(600,600)
for x in 0..599
for y in 0..599
a[x][y]=[0,0,0]
end
end
for b in 0..6
c=b*100
for k in 0..6
m=k*100
for x in 0..599
for y in 0..599
l=distance(x,y,c,m)
if l>=50 then
a[x][y]=a[x][y]
else
t=2*3.1416*l/50
a[x][y]=[0.5+sin(t)/2 , 0.5-sin(t+3.1416*2/3)/2 , 0.5-sin(t+3.1416*4/3)/2]
end
end
end
end
end
a
end
- (00-340236B )
def isetan(s)
gr=[0,0.4,0.3]
yl=[0.7,0.7,0]
mg=[0.7,0,0.4]
gy=[0.35,0.55,0.15]
gm=[0.35,0.2,0.35]
ym=[0.7,0.35,0.2]
image=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
a=x%40
b=y%40
if (a<=19 || a==27 || a==28 || a==34) && (b<=19 || b==27 || b==28 || b==34)
image[y][x] = gr
elsif (29<=a && a<=33 || 35<=a && a<=39) && (29<=b && b<=33 || 35<=b && b<=39)
image[y][x] = yl
elsif (20<=a && a<=26) && (20<=b && b<=26)
image[y][x] = mg
elsif ((29<=a && a<=33 || 35<=a && a<=39) && (b<=19 || b==27 || b==28 || b==34)) || ((a<=19
a==27 a==28 a==34) && (29<=b && b<=33 35<=b && b<=39))
image[y][x] = gy
elsif ((=a && a<=26) && (b<=19 || b==27 || b==28 || b==34)) || ((a<=19 || a==27 || a==28
a==34) && (20<=b && b<=26))
image[y][x] = gm
else
image[y][x] = ym
end
end
end
image
end
- (00-340542J)
def Pi()
3.14159265358979 #atan(1)*4
end
def make3d(dim1,dim2,dim3) #3次元配列
a = Array.new(dim1)
for i in 0..(dim1-1)
a[i] = make2d(dim2,dim3)
end
a
end
def direction(size,x,y) #中心回りの時計回りの角度を求める
s = (size-1)/2.0
theta = 0.0
if x > s
theta = Pi()/2.0 - atan( (s-y)/(x-s) )
elsif x == s
if y <= s
theta = 0.0
else
theta = Pi()
end
else
theta = 3*Pi()/2.0 + atan( (s-y)/(s-x) )
end
theta
end
def basecolor(theta) #中心周りの角度に応じて元となる色を決める
p = Pi()/3
if 0 <= theta && theta < p
[1.0,theta/p,0.0]
elsif p <= theta && theta < p*2
[1.0-(theta-p)/p,1.0,0.0]
elsif p*2 <= theta && theta < p*3
[0.0,1.0,(theta-p*2)/p]
elsif p*3 <= theta && theta < p*4
[0.0,1.0-(theta-p*3)/p,1.0]
elsif p*4 <= theta && theta < p*5
[(theta-p*4)/p,0.0,1.0]
else
[1.0,0.0,1.0-(theta-p*5)/p]
end
end
def colorcircle(size)
a = make3d(size,size,3)
s = (size-1)/2.0
for y in 0..(size-1)
for x in 0..(size-1)
d = distance(x,y,s,s)
if d <= s
for i in 0..2
a[y][x][i] = ( (basecolor(direction(size,x,y) ) )[i]) * sin(Pi()*d/s/2.0) #明るさを変える
end
else
a[y][x] = [0.0,0.0,0.0]
end
end
end
show(a)
end
- (00-340954I )
#tsurai
# 上から白…黒5パターン
# 結局白黒2色に変更
v = 1
z = 0
#0行目…12行目 各89列
a = [v,v,z,v,v,v,v,v,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,z,v,v,v,v,v,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v]
b = [v,z,v,v,v,v,v,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,z,v,v,v,v,v,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,z,z,z,z,v,v,v,v,v,v,z,v,v,v,v,v,v,z,v,v,v]
c = [v,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,z,z,z,z,z,z,z,v,v,v,v,v,v,v,v,v,z,z,z,v,v,v,z,v,v,v,v,v,v,v,z,v,v]
d = [z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,z,v,v,v,v,v,v,v,v,v,v,v,v,z,v,v,v,v,v,v,z,z,z,v,v,v,v,v,v,z,z,v,v,v,z,v,v,v,v,v,v,v,v,v,v,z,v,v,v,v,v,v,v,z,v,v]
e = [z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,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
k = [v,z,v,v,v,v,v,v,v,v,v,z,v,z,z,v,z,z,v,z,z,v,z,v,v,v,v,v,v,v,v,v,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,z,z,z,z,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v]
l = [v,z,v,v,v,v,v,v,v,v,v,v,z,v,v,z,v,v,z,v,v,z,v,v,v,v,v,v,v,v,v,v,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v]
m = [v,v,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,z,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v]
tsurai = [a,b,c,d,e,f,g,h,i,j,k,l,m]
show(tsurai)
- ( 00-340971B )
def ironcross(s)
make2d(s,s)
image=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x]=[1,0,0]
if -s/4<(x-s/2) &&(x-s/2)< s/4 && -s/4<(y-s/2) &&(y-s/2)< s/4
image[y][x]=[0,0,0]
end
if distance(0,s/2,x,y)< s/2.2 && distance(s/2,0,x,y)< s/2.2
image[y][x]=[1,0,0]
end
if distance(0,s/2,x,y)< s/2.2 && distance(s/2,s,x,y)< s/2.2
image[y][x]=[1,0,0]
end
if distance(s,s/2,x,y)< s/2.2 && distance(s/2,s,x,y)< s/2.2
image[y][x]=[1,0,0]
end
if distance(s,s/2,x,y)< s/2.2 && distance(s/2,0,x,y)< s/2.2
image[y][x]=[1,0,0]
end
end
end
for y in 0..(s-1)
for x in 0..(s-1)
if s/2.4>sqrt((x-s/2)**2) && s/2.4>sqrt((y-s/2)**2)
for n in 1..10
if image[y-(s/50*n/10)][x-(s/50*n/10)]==[0,0,0] && image[y][x]==[1,0,0]
image[y][x]=[193,193,193]
end
if image[y+(s/50*n/10)][x-(s/50*n/10)]==[0,0,0] && image[y][x]==[1,0,0]
image[y][x]=[193,193,193]
end
if image[y-(s/50*n/10)][x+(s/50*n/10)]==[0,0,0] && image[y][x]==[1,0,0]
image[y][x]=[193,193,193]
end
if image[y+(s/50*n/10)][x+(s/50*n/10)]==[0,0,0] && image[y][x]==[1,0,0]
image[y][x]=[193,193,193]
end
end
end
end
end
image
end
- (00-340606A )
def expsin(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
if y < s/2.0*(1-exp(-x*1.3862943/s))
b = 1-distance(x,y,x,0)/(s/2.0)
image[y][x] = [0,0,b]
else
if y > s/2.0*(1+exp(-x*1.3862943/s))
b = 1-distance(x,y,x,s)/(s/2.0)
image[y][x] = [0,0,b]
else
if y < s/2.0*(1+sin(6*3.1415926*x/s)*exp(-x*1.3862943/s))
r = 1-distance(x,y,0,y)/s
image[y][x] = [r,0,0]
else
g = 1-distance(x,y,0,y)/s
image[y][x] = [0,g,0]
end
end
end
end
end
image
end
- (00-340526J )
def graph()
image=make2d(400,400)
for y in 0..399
for x in 0..399
if distance(y,x,200,200)<200
image[y][x]=[1,0,0]
else
image[y][x]=[1,1,1]
end
if (distance(y,x,200,200)<195 && distance(y,x,200,200)>190)
image[y][x]=[1,1,1]
end
if distance(y,x,200,200)<130
image[y][x]=[0,0.31640,0.60156]
end
if (distance(y,x,200,200)<140 && y-x>-20 && y-x<20)
image[y][x]=[1,0,0]
end
end
end
image
end
- (00-220273J)
def b(s,x,y)
r = s
if (distance(x, y, r, r) <= r)
return [1 - ((r - distance(x, y, r, r)) / r), 0, 0]
else
return [1,0.5,0]
end
end
def sphere(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x] = b(s,x,y)
end
end
return image
end
- (00-340616B )
# ロータリーエンジンのローター部分となるルーローの三角形を作って、それぞれの円の色をRGBに割り当てまし
た。
# 色は円の中心からの距離を3で割ったものをsinに入れたものです。
def d(x,y,u,v)
sqrt((u-x)**2+(v-y)**2)
end
def b1(s,x,y)
if d(x,y,0,s)<=s
sin(d(x,y,0,s)/3)
else
0
end
end
def b2(s,x,y)
if d(x,y,s,s)<=s
sin(d(x,y,s,s)/3)
else
0
end
end
def b3(s,x,y)
if d(x,y,s/2,0)<=s
sin(d(x,y,s/2,0)/3)
else
0
end
end
def rotary3(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x]=[b1(s,x,y),b2(s,x,y),b3(s,x,y)]
end
end
show(image)
end
- (00-340621H )
def hearts1()
a=make2d(500,500)
for j in 0..499
for i in 0..499
if distance(i/200.0,j/200.0,0.98,1.08)<=0.18||
distance(i/200.0,j/200.0,1.52,1.08)<=0.18||
distance(i/200.0,j/200.0,1.25,1.4)<=0.3
a[j][i]=
[cos(distance(i/200.0,j/200.0,1.3,1.5)*1.3)+0.1,
cos(distance(i/200.0,j/200.0,1.0,1.1))-0.3,
sin(distance(i/200.0,j/200.0,1.55,1.18)*1.3)+0.13]
else
r=distance(i/200.0,j/200.0,1.25,1.25)
s=(i/200.0-1.25)/1.25
t=1.5-j/200.0
if s**2+(t-(s**2)**(1/3.0))**2<=1
a[j][i]=[1.0-r/3.0,0.6-r/3.0,0.9]
else
a[j][i]=[1.0-r/3.0,1.0-r/3.0,0.9]
end
end
end
end
a
end
- (00-340071E )
def c(s,n,x,y)
r=s/2.0
if distance(x,y,0,r)<=2*r
sin( (2*r-distance(x,y,0,r))*3.14*n/(2.0*r))
else
0
end
end
def d(s,n,x,y)
r=s/2.0
if distance(x,y,s,r)<=2*r
sin( (2*r-distance(x,y,s,r))*3.14*n/(2.0*r))
else
0
end
end
def wave(s,n)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x] = [c(s,n,x,y),d(s,n,x,y),0]
end
end
image
end
- (00-340048C)
def zettaiti(n)
if n < 0
-n
else
n
end
end
def yltbv(s)
image = make2d(s,s)
for i in 0..s-1
for j in 0..s-1
a = sin(i/(s-1.0))*sin(j/(s-1.0))
b = cos(i/(s-1.0))*sin(j/(s-1.0))
c = cos(i/(s-1.0))*cos(j/(s-1.0))
image[i][j] = [zettaiti(a),zettaiti(b),zettaiti(c)]
end
end
image
end
- ( 00-340958A )
def square1(s)
image=make2d(s,s)
for x in 0..(s-1)
for y in 0..(s-1)
image[x][y]=[1-k(x,100+y),1-k(x,y),1-k(x,y-100)]
end
end
image
end
def k(s,t)
if t>s && s+100.0>=t
(t-s)/100.00
else
if t>s+300 && s+400>=t
(t-s-300)/100.00
else
if t>s-300 && s-200>=t
(t-s+300)/100.00
else
if s+200>t && t>s+100
1.0-(t-s-100.0)/100.00
else
if s+500>t && t>s+400
1.0-(t-s-400.0)/100.00
else
if s-100>t && t>s-200
1.0-(t-s+200.0)/100.00
else
if t>s-600 && s-500>=t
(t-s+600)/100.00
else
if s-400>t && t>s-500
1.0-(t-s+500.0)/100.00
else
0
end
end
end
end
end
end
end
end
end
- ( 00-340956E )
# 色の錯覚を作りました。
# 下の二つの色の縞がかかっていますが、二つの円は同じ色です。
def kadai(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
if distance(x,y,s/4,s/4)<=s/4 && x%2==0
image[y][x] = [0,1,0.5]
else
if distance(x,y,3*s/4,s/4)<=s/4 && x%2==1
image[y][x] = [0,1,0.5]
else
if y< s/2 && x%2==0
image[y][x] = [1,0,1]
else
if y< s/2 && x%2==1
image[y][x] = [1,1,0]
else
if y>=s/2 && y<(3*s)/4
image[y][x] = [0,1,0.5]
else
if y>=(3*s)/4 && x< s/2
image[y][x] = [1,0,1]
else
image[y][x] = [1,1,0]
end
end
end
end
end
end
end
end
image
end
- ( 00-340624G )
def qb(n)
a=make2d(n,2*n)
for y in 0..n-1
for x in 0..2*n-1
s=n/2.5
t=n/2.5
u=(2-1/2.5)*n
v=n/2.5
if distance(x,y,s,t)n/28.0
if distance(x,y,s,t)n/28.0
if distance(x,y,u,v)=(5/n)*(x-0.9*n)**2+0.13*n || n-y>=(5/n)*(x-1.1*n)**2+0.13*n ) &&
(n-y<=(5/n)*(x-0.9*n)**2+0.14*n && n-y<=(5/n)*(x-1.1*n)**2+0.14*n)
a[y][x]=[0.3,0.1,0.1]
else
a[y][x]=[1,1,1]
end
end
end
end
end
show(a)
end
注 : 一昨年度の作品(11/16の課題の8番)と画像は類似しているのですが,プログラムは独立に書かれているので,投票の対象にします.
- ( 00-340069H )
def csphere(s,r,g,b)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x] = make1d(3)
c=b(s,x,y)
back=[1-r/5,1-g/5,1-b/5]
if c == 1
for i in 0..2
image[y][x][i]=back[i]
end
else
image[y][x][0]=1-r*c
image[y][x][1]=1-g*c
image[y][x][2]=1-b*c
end
end
end
image
end
- ( 00-340060A )
def wave(s)
image=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
if y<(s*(1-sin(12*atan(1)*x/s)))/2
r=(y+1.0)/s
g=0
b=(x+1.0)/s
image[y][x]=[r,g,b]
else
r=0
g=(cos(8*atan(1)*distance(x,y,s/2,s)/s))**2
b=0
image[y][x]=[r,g,b]
end
end
end
image
end
- ( 00-340545I )
def original()
a=make2d(100,100)
for y in 0..99
for x in 0..99
a[y][x]=[rand(x+y)/200.0,rand(x*y)/10000.0,rand(x**2+y**2)/20000.0]
end
end
show(a)
end
- ( 00-340252B )
def w(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x]=[sin(x*0.0123456),sin((x+y)*0.0123456),sin(distance(cos(x),sin(y),5*s/6,s/2)/7.0)]
end
end
image
end
show(w(200))
- ( 00-340967I )
def asteroids()
a=make2d(400,400)
for y in 0..399
for x in 0..399
if ((x-199)**2)**(1/3.0)+((y-199)**2)**(1/3.0) >=(200**2)**(1/3.0)
a[y][x]=[1-distance(x,y,199,199)/200,1-distance(x,y,299,299)/200,1- distance(x,y,99,99)/200]
else
if (((x-199)+(y-199))**2)**(1/3.0)+(((x-199)-(y-199))**2)**(1/3.0)>=(200**2/2.0)**(1/3.0)
a[y][x]=[distance(x,y,199,199)/200,sin(distance(x,y,199,199)/200),cos(distance(x,y,99,99)/200)]
else
if ((x-199)**2)**(1/3.0)+((y-199)**2)**(1/3.0) >=(50**2)**(1/3.0)
a[y][x]=[1-distance(x,y,199,199)/200,tan(1-distance(x,y,199,199)/200),y/400.0]
else
a[y][x]=[0.3,distance(x,y,199,199)/50,y/25.0]
end
end
end
end
end
show(a)
end
- (00-340063J)
def make1d_f(n)
a=Array.new(n)
for i in 0..(n-1)
a[i] = 0
end
a
end
def make2d_f(h,w)
a=Array.new(h)
for i in 0..(h-1)
a[i] = make1d_f(w)
end
a
end
def distance(r1,r2)
sqrt((r1[0]-r2[0])**2+(r1[1]-r2[1])**2)
end
def abs(x)
if x > 0
x
else
-x
end
end
def cor_trf(r,xo)
x = r[0]
y = r[1]
x1 = sqrt(5)*(x+2*y-xo)/4
y1 = sqrt(5)*(xo-x+2*y)/4
[x1,y1]
end
def cor_trf_inv(r,xo)
x = r[0]
y = r[1]
x1 = 2*(x-y)/sqrt(5) + xo
y1 = (x+y)/sqrt(5)
[x1,y1]
end
def distort(r,c,f)
x = r[0]
y = r[1]
xc = c[0]
yc = c[1]
d = distance(r,c)
if d > 0
x = x - f/d
y = y - f/d
else
x = x - f
y = y - f
end
[x,y]
end
def latice(r,d)
x = r[0]
y = r[1]
if (x%d >= 0 && x%d <= 1) && (x > 0) && (y > 0)
1
else
if (y%d >= 0 && y%d <= 1) && (x > 0) && (y > 0)
1
else
0
end
end
end
def d_p(rk)
n = 300
img = make2d_f(n,n)
xo = n/2
c = [rand()*2.2*xo,rand()*2.2*xo]
for x in 0..(n-1)
for y in 0..(n-1)
r = [x,y]
img[y][x] = latice(distort(cor_trf(r,xo),c,10*rk**1.4),2*n/30)
if distance(r,cor_trf_inv(c,xo)) < rk
t = (rk-distance(r,cor_trf_inv(c,xo))*0.9)/rk
img[y][x] = t
end
end
end
show(img)
end
- (00-340975D)
def yc(n,k)
(n.transpose+k.transpose).transpose
end
def gbar(n)
image=make1d(n)
for x in 0..n-1
image[x]=0.5
end
image
end
def w()
image=make2d(12,12)
for y in 0..11
image[y][11]=0.5
end
image+[gbar(12)]
end
def h(n)
n%100
end
def c(n)
(n/100.0).floor
end
def week(n,k)
if n!=(n.floor)||k!=(k.floor)
9
else
if k<=0 || k>=13
9
else
if n<=3
8
else
if k<=2
k=k+12
n=n-1
end
if 1582<=n
(1+(26*(k+1)/10.0).floor+h(n)+(h(n)/4.0).floor+5*c(n)+(c(n)/4.0).floor)%7
else
(1+(26*(k+1)/10.0).floor+h(n)+(h(n)/4.0).floor+6*c(n)+5)%7
end
end
end
end
end
# ※上記がn年k月1日の曜日を計算する式
def uruu(n)
if n%4==0
if n%100==0
if n%400==0
29
else
28
end
else
29
end
else
28
end
end
def yc7(a,b,c,d,e,f,g)
(a.transpose+b.transpose+c.transpose+d.transpose+e.transpose+f.transpose+g.transpose).transpose
end
$sun=[[0,0,0,0,0,0,0,0,0,0,0,0.5],
[0,0,1,1,1,1,1,1,1,0,0,0.5],
[0,0,1,0,0,0,0,0,1,0,0,0.5],
[0,0,1,0,0,0,0,0,1,0,0,0.5],
[0,0,1,0,0,0,0,0,1,0,0,0.5],
[0,0,1,0,0,0,0,0,1,0,0,0.5],
[0,0,1,1,1,1,1,1,1,0,0,0.5],
[0,0,1,0,0,0,0,0,1,0,0,0.5],
[0,0,1,0,0,0,0,0,1,0,0,0.5],
[0,0,1,0,0,0,0,0,1,0,0,0.5],
[0,0,1,0,0,0,0,0,1,0,0,0.5],
[0,0,1,1,1,1,1,1,1,0,0,0.5],
[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]]
$mon=[[0,0,0,1,1,1,1,1,1,0,0,0.5],
[0,0,0,1,0,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0,0,0,0,0.5],
[0,0,1,1,1,1,1,1,1,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[1,1,1,1,1,1,1,1,1,1,1,0.5],
[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]]
$top=[gbar(12*7)]+
((sun.transpose+mon.transpose+tue.transpose+wed.transpose+thr.transpose+fry.transpose+$
sat.transpose).transpose)
def ybar(n)
image=make2d(n,1)
for y in 0..n-1
image[y][0]=0.5
end
image
end
def final1(a,b,c,d,e,f,g)
yc(ybar(13*6+1),$top+yc7(a,b,c,d,e,f,g))
end
def final2(a,b,c,d,e,f,g)
yc(ybar(13*7+1),$top+yc7(a,b,c,d,e,f,g))
end
# ※ここまでが補助関数群
def calendar(n,k)
aa=[[0,0,0,0,0,0,0,0,0,0,0,0.5],
[0,0,0,0,0,0,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,1,1,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,0,1,0,0,0,0,0,0.5],
[0,0,0,0,1,1,1,0,0,0,0,0.5],
[0,0,0,0,0,0,0,0,0,0,0,0.5],
[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]]
ab=[[0,0,0,0,0,0,0,0,0,0,0,0.5],
[0,0,0,0,0,0,0,0,0,0,0,0.5],
[0,0,0,1,1,1,1,1,0,0,0,0.5],
[0,0,0,0,0,0,0,1,0,0,0,0.5],
[0,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ccc=ac+aj+bg+cd
ddd=ad+ba+bh+ce
eee=ae+bb+bi+cf
fff=af+bc+bj+cg
ggg=ag+bd+ca+ch
p=ci
q=cj
r=da
if
week(n,k)==9
"no such year or month"
elsif
week(n,k)==8
"before A.D.4, people used completely different calendar from today's. So, It can't be output"
elsif week(n,k)==1
d=ddd+w
e=eee+w
f=fff+w
g=ggg+w
if k==1||k==3||k==5||k==7||k==8||k==10||k==12
a=aaa+p
b=bbb+q
c=ccc+r
elsif k==4||k==6||k==9||k==11
a=aaa+p
b=bbb+q
c=ccc+w
else
if uruu(n)==28
a=aaa+w
b=bbb+w
c=ccc+w
else
a=aaa+p
b=bbb+w
c=ccc+w
end
end
show(final1(a,b,c,d,e,f,g))
elsif week(n,k)==2
e=ddd+w
f=eee+w
g=fff+w
a=w+ggg
if k==1||k==3||k==5||k==7||k==8||k==10||k==12
b=aaa+p
c=bbb+q
d=ccc+r
elsif k==4||k==6||k==9||k==11
b=aaa+p
c=bbb+q
d=ccc+w
else
if uruu(n)==28
b=aaa+w
c=bbb+w
d=ccc+w
else
b=aaa+p
c=bbb+w
d=ccc+w
end
end
show(final1(a,b,c,d,e,f,g))
elsif week(n,k)==3
f=ddd+w
g=eee+w
a=w+fff
b=w+ggg
if k==1||k==3||k==5||k==7||k==8||k==10||k==12
c=aaa+p
d=bbb+q
e=ccc+r
elsif k==4||k==6||k==9||k==11
c=aaa+p
d=bbb+q
e=ccc+w
else
if uruu(n)==28
c=aaa+w
d=bbb+w
e=ccc+w
else
c=aaa+p
d=bbb+w
e=ccc+w
end
end
show(final1(a,b,c,d,e,f,g))
elsif week(n,k)==4
g=ddd+w
a=w+eee
b=w+fff
c=w+ggg
if k==1||k==3||k==5||k==7||k==8||k==10||k==12
d=aaa+p
e=bbb+q
f=ccc+r
elsif k==4||k==6||k==9||k==11
d=aaa+p
e=bbb+q
f=ccc+w
else
if uruu(n)==28
d=aaa+w
e=bbb+w
f=ccc+w
else
d=aaa+p
e=bbb+w
f=ccc+w
end
end
show(final1(a,b,c,d,e,f,g))
elsif week(n,k)==5
a=w+ddd
b=w+eee
c=w+fff
d=w+ggg
if k==1||k==3||k==5||k==7||k==8||k==10||k==12
e=aaa+p
f=bbb+q
g=ccc+r
elsif k==4||k==6||k==9||k==11
e=aaa+p
f=bbb+q
g=ccc+w
else
if uruu(n)==28
e=aaa+w
f=bbb+w
g=ccc+w
else
e=aaa+p
f=bbb+w
g=ccc+w
end
end
show(final1(a,b,c,d,e,f,g))
elsif week(n,k)==6
if k==1||k==3||k==5||k==7||k==8||k==10||k==12
a=w+ccc+r
b=w+ddd+w
c=w+eee+w
d=w+fff+w
e=w+ggg+w
f=aaa+p+w
g=bbb+q+w
show(final2(a,b,c,d,e,f,g))
else
a=w+ccc
b=w+ddd
c=w+eee
d=w+fff
e=w+ggg
if k==4||k==6||k==9||k==11
f=aaa+p
g=bbb+q
else
if uruu(n)==28
f=aaa+w
g=bbb+w
else
f=aaa+p
g=bbb=w
end
end
show(final1(a,b,c,d,e,f,g))
end
elsif week(n,k)==0
if k==2
a=w+bbb
b=w+ccc
c=w+ddd
d=w+eee
e=w+fff
f=w+ggg
if uruu(n)==28
g=aaa+w
else
g=aaa+p
end
show(final1(a,b,c,d,e,f,g))
else
c=w+ddd+w
d=w+eee+w
e=w+fff+w
f=w+ggg+w
g=aaa+p+w
a=w+bbb+q
if k==1||k==3||k==5||k==7||k==8||k==10||k==12
b=w+ccc+r
else k==4||k==6||k==9||k==11
b=w+ccc+w
end
show(final2(a,b,c,d,e,f,g))
end
end
end
- (00-340969E)
imagesizex = 500
imagesizey = 300
image = make2d(imagesizey,imagesizex)
def hexagon(offsetx,offsety,sidelength,image)
for x in (offsetx - sidelength)..(offsetx + sidelength)
for y in (offsety - sidelength)..(offsety + sidelength)
if (x<0||x>499||y<0||y>299)
elsif ((x-offsetx).abs() < sqrt(3) / 2.0 * sidelength ) && ((y-offsety).abs() + (x-
offsetx).abs() / sqrt(3) < sidelength)
image[y][x] = [image[y][x][0] / 2.0 + 0.5,image[y][x][1] / 2.0 + 0.5,image[y][x][2] /
2.0 + 0.5]
end
end
end
end
for x in 0..(imagesizex - 1)
for y in 0..(imagesizey - 1)
if (x == imagesizex/2.0) && (y >= imagesizey / 2.0)
image[y][x] = [1,0,1]
elsif (x == imagesizex/2.0) && (y < imagesizey / 2.0)
image[y][x] = [0,1,0]
else
angle = (y - imagesizey / 2.0) / (x - imagesizex/2.0)
if (x > imagesizex / 2.0)
if angle < -1 then
image[y][x] = [0,1,1/ angle.abs()]
elsif angle < 1 then
image[y][x] = [0,0.5 - angle/2.0,1]
else
image[y][x] = [1 - 1.0/angle,0,1]
end
else
if angle < -1 then
image[y][x] = [1,0,1-(1.0/angle).abs]
elsif angle < 1 then
image[y][x] = [1,0.5 + angle/2.0,0]
else
image[y][x] = [1.0/angle,1,0]
end
end
end
end
end
cogoffsetx1 = 30
cogoffsety1 = 10
cogoffsetx2 = 450
cogoffsety2 = 250
for x in 0..(imagesizex-1)
for y in 0..(imagesizey-1)
radius1 = distance(cogoffsetx1,cogoffsety1,x,y)
radius2 = distance(cogoffsetx2,cogoffsety2,x,y)
if (x<0||x>499||y<0||y>299)
elsif ( (radius1 > 20 && radius1 < 40) || (radius2 > 20 && radius2 < 40) ) then
image[y][x] = [image[y][x][0] / 2.0 + 0.5,image[y][x][1] / 2.0 + 0.5,image[y][x][2] / 2.0 +
0.5]
elsif ( (radius1 > 60 && radius1 < 120) || (radius2 > 60 && radius2 < 120) ) then
image[y][x] = [image[y][x][0] / 2.0 + 0.5,image[y][x][1] / 2.0 + 0.5,image[y][x][2] / 2.0 +
0.5]
elsif ( (radius1 > 150 && radius1 < 170) || (radius2 > 150 && radius2 < 170) ) then
image[y][x] = [image[y][x][0] / 2.0 + 0.5,image[y][x][1] / 2.0 + 0.5,image[y][x][2] / 2.0 +
0.5]
elsif (radius1 >= 170 && radius1 < 190) then
if (cogoffsetx1 == x)
else
cogangle1 = (y - cogoffsety1) / (x - cogoffsetx1 /1.0)
if (sin(atan(cogangle1) * 36 ) > (radius1 - 160) / 40.0 - 1.0 )
image[y][x] = [image[y][x][0] / 2.0 + 0.5,image[y][x][1] / 2.0 + 0.5,image[y][x]
[2] / 2.0 + 0.5]
end
end
elsif (radius2 >= 170 && radius2 < 190) then
if (cogoffsetx2 == x )
else
cogangle2 = (y - cogoffsety2) / (x - cogoffsetx2 /1.0)
if (sin(atan(cogangle2) * 36 ) > (radius2 - 160) / 40.0 - 1.0 )
image[y][x] = [image[y][x][0] / 2.0 + 0.5,image[y][x][1] / 2.0 + 0.5,image[y][x]
[2] / 2.0 + 0.5]
end
end
end
end
end
for x in 0..(imagesizex - 1)
for y in 0..(imagesizey - 1)
image[y][x] = [image[y][x][0] / 2.0 + 0.5,image[y][x][1] / 2.0 + 0.5,image[y][x][2] / 2.0 + 0.5]
end
end
for interval in 0..200
for x in 0..(imagesizex - 1)
for y in 0..(imagesizey - 1)
if (x<0||x>499||y<0||y>299) then
elsif ((y - x / sqrt(3) + interval * 3 - 300) < 0.5 && (y - x / sqrt(3) + interval * 3 - 300) >
-0.5) then
image[y][x] = [image[y][x][0] / 2.0 + 0.5,image[y][x][1] / 2.0 + 0.5,image[y][x][2] /
2.0 + 0.5]
end
end
end
end
for xnum in 0..25
for ynum in 0..15
if ((xnum + ynum)%11 < 7 && (xnum * ynum)%12 > 1)
if (ynum % 2 == 0)
hexagon(xnum*27,ynum*24 + 14,14,image)
else
hexagon(xnum*27 + 14,ynum*24 + 14,14,image)
end
else
end
if ((xnum *3 + ynum * 5)%7 <5 && ((xnum + 1) ** 2 + ynum)% 13 < 10)
if (ynum % 2 == 0)
hexagon(xnum*27,ynum*24 + 14,14,image)
else
hexagon(xnum*27 + 14,ynum*24 + 14,14,image)
end
else
end
end
end
show(image)
- ( 00-340966F )
def abs(x)
if x >= 0
x
else
-x
end
end
def make3d(height,width,depth)
a = Array.new(height)
for i in 0..(height-1)
a[i] = make2d(width,depth)
end
a
end
def make4d(height,width,depth,n)
a = Array.new(height)
for i in 0..(height-1)
a[i] = make3d(width,depth,n)
end
a
end
def d(x,y,z,a,b,c)
sqrt( (x-a)**2 + (y-b)**2 + (z-c)**2 )
end
点(x,y,z)が点(gx,gy,gz)を重心とする1辺の長さがlの立方体(dx,dyは傾き)の「辺」上にあるときは1を、ない
ときは0を返すプログラムです
def make_cube(x,y,z,gx,gy,gz,dx,dy,l)
m = dx**2+dy**2
point = [[gx+dx*l,gy+dy*l,gz+sqrt(1-m)*l],[gx-dy/sqrt(m)*l,gy+dx/sqrt(m)*l,gz],
[gx+dx*sqrt(1/m-1)*l,gy+dy*sqrt(1/m-1)*l,gz-sqrt(m)*l],[gx-dx*l,gy-dy*l,gz-sqrt(1-m)*l],
[gx+dy/sqrt(m)*l,gy-dx/sqrt(m)*l,gz],[gx-dx*sqrt(1/m-1)*l,gy-dy*sqrt(1/m-1)*l,gz+sqrt(m)*l]]
tf = make2d(6,6)
if d(x,y,z,gx,gy,gz) < sqrt(3)/2*l
for j in 0..5
for i in 0..5
if i!=j && abs(d(x,y,z,point[i][0],point[i][1],point[i][2])-d(x,y,z,gx,gy,gz)) < 3.00
&& abs(d(x,y,z,point[j][0],point[j][1],point[j][2])-d(x,y,z,gx,gy,gz)) < 3.00
tf[i][j] = 1
end
end
end
end
if tf.all? {|s| s == make1d(6) }
0
else
1
end
end
n×n×nの3次元上にプロットした点を2次元に射影するプログラムです
def projection(n)
w = make4d(n,n,n,3)
image = make3d(n,n,3)
for mz in 0..(n-1)
for y in 0..(n-1)
for x in 0..(n-1)
z = n-mz+1
xa = x - (n/4).to_i
ya = y - (n/4).to_i
za = z - (n/4).to_i
if ya == 0 && za == 0 # x軸
w[x][y][z] = [1.00,1.00,1.00]
elsif za == 0 && xa == 0 # y軸
w[x][y][z] = [1.00,1.00,1.00]
elsif xa == 0 && ya == 0 # z軸
w[x][y][z] = [1.00,1.00,1.00]
elsif make_cube(xa,ya,za,n/4,n*2/7,n/4,0.1,0.0,n/5) == 1 # 立方体(緑色)
w[x][y][z] = [0.20,0.90,0,20]
elsif make_cube(xa,ya,za,n/8,n/3,n/6,0.6,0.4,n/3) == 1 # 立方体(赤色)
w[x][y][z] = [0.90,0.00,0,00]
elsif make_cube(xa,ya,za,n*6/13,n*2/7,n/3,0.1,0.5,n*4/9) == 1 # 立方体(黄色)
w[x][y][z] = [0.80,0.80,0,10]
elsif make_cube(xa,ya,za,n/3,n/6,n/7,0.9,0.1,n/3) == 1 # 立方体(紫色)
w[x][y][z] = [0.90,0.00,0.90]
elsif (xa-n/4)**2 + (ya-n/4)**2 + (za-n/4)**2 < (n/10)**2 # 中心(n/4,n/4,n/4),半径n/10の球
w[x][y][z] = [0.60,0.60,0.90]
else
w[x][y][z] = [0.00,0.00,0.00]
end
p = n-(-0.10*xa + ya + 0.40*za + n/4.50)*0.90
q = (xa + 0.30*za + n/5.00)*0.90
if p.to_i > 0 && p.to_i < (n-1) && q.to_i > 0 && q.to_i < (n-1) && w[x][y][z] != [0,0,0]
image[p.to_i][q.to_i] = [w[x][y][z][0]*(n-z)/n,w[x][y][z][1]*(n-z)/n,w[x][y][z][2]*(n-z)/n]
end
end
end
end
image
end
- ( 00-340962D )
def b(s,x,y)
r=s/4.0
if y>=2*r and ((x-2*r)**2/(2*s/5.0)**2)+((y-2*r)**2/(s/10.0)**2)<=1 and ((x-
2*r)**2/(3*s/10.0)**2)+((y-2*r)**2/(s/30.0)**2)>=1
[1,1,0]
else
if y<=2*r and ((x-2*r)**2/(2*s/5.0)**2)+((y-2*r)**2/(s/10.0)**2)<=1 and ((x-
2*r)**2/(3*s/10.0)**2)+((y-2*r)**2/(s/30.0)**2)>=1 and distance(x,y,r*2,r*2)>=r
[1,1,0]
else
if distance(x,y,r*2,r*2)<=r
[(r-distance(x,y,r*2,r*2))/r,1,(r-distance(x,y,2*r,2*r))/r]
else
if rand()<=0.001
[1,1,1]
else
[0,0,0.5]
end
end
end
end
end
def star(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x] = b(s,x,y)
end
end
image
end
show(star(400))
- (00-340059G)
# burningship.rb
@x = -1.6739552413618408
@y = -0.009813549135403247
@d = 0.0008116000224706308
@count_max = 256
@color_base = 32
@color0 = [0, 0, 0]
@color1 = [1.0, 1.0, 0.6]
@color2 = [0.4, 0, 0.4]
def check_div(a, b)
x = a.abs
y = b.abs
for i in 1..@count_max
return i if x**2 + y**2 >= 4
zx = x**2 - y**2 + a
zy = 2 * x * y + b
x = zx.abs
y = zy.abs
end
-1
end
def get_color(count)
return @color0 if count < 0
d = count % (@color_base * 2)
d = d < @color_base ? d : @color_base * 2 - d
d = d / @color_base.to_f
color = Array.new(3)
for i in 0..2
color[i] = @color1[i] * d + @color2[i] * (1.0 - d)
end
color
end
def draw(s)
img = make2d(s, s)
dd = @d * 2 / s.to_f
x_min = @x - @d
y_min = @y - @d
for i in 0..(s-1)
for j in 0..(s-1)
a = x_min + dd * j
b = y_min + dd * i
count = check_div(a, b)
img[i][j] = get_color(count)
end
end
img
end
# 燃える船の一部です