找回密码
 注册用户
查看: 4|回复: 0

[开发日志] urge自用渐变字体

[复制链接]

96

主题

13

回帖

1313

积分

资深会员

积分
1313
发表于 昨天 17:07 | 显示全部楼层 |阅读模式
催更urge作者拿到了支持渐变字体的版本,拿 CP Gradient Text script 改一个自用的版本
效果:
QQ截图20251106170548.png


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

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

  18. class Bitmap  ## Alias draw_text for all the new functions.
  19.   alias gtu_draw_grad_text draw_text unless $@
  20.   def draw_text(*args)
  21.     if not GTU::GRADIENT
  22.       return gtu_draw_grad_text(*args)
  23.     end
  24.     dark = font_color_dark
  25.     dark.alpha = 255.0 * (1 - GTU::LIGHT / 100)
  26.     self.font.gradient_color = dark
  27.     res = gtu_draw_grad_text(*args)
  28.     self.font.gradient_color = Color.new(0, 0, 0, 0)
  29.     return res
  30.   end
  31.   
  32.   def font_color_dark  ## Creates the dark font color.
  33.     r = font.color.red
  34.     g = font.color.green
  35.     b = font.color.blue
  36.     color = []
  37.     [r, g, b].each {|c| color.push(c - c * GTU::DARK / 100) }
  38.     return Color.new(color[0], color[1], color[2], font.color.alpha)
  39.   end
  40. end
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册用户

本版积分规则

Archiver|QQ群: 48625831|爱上RPG|哈库纳玛塔塔 |网站地图 Clicky

GMT+8, 2025-11-7 02:01 , Processed in 0.083497 second(s), 21 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表