赞 | 342 |
VIP | 10 |
好人卡 | 8 |
积分 | 262 |
经验 | 235776 |
最后登录 | 2024-9-23 |
在线时间 | 2387 小时 |
Lv5.捕梦者 (版主) 遠航の猫咪
- 梦石
- 3
- 星屑
- 23201
- 在线时间
- 2387 小时
- 注册时间
- 2005-10-15
- 帖子
- 1166
|
SEP Core插件应该可以满足你
节选:
#============================================================================== # ■ 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
#==============================================================================
# ■ 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
|
评分
-
查看全部评分
|