查看: 2637|回复: 2

[已经过期] 如何解决文字阴影效果F12后的问题?

[复制链接]
梦石
0
星屑
615
在线时间
84 小时
注册时间
2012-8-12
回帖
127
发表于 2018-1-9 23:20:59 | 显示全部楼层 |阅读模式

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

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

×
#======================================================================
# 脚本来自www.66rpg.com,使用请保留此信息
# 作者:SailCat;升级:柳柳;最后升级日期:2006年4月30日
#======================================================================
class Bitmap
  unless $OK
    alias sailcat_draw_text draw_text
    def draw_text(p1, p2, p3 = 0, p4 = 3, p5 = nil, p6 = 0, p9 = false, p7 = 3, p8 = nil)
      case p1
      when Numeric
        x = p1
        y = p2
        width = p3
        height = p4
        text = p5
        align = p6
        shadow_direction = p7
        shadow_color = p8
        if shadow_color.nil?
          shadow_color = Color.new(0, 0, 0, self.font.color.alpha * 0.99)
        end
      when Rect
        x = p1.x
        y = p1.y
        width = p1.width
        height = p1.height
        text = p2
        align = p3
        shadow_direction = p4
        shadow_color = p5
        if shadow_color.nil?
          shadow_color = Color.new(0, 0, 0, self.font.color.alpha * 0.99)
        end
      end
      if p9
        sailcat_draw_text(x, y, width, height, text, align)
        return
      end
      color_temp = self.font.color.clone
      if shadow_direction != 0
        self.font.color = shadow_color
        case shadow_direction
        when 1
          sailcat_draw_text(x-1, y+1, width, height, text, align)
        when 3
          sailcat_draw_text(x+1, y+1, width, height, text, align)
        when 7
          sailcat_draw_text(x-1, y-1, width, height, text, align)
        when 9
          sailcat_draw_text(x+1, y-1, width, height, text, align)
        end
        self.font.color = color_temp
      end
      $OK = true
      sailcat_draw_text(x, y, width, height, text, align)
    end
  end
end

F12之后报错,这问题可以解决吗
不要屏蔽F12这个方法
或者有没有更好的文字阴影脚本

遠航の猫咪

梦石
3
星屑
26947
在线时间
2423 小时
注册时间
2005-10-15
回帖
987

开拓者

发表于 2018-1-10 00:43:29 | 显示全部楼层
SEP Core插件应该可以满足你

节选:
[pre lang="ruby"]#==============================================================================
# ■ Bitmap
#------------------------------------------------------------------------------
#   位图的增强功能,植入部分RGSS2的功能。
#==============================================================================
class Bitmap
  #--------------------------------------------------------------------------
  # ● 方法重定义
  #--------------------------------------------------------------------------
  unless method_defined?(:sailcat_sepcore_dispose)
    alias sailcat_sepcore_draw_text draw_text
  end
  #--------------------------------------------------------------------------
  # ● 获得描绘缓存
  #--------------------------------------------------------------------------
  def buffer
    @buffer ||= Bitmap.new(width, height)
  end
  #--------------------------------------------------------------------------
  # ● 清除缓存
  #--------------------------------------------------------------------------
  def clear_buffer
    self.buffer.clear
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    sailcat_sepcore_dispose
    @buffer.dispose if @buffer
  end
  #--------------------------------------------------------------------------
  # ● 绘制带有阴影或描边的文字
  #     args : 参数,写法同RGSS2
  #       参数1:x, y, width, height, str[, align[, shadow_direction[, color]]]
  #       参数2:rect, str[, align[, shadow_direction[, color]]]
  #     shadow_direction : 阴影的方向(0/1/3/5/7/9),0取消,1/3/7/9四角,5描边
  #     color : 阴影的颜色,不透明度会自动调整
  #--------------------------------------------------------------------------
  def draw_text(*args)
    case args[0]
    when Numeric
      x, y, width, height, text, align, shadow_direction, shadow_color = args
      align ||= 0
      shadow_direction ||= 3
      shadow_color ||= Color.new(0, 0, 0)
      shadow_color.alpha = font.color.alpha * 160 / 255
    when Rect
      rect, text, align, shadow_direction, shadow_color = args
      x = args[0].x
      y = args[0].y
      width = args[0].width
      height = args[0].height
      align ||= 0
      shadow_direction ||= 3
      shadow_color ||= Color.new(0, 0, 0)
      shadow_color.alpha = font.color.alpha * 160 / 255
    end
    text = text.to_s unless text.is_a?(String)
    color_temp = font.color.clone
    if shadow_direction != 0
      font.color = shadow_color
      if shadow_direction == 5
        buffer_rect = Rect.new(0, 0, width, height)
        clear_buffer
        buffer.font = font.clone
        buffer.font.color = shadow_color
        buffer.sailcat_sepcore_draw_text(buffer_rect, text, align)
        blt(x - 1,y - 1, buffer, buffer_rect)
        blt(x - 1,y + 1, buffer, buffer_rect)
        blt(x + 1,y - 1, buffer, buffer_rect)
        blt(x + 1,y + 1, buffer, buffer_rect)
      else
        a = shadow_direction % 6 == 1 ? -1 : 1
        b = shadow_direction / 6 == 1 ? -1 : 1
        sailcat_sepcore_draw_text(x + a, y + b, width, height, text, align)
      end
      font.color = color_temp
    end
    sailcat_sepcore_draw_text(x, y, width, height, text, align)
  end
end[/pre]

点评

甚至原作者都出来了。  发表于 2018-1-10 10:40

评分

参与人数 1星屑 +20 收起 理由
RyanBern + 20 塞糖

查看全部评分

SailCat (小猫子·要开心一点) 共上站 24 次,发表过 11 篇文章 上 次 在: [2006年01月28日11:41:18 星期六] 从 [162.105.120.91] 到本站一游。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部