さらに縁取り
なんだかアルゴリズムが腐ってるっぽかったので、きちんと考え直した。
これでバッチリだろう。
これだと黒い縁取りの白い文字にしか対応できないから、別の色とかもできるようになればいいのだが、どうしたらいいのやら。
# DXRuby1.0.6サンプル require 'dxruby' font = Font.new(128) image = Image.new(200,200).drawFont(0,0,"和",font) image2 = image.dup # dupできるよーになったよ! Window.bgcolor = [255,0,0] Window.width = 400 Window.height = 200 # 半透明の部分を黒にする for y in 0..199 for x in 0..199 temp = image[x, y][0] image2[x, y] = [temp, 0, 0, 0] if temp != 255 end end # 真っ白の部分に対して、横の影響を与える for y in 1..198 for x in 1..198 if image2[x, y][0] == 255 temp_color = 0 count = 0 if image2.compare(x-1, y, [0,0,0]) temp_color += image2[x-1, y][0] count+=1 end if image2.compare(x+1, y, [0,0,0]) temp_color += image2[x+1, y][0] count+=1 end if image2.compare(x, y-1, [0,0,0]) temp_color += image2[x, y-1][0] count+=1 end if image2.compare(x, y+1, [0,0,0]) temp_color += image2[x, y+1][0] count+=1 end temp_color /= count if count > 0 image2[x,y] = [255, temp_color, temp_color, temp_color] if count > 0 end end end Window.loop do Window.draw(0,0,image) Window.draw(200,0,image2) end
しかし文字を小さくしたら汚れているように見えてしまう。
文字のサイズに合わせて縁の太さを変えたりしないといけないんだろうか。
昨日のんと比較できるように「あ」もおいとく。