- ( 00-240210A )
def image_gra(s)
g = make2d(s,s)
a = rand(11)/10.0
b = rand(11)/10.0
c = rand(11)/10.0
for y in 0..(s-1)
for x in 0..(s-1)
g[y][x] = [a+(s-distance(x,y,0,0))/s,
b+(s-distance(x,y,0,0))/s,c+(s-distance(x,y,0,0))/s]
end
end
g
end
- ( 00-240603A )
a=make2d(10,10)
for i in 0..9
if i%2==0
for j in 0..10
if j%2==0
a[i][j]=1
else
a[i][j]=0
end
end
else
for k in 0..10
if k%2==0
a[i][k]=0
else
a[i][k]=1
end
end
end
end
show(a)
def sierpinski(n)
load("./make1d.rb")
load("./make2d.rb")
load("combination_loop.rb")
sier=make2d(n,n)
for i in 0..(n-1)
for j in 0..(n-1)
if i < j
sier[i][j]=0
else
sier[i][j]=combination_loop(i,j)%2
end
end
end
sier
end
- ( 00-240078E )
画像は著作権的に問題があるため,投票後に削除しました.
def a
[0,0,0]
end
(省略)
def d
[0.92,0.64,0.09]
end
def one
[a,a,a,a,a,a,a,a,a,a,a,a,a,a]
end
(省略)
def eighteen
[a,a,a,a,a,a,a,a,a,a,a,a,a,a]
end
def mario
[one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,eighteen
]
end
show(mario)
- ( 00-240065E )
画像は著作権的に問題があるため,投票後に削除しました.
def a
[1,1,1]
end
(省略)
def e
[1,0,0]
end
def one
[a,a,a,a,a,b,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a]
end
(省略)
def thirtyseven
[a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,b,b,a,b,b,a,a,a,a,a,a,a,a,a,a,a,a,a,a]
end
def pika
[one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen,twenty,twentyone,twentytwo,twentythree,twentyfour,twentyfive,twentysix,twentyseven,twentyeight,twentynine,thirty,thirtyalpha,thirtyone,thirtytwo,thirtythree,thirtyfour,thirtyfive,thirtysix,thirtyseven]
end
show(pika)
def a
[1,1,1]
end
(省略)
def g
[0.9,0.65,0.2]
end
def one
[a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a]
end
(省略)
def eighteen
[a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a]
end
show([one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen])
- ( 00-240067A )
def owl()
i = make2d(28,30)
for y in(0..7)
for x in(0..4)
i[y][x] = [0,0,0]
end
for x in(25..29)
i[y][x] = [0,0,0]
end
end
(省略)
for y in(24..25)
for x in(7..10)
i[y][x] = [0.6,0.5,0.3]
end
for x in(19..22)
i[y][x] = [0.6,0.5,0.3]
end
end
i
end
- ( 00-240581J )
#データ入力部
################
# チップ #
################
#白マス
def white()
w = [1,1,1]
b = [0,0,0]
g = [0.38,0.38,0.38]
h = [0.66,0.66,0.66]
image = make2d(16,16)
image = [[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w]]
image
end
(省略)
#全体ぶつぶつ
def butu2()
w = [1,1,1]
b = [0,0,0]
g = [0.38,0.38,0.38]
h = [0.66,0.66,0.66]
image = make2d(16,16)
image = [[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,h,w,w,w,w,w,h,w,h,w,w,w,w,w,h],
[w,w,w,w,h,w,w,w,w,w,w,w,h,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[h,w,w,w,w,w,w,w,h,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,h,w,w,w,w,w,w,w,h],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,h,w,w,w,w,w,w,w,h,w,w,w,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,h,w,w,w,w,w,h,w,h,w,w,w,w,w,h],
[w,w,w,w,h,w,w,w,w,w,w,w,h,w,w,w],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[h,w,w,w,w,w,w,w,h,w,w,w,w,w,w,w],
[w,w,w,w,w,w,w,h,w,w,w,w,w,w,w,h],
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
[w,h,w,w,w,w,w,w,w,h,w,w,w,w,w,w]]
image
end
#各座標にデータ入力
def masara()
# id
w = 0
b = 1
(省略)
ga = 40
image = make2d(18,20)
idar = [[g ,g ,g ,b ,g ,g ,g ,g ,g ,b ,e ,e ,b ,g ,g ,g ,g ,g ,b ,g ],
[b ,b ,b ,b ,b ,b ,b ,b ,b ,b ,e ,e ,b ,b ,b ,b ,b ,b ,b ,b ],
[b ,g ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,g ,b ],
[b ,g ,w ,gl,r1,r2,r2,r3,w ,gl,w ,gl,r1,r2,r2,r3,w ,gl,g ,b ],
[b ,g ,ga,ga,h1,h2,h3,h4,gl,w ,ga,ga,h1,h2,h3,h4,gl,w ,g ,b ],
[b ,g ,ga,k ,h5,h6,h7,h8,w ,gl,ga,k ,h5,h6,h7,h8,w ,gl,g ,b ],
[b ,g ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,g ,b ],
[b ,g ,w ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,gl,w ,gl,g ,b ],
[b ,g ,gl,w ,ga,ga,ga,ga,gl,w ,y1,y3,y3,y3,y3,y5,gl,w ,g ,b ],
[b ,g ,w ,gl,s ,s ,s ,k ,w ,gl,y2,y4,y4,y4,y4,y6,w ,gl,g ,b ],
[b ,g ,gl,w ,r ,r ,r ,r ,gl,w ,l1,l2,l4,l5,l3,l6,gl,w ,g ,b ],
[b ,g ,w ,gl,l ,l ,l ,l ,w ,gl,l7,h7,h6,h7,h7,l8,w ,gl,g ,b ],
[b ,g ,gl,w ,gl,w ,gl,w ,gl,w ,ga,ga,ga,ga,ga,ga,ga,ga,g ,b ],
[b ,g ,w ,gl,w ,gl,w ,gl,w ,gl,s ,s ,s ,k ,s ,s ,ga,ga,g ,b ],
[b ,g ,g ,g ,p ,u ,u ,q ,ga,ga,r ,r ,r ,r ,g ,g ,ga,ga,g ,b ],
[b ,g ,g ,g ,t ,m ,m ,j ,ga,ga,l ,l ,l ,l ,g ,g ,ga,ga,g ,b ],
[b ,g ,g ,g ,t ,m ,m ,j ,ga,ga,ga,ga,ga,ga,ga,ga,ga,ga,g ,b ],
[b ,b ,g ,g ,t ,m ,m ,j ,b ,b ,b ,b ,b ,b ,b ,b ,b ,b ,b ,b ]]
masara = make2d(288,320)
for y in 0..287
ly = (y/16).to_i
line = make1d(320)
for lx in 0..19
id = idar[ly][lx]
my = y % 16
#id対応
#白ぬり
if id == 0
pl = white
end
(省略)
#全体ぶつぶつ
if id == 40
pl = butu2
end
line[lx*16..(lx+1)*16-1] = pl[my]
end
masara[y] = line
end
show(masara)
end
- ( 00-240584I )
画像は著作権的に問題があるため,投票後に削除しました.
- ( 00-240593G )
画像は著作権的に問題があるため,投票後に削除しました.
def w
[1,1,1]
end
(省略)
def o
[0.96,0.8,0.64]
end
def one
[[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,
w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
(省略)
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,
w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w]]
end
- ( 00-240956D )
def show_color_picture()
a=make2d(100,100)
for y in 0..99
for x in 0..99
a[y][x]=[rand(y)/99.0,rand(x)/99.0,rand(x*y)/10000.0]
end
end
show(a)
end
- ( 00-240061C )
def tree
w = [1,1,1]
g = [0,0.4375,0]
b = [0.71875,0.4375,0]
a = Array.new(10)
a[0] = [w,w,w,w,g,w,w,w,w,w]
(省略)
a[9] = [w,w,w,w,w,w,w,w,w,w]
t = Array.new(10)
for n in 0..9
t[n] =
a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[n]+a[
n]
end
c = [t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9]]
d = c+c+c+c+c+c+c+c+c+c+c+c+c+c+c+c+c+c+c+c
d
end
- ( 00-240966E )
def rainbow()
image = make2d(7,15)
for x in (0..14)
image[0][x]=[1,0,0]
image[1][x]=[1,0.5,0]
image[2][x]=[1,1,0]
image[3][x]=[0,1,0]
image[4][x]=[0,0,1]
image[5][x]=[0,0,0.75]
image[6][x]=[0.5,0,1]
end
image
end
- ( 00-240939A )
def d(x,y,u,v)
sqrt((x-u)**2.0+(y-v)**2.0)
end
def R(s,x,y)
r=s/2
if d(x,y,r,r) < r/4.0
d(x,y,r,r)*4.0/r
else
if d(x,y,r,r) < r/2.0
1.0-(d(x,y,r,r)-r/4.0)/r*2.0
else
if d(x,y,r,r) < r*3.0/4.0
0.5+(d(x,y,r,r)-r/2.0)/r*4.0/3.0*2.0
else
if d(x,y,r,r) < r
1.0-(d(x,y,r,r)-r*3.0/4.0)/r
else
0
end
end
end
end
end
def B(s,x,y)
r=s/2
if d(x,y,r,r) < r/4.0
1.0
else
if d(x,y,r,r) < r/2.0
1.0-(d(x,y,r,r)-r/4.0)/r*2.0
else
if d(x,y,r,r) < r*3.0/4.0
0.5-(d(x,y,r,r)-r/2.0)/r*4.0/3.0/2.0
else
if d(x,y,r,r) < r
0
else
0
end
end
end
end
end
def G(s,x,y)
r=s/2
if d(x,y,r,r) < r/4.0
0
else
if d(x,y,r,r) < r*0.5
0
else
if d(x,y,r,r) < r*0.75
0
else
if d(x,y,r,r) < r
(d(x,y,r,r)-r*3.0/4.0)/r/2.0
else
0
end
end
end
end
end
def Sphere(s)
a = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
a[y][x]=[R(s,x,y),G(s,x,y),B(s,x,y)]
end
end
show(a)
end
Sphere(100)
- ( 00-240952B )
a=make2d(256,256)
for y in 0..255
for x in 0..255
a[y][x]=[((1.0/128.0)**2)*(x-127.0)**2,1-((1.0/128.0)**2)*(x-127.0)**2,((1.0/128.0)**2)*(x)**2]
end
end
show(a)
- ( 00-240233B )
def HSVtoRGB(h,s,v)
x=h/60
f=h*1.0/60-x
p=v*(1-s)
q=v*(1-f*s)
r=v*(1-(1-f)*s)
if x==0
[v,r,p]
elsif x==1
[q,v,p]
elsif x==2
[p,v,r]
elsif x==3
[p,q,v]
elsif x==4
[r,p,v]
elsif x==5
[v,p,q]
end
end
def init(h,w)
a=Array.new(h)
for i in 0..(h-1)
a[i]=Array.new(w)
for j in 0..(w-1)
a[i][j]=[0,0,0]
end
end
a
end
def fractal(n)
x=0
y=0
s=[0,1,0,3,0]
h=(3**n)*2+1
w=3**n
image=init(h,w)
for i in 0..(h-1)
for j in 0..(w-1)
image[i][j]=HSVtoRGB(i*360/h,1,0.3)
end
end
image[0][0]=HSVtoRGB(0,1,1)
max=5**n
for i in 0..(max-1)
tmp=i
dir=0
while tmp>0
dir=(dir+s[tmp%5])%4
tmp=tmp/5
end
if dir==0
x=x+2
image[x-1][y]=HSVtoRGB(i*360/max,1,1)
elsif dir==1
y=y+2
image[x][y-1]=HSVtoRGB(i*360/max,1,1)
elsif dir==2
x=x-2
image[x+1][y]=HSVtoRGB(i*360/max,1,1)
else
y=y-2
image[x][y+1]=HSVtoRGB(i*360/max,1,1)
end
image[x][y]=HSVtoRGB(i*360/max,1,1)
end
image
end
- ( 00-240605G )
def check(n,k)
c = make2d(n,k)
for i in 0..(n-1)
for j in 0..(k-1)
if divisible(i+j,2)
c[i][j] = 1
else
c[i][j] = 0
end
end
end
show(c)
end
- ( 00-240507J )
def chaos(s)
image=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x]=[(x**2)/(x**2+y**2+0.01)+x*y/10000-x**2/40000+0.5,
(y**2)/(x**2+y**2+0.01)+x*y/10000-y**2/40000+0.5,(x*y)/(x**2+y**2+0.01)+x*y/10000-
(x**2+y**2)/40000+0.5]
end
end
image
end
- ( 00-240960G )
def distance(x,y,u,v)
sqrt((x-u)**2+(y-v)**2)
end
def a(s,x,y)
if x<(s-1)/2 && y<(s-1)/2
[(x+y)/(2.0*s),(s-1-x+y)/(2.0*s),((s/4-distance(x,y,s/4,s/4))/(s/4.0)+(s/2-
distance(x,y,s/2,s/2))/(s/2.0))/2.0]
else
if x<(s-1)/2 && (s-1)/2 < y
[(x+y)/(2.0*s),(s-1-x+y)/(2.0*s),((s/4-distance(x,y,s/4,3*s/4))/(s/4.0)+(s/2-distance(x,y,s/2,s/2))/(s/2.0))/2.0]
else
if (s-1)/2 < x && y < (s-1)/2
[(x+y)/(2.0*s),(s-1-x+y)/(2.0*s),((s/4-distance(x,y,3.0*s/4,s/4))/(s/4.0)+(s/2-
distance(x,y,s/2,s/2))/(s/2.0))/2.0]
else
if (s-1)/2 < x && (s-1)/2 < y
[(x+y)/(2.0*s),(s-1-x+y)/(2.0*s),((s/4-distance(x,y,3.0*s/4,3.0*s/4))/(s/4.0)+(s/2-distance(x,y,s/2,s/2))/(s/2.0))/2.0]
else
[(x+y)/(2.0*s),(s-1-x+y)/(2.0*s),((s/2-distance(x,y,s/2,s/2))/(s/2.0))/2.0]
end
end
end
end
end
def kadai(s)
image=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x]=a(s,x,y)
end
end
image
end
- ( 00-240229I )
def dkadai(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x]=[sin(x*0.03141592),sin(y*0.03141592),sin((x+y)*0.03141592)]
end
end
image
end
show(dkadai(100))
- ( 00-240215F )
include Math
load("./make2d.rb")
load("./distance.rb")
def u(a,b,c)
sin(a-b)/cos(c)
end
def show_color_picture(s)
a=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
a[y][x]=[u(x,y,(s-1)),1-u(y,x,(s-1)),1.0]
end
end
show(a)
end
- ( 00-240234E )
def b1(s,x,y)
include(Math)
d=distance(s,y,s,s)
if y <= (s/2)*sin((4.0*x/s)*3.1415)+s/2
(s-d)/s
else
(d*1.0)/s
end
end
def b2(s,x,y)
include(Math)
d=distance(s,y,s,s)
if y <= (s/2)*sin((4.0*x/s)*3.1415)+s/2
d/s
else
(d*1.0+1.0)/s
end
end
def sphere(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),0]
end
end
image
end
def b(s,x,y)
include(Math)
r=distance(x,y,s/2,s/2)
a=5.0
if y >= (s/2)*cos(a*x/s*3.14159)+s/2 && x >= (s/2)*cos(a*y/s*3.141592)+s/2
(s-r*2.0)/s*0.8+0.2
else if y <= (s/2)*cos(a*x/s*3.141592)+s/2 && x <= (s/2)*cos(a*y/s*3.141592)+s/2
(s-r*2.0)*0.8/s+0.2
else
r*1.0/s*0.8+0.2
end
end
end
def kadai(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
if y>x
image[y][x] = [b(s,x,y),0,0]
else if y<=x
image[y][x] = [0.1,0.1,b(s,x,y)]
else
1
end
end
end
end
image
end
- ( 00-240967H )
def kadai(s)
image=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
if (x < s/2&&y>s/2)||(x>s/2&&y < s/2)
r=(sin(0.1*(x-y))*(0.5-distance(x,y,s/4,s/4)/sqrt(0.5*s**2))+(0.3-distance(x,y,s/2,s/2)/sqrt(0.5*s**2))*cos(0.6*(x+y)))*0.7
else
r=(cosh(0.1*(x-y))*(0.3-distance(x,y,s/2,s/2)/sqrt(0.5*s**2))+(0.5-distance(x,y,s/2,s/2)/sqrt(0.5*s**2))*cos(0.6*(x+y)))*0.8
end
if distance(s/2,s/2,x,y) < s/4.8
g=(cos(0.5*(x-y))*(1.0-distance(x,y,s/3,s/3)/sqrt(0.5*s**2))+(0.4-distance(x,y,s/2,s/2)/sqrt(0.5*s**2))*cos(0.3*(x+y)))*0.9
else
g=0
end
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
image[y][x]=[r,g,b]
end
end
image
end
- ( 00-240578J )
def a
[0.1,0,0]
end
(省略)
def j
[1,0,0]
end
def k
[a,b,c,d,e,f,g,h,i,j]
end
def l
[k,k,k,k,k,k,k,k,k,k,k,k,k,k]
end
- ( 00-240214C )
def sphere(s)
a = make2d(s,s)
p = rand(11)/10.0
q = rand(15)/10.0
r = rand(13)/10.0
for y in 0..(s-1)
for x in 0..(s-1)
a[y][x]=[p+(s-distance(x,y,s/2.0,s/2.0))/s,q+(s-distance(x,y,s/2.0,s/2.0))/s,r+(s-distance(x,y,s/2.0,s/2.0))/s]
end
end
show(a)
end
sphere(100)
- ( 00-240961J )
def picture(n)
image=make2d(n,n)
m=n/2.0-0.5
for y in 0..(n-1)
for x in 0..(n-1)
if distance(x,y,m,m)==0
image[y][x]=[0,0,1]
else
image[y][x]=[distance(x,y,m,m)/m,1-distance(x,y,m,m)/m,1]
end
if x+m<=y
image[y][x][2]=0.5
end
if x-m>=y
image[y][x][2]=0.5
end
if x%2==0&&y%2==0
image[y][x]=[1,1,1]
else
end
end
end
image
end
(画像は著作権的に問題があるため,投票後に削除しました.)
画像をモノクロにするプログラムです
isrbに入る画像ならどんなサイズにも適応できます
show(monokuro(画像の配列)) で表示します
サンプルは掲示板からとってきました
def monokuro(a)
b=a
for x in 0..(a[0].length()-1)
for y in 0..(a.length()-1)
s=sqrt(a[y][x][0]**2+a[y][x][1]**2+a[y][x][2]**2)/sqrt(3)
b[y][x]=[s,s,s]
end
end
b
end
- ( 00-240963F )
円周率を視覚的に見てみよう!!!
ということで円周率の数字を白黒の濃さに割り当てて画像にしてみました。
例として小数第十位までのやつから
a=[0.1,0.4,0.1,0.5,0.9,0.2,0.6,0.5,0.3,0.5]
pi10 = [a]
end
show(pi10)
円周率の小数点以下1415926535 を 0.1,0.4,0.1,0.5,0.9,0.2,0.6,0.5,0.3,0.5 に変換し
表示させたのが上のプログラムと画像です。
これを同様に1000桁までやってみました
これが
です。(プログラムは長過ぎるので省略。10桁のときとほぼ同じだが、縦の長さだけ追加した。)
1000桁までやると黒と白が混ざって灰色に見えるのかなと思いきや、くっきり白と黒が分かれました。
円周率は乱数ではないかといわれていますが、乱数というのは濃さ(数字)がバラツキすぎず、かたまりすぎず
ちょうどバーコードのように見えることがわかりました。
乱数について思った以上に理解を深めることができました。
(画像についても数字を10で割り、コンマをつけるというプログラムの作成を試行錯誤したのでプログラミン
グ技術も向上したのでは…と思います。ただ、目的から少し外れてしまった感じは否めませんが…)
できれば桁数を増やしたいです。
- ( 00-240950F )
def show_color_picture()
a=make2d(200,200)
for y in 0..199
for x in 0..199
a[y][x]=[log(1+x**2+x*y*rand())+2*x-3*y/(rand()+0.1),(sin(x+y*x-y**3)+cos(y**2-
x**3+2*x)/(tan(y)-4))/(rand()+0.01),tanh(y*rand()-x)]
end
end
show(a)
end
- ( 00-240505D )
def a
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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
(省略)
def p
[1,1,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,
0,0,0,1,1,1]
end
show([a,a,a,a,a,a,a,a,a,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,a,a,a,a,a,a,a,a,a,a,a])
- ( 00-240491H )
def length3(a,x)
len = a.length()
if 0 < x && x < len - 1
3
else if len > 1 && ( x == 0 || x == len - 1 )
2
else if (x =- 0 && len == 1)
1
end
end
end
end
def sum2(a,x,color)
if length3(a,x) == 1
return a[0][color]
end
if x == 0
a[x][color] + a[x+1][color]
else if x == a.length() -1
a[x-1][color] + a[x][color]
else if 0 < x && x < a.length() -1
a[x-1][color] + a[x][color] +a[x+1][color]
end
end
end
end
def kadai_average(image,x,y,color)
if length3(image,x) == 1 && length3(image[x],y) == 1
return image[0][0]
end
if x == 0
r = sum2(image[x],y,color) + sum2(image[x+1],y,color)
if length3(image[x],y) == 2
r / 4.0
else
r / 6.0
end
else if x == image.length() - 1
r = sum2(image[x-1],y,color) + sum2(image[x],y,color)
if length3(image[x],y) == 2
r / 4.0
else
r / 6.0
end
else
r = sum2(image[x-1],y,color) + sum2(image[x],y,color) + sum2(image[x+1],y,color)
if length3(image[x],y) == 2
r / 6.0
else
r / 9.0
end
end
end
end
def kadai(n,time,t)
#初期化
a = make2d(n,n)
i = 0
j = 0
for i in 0..n-1
for j in 0..n-1
a[j][i] = [1,1,1]
end
end
#time回円を置く
for kai in 0..time
i = rand(n)
j = rand(n)
r = rand()
g = rand()
b = rand()
d = 0.2*n*rand()
dd= d.to_i()
if i-dd<0
sx = 0
else
sx = i-dd
end
if i+dd>n-1
ex = n-1
else
ex = i+dd
end
if j-dd<0
sy = 0
else
sy = j-dd
end
if j+dd>n-1
ey = n-1
else
ey = j+dd
end
for x in sx..ex
for y in sy..ey
if (x-i)**2+(y-j)**2 <=d**2
a[y][x][0] = 0.6*(a[y][x][0] + r)
a[y][x][1] = 0.6*(a[y][x][1] + g)
a[y][x][2] = 0.6*(a[y][x][2] + b)
end
end
end
end
b = make2d(n,n)
for i in 0..n-1
for j in 0..n-1
b[j][i] = [0,0,0]
end
end
c = make2d(n,n)
for x in 0..(n-1)
for y in 0..(n-1)
c[x][y] = [0,0,0]
for color in 0..2
c[x][y][color] = kadai_average(a,x,y,color)
end
end
end
for k in 0..(t-1)/2
for x in 0..(n-1)
for y in 0..(n-1)
for color in 0..2
b[x][y][color] = kadai_average(c,x,y,color)
end
end
end
c = b
end
show c
end
- ( 00-240499B )
def show_color_picture()
a=make2d(200,200)
for y in 0..199
for x in 0..199
a[y][x]=[x/sqrt(x**2+y**2+100),sin(y**2+log(2*x**2+1)),sin(x**2+log(2*y**2+1))]
end
end
show(a)
end
def show_color_picture(s)
a=make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
a[y][x]=[x/120.0*sin(y+x*2)*rand(),(sin(x**12))*cos(y**7),log(1+x/sqrt(x**2+y**2+100))]
end
end
show(a)
end
show(show_color_picture(135))
- ( 00-240968A )
def func(x)
m=-0.8 #パラメータm
return m*x+(2*(1-m)*x*x)/(1+x*x)
end
def fx(x,y)
a=0.00240968 #パラメータa
b=0.04301407533 #パラメータb
return y+a*(1-b*y*y)*y+func(x)
end
def fy(j,y)
return -j+func(fx(j,y))
end
def draw(s)
image = make2d(s,s)
maxi=0
x=0.1
y=0.1
for i in 0..(s-1)
for j in 0..(s-1)
image[i][j]=[0,0,0]
end
end
for i in 0..(s*s)
j=x
x=fx(j,y)
y=fy(j,y)
nx=x*13.0+s/2.0 #13は倍率
ny=y*13.0+s/2.0
if(0<=nx&&x*13 < s/2&&0<=ny&&y*13 < s/2&&image[nx][ny]=[0,0,0])
image[nx][ny]=[1,1.0-(0.0+ny)/(s+0.0),(nx+0.0)/(s+0.0)]
end
end
image
end
この写像はカオス性を有しているので、m,a,bの3つのパラメータを変化させることで全く
違う図形が描かれます。
今回はパラメータa,bを自分の学籍番号と学生IDに固定しました。
mを適当に決めて描いてみたところ、花みたいな形になったので、ピンクにしてみまし
た。
でも、花びらの部分は鳥の羽にもみえるなぁ..
- ( 00-240240D )
def a
a=make2d(100,100)
for x in 0..99
for y in 0..99
a[y][x]=[abs(sin(x*y)),abs(cos(x*y)),abs(cos(x+y))]
end
end
show(a)
end
- ( 00-240947F )
def show_color_picture()
a=make2d(100,100)
for y in 0..99
for x in 0..99
if (x-y)%3==0&&(x-y)%5==0
a[y][x]=[1,1,1]
else
if (x-y)%3==0||(x-y)%5==0
a[y][x]=[0.3,0.3,0.3]
else
a[y][x]=[(x-y)/198.0,(y-x)/198.0,0.7]
end
end
end
end
a
show(a)
end
- ( 00-240057J )
def local_fujimigaoka()
b = [0,0,0]
w = [1,1,1]
image = make2d(32,146)
for x in(0...146)
if (x >= 2 && x <= 44) || x == 57 || x == 58 || (x >= 137 && x <= 140)
image[0][x] = w
else
image[0][x] = b
end
(省略)
if (x >= 2 && x <= 44) || x == 69 || x == 76 || x == 77 || x == 81 || x == 82 || x == 86 || x == 89
x == 91 x == 93 x == 96 (x >= 100 && x <= 102) (x >= 105 && x <= 107) x == 110
x == 111 || x == 114 || x == 117 || (x >= 120 && x <= 122)
image[31][x] = w
else
image[31][x] = b
end
end
image
end
show(local_fujimigaoka())
- ( 00-240487E )
def tri(s)
a = sqrt(3)
b = s/2.0
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
c = x-b
d = y-b
image[y][x]=[san(x,y,s),san(-x/2.0+a*y/2.0+10,-a*x/2.0-y/2.0-10,s),san(-c/2.0-
a*d/2.0+b,a*c/2.0-d/2.0+b+10,s)]
end
end
image
end
def san(y,x,s)
a=(-y+s/2.0+s*tan(x*6.28/s)/2.0)/s*2+0.5
a
end
- ( 00-240577G )
def colorGenerator1(x,y,width,height)
return [0.5,Math.cos(Math::PI*y/height).abs,Math.sin(Math::PI*x/width).abs]
end
def circle(buffer,x,y,r,width,height)
density = 360
density.times { |i|
tw=r*cos(Math::PI*2*i/density)+x
th=r*sin(Math::PI*2*i/density)+y
if buffer[th] != nil && buffer[th][tw] != nil then
buffer[th][tw] = colorGenerator1(tw,th,width,height)
end
}
end
def genarateView(width,height)
image = make2d(width,height)
for y in 0..(height-1)
for x in 0..(width-1)
image[y][x] = [0,0,0]
end
end
density = 360
density.times { |i|
x=width*cos(Math::PI*2*i/density)+width/2
y=height*sin(Math::PI*2*i/density)+height/2
circle(image,x,y,width/2*i/density,width,height)
}
return image
end
show(genarateView(500,500))
- ( 00-240602H )
def kadai(i)
image=make2d(i,i)
for y in 0..(i-1)
for x in 0..(i-1)
image[x][y]=[(sin(x**x))/1.003,(cos(y**y))/1.01,(x+y)/(2*i)]
end
end
image
end
show(kadai(100))
- ( 00-240500I )
def b(s)
image = make2d(s,s)
for n in 0..(s-1)
for y in 0..(s-1)
for x in 0..(s-1)
if !(y == x+n || y == x-n)
image[y][x] = image[y][x]
else
image[y][x] = [sin(n),cos(n),tan(n)]
end
end
end
end
image
show(image)
end
- ( 00-240493D )
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)
sin(distance(x,y,3*s/4,s/4)/5.0)
end
def c(s,x,y)
sin(distance(x,y,s/2,3*s/4)/20.0)
end
def kadai(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-c(s,x,y),a(s,x,y)]
end
end
image
end
- ( 00-240494G )
def d(x,y,u,v)
sqrt((x-u)**2+(y-v)**2)
end
def astroid(x,y,u,v)
(sqrt((x-u)**2))**(0.666666)+(sqrt((y-v)**2)**(0.66666))
end
def show_color_picture2()
a=make2d(500,500)
for y in 0..499
for x in 0..499
if d(x,y,125,125)<125
if astroid(x,y,125,125)<125**(0.66666)
then a[y][x]=[(125-d(x,y,125,125))/125,d(x,y,125,125)/125,d(x,y,125,125)/125]
else a[y][x]=[1,1,1]
end
elsif d(x,y,375,125)<125
if astroid(x,y,375,125)<125**(0.66666)
then a[y][x]=[(125-d(x,y,375,125))/125,d(x,y,375,125)/125,(125-d(x,y,375,125))/125]
else a[y][x]=[1,1,1]
end
elsif d(x,y,125,375)<125
if astroid(x,y,125,375)<125**(0.66666)
then a[y][x]=[d(x,y,125,375)/125,0,(125-d(x,y,125,375))/125]
else a[y][x]=[1,1,1]
end
elsif d(x,y,375,375)<125
if astroid(x,y,375,375)<125**(0.66666)
then a[y][x]=[(125-d(x,y,375,375))/125,(125-d(x,y,375,375))/125,d(x,y,375,375)/125]
else a[y][x]=[1,1,1]
end
elsif astroid(x,y,250,250)<125**(0.66666)
then a[y][x]=[d(x,y,250,250)/125,(125-d(x,y,250,250))/125,0]
else a[y][x]=[0,0,0]
end
end
end
show(a)
end
- ( 00-240209G )
def a(s,x,y)
include(Math)
if d(x,y,s/2,s/2)<=s/8
1
else if d(x,y,s/2,s/2)>s/7 && d(x,y,s/2,s/2)<=s/2 && y>=4*s/9+s/10*sin((1.0*x/s)*3.1415)
1
else if d(x,y,s/2,s/2)>s/7 && d(x,y,s/2,s/2)<=s/2 && y<=3*s/7+s/10*sin((1.0*x/s)*3.1415)
1
else
0
end
end
end
end
def b(s,x,y)
include(Math)
if d(x,y,s/2,s/2)<=s/8
1
else if d(x,y,s/2,s/2)>s/7 && d(x,y,s/2,s/2)<=s/2 && y>=4*s/9+s/10*sin((1.0*x/s)*3.1415)
1
else
0
end
end
end
def ball(s)
image = make2d(s,s)
for y in 0..(s-1)
for x in 0..(s-1)
image[y][x] = [a(s,x,y),b(s,x,y),b(s,x,y)]
end
end
image
end
- ( 00-240244F )
def ab(n)
if n>0.0
n=n
else
n=-n
end
n
end
load("./make2d.rb")
load("./distance.rb")
def a8(n)
image=make2d(n,n)
for x in 0..(n-1)
for y in 0..(n-1)
image[y][x]=[ab(sin(x*y)),ab(cos(distance(x,y,n/2,n/2))),ab(tan(x*y))]
end
end
image
end
- ( 00-240501B )
def hamonn(n)
image=make2d(2*n+1,2*n+1)
for k in 0..2*n
for l in 0..2*n
r=1-sqrt*1**2)
g=1-sqrt*2**2)
b=(1-cos(distance(k,l,n,n)))*0.5
image[k][l]=[r,g,b]
end
end
image
end
show(hamonn(100))
- ( 00-240599E )
def w
[1,1,1]
end
(省略)
def r
[1,0,0]
end
[[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],
(省略)
[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w]]
- ( 00-240504A )
def red(x,y,r)
if distance(x,y,3*r,2*r)>r
[1,1,1]
else
[1,0,0]
end
end
def japan(r)
image=make2d(4*r,6*r)
for y in 0..(4*r-1)
for x in 0..(6*r-1)
image[y][x]=red(x,y,r)
end
end
image
end
def colorful(x,y,r)
if distance(x,y,8*r,8*r)< r
[1,1,1]
else if distance(x,y,8*r,8*r)<2*r
[0,0,0]
else if distance(x,y,8*r,8*r)<3*r
[1,1,1]
else if distance(x,y,8*r,8*r)<4*r
[0,0,1]
else if distance(x,y,8*r,8*r)<5*r
[1,1,1]
else if distance(x,y,8*r,8*r)<6*r
[0,1,0]
else if distance(x,y,8*r,8*r)<7*r
[1,1,1]
else if distance(x,y,8*r,8*r)<8*r
[1,0,0]
else if distance(x,y,8*r,8*r)<9*r
[1,1,1]
else if distance(x,y,8*r,8*r)<10*r
[1,1,0]
else if distance(x,y,8*r,8*r)<11*r
[1,1,1]
else if distance(x,y,8*r,8*r)<12*r
[1,0,1]
else if distance(x,y,8*r,8*r)<13*r
[1,1,1]
else if distance(x,y,8*r,8*r)<14*r
[0,1,1]
else
[1,1,1]
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
def rings(r)
image=make2d(16*r,16*r)
for y in 0..(16*r-1)
for x in 0..(16*r-1)
image[y][x]=colorful(x,y,r)
end
end
image
end
- ( 00-240592D )
def b(x,y,r)
if x+y<=r/2
[sin(d(x,y,0,0)),0.95**(d(x,y,r/8,r/4)),cos(d(x,y,0,0))]
elsif x+y>r/2 && x<=r/2 && y<=r/2
[cos(d(x,y,r/2,r/2)),sin(d(x,y,r/2,r/2)),sin(d(x,y,r/9,5/r))]
elsif x>r/2 && y<=r/2 && -x+y>-r/2
[0.95**(d(x,y,r/2,r/7)),cos(d(x,y,0,0)),sin(d(x,y,r/4,r))]
elsif -x+y<=-r/2
[sin(d(x,y,r,0)),cos(d(x,y,r,0)),cos(d(x,y,r/5,r/12))]
elsif -x+y>r/2
[cos(d(x,y,0,r)),0.95**(d(x,y,0,r)),sin(d(x,y,r/1.5,2*r/3))]
elsif -x+y<=r/2 && x<=r/2 && y>r/2
[cos(d(x,y,r/1.25,r/1.75)),sin(d(x,y,r,r/2)),cos(d(x,y,r/4,r/1.33))]
elsif x+y>3*r/2
[cos(d(x,y,r,r)),0.95**(d(x,y,r,r)),sin(d(x,y,r,r/2))]
else x+y<=3*r/2 && x>r/2 && y>r/2
[sin(d(x,y,r,r)),sin(d(x,y,r/1.4,r/1.7)),cos(d(x,y,r/1.8,r/1.45))]
end
end
def colar(r)
image=make2d(r,r)
for y in 0..r-1
for x in 0..r-1
image[y][x]=b(x,y,r)
end
end
image
end
- ( 00-240241G )
def distance(x,y,u,v)
sqrt((x-u)**2+(y-v)**2)
end
def show_color_picture()
a=make2d(201,201)
for y in 0..200
for x in 0..200
a[y][x]=[distance(x,y,0,0)/(201.0*sqrt(2)),
distance(x,y,200,200)/(201.0*sqrt(2)),distance(x,y,100,100)/(200.0*sqrt(2))]
end
end
show(a)
end
- ( 00-240606J )
def black_square(h,w)
a=make2d(h,w)
for x in 0..w-1
for y in 0..h-1
a[y][x]=[0,0,0]
end
end
a
end
def light(h,w)
li=make2d(h,w)
for x in 0..w-1
for y in 0..h-1
if x==0 || y==0 || x==w-1 || y==h-1
li[y][x]=[0,0,0]
else
li[y][x]=[1,1,1]
end
end
end
li
end
def exp_light(h,w,color)
exli=make2d(h,w)
for x in 0..w-1
for y in 0..h-1
exli[y][x]=make1d(3)
if x==0 || y==0 || x==w-1 || y==h-1
for z in 0..2
if color[z]>=0.05
exli[y][x][z]=color[z]-0.05
else
exli[y][x][z]=color[z]
end
end
else
exli[y][x]=[0,0,0]
end
end
end
exli
end
def window(h,w,r_or_l)
wi=black_square(h,w)
sus=[0.7,0.7,0.7]
for x in 0..w-1
wi[0][x]=sus
wi[h-1][x]=sus
end
for y in 0..h-1
if r_or_l=="r"
wi[y][0]=sus
else
wi[y][w-1]=sus
end
end
wi
end
def roof(h,w,back,color)
r=make2d(h,w)
for x in 0..w-1
for y in 0..h-1
s= ( (h-1)*sin(3.14159*x/w) ).to_i()
if h-1-y==s
r[y][x]=[0,0,0]
elsif h-1-y < s
r[y][x]=color
else
r[y][x]=back
end
end
end
r
end
def rainbow(h)
ra=make2d(h,100)
for y in 0..h-1
ra[y][0]=[0,0,0]
for x in 1..16
ra[y][x]=[1,0.5+x/16.0*0.5,0]
end
for x in 17..32
ra[y][x]=[1-(x-17)/16.0,1,0]
end
for x in 33..48
ra[y][x]=[0,1,(x-33)/16.0]
end
for x in 49..64
ra[y][x]=[0,1-(x-49)/16.0,1]
end
for x in 65..80
ra[y][x]=[(x-65)/16.0,0,1]
end
for x in 80..98
ra[y][x]=[1,0,1-(x-80)/16.0*0.5]
end
ra[y][99]=[0,0,0]
end
ra
end
def body(color)
back=[1,1,1]
sus=[0.7,0.7,0.7]
b=make2d(100,100)
r=roof(10,100,[1,1,1],color)
for x in 0..99
for y in 0..9
b[y][x]=r[y][x]
end
for y in 10..69
if x==0 || x==99
b[y][x]=[0,0,0]
else
b[y][x]=color
end
end
for y in 70..79
if x==0 || x==99
b[y][x]=[0,0,0]
else
b[y][x]=sus
end
end
for y in 80..99
if (y-80)/4==x || (y-80)/4==-(x-99)
b[y][x]=[0,0,0]
elsif (y-80)/4 < x && (y-80)/4<-(x-99)
b[y][x]=sus
else
b[y][x]=back
end
end
end
b
end
def inokashira(color_code)
color_array=make1d(35)
#レインボー
color_array[29]=[1,1,1]
#ライトブルー
color_array[21]=[0,0.7,1]
color_array[28]=[0,0.7,1]
#ブルーグリーン
color_array[22]=[0.4,0.8,0.9]
#アイボリー
color_array[23]=[1,1,0.8]
color_array[30]=[1,1,0.8]
#サーモンピンク
color_array[24]=[1,0.5,0.6]
color_array[31]=[1,0.5,0.6]
#ライトグリーン
color_array[25]=[0.6,0.8,0.4]
color_array[32]=[0.6,0.8,0.4]
#バイオレット
color_array[26]=[0.8,0.6,1]
color_array[33]=[0.8,0.6,1]
#オレンジベージュ
color_array[27]=[1,0.6,0.2]
color_array[34]=[1,0.6,0.2]
c=color_array[color_code]
b=body(c)
led=black_square(10,50)
exp=exp_light(4,5,c)
wl=window(45,47,"l")
wr=window(45,47,"r")
li=light(5,7)
ra=rainbow(4)
for y in 6..15
for x in 25..74
b[y][x]=led[y-6][x-25]
end
end
for y in 10..13
for x in 10..14
b[y][x]=exp[y-10][x-10]
end
for x in 85..89
b[y][x]=exp[y-10][x-85]
end
end
for y in 24..68
for x in 1..47
b[y][x]=wl[y-24][x-1]
end
for x in 52..98
b[y][x]=wr[y-24][x-52]
end
end
for y in 78..82
for x in 10..16
b[y][x]=li[y-78][x-10]
end
for x in 83..89
b[y][x]=li[y-78][x-83]
end
end
if color_code==29
for y in 70..73
for x in 0..99
b[y][x]=ra[y-70][x]
end
end
end
for x in 19..50
b[18][x]=[0,0,0]
b[94][x]=[0,0,0]
end
for y in 18..94
b[y][19]=[0,0,0]
b[y][50]=[0,0,0]
end
b
end
- ( 00-240583F )
def f1(i,x,s)
if i>=2
f(i-1,x,s)+s/(4*(2*i-1))*sin(3*3.14*(2*i-1)*x/s)
else
s/4.0*sin(5*3.14*x/s)
end
end
def f2(i,x,s)
if i>=2
f(i-1,x,s)+s/(4*(2*i-1))*sin(2*3.14*(2*i-1)*x/s)
else
s/4.0*sin(6*3.14*x/s)
end
end
def f3(i,x,s)
if i>=2
f(i-1,x,s)+s/(4*(2*i-1))*sin(3.14*(2*i-1)*x/s)
else
s/4.0*sin(4*3.14*x/s)
end
end
def b1(s,x,y)
if y>=s/2.0+f1(10,x,s)-10 && y<=s/2.0+f1(10,x,s)+10
0
else
1
end
end
def b2(s,x,y)
if y>=s/2.0+f2(10,x,s)-10 && y<=s/2.0+f2(10,x,s)+10
0
else
1
end
end
def b3(s,x,y)
if y>=s/2.0+f3(10,x,s)-10 && y<=s/2.0+f3(10,x,s)+10
0
else
1
end
end
def fourier(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
image
end