11/17の課題

プログラム中のmake1d, make2d, make3d等の定義は取り除いた. インデントも付け直した.
  1. ( g030066 )

    include(Math)
    def d(n,x,y)
      sqrt(x**2+(y-n)**2)
    end
    load("./make2d.rb")
    def c(n,x,y)
      if d(n,x,y) < n/2.0 || n < d(n,x,y)
        [1, 1, 1]
      else
        m = 12.0/n
        if n/2.0 <= d(n,x,y) && d(n,x,y) < 7.0/12.0*n
          [1, (d(n,x,y)-n/2.0)*m, 0]
        else
          if 7.0/12.0*n <= d(n,x,y) && d(n,x,y) < 2.0/3.0*n
            [(2.0/3.0*n-d(n,x,y))*m, 1, 0]
          else
            if 2.0/3.0*n <= d(n,x,y) && d(n,x,y) < 3.0/4.0*n
              [0, 1, (d(n,x,y)-2.0/3.0*n)*m]
            else
              if 3.0/4.0*n <= d(n,x,y) && d(n,x,y) < 5.0/6.0*n
                [0, (5.0/6.0*n-d(n,x,y))*m, 1]
              else
                if 5.0/6.0*n <= d(n,x,y) && d(n,x,y) < 11.0/12.0*n
                  [(d(n,x,y)-5.0/6.0*n)*m, 0, 1]
                else
                  [1, 0, (n-d(n,x,y))*m]
                end
              end
            end
          end
        end
      end
    end
    def rainbow(n)
      image = make2d(n,n)
      for y in 0..(n-1) 
        for x in 0..(n-1)
          image[y][x] = c(n,x,y)
        end        
      end        
      image
    end
    show(rainbow(200))
    
  2. ( g040541 )

    def illust(t)
      a=make3d(t,t,3)
      for y in 0..t-1
        for x in 0..t-1
          p=3.1415926
          a[y][x]=[y*(cos(p*x+y*2)+sin(p*x+y*2))/(x+1),x*(sin(x*2+y*p)-cos(x*2-y*p))/(y+1),(x-y)*(y*sin(p*x*2+y*2)-x*cos(x*2-p*y*2))/(x+1)]
        end
      end
      a
    end
    show(illust(200))
    
  3. ( g040925 )

    def rainbow(n)
     image = make3d(n,n,3)
      for y in 0..(n-1)
       for x in 0..(n-1)
        if distance(x,y,n/2,n)<=n/2
         if distance(x,y,n/2,n)>=n/4
          if distance(x,y,n/2,n)>=13*n/28
                image[y][x][0] = 1
                image[y][x][1] = 0.1
                image[y][x][2] = 0
          else
           if distance(x,y,n/2,n)>=3*n/7
                image[y][x][0] = 0.9
                image[y][x][1] = 0.8
                image[y][x][2] = 0.1
           else
            if distance(x,y,n/2,n)>=11*n/28
                image[y][x][0] = 0.8
                image[y][x][1] = 0.9
                image[y][x][2] = 0.2
            else
             if distance(x,y,n/2,n)>=5*n/14
                image[y][x][0] = 0.3
                image[y][x][1] = 0.9
                image[y][x][2] = 0.3
             else
              if distance(x,y,n/2,n)>=9*n/28
                image[y][x][0] = 0.2
                image[y][x][1] = 0.8
                image[y][x][2] = 0.7
              else
               if distance(x,y,n/2,n)>=2*n/7
                image[y][x][0] = 0.1
                image[y][x][1] = 0.6
                image[y][x][2] = 0.9
               else
                image[y][x][0] = 0
                image[y][x][1] = 0.15
                image[y][x][2] = 1
               end
              end
             end
            end
           end
          end
         else
                image[y][x][0] = 0.7
                image[y][x][1] = 0.9
                image[y][x][2] = 1
         end
        else
         if distance(x,y,n/4,n/4)<=n/8
                image[y][x][0] = 1
                image[y][x][1] = 1
                image[y][x][2] = 1
         else
          if distance(x,y,3*n/8,n/4)<=n/8
                image[y][x][0] = 1
                image[y][x][1] = 1
                image[y][x][2] = 1
          else
           if distance(x,y,n/2,n/4)<=n/8
                image[y][x][0] = 1
                image[y][x][1] = 1
                image[y][x][2] = 1
           else
                image[y][x][0] = 0.7
                image[y][x][1] = 0.9
                image[y][x][2] = 1
           end
          end
         end
        end
       end
      end
     image
    end
    
  4. ( g040201 )

    def divisible(x,y)
      x%y==0
    end
    
    def show_color_picture()
      a=make3d(50,50,3)
      for y in 0..49
        for x in 0..49
          if divisible(x+y,2)
            a[x][y]=[1,1,1]
          else
            a[x][y]=[0,0,0]
          end
        end
      end
      show(a)
    end
    
  5. ( g040189 )

    def distance(x,y,u,v)
     sqrt((x-u)**2+(y-v)**2)
    end
    
    def t(x,y)
      if  (distance(x,y,0,200)%11)/11>0.75&&(distance(x,y,400,200)%17)/17>0.75
        1
      else
        0
      end
    end
    
    def kanshou()
      a=make3d(400,400,3)
      for y in 0..399
        for x in 0..399
          a[y][x]=[(distance(x,y,0,200)%11)/11,t(x,y), (distance(x,y,400,200)%17)/17]
        end 
      end
      show(a)
    end
    
  6. ( g040049 )

    def complex(n)
      load("./make2d.rb")
      a=make2d(2*n,2*n)
      for i in 0..2*n-1
        x=(i-n+0.5)/(1.0*n)
        if x>=0
          pure_r=0
          pure_g=1-x
          pure_b=x
        else
          pure_r=-x
          pure_g=1+x
          pure_b=0
        end
        for j in 0..2*n-1
          y=(j-n+0.5)/(1.0*n)
          if y>=0
            r=(1-y)*pure_r+y*1
            g=(1-y)*pure_g+y*1
            b=(1-y)*pure_b+y*1
          else
            r=(1+y)*pure_r
            g=(1+y)*pure_g
            b=(1+y)*pure_b
          end
          a[j][i]=[r, g, b]
        end
      end
      show(a)
    end
    
  7. ( g040564 )

    def d(x,y,r)
      ((x-r)**2.0+(y-r)**2.0)**0.5
    end
    
    def b(s,x,y)
      r=s/2.0
      if r<=d(x,y,r)
        1
      else
        (r-d(x,y,r))/r
      end
    end
    
    def show_color_picture
      include Math
      a=make3d(100,100,3)
      for i in 0..99
        for j in 0..99
          a[j][i]=[b(100.0,i,j),cos(d(i,j,50.0)),sin(i+j+i*j)]
        end
      end
      show(a)
    end
    
  8. ( g041175 )

    load("./make2d.rb")
    
    def line(hor,ver,a)
      n=a.size
      temp=a
      for i in 0..(hor-1)
        y=ver-ver/hor.to_f*i
        temp[i][y.to_i]=1
      end
      for i in 0..(ver-1)
        x=hor-hor/ver.to_f*i
        temp[x.to_i][i]=1
      end
      temp
    end
    
    def inverse(a)
      n=a.size
      temp=a
      for x in 0..(n-1)
        for y in 0..(n-1)
          if x+y>n
            temp[x][y]=temp[n-1-y][n-1-x]
          end
        end
      end
      temp
    end
    
    #メインfunction
    
    def main(n)
      a=make2d(n,n)
      dt=10
      a=line(n/2,n/2,a)
      for i in 1..dt
        a=line(i*n/dt,n-i*n/dt,a)
      end
      a=inverse(a)
      show(a)
    end
    
  9. ( g040186 )

    def distance(x,y,u,v)
    sqrt((x-u)**2+(y-v)**2)
    end
    
    def show_color_picture()
      a=make3d(400,400,3)
      for y in 0..399
        for x in 0..399
          a[y][x]=[cos(distance(x,y,200,200)/5.0),1.0-(cos(distance(x,y,100,100)/5.0)+cos(distance(x,y,300,300)/5.0)),sin(distance(x,y,100,300)/5.0)+sin(distance(x,y,300,100)/5.0)]
        end
      end
      show(a)
    end
    
  10. ( g040184 )

    def arc()
      def dis(x,y,z,w)
        sqrt((x-w)**2+(y-w)**2)
      end
      def len(x,y,z)
        z-x
      end
      a=make3d(400,400,3)
      for y in 0..399
        for x in 0..399
          circle=sin(dis(x,y,200,200)*0.2)*0.3+0.7
          line=sin(len(x,y,400)*0.2)*0.3+0.7
          rate=((circle+line)/2)**4
          red=dis(x,y,40,0)/400
          green=dis(x,y,400,200)/400
          blue=dis(x,y,40,400)/400
          a[x][y]=[rate+red**3,rate+green**3,rate+blue**3]
        end
      end
      show(a)
    end
    
    arc()
    
  11. ( g040197 )

    def dis(x,y,z,w)
      sqrt((x-z)**2+(y-w)**2)
    end
    
    def moyou()
      a=make3d(400,400,3)
      for y in 0..399
        for x in 0..399
          circle1=sin(dis(x,y,200.0,200.0)/5)
          circle2=sin(dis(x,y,200.0,200.0)/3)
          circle3=sin(dis(x,y,100.0,100.0)/4)
          circle4=sin(dis(x,y,100.0,300.0)/8)
          circle5=sin(dis(x,y,300.0,100.0)/7)
          circle6=sin(dis(x,y,300.0,300.0)/6)
          a[y][x]=[circle1+circle4,circle2+circle5,circle3+circle6]
        end
      end
      show(a)
    end
    
    
  12. ( g040195 )

    def get()
     a=make3d(200,200,3)
     for y in 0..199
       for x in 0..199
         a[y][x]=[cos(sqrt(x**2+y**2)/200.0),cos(sqrt*1**2+y**2)/200.0),cos(sqrt((x-49.0)**2.0+(y-99.0)**2.0)/200.0)]
       end 
     end
     show(a)
    end
    
  13. ( g040542 )

    def show_color_picture()
      a=make3d(50,50,3)
      for y in 0..49
        for x in 0..49
          a[y][x]=[x/49.0,(x+y)%2,1-(x+y)/98.0]
        end 
      end
      show(a)
    end
    
  14. ( g040180 )

    def dis(a,b,x,y)
      sqrt((a-x)**2+(b-y)**2)
    end
    
    def show_color_picture()
      s=200
      a=make3d(s,s,3)
      for y in 0..s-1
        for x in 0..s-1
          d=dis(s/2,s/2,y,x)
          for c in 0..2
            if(c==1)
              dh=sqrt((s/2-y)**6+(s/2-x)**4)
              a[y][x][c]=(0.77**(d/(s/10)))*sin(dh/(s/4))
            else
              di=dis(s*(c+1)/4,s*(c+1)/4,y,x)
              a[y][x][c]=sin(cos(di/(s/40))*4+d/(s/40))*0.75+0.25
            end
          end
        end 
      end
      show(a)
    end
    
  15. ( g040063 )

    def image(r)
     a = make2d(3*r,6*r)
     for y in 0..r-1
      for x in 0..2*r-1
       c1 = 0.42+0.58*rand()
       c2 = 0.05+0.5*rand()
       c3 = 0.1+0.1*rand()
       for yy in 0..2
        for xx in 0..2
         cr = 0.75 + 0.25*rand()
         a[3*y+yy][3*x+xx] = [cr*c1,cr*c2,cr*c3]
        end
       end
      end
     end
     for x in 5*r..6*r-1
      for y in 0..x-5*r
       cs = 0.93 + rand()*0.0625
       a[y][x] = [0.2*cs , 0.5*cs , 0.9*cs]
      end
     end
     for x in 3*r..5*r-1
      for y in 0..5*r-1-x
       cs = 0.93 + rand()*0.0625
       a[y][x] = [0.2*cs , 0.5*cs , 0.9*cs]
      end
     end
     for x in 2*r..3*r-1
      for y in 0..x-r-1
       cs = 0.93 + rand()*0.0625
       a[y][x] = [0.2*cs , 0.5*cs , 0.9*cs]
      end
     end
     for x in 0..2*r-1
      for y in 0..3*r-1-x
       cs = 0.93 + rand()*0.0625
       a[y][x] = [0.2*cs , 0.5*cs , 0.9*cs]
      end
     end
     for y in 0..r*0.4
      rr = 0.8*r+rand(3*r)
      for x in 0..rr
       a[2*y][x] = [1,1,1]
      end
     end
     a
    end
    show(image(48))
    
  16. ( g040916 )

    def gr3you2(s)
      load("./make3d.rb")
      load("./distance.rb")
      load("./cos3theta.rb")
      image=make3d(s,s)
      r=(s+1)/2
      for x in 0..(s-1)
        for y in 0..(s-1)
          if (cos3theta(x,y,r)-4) < distance(x,y,r,r) && distance(x,y,r,r)<(cos3theta(x,y,r)+4)
            image[x][y]=[1,0,1]
          else
            if (-cos3theta(x,y,r)-4) < distance(x,y,r,r) && distance(x,y,r,r)<(-cos3theta(x,y,r)+4)
              image[x][y]=[0,1,1]
            else
              image[x][y]=[(r*1.41-distance(x,y,r,r))/(r*1.41),(r*1.41-distance(x,y,r,r))/(r*1.41),1-(r*1.41-distance(x,y,r,r))/(r*1.41)]
            end
          end
        end
      end
      image
    end
    
    #cos3theta
    load ("./distance.rb")
    def cos3theta(x,y,r)
      r*(4*((x-r)/distance(x,y,r,r))**3-3*((x-r)/distance(x,y,r,r)))
    end
    
  17. ( g040921 )

    include(Math)
    
    def m1d(n)
      a = Array.new(n)
      for i in 0..(n-1)
        a[i] = 0
      end
      a
    end
    def m2d(h,w)
      b = Array.new(h)
      for k in 0..(h-1)
        b[k] = m1d(w)
      end
      b
    end
    
    def pict()
      s=500
      def dis(h,i,j,k)
        sqrt(h*(i)**2+j*(k)**2)
      end
      image = m2d(s,s)
      for y in 0..(s-1)
        for x in 0..((s-1)/2)
          if dis(1,(x-s*0.43),0.25,(y-s*0.4))<=(s*0.02)
            image[y][x] = [1,1,1]
          else if dis(1,(x-s*0.43),0.25,(y-s*0.47))<=(s*0.02) && dis(1,(x-s*0.43),1,(y-s*0.435))>=(s*0.03)
            image[y][x] = [0,0,0.5]
          else if dis(1,(x-s*0.43),0.11,(y-s*0.435))<=(s*0.03)
            image[y][x] = [0,0,0]
          else if dis(0.25,(x-s*0.32),1,(y-s*0.5))<=(s*0.025)
            image[y][x] = [0.86328125,0.3671875,0.515625]
          else if dis(1,(x-s*0.5),0.6,(y-s*0.55))<=(s*0.035) && dis(0.6,(x-s*0.5),1,(y-s*0.6))<=(s*0.035)
            image[y][x] = [0.94921875,0.49609375,0.453125]
          else if dis(1,(x-s*0.5),0.6,(y-s*0.55))<=(s*0.035) && y>=s*0.55
            image[y][x] = [0.3984375,0.19921875,0.19921875]
          else if dis(1,(x-s*0.5),1,(y-s*0.55))<=(s*0.4) || dis(1,(x-s*0.125),1,(y-s*0.55))<=(s*0.1)
            image[y][x] = [0.9375,0.57421875,0.65625]
          else if dis(1,(x-s*0.275),1,(y-s))<=(s*0.15) && y<=-0.03*(x-s*0.5)+s*0.97
            image[y][x] = [0.578125,0.16015625,0.30078125]
          else
            p = (x+y)/(1.0*s)
            image[y][x] =[0,p,p]
          end
          end
          end
          end
          end
          end
          end
          end
        end
      end
    
      for y in 0..(s-1)
        for x in ((s-1)/2+1)..(s-1)
          if (dis(1.5,(x-s*0.5),1,(y-s*0.55))>=(s*0.4) && dis(1,(x-s*0.5),1,(y-s*0.55))<=(s*0.4)) || (dis(1,(x-s*0.875),1,(y-s*0.55))<=(s*0.1) && dis(1,(x-s*0.875),0.8,(y-s*0.6))>=(s*0.06) && x>=(s*0.875))
            image[y][x] = [0.765625,0.4140625,0.46875]
          else if dis(1,(x-s*0.5),1,(y-s*0.55))>=(s*0.4) && dis(1,(x-s*0.725),1,(y-s))<=(s*0.15) && y<=0.03*(x-s*0.5)+s*0.97 && dis(1,(x-s*0.55),1.4,(y-s))>=(s*0.225)
            image[y][x] = [0.31640625,0.16796875,0.20703125]
          else
            image[y][x] = image[y][(s-1)-x]
          end
          end
        end
      end
    
      for y in 0..(s-1)
        for x in 0..(s-1)
          if dis(1,(x-s*0.125),1,(y-s*0.55))<=(s*0.1) && dis(0.8,(x-s*0.025),2,(y-s*0.55))>=(s*0.1) && dis(1,(x-s*0.5),1,(y-s*0.55))>=(s*0.4) && y>=s*0.55
          image[y][x] = [0.765625,0.4140625,0.46875]
          else if dis(1,(x-s*0.5),1,(y-s*0.55))>=(s*0.4) && dis(1,(x-s*0.275),1,(y-s))<=(s*0.15) && y<=0.03*(s*0.5-x)+s*0.97 && dis(1,(x-s*0.1),0.5,(y-s*0.8))>=(s*0.22)
            image[y][x] = [0.31640625,0.16796875,0.20703125]
          else
          end
          end
        end
      end
      image
    end
    
  18. ( g040075 )

    #二点間(x,y)(u,v)の距離
    def d(x,y,u,v)
     sqrt((x-u)**2+(y-v)**2)
    end
    
    #準線1:y=0
    #焦点1:(n/2,n/4)
    #準線1と焦点1からの距離の差s(x,y,n)
    def s(x,y,n)
     sqrt((d(x,y,n/2,n/4)-y)**2)
    end
    
    #準線2:x=0
    #焦点2:(n/4,n/2)
    #準線2と焦点2からの距離の差t(x,y,n)
    def t(x,y,n)
     sqrt((d(x,y,n/4,n/2)-x)**2)
    end
    
    def picture(n)
    #n*nの箱に3色の配列を作り、s(x,y,n)とt(x,y,n)を使って色をいじる
    image=make3d(n,n,3)
     for x in 0..(n-1)
     for y in 0..(n-1)
      image[x][y][0]=(1-s(x,y,n)/n)+(t(x,y,n)/n)
      image[x][y][1]=(s(x,y,n)/n)+(t(x,y,n)/n)+((t(x,y,n)*s(x,y,n))/(n*n))
      image[x][y][2]=(1-s(x,y,n)/(10*n))+(t(x,y,n)/n)
     end
     end
    show(image)
    end
    
  19. ( g040917 )

    a=Array.new(500)
    for y in 0..499
      a[y]=Array.new(500)
    end
    for y in 0..499
      for x in 0..499
        a[y][x]=[1.0-(y**2+x**2)/(500.0**2+500.0**2),1.0-((y-500.0)**2+x**2)/(500.0**2+500**2),1.0-(y**2+(x-500.0)**2)/(500.0**2+500.0**2)]
      end
    end
    for y in 0..499
      for x in 0..499
        if (x-370)**2+(y-375)**2<=125**2
          a[y][x]=[1,1,1]
        end
        if (x-370)**2+(y-190)**2<=80**2
          a[y][x]=[1,1,1]
        end
        if (x-350)**2+(y-170)**2<=10**2
          a[y][x]=[0,0,0]
        end
        if (x-390)**2+(y-170)**2<=10**2
          a[y][x]=[0,0,0]
        end
        if 190<=y && y<=210 && 365<=x && x<=375
          a[y][x]=[0,0,0]
        end
        if 350<=x && x<=390 && 220<=y && y<=240
         a[y][x]=[0,0,0]
        end
      end
    end
    show(a)
    
  20. ( g040923 )

    include Math
    
    def distance(x,z,w)
            sqrt((x[0]-z)**2+(x[1]-w)**2)
    end
    
    def othello(black,white)#black,whiteコマ数*座標の配列
            a=make2d(270,270)#辺の長さは外枠4、マス31、マス枠幅は2
    #とりあえず全て緑に
    for i in 0..269
            for j in 0..269
                    a[i][j]=[0.18,0.7,0.15]
            end
    end
    #横線
    for i in 0..269
            if i==0||i==1||(i-2)%33==0||(i-3)%33==0||i==268||i==269
                    for j in 0..269
                            a[i][j]=[0,0,0]
                    end
            end
    end
    #縦線
    for i in 0..269
            if i==0||i==1||(i-2)%33==0||(i-3)%33==0||i==268||i==269
                    for j in 0..269
                            a[j][i]=[0,0,0]
                    end
            end
    end
    #マスの中央
    b=[19,52,85,118,151,184,217,250]
    
    #黒のコマをおく
    lb=black.length()
    bb=Array.new(lb)
    for k in 0..lb-1
            bb[k]=[b[black[k][0]-1],b[black[k][1]-1]]
    end
    for k in 0..lb-1
            for i in 0..269
                    for j in 0..269
                            if distance(bb[k],i,j)<14
                                    a[i][j]=[0,0,0]
                            end
                    end
            end
    end
    
    #白のコマをおく
    lw=white.length()
    wb=Array.new(lw)
    for k in 0..lw-1
            wb[k]=[b[white[k][0]-1],b[white[k][1]-1]]
    end
    for k in 0..lw-1
            for i in 0..269
                    for j in 0..269
                            if distance(wb[k],i,j)<14
                                    a[i][j]=[0,0,0]
                            end
                            if distance(wb[k],i,j)<12
                                    a[i][j]=[1,1,1]
                            end
                    end
            end
    end
    show(a)
    end
    
    othello([[2,5],[3,4],[3,5],[4,4],[4,5]],[[5,2],[5,3],[5,4],[5,5],[5,6],[5,7],[6,4],[6,5],[6,6]])
    
  21. ( g040927 )

    #ガウス記号
    def gauss(k)
      if k%1==0
        k
      else
        k-(k%1)
      end
    end
    def show_mono_picture()
      swell=make3d(48,48,3)
      for y in 0..23
        for x in 0..23
          swell[y][x]=[((x-y)/3.0-gauss((x-y)/3.0))*3.0,((x-y)/3.0-gauss((x-y)/3.0)),((x-y)/3.0-gauss((x-y)/3.0))*3.0]
        end
      end 
      for y in 24..47
        for x in 24..47
          swell[y][x]=[((x-y)/3.0-gauss((x-y)/3.0))*3.0,((x-y)/3.0-gauss((x-y)/3.0))*3.0,((x-y)/3.0-gauss((x-y)/3.0))*3.0]
        end
      end 
      for y in 24..47
        for x in 0..23
          swell[y][x]=[((x+y)/3.0-gauss((x+y)/3.0))*3.0,((x+y)/3.0-gauss((x+y)/3.0))*3.0,((x+y)/3.0-gauss((x+y)/3.0))*3.0]
        end
      end 
      for y in 0..23
        for x in 24..47
          swell[y][x]=[((x+y)/3.0-gauss((x+y)/3.0))*3.0,((x+y)/3.0-gauss((x+y)/3.0))*3.0,((x+y)/3.0-gauss((x+y)/3.0))*3.0]
        end
      end
      show(swell)
    end
    
  22. ( g040183 )

    def cafe_wall_illusion(n)
      a=make3d(n,n,3)
      for x in 0..(n-1)
        for y in 0..(n-1)
          if (x-19)%20==0
            a[x][y]=[0,0,0]
          else
            if (x/20)%2.0==0
          a[x][y]=[1.0-(y/20)%2,1.0-(y/20)%2,1.0-(y/20)%2]
          else
            a[x][y]=[1.0-((y+10)/20)%2,1.0-((y+10)/20)%2,1.0-((y+10)/20)%2]
          end
          end
        end
      end
      a
    end
    show(cafe_wall_illusion(500))
    
  23. ( g040550 )

    def show_color_picture()
      a=make3d(50,50,3)
      for y in 0..49
        for x in 0..49
          if (x+y)%2==0
            a[y][x]=[cos((49.0-x)*3.14/49.0),1.0,cos((49.0-y)*3.14/49.0)]
          else
            a[y][x]=[sin((49.0-x)*3.14/49.0),1.0,sin((49.0-y)*3.14/49.0)]
          end
        end
      end
      show(a)
    end
    
  24. ( g040943 )

    def d(x,y,u,v)
       sqrt((x-u)**2+(y-v)**2)
    end
    def b(s,x,y,a,b)
      2*sqrt(2)*d(x,y,a,b)/3/s
    end
    def p(s)
      a = make3d(s,s,3)
      for y in 0..(s-1)
        for x in 0..(s-1)
          a[y][x][0] = b(s,x,y,s/4,s/2)
          a[y][x][1] = b(s,x,y,3*s/4,s/4)
          a[y][x][2] = b(s,x,y,3*s/4,3*s/4)
        end
      end
      a
    end
    show(p(300))
    
  25. ( g040549 )

    a=make2d(50,50)
    for y in 0..49
            for x in 0..49
                    if  x %2 == 1
                            a[y][x]= [0]
                    else
                            a[y][x]=[1]
                    end
            end 
    end
    show(a)
    
  26. ( g040052 )

    def show_color_picture()
      a=make3d(50,50,3)
      for y in 0..49
        for x in 0..49
          a[y][x]=[1.0-x*(rand())/49.0,(x+y)*(rand())/98.0,y/49.0]
        end 
      end
      show(a)
    end
    show_color_picture()
    
  27. ( g040945 )

    load("./make2d.rb")
    def test3
      s=100
      a=make2d(s,s)
      for y in 0..(s-1)
        for x in 0..(s-1)
          if x<=60
            g=sqrt((s-x)**2+(s-y)**2)/2.0
            b=sin(x+1.0)+sin(y+1.0)
            r=((x+1.0)+(y+1.0))/s
            a[x][y]=[r,g,b]
          else
            a[x][y]=[1,1,1]
          end
        end
      end
      for y in 0..(s-1)
        for x in 0..(s-1)
          if 70<=x&&x<=80&&15<=y&&y<=20
            a[x][y]=[0,0,0]
          end
          if 70<=x&&x<=80&&80<=y&&y<=85
            a[x][y]=[0,0,0]
          end
          if 60 < x&& 0<=y&&y<=5
            a[x][y]=[0.6,2.7,0.5]
          end
          if 60 < x&&95<=y
            a[x][y]=[1,1,0]
          end
        end
      end
      a
    end
    show(test3)
    
  28. ( g040060 )

    def show_color_picture()
      a=make3d(50,50,3)
      for y in 0..49
        for x in 0..49
           a[y][x]=[50.0-x*(rand())/0.5,y*(rand())/100.0,0.5]
        end 
      end
      show(a)
    end
    show_color_picture()
    
  29. ( g040922 )

    def d(x,y,u,v)
      sqrt((u-x)**2+(v-y)**2)
    end
    
    load("./make3d.rb")
    load("./d.rb")
    def hamon3(n)
      a=make3d(200,200,3)
      k=1
      while k < n
        x=200*rand
        y=200*rand
        c1=rand
        c2=rand
        c3=rand
        for i in 0..199
          for j in 0..199
            a[i][j][0]=a[i][j][0]+(1+sin(d(x,y,j,i)))*c1*d(x,y,j,i)/400
            a[i][j][1]=a[i][j][1]+(1+sin(d(x,y,j,i)))*c2*d(x,y,j,i)/400
            a[i][j][2]=a[i][j][2]+(1+sin(d(x,y,j,i)))*c3*d(x,y,j,i)/400
          end
        end
        k=k+1
      end
      a
    end
    
    
  30. ( g040565 )

    #呼び込み
    load("./make2d.rb")
    #各補正値
    #light_revise_1        = 0.400
    #light_revise_2        = 2
    #red_revise        = 1.20
    #green_revise        = 0.80
    #blue_revise        = 1.20
    #明るさ /*
    def light_1(r,x,y,reverse)
            if reverse == 1
                    if (r-x) > y
                            (x**2.0+(r-y)**2.0)**0.500/r
                    else
                            1
                    end
            else # reverse == 0
                    if (r-x) < y
                            (x**2.0+(r-y)**2.0)**0.500/r
                    else
                            1
                    end
            end
    end
    
    def light_2(r,x,y,reverse)
            if reverse == 1
                    if x > y
                            (x**2.0+y**2.0)**0.500/r
                    else
                            1
                    end
            else
                    if x < y
                            (x**2.0+y**2.0)**0.500/r
                    else
                            1
                    end
            end
    end
    
    def light_3(r,x,y,reverse)
            if reverse == 1
                    if (r-x) < y
                            ((r-x)**2.0+y**2.0)**0.500/r
                    else
                            1
                    end
            else
                    if (r-x) > y
                            ((r-x)**2.0+y**2.0)**0.500/r
                    else
                            1
                    end
            end
    end
    
    def light_4(r,x,y,reverse)
            if reverse == 1
                    if x < y
                            ((r-x)**2.0+(r-y)**2.0)**0.500/r
                    else
                            1
                    end
            else
                    if x > y
                            ((r-x)**2.0+(r-y)**2.0)**0.500/r
                    else
                            1
                    end
            end
    end
    
    def light( r , x , y , reverse , light_revise_1 , light_revise_2 )
             
      (light_1(r,x,y,reverse)*light_2(r,x,y,reverse)*light_3(r,x,y,reverse)*light_4(r,x,y,reverse)+light_revise_1)**light_revise_2
    
    end
    #明るさ */
    #明るさテスト用
    "def picture( r , randomness , random, light )
    blue_revise=1.20
            if  ((r > 0) && ((reverse == 0) || (reverse == 1)) && ((randomness == 0) || ((randomness == 1) && 
    (random >= 1))) &&
    
            (red_revise >= 0) && (green_revise >= 0) && (blue_revise >= 0) && ((light == 0) || (light == 1)) && 
    (light_revise_1 >= 0) && (light_revise_2 >= 0) )
    
                    p = make2d(r,r)
                    for y in 0..(r-1)
                            for x in 0..(r-1)
                                    p[y][x] =        [ light(r,x,y,reverse,light_revise_1,light_revise_2) ]
                                                    #[ light_1(r,x,y,reverse,light_revise_1,light_revise_2) ]
                                                    #[ light_2(r,x,y,reverse,light_revise_1,light_revise_2) ]
                                                    #[ light_3(r,x,y,reverse,light_revise_1,light_revise_2) ]
                                                    #[ light_4(r,x,y,reverse,light_revise_1,light_revise_2) ]
                            end
                    end
                    show(p)
            end
    end
    "
    #描画
    def picture( r , reverse , randomness , random , red_revise ,green_revise , blue_revise , light , 
    light_revise_1 , light_revise_2 )
    
            if  ((r > 0) && ((reverse == 0) || (reverse == 1)) && ((randomness == 0) || ((randomness == 1) && 
    (random >= 1))) &&
    
            (red_revise >= 0) && (green_revise >= 0) && (blue_revise >= 0) && ((light == 0) || (light == 1)) && 
    (light_revise_1 >= 0) && (light_revise_2 >= 0) )
    
                    p = make2d(r,r)
                    if randomness == 1
                            if light == 1
                                    for y in 0..(r-1)
                                            for x in 0..(r-1)
                                                    p[y][x] = [        (x/(r-
    1.0))*light(r,x,y,reverse,light_revise_1,light_revise_2)*(rand()/random+(1-1/random))*red_revise ,
    
                                                                    (y/(r-
    1.0))*light(r,x,y,reverse,light_revise_1,light_revise_2)*(rand()/random+(1-1/random))*green_revise ,
    
                                                                    (1.0-(x+y)/(r-
    1.0))*light(r,x,y,reverse,light_revise_1,light_revise_2)*(rand()/random+(1-1/random))*blue_revise ]
    
                                            end
                                    end
                                    show(p)
                            else # if light == 0
                                    for y in 0..(r-1)
                                            for x in 0..(r-1)
                                                    p[y][x] = [        (x/(r-1.0))*(rand()/random+(1-1/random))*red_revise  ,
                                                                    (y/(r-1.0))*(rand()/random+(1-1/random))*green_revise  , 
                                                                    (1.0-(x+y)/(r-1.0))*(rand()/random+(1-1/random))*blue_revise ]
                                            end
                                    end
                                    show(p)
                            end
                    else # if randomness == 0
                            if light == 1
                                    for y in 0..(r-1)
                                            for x in 0..(r-1)
                                                    p[y][x] = [        (x/(r-
    1.0))*light(r,x,y,reverse,light_revise_1,light_revise_2)*red_revise ,
    
                                                                    (y/(r-
    1.0))*light(r,x,y,reverse,light_revise_1,light_revise_2)*green_revise ,
    
                                                                    (1.0-(x+y)/(r-
    1.0))*light(r,x,y,reverse,light_revise_1,light_revise_2)*blue_revise ]
    
                                            end
                                    end
                                    show(p)
                            else # if light == 0
                                    for y in 0..(r-1)
                                            for x in 0..(r-1)
                                                    p[y][x] = [        (x/(r-1.0))*red_revise  , 
                                                                    (y/(r-1.0))*green_revise  ,
                                                                    (1.0-(x+y)/(r-1.0))*blue_revise ]
                                            end
                                    end
                                    show(p)
                            end
                    end
            else 
                    #error
            end
    end
    picture(512 , 0 , 1 , 3 , 1.20 , 0.80 , 1.40 , 1 , 0.400 , 2)