| 赞 | 0  | 
 
| VIP | 8 | 
 
| 好人卡 | 27 | 
 
| 积分 | 66 | 
 
| 经验 | 41413 | 
 
| 最后登录 | 2012-10-21 | 
 
| 在线时间 | 833 小时 | 
 
 
 
 
 
Lv4.逐梦者 弓箭手?剑兰 
	- 梦石
 - 0 
 
        - 星屑
 - 6559 
 
        - 在线时间
 - 833 小时
 
        - 注册时间
 - 2010-11-17
 
        - 帖子
 - 1140
 
 
 
 | 
	
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员  
 
x
 
0.序 
可能以前早就有人有这个想法了,在 >这一帖(计时器)< 已用到类似的技术了。 
用法是这样: 
     bitmap对象.draw_number(x, y, number, flie_id) 
       number    : 数字的字符串/整数类 
       flie_id   : "A"-"Z" 的数字图片 
就是先做定一些"A"至"Z"的数字图片,左至右为 0123456789。存放在"Graphics/System/Number/"。 
然后就在bitmap对象用以上方法,绘画出数字。 
默认为"Graphics/System/Number/"路径下的"A.png"的图片。 
 
1.效果观看 
使用这个放在"Graphics/System/Number/"路径下:
 
 
再做绘画: 
 
 
 
2.脚本 
 
- #==============================================================================
 
 - # ■ 图片数字 v1.0     by 一箭烂
 
 - #------------------------------------------------------------------------------
 
 - #
 
 - #  使用说明:
 
 - #
 
 - #     bitmap对象.draw_number(x, y, number, flie_id)
 
 - #       number    : 数字的字符串/整数类
 
 - #       flie_id   : "A"-"Z" 的数字图片
 
 - #==============================================================================
 
 - class Bitmap
 
 -   @@cache = {}
 
 -   for i in "A".."Z"
 
 -     @@cache[i] = Bitmap.new("Graphics/System/Number/#{i}.png") if FileTest.exist?("Graphics/System/Number/#{i}.png")
 
 -   end
 
 -   #--------------------------------------------------------------------------
 
 -   # ● draw_number
 
 -   #--------------------------------------------------------------------------
 
 -   def draw_number(x, y, number, flie_id = "A")
 
 -     number = number.to_s unless number.is_a?(String)
 
 -     bitmap_width = @@cache[flie_id].width / 10
 
 -     bitmap_height = @@cache[flie_id].height
 
 -     rect = Rect.new(0, 0, bitmap_width, bitmap_height)
 
 -     buff = Bitmap.new(width * number.size, bitmap_height)
 
 -     number_array = number.split(//)
 
 -     index = -1
 
 -     for i in number_array
 
 -       index += 1
 
 -       if i != " "
 
 -         rect.x = number_array[index].to_i * bitmap_width
 
 -         buff.blt(index * bitmap_width, 0, @@cache[flie_id], rect)
 
 -       end
 
 -     end
 
 -     self.blt(x, y, buff, Rect.new(0, 0, bitmap_width * number.size, height))
 
 -     buff.dispose
 
 -   end
 
 - end
 
  复制代码 
3.范例 
 
图片数字_v1.0.zip
(269.66 KB, 下载次数: 453)
 
 
4.更新历史及下一个版本的期望 
目前为初版v1.0 
下一个版本希望能够支持: 
- 浮点数
 - draw_text的width、height和align参数以及功能。
 
 
  |   
 
评分
- 
查看全部评分
 
 
 
 
 
 |