#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/???????????? ? KGC_FrameShadowText?
#_/----------------------------------------------------------------------------
#_/?draw_text ????????????????????????
#_/ Provides functions to draw texts which framed or dropped shadow.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
=begin
????? ?????? - Methods ???????????????????????
???? Class - Bitmap ????????????????????????????
? draw_frame_text(x, y, width, height, string[, align, frame_color])
? draw_frame_text(rect, string[, align, frame_color])
? x, y : ????? [Integer]
? Destination.
? width, height : ????? [Integer]
? Size.
? rect : ???? [Rect]
? Rectangle.
? string : ????? [String]
? Output text.
? align : ?????? [Integer]
? Alignment.
? frame_color : ???? [Color]
? Frame color.
? ??? frame_color ????????????????
? Draws a character string framed in 'frame_color'.
?
? draw_shadow_text(x, y, width, height, string[, align, frame_color])
? draw_shadow_text(rect, string[, align, frame_color])
? x, y : ????? [Integer]
? Destination.
? width, height : ????? [Integer]
? Size.
? rect : ???? [Rect]
? Rectangle.
? string : ????? [String]
? Output text.
? align : ?????? [Integer]
? Alignment.
? frame_color : ???? [Color]
? Frame color.
? ???????????????????
? Draws a character string which drops shadow to lower right.
?
????????????????????????????????????????
=end
$imported = {} if $imported == nil
$imported["FrameShadowText"] = true
#==============================================================================
# ? Bitmap
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# ? ???????
# x, y, width, height, string[, align, frame_color]
# rect, string[, align, frame_color]
#--------------------------------------------------------------------------
def draw_frame_text(*args)
# ????
if args[0].is_a?(Rect)
if args.size >= 2 && args.size <= 4
# ?????????????????
x, y = args[0].x, args[0].y
width, height = args[0].width, args[0].height
string = args[1]
align = args[2].equal?(nil) ? 0 : args[2]
frame_color = args[3].equal?(nil) ? Color.new(0, 0, 0) : args[3]
else
# ?????????????
raise(ArgumentError, "wrong number of arguments(#{args.size} of #{args.size < 2 ? 2 : 4})")
return
end
else
if args.size >= 5 && args.size <= 7
# ?????????????????
x, y, width, height = args
string = args[4]
align = args[5].equal?(nil) ? 0 : args[5]
frame_color = args[6].equal?(nil) ? Color.new(0, 0, 0) : args[6]
else
# ?????????????
raise(ArgumentError, "wrong number of arguments(#{args.size} of #{args.size < 5 ? 5 : 7})")
return
end
end
# ??????
origin_color = font.color.dup
# ???
font.color = frame_color
draw_text(x - 1, y - 1, width, height, string, align)
draw_text(x - 1, y + 1, width, height, string, align)
draw_text(x + 1, y - 1, width, height, string, align)
draw_text(x + 1, y + 1, width, height, string, align)
# ??????
font.color = origin_color
draw_text(x, y, width, height, string, align)
end
#--------------------------------------------------------------------------
# ? ?????
# x, y, width, height, string[, align, shadow_color]
# rect, string[, align, shadow_color]
#--------------------------------------------------------------------------
def draw_shadow_text(*args)
# ????
if args[0].is_a?(Rect)
if args.size >= 2 && args.size <= 4
# ?????????????????
x, y = args[0].x, args[0].y
width, height = args[0].width, args[0].height
string = args[1]
align = args[2].equal?(nil) ? 0 : args[2]
shadow_color = args[3].equal?(nil) ? Color.new(0, 0, 0) : args[3]
else
# ?????????????
raise(ArgumentError, "wrong number of arguments(#{args.size} of #{args.size < 2 ? 2 : 4})")
return
end
else
if args.size >= 5 && args.size <= 7
# ?????????????????
x, y, width, height = args
string = args[4]
align = args[5].equal?(nil) ? 0 : args[5]
shadow_color = args[6].equal?(nil) ? Color.new(0, 0, 0) : args[6]
else
# ?????????????
raise(ArgumentError, "wrong number of arguments(#{args.size} of #{args.size < 5 ? 5 : 7})")
return
end
end
# ??????
origin_color = font.color.dup
# ???
font.color = shadow_color
draw_text(x + 2, y + 2, width, height, string, align)
# ??????
font.color = origin_color
draw_text(x, y, width, height, string, align)
end
end