| 赞 | 153 |
| VIP | |
| 好人卡 | |
| 积分 | 93 |
| 经验 | |
| 最后登录 | 2024-5-6 |
| 在线时间 | 2504 小时 |
- 梦石
- 0
- 星屑
- 9292
- 在线时间
- 2504 小时
- 注册时间
- 2011-5-20
- 回帖
- 14521

|
发表于 2013-10-12 17:00:33
|
显示全部楼层
- class Bitmap
- alias draw_text2 draw_text
- def draw_text(*args)
- case args.size
- when 2
- rect = args[0]
- text = args[1].split("\n")
- auto = 0
- when 3
- rect = args[0]
- text = args[1].split("\n")
- auto = args[2]
- when 5
- rect = Rect.new(*(args[0,4]))
- text = args[4].split("\n")
- auto = 0
- when 6
- rect = Rect.new(*(args[0,4]))
- text = args[4].split("\n")
- auto = args[5]
- else
- raise ArgumentError,"错误的参数个数(#{args.size} to 2,3,5,6)."
- end
- wmax = [text.map{|t| self.text_size(t).width}.max,rect.width].min
- h = self.text_size(text[0]).height
- hmax = [h*text.size,rect.height].min
- bmp = Bitmap.new(wmax,hmax)
- bmp.font = self.font.clone
- text.each_with_index{|t,i|
- bmp.draw_text2(0,i*h,wmax,h,t,auto%3)
- }
- y = rect.y+(rect.height-bmp.height)/2
- case auto%3
- when 0
- x = rect.x
- when 1
- x = rect.x+(rect.width-bmp.width)/2
- when 2
- x = rect.x+rect.width-bmp.width
- end
- self.blt(x,y,bmp,bmp.rect)
- bmp.dispose
- self
- end
- end
复制代码 补充说明···你需要在工程里再放一个这个···(来自http://rpg.blue/thread-330587-1-1.html) |
评分
-
查看全部评分
|