查看: 1304|回复: 2

[已经解决] 求解一段脚本

[复制链接]
梦石
3
星屑
50
在线时间
762 小时
注册时间
2010-8-17
回帖
594
发表于 2010-11-12 19:54:24 | 显示全部楼层 |阅读模式

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

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

×
  1. class Bitmap
  2.   def draw_text2(x, y, width, height, text, align = 0)
  3.     case align
  4.     when 0 then y = 0
  5.     when 1 then y = (self.height - height) / 2
  6.     when 2 then y = self.height - height - 10
  7.     end
  8.     y = 0 if align > 2
  9.     if text.nil? then return end
  10.     for i in 0..text.length / 3
  11.       self.draw_text(x, i * self.font.size + y, 32, 32, text[i * 3, 3])
  12.     end
  13.   end
  14. end
复制代码
请教这是什么意思?

可以吃的头衔

梦石
0
星屑
1015
在线时间
424 小时
注册时间
2010-10-17
回帖
586
发表于 2010-11-12 20:16:36 | 显示全部楼层
回复 嚴子 的帖子
  1. class Bitmap
  2.   def draw_text2(x, y, width, height, text, align = 0)#定义描绘字符方法
  3.     case align  #对对齐方式做出判断
  4.     when 0 then y = 0  #当居中时 Y = 0
  5.     when 1 then y = (self.height - height) / 2 #当左对齐时Y = 自己高度-传递高度 / 2
  6.     when 2 then y = self.height - height - 10  #同理
  7.     end
  8.     y = 0 if align > 2   #如果对齐方式大于2
  9.     if text.nil? then return end   #如果文本为空则返回空值
  10.     for i in 0..text.length / 3  #历遍所有字
  11.       self.draw_text(x, i * self.font.size + y, 32, 32, text[i * 3, 3])  #描绘
  12.     end
  13.   end
  14. end
复制代码

评分

参与人数 1星屑 +376 收起 理由
fux2 + 376 认可答案+脸熟

查看全部评分

……
回复

使用道具 举报

梦石
3
星屑
50
在线时间
762 小时
注册时间
2010-8-17
回帖
594
 楼主| 发表于 2010-11-12 20:23:52 | 显示全部楼层
谢谢
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部