昨日のstrange attractorがあまりにも微妙だったので、再挑戦。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
require 'tk' include Math root = TkRoot.new canvas = TkCanvas.new(root){ width 1000 height 1000 bg "white" pack } # aを変更すると絵柄が変わる a = -10 #ループ TkTimer.start(1){ x = rand(75)/50.0 y = rand(75)/50.0 # カラーコード生成 c_code ="#" + "%06x" % (rand * 0xffffff) 500.times do new_x = x*cos(a) - (y-x**2)*sin(a) new_y = x*sin(a) + (y-x**2)*cos(a) x = new_x y = new_y TkcRectangle.new(canvas, x*200+500, y*200+500, x*200+501, y*200+501){ fill c_code width 0.0 } end } Tk.mainloop |