[#1371] Re: [ruby-list:6104] Re: パースエラー等の嵐を Dos窓で受けるには ...? — Masao Kanemitsu <masao-k@...>
<9801290711.AA10183@pbsun10.pb.ascii.co.jp> の、
[#1381] bound method — shugo@... (Shugo Maeda)
前田です。
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
前田です。
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
[#1386] downcase — Shin-ichiro HARA <sinara@...>
原です。
原です。
[#1410] GD — Masao Kanemitsu <masao-k@...>
まつもと ゆきひろです
わたなべです.
<199802100623.PAA03533@eban.ase.ptg.sony.co.jp> の、
わたなべです.
<199802100733.QAA04028@eban.ase.ptg.sony.co.jp> の、
わたなべです.
<199802100757.QAA04212@eban.ase.ptg.sony.co.jp> の、
わたなべです.
<199802100952.SAA04346@eban.ase.ptg.sony.co.jp> の、
わたなべです.
<199802120449.NAA00398@eban.ase.ptg.sony.co.jp> の、
わたなべです.
<199802120600.PAA00591@eban.ase.ptg.sony.co.jp> の、
わたなべです.
<199802120717.QAA00774@eban.ase.ptg.sony.co.jp> の、
> Windows 95では、GDだけロードエラーに。(3台で確認)
[#1412] GD — Masao Kanemitsu <masao-k@...>
まつもと ゆきひろです
<199802100636.PAA16869@picachu.netlab.co.jp> の、
[#1468] tcltk library — Masao Kanemitsu <masao-k@...>
[#1481] tkmandel — Masao Kanemitsu <masao-k@...>
[#1483] 拡張モジュール on Windows — Masao Kanemitsu <masao-k@...>
わたなべです.
[#1501] Re: 拡張モジュールon Windows — Masao Kanemitsu <masao-k@...>
> <199802180824.RAA20375@eban.ase.ptg.sony.co.jp> の、
[#1505] final.rb:35: [BUG] bug in variable assignment — shugo@... (Shugo Maeda)
前田です。
[#1506] [BUG] instance_of? — keiju@... (Keiju ISHITSUKA)
けいじゅ@日本ラショナルソフトウェアです.
[#1520] SizedQueue and some question — keiju@... (Keiju ISHITSUKA)
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
[#1528] Mutex#unlock — shugo@... (Shugo Maeda)
前田です。
[ruby-dev:1500] Re: tkmandel
<199802190520.OAA31625@picachu.netlab.co.jp> の、 "[ruby-dev:1495] Re: tkmandel" において、 "matz@netlab.co.jp (Yukihiro Matsumoto)"さんは書きました: > |ズーム機能のバグ修正と手直し(ゆっくり深まるように)です: > > このパッチ↓でdevided by zeroがでるようになってしまいました. > どうしてなんでしょう? > > |- size = (d - a).abs if (size < (d - a).abs) > |+ size = (d - b).abs if (size < (d - b).abs) sizeが0になるような場合に、1に上げてやる必要がありますね。 > > さて,数回ズームすると落っこちる件ですが,毎回イメージを生成 > していた部分を流用するようにしたら,とりあえず落ちないように > なりました.恐らくTkの内部でリークしているのだと思います. > > まつもと ゆきひろ /:|) す、すごい。すごいきれいに治ってる。 すばらしいです。あと、一応、倍率が少しずつ深まるように もう一段sqrtをかませたのと、初期値を少し上げてみました。 それから、 # z = c = Complex(re, im) # for i in 0 .. $max_depth # z = (z * z) + c # break if z.abs2 > 5 ← ココ。 # end # return i の部分、以前は z.abs2 > 4 相当だったのですが、拡張モジュールになりますが 少し上げて 5 にしてやると、より深まるようです。 ありがとうございました。 M.Kanemitsu
Attachments (1)
# require "complex"
require "mandel"
require "tkclass"
require "GD"
DefaultMaxDepth = 50
DefaultSX = -2.25
DefaultSY = 1.75
DefaultEX = 1.25
DefaultEY = -1.75
def reset
$max_depth = DefaultMaxDepth
$s_re = DefaultSX
$s_im = DefaultSY
$e_re = DefaultEX
$e_im = DefaultEY
$dx = ($e_re - $s_re).abs / Width
$dy = ($e_im - $s_im).abs / Height
end
Width = 400
Height = 400
$c = Canvas.new {
width Width
height Height
}
$c.pack
$c_rect = Rectangle.new($c, 0, 0, Width+1, Height+1)
$c_rect.fill "white"
$colors = []
def gd_setup
$im = GD::Image.new(Width, Height)
$white = $im.colorAllocate(255, 255, 255)
$black = $im.colorAllocate(0, 0, 0)
$im.transparent($white)
$im.interlace = TRUE
$color_max = 0
for i in 0 .. 125
$colors[$color_max] = $im.colorAllocate(250 - (i*2), i*2, 0)
$color_max += 1
end
for i in 0 .. 125
$colors[$color_max] = $im.colorAllocate(0, 250 - (i*2), i*2)
$color_max += 1
end
$color_max -= 1
end
def zoom(a, b, c, d)
center_x = (a + c) / 2
center_y = (b + d) / 2
size = (c - a).abs
size = (d - b).abs if (size < (d - b).abs)
size = 1 if (size < 1)
zoom_rate = ((Width + Height) / 2).to_f / size
$max_depth = ($max_depth.to_f * Math.sqrt(Math.sqrt(Math.sqrt(zoom_rate)))).to_i
move_x_rate = (center_x - (Width / 2)).to_f / (Width / 2)
move_y_rate = (center_y - (Height / 2)).to_f / (Height / 2)
center_re = ($s_re + $e_re) / 2
center_im = ($s_im + $e_im) / 2
c_size_re = ($e_re - $s_re).abs
c_size_im = ($e_im - $s_im).abs
center_re = center_re + (move_x_rate * (c_size_re / 2))
center_im = center_im - (move_y_rate * (c_size_im / 2))
$s_re = center_re - ((c_size_re / 2) / zoom_rate)
$s_im = center_im + ((c_size_im / 2) / zoom_rate)
$e_re = center_re + ((c_size_re / 2) / zoom_rate)
$e_im = center_im - ((c_size_im / 2) / zoom_rate)
$dx = ($e_re - $s_re).abs / Width
$dy = ($e_im - $s_im).abs / Height
end
def mandel(x, y)
re = $s_re + ($dx * x)
im = $s_im - ($dy * y)
# z = c = Complex(re, im)
# for i in 0 .. $max_depth
# z = (z * z) + c
# break if z.abs2 > 5
# end
# return i
return Mandel.loop(re, im, $max_depth)
end
def calc
return if $current_rect
for x in 0 .. Width - 1
depth = mandel(x, $calc_y)
if depth >= $max_depth
$im.setPixel(x, $calc_y, $black)
else
$im.setPixel(x, $calc_y, $colors[ $color_max * depth / $max_depth ])
end
end
$calc_y += 1
if (($calc_y % 20) == 0)
print "#{($calc_y * 100 / Height)}% done. -- depth #{$max_depth}\n"
open("#tmpmandel#.gif", "w") do |f|
$im.gif(f)
end
unless $gif
$gif = TkPhotoImage.new { file "#tmpmandel#.gif" }
else
$gif.file "#tmpmandel#.gif"
end
unless $mandel
$mandel = TkcImage.new($c, Width/2, Height/2) { image $gif }
else
$mandel.image($gif)
end
end
if ($calc_y > Height - 1)
$calc_y = StartCalcY
$calc_on = false
open("#tmpmandel#.gif", "w") do |f|
$im.gif(f)
end
$gif.file "#tmpmandel#.gif"
$mandel.image($gif)
# $gif.destroy
# $gin = nil
end
if $calc_on
Tk.after(1) { calc() }
end
end
reset()
$calc_y = StartCalcY = 0
$calc_on = true
gd_setup()
calc()
def clear
# $mandel.destroy if $mandel
$calc_y = StartCalcY
end
$start_x = $start_y = 0
$current_rect = nil
def do_press(x, y)
$start_x = x
$start_y = y
$current_rect = Rectangle.new($c, x, y, x, y) { outline "white" }
end
def do_motion(x, y)
if $current_rect
$current_rect.coords $start_x, $start_y, x, y
end
end
def do_release(x, y)
if $current_rect
$current_rect.coords $start_x, $start_y, x, y
$current_rect.destroy
$current_rect = nil
clear()
$calc_on = true
gd_setup()
zoom($start_x, $start_y, x, y)
calc()
end
end
$c.bind("1", proc{|e| do_press e.x, e.y})
$c.bind("B1-Motion", proc{|x, y| do_motion x, y}, "%x %y")
$c.bind("ButtonRelease-1", proc{|x, y| do_release x, y}, "%x %y")
begin
Tk.mainloop
ensure
File.delete("#tmpmandel#.gif")
end