赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 5186 |
最后登录 | 2021-3-28 |
在线时间 | 81 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 110
- 在线时间
- 81 小时
- 注册时间
- 2013-9-18
- 帖子
- 68
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 jxy 于 2014-8-11 12:05 编辑
如题。我用的是图书馆里的渐变文字脚本,结果出现了如图的错误:
这是原脚本:# 绘制色彩渐变v1.1 # 说明:文字中输入\u[颜色1,颜色2...] 就以渐变色绘制文字,结束渐变插入\u,大小写均可 # 插入文本框测试例子:\u[0,18,9,8]这是渐变文字\u渐变结束 class Window_Base GRADUAL_SYM = 'U' #修改控制符,需大写。 #- alias_method :process_escape_character_NOgradual, :process_escape_character def process_escape_character(code, text, pos) code.upcase == GRADUAL_SYM ? obtain_gradual_param(text, pos) : process_escape_character_NOgradual(code, text, pos) end def obtain_gradual_param(text, pos) text = text.slice!(/^\[.*]/) if text pos[:colors] = [] text.scan(/\d+/).each_with_index {|c, i| pos[:colors] = c.to_i} return if pos[:colors].size >= 2 end pos[:colors] = nil end # alias_method :process_nomarl_character_NOgradual, :process_normal_character def process_normal_character(c, pos) pos[:colors] ? process_nomarl_character_gradual(c, pos) : process_nomarl_character_NOgradual(c, pos) end def process_nomarl_character_gradual(c, pos) text_width = text_size(c).width draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c) colors = pos[:colors].collect {|c| text_color(c)} csz = colors.size uy = pos[:y] l = (pos[:y] + pos[:height] - uy).fdiv(csz - 1) for x in pos[:x]...(pos[:x] + text_width) sy = uy colors.each_with_index {|c1, i| for y in sy.round...(sy + l).round c = contents.get_pixel(x, y) next if c.alpha == 0 r = (y - sy) / l c2 = colors[i + 1] c.red *= calc_gradual_rgb(r, c1.red, c2.red) c.blue *= calc_gradual_rgb(r, c1.blue, c2.blue) c.green *= calc_gradual_rgb(r, c1.green, c2.green) contents.set_pixel(x, y, c) end break if i == csz - 2 sy += l } end pos[:x] += text_width end def calc_gradual_rgb(r, v1,v2) (v2 > v1 ? (r * (v2-v1) + v1) : ((1-r) * (v1-v2) + v2)) / 255 end end
# 绘制色彩渐变v1.1
# 说明:文字中输入\u[颜色1,颜色2...] 就以渐变色绘制文字,结束渐变插入\u,大小写均可
# 插入文本框测试例子:\u[0,18,9,8]这是渐变文字\u渐变结束
class Window_Base
GRADUAL_SYM = 'U' #修改控制符,需大写。
#-
alias_method :process_escape_character_NOgradual, :process_escape_character
def process_escape_character(code, text, pos)
code.upcase == GRADUAL_SYM ?
obtain_gradual_param(text, pos) :
process_escape_character_NOgradual(code, text, pos)
end
def obtain_gradual_param(text, pos)
text = text.slice!(/^\[.*]/)
if text
pos[:colors] = []
text.scan(/\d+/).each_with_index {|c, i| pos[:colors] = c.to_i}
return if pos[:colors].size >= 2
end
pos[:colors] = nil
end
#
alias_method :process_nomarl_character_NOgradual, :process_normal_character
def process_normal_character(c, pos)
pos[:colors] ?
process_nomarl_character_gradual(c, pos) :
process_nomarl_character_NOgradual(c, pos)
end
def process_nomarl_character_gradual(c, pos)
text_width = text_size(c).width
draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
colors = pos[:colors].collect {|c| text_color(c)}
csz = colors.size
uy = pos[:y]
l = (pos[:y] + pos[:height] - uy).fdiv(csz - 1)
for x in pos[:x]...(pos[:x] + text_width)
sy = uy
colors.each_with_index {|c1, i|
for y in sy.round...(sy + l).round
c = contents.get_pixel(x, y)
next if c.alpha == 0
r = (y - sy) / l
c2 = colors[i + 1]
c.red *= calc_gradual_rgb(r, c1.red, c2.red)
c.blue *= calc_gradual_rgb(r, c1.blue, c2.blue)
c.green *= calc_gradual_rgb(r, c1.green, c2.green)
contents.set_pixel(x, y, c)
end
break if i == csz - 2
sy += l
}
end
pos[:x] += text_width
end
def calc_gradual_rgb(r, v1,v2)
(v2 > v1 ? (r * (v2-v1) + v1) : ((1-r) * (v1-v2) + v2)) / 255
end
end
|
|