Project1
标题:
求解一段脚本
[打印本页]
作者:
嚴子
时间:
2010-11-12 19:54
标题:
求解一段脚本
class Bitmap
def draw_text2(x, y, width, height, text, align = 0)
case align
when 0 then y = 0
when 1 then y = (self.height - height) / 2
when 2 then y = self.height - height - 10
end
y = 0 if align > 2
if text.nil? then return end
for i in 0..text.length / 3
self.draw_text(x, i * self.font.size + y, 32, 32, text[i * 3, 3])
end
end
end
复制代码
请教这是什么意思?
作者:
fux4
时间:
2010-11-12 20:16
回复
嚴子
的帖子
class Bitmap
def draw_text2(x, y, width, height, text, align = 0)#定义描绘字符方法
case align #对对齐方式做出判断
when 0 then y = 0 #当居中时 Y = 0
when 1 then y = (self.height - height) / 2 #当左对齐时Y = 自己高度-传递高度 / 2
when 2 then y = self.height - height - 10 #同理
end
y = 0 if align > 2 #如果对齐方式大于2
if text.nil? then return end #如果文本为空则返回空值
for i in 0..text.length / 3 #历遍所有字
self.draw_text(x, i * self.font.size + y, 32, 32, text[i * 3, 3]) #描绘
end
end
end
复制代码
作者:
嚴子
时间:
2010-11-12 20:23
谢谢
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1