烁灵 发表于 2025-11-6 17:07:01

urge自用渐变字体

催更urge作者拿到了支持渐变字体的版本,拿 CP Gradient Text script 改一个自用的版本
效果:



module GTU    # Do not edit                                                                                 #
#                                                                              #
# Chooses if the gradient colors are applied.Can be turned to false if you   #
# just want to use the font buffer.                                          #
GRADIENT = true # Default = true                                             #
#                                                                              #
# The bop and bottom shading of the font.A number between 0 and 100 should   #
# be used.The top is changed to black while the bottom is changed to white.#
LIGHT = 70 # Default = 70                                                      #
DARK = 40 # Default = 40
end

#~ 渐变使用方法:
#~ Font.default_gradient_color = Color.new(0, 0, 0, 125)
#~ 其中font.color为顶层颜色
#~ font.gradient_color为底层颜色,
#~ font.gradient_color.alpha属性决定渐变程度,
#~ 设置为0时则不使用渐变效果

class Bitmap## Alias draw_text for all the new functions.
alias gtu_draw_grad_text draw_text unless $@
def draw_text(*args)
    if not GTU::GRADIENT
      return gtu_draw_grad_text(*args)
    end
    dark = font_color_dark
    dark.alpha = 255.0 * (1 - GTU::LIGHT / 100)
    self.font.gradient_color = dark
    res = gtu_draw_grad_text(*args)
    self.font.gradient_color = Color.new(0, 0, 0, 0)
    return res
end

def font_color_dark## Creates the dark font color.
    r = font.color.red
    g = font.color.green
    b = font.color.blue
    color = []
    .each {|c| color.push(c - c * GTU::DARK / 100) }
    return Color.new(color, color, color, font.color.alpha)
end
end


页: [1]
查看完整版本: urge自用渐变字体