查看: 3412|回复: 3

[已经过期] 关于字体的描边

[复制链接]

梦石
1
星屑
23241
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 2014-5-1 14:01:36 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
Font类自己的outline属性允许给字体增加描边,但是描边的厚度只有1个像素,请问如何实现2个像素乃至任意像素的字体描边?
梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
回帖
2257

贵宾

发表于 2014-5-1 14:11:22 | 显示全部楼层
photoshop
回复

使用道具 举报

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-5-1 14:56:54 | 显示全部楼层
试着只用脚本编辑器写了一下,结果就是个杯具
所以说这种东西应该不太能只用RGSS3来实现吧……

然后送一段杯具的代码=。=

[pre lang="ruby" line="1"]
class Font
  
  attr_accessor :outline_size
  
  singleton_class.send :attr_accessor, :default_outline_size
  
  self.default_outline_size = 1
  
  alias initialize_without_outline initialize
  
  def initialize(*args)
    initialize_without_outline(*args)
    @outline_size = Font.default_outline_size
  end

end

class Bitmap
  
  alias draw_text_without_outline draw_text
  
  def draw_text(*args)
   
    draw_text_without_outline(*args)
    return unless font.outline_size
   
    white = Color.new(255,255,255)
   
    temp = Bitmap.new(width, height)
    temp.fill_rect(0, 0, width, height, white)
    temp.draw_text_without_outline(*args)

    width.times do |x|
      height.times do |y|
        unless temp.get_pixel(x, y) == white
          (x - font.outline_size + 1).upto(x + font.outline_size - 1) do |i|
            (y - font.outline_size + 1).upto(y + font.outline_size - 1) do |j|
              set_pixel(i, j, font.out_color)
            end
          end
        end
      end
    end
   
    temp.dispose
   
  end
  
end
[/pre]
回复

使用道具 举报

梦石
0
星屑
122
在线时间
552 小时
注册时间
2012-8-18
回帖
1392
发表于 2014-5-2 15:30:02 | 显示全部楼层
偏移几像素多画几遍呗233,虽然这样很没效率

评分

参与人数 1星屑 +40 收起 理由
喵呜喵5 + 40 MATERIAL BRAVE 不用谢

查看全部评分

我要填坑!我要背单词!我要学日语!我要每天锻炼!
好吧呵呵= =
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部