#****************************************************************************** # # * 太縁取り #010 # # -------------------------------------------------------------------------- # バージョン : 1.0.1 # 対 応 : RPGツクールVX Ace : RGSS3 # 制 作 者 : CACAO # 配 布 元 : http://cacaosoft.web.fc2.com/ # -------------------------------------------------------------------------- # == 概 要 == # # : デフォルトより太い縁取りを行います。 # # -------------------------------------------------------------------------- # == 注意事項 == # # ※ 組み込みクラス Bitmap#draw_text を再定義しています。 # ※ 文字の描画に、通常の倍ほどの時間が掛かります。 # # #****************************************************************************** #============================================================================== # ◆ 設定項目 #============================================================================== module CAO_010 #-------------------------------------------------------------------------- # ◇ 縁取りの色を自動で変更する #-------------------------------------------------------------------------- # 自動で変更する場合は、文字色より暗い色になります。 #-------------------------------------------------------------------------- AUTO_COLOR = true #-------------------------------------------------------------------------- # ◇ 縁取りの濃さを半分にする #-------------------------------------------------------------------------- HALF_BORDER = false #-------------------------------------------------------------------------- # ◇ 位置補正 #-------------------------------------------------------------------------- # [x, y] の配列で設定します。 # 設定された値だけ描画位置をずらします。 # ※ 通常の描画(draw_text)には適用されません。 #-------------------------------------------------------------------------- POSITION = [0, 0] end #/////////////////////////////////////////////////////////////////////////////# # # # 下記のスクリプトを変更する必要はありません。 # # # #/////////////////////////////////////////////////////////////////////////////# class Bitmap #-------------------------------------------------------------------------- # ● 別名定義 #-------------------------------------------------------------------------- alias cao010_draw_text draw_text #-------------------------------------------------------------------------- # 〇 新 draw_text #-------------------------------------------------------------------------- def draw_text(*args) if self.font.outline last_shadow = self.font.shadow self.font.shadow = false _draw_border_text(*_chack_arg_draw_text(args)) self.font.shadow = last_shadow else cao010_draw_text(*_chack_arg_draw_text(args)) end end private #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def _chack_arg_draw_text(args) case args.size when 2, 3 if args[0].kind_of?(Rect) r, text, align = args[0], args[1], args[2] || 0 x, y, width, height = r.x, r.y, r.width, r.height else msg = "cannot convert #{args[0].class} into Rect" raise TypeError, msg, caller(2) end when 5, 6 x, y, width, height, text, align = args align ||= 0 else msg = "wrong number of argsuments (#{args.size} for 5)" raise ArgumentError, msg, caller(2) end [x, y, width, height, align].each do |value| next if value.kind_of?(Numeric) msg = "cannot convert #{value.class} into Integer" raise TypeError, msg, caller(5) end unless text.kind_of?(String) text = (text.respond_to?(:to_s) ? text.to_s : text.inspect) end return x, y, width, height, text, align end #-------------------------------------------------------------------------- # ● 縁取り文字の描画 #-------------------------------------------------------------------------- def _draw_border_text(x, y, width, height, text, align) border = Bitmap.new(width, height) border.font = self.font.dup if CAO_010::AUTO_COLOR border.font.color.red /= 3 border.font.color.green /= 3 border.font.color.blue /= 3 else border.font.color = border.font.out_color end border.font.out_color.set(0, 0, 0, 0) border.cao010_draw_text(0, 0, width, height, text, align) x += CAO_010::POSITION[0] y += CAO_010::POSITION[1] alpha = (CAO_010::HALF_BORDER ? 128 : 255) self.blt(x, y - 2, border, border.rect, alpha) self.blt(x, y + 2, border, border.rect, alpha) self.blt(x - 2, y, border, border.rect, alpha) self.blt(x + 2, y, border, border.rect, alpha) self.blt(x - 1, y - 2, border, border.rect, alpha) self.blt(x + 1, y - 2, border, border.rect, alpha) self.blt(x - 1, y + 2, border, border.rect, alpha) self.blt(x + 1, y + 2, border, border.rect, alpha) self.blt(x - 2, y - 1, border, border.rect, alpha) self.blt(x - 2, y + 1, border, border.rect, alpha) self.blt(x + 2, y - 1, border, border.rect, alpha) self.blt(x + 2, y + 1, border, border.rect, alpha) last_out_color = self.font.out_color.dup self.font.out_color.set(0, 0, 0, 0) cao010_draw_text(x, y, width, height, text, align) self.font.out_color = last_out_color border.dispose end end