ページ 11

顔グラにグラデーション(解決済み)

Posted: 2016年1月05日(火) 11:57
by ホノルメイド
顔グラにA1さんのようなグラデーションをスクリプト版で出来るのを探していますが、見つからないのでリクエストへ。

スクリプトで顔グラにグラデーションかけれるのがほしいですが、A1さんのですと注釈であり、どうしても競合を起こしてしまいます。
なので、スクリプトで出来るものをリクエストします。

サンプル画像は添付したとおりです。
さんぷりゃあ.png
さんぷりゃあ.png (1.04 KiB) 閲覧された回数 4765 回
こんな感じにできれば満足です。

お願いします。

Re: 顔グラにグラデーション

Posted: 2016年1月10日(日) 11:36
by faida
はじめまして。
とりあえず作ってみました。
機能追加など何かありましたら遠慮なくどうぞ。

コード: 全て選択

=begin
◆概要
メッセージウィンドウの顔グラフィックにグラデーションをかけます。

◆機能
・イベントコマンドで「set_gradation」と記入すると、初期設定のグラデーションが
かけられます。
・イベントコマンドで「set_gradation(c1,c2,vert,cont)」と記入すると、
その通りのグラデーションがかけられます。

◆仕様
・自動グラデーション機能とかはなし。

◆使用上の注意
・★……エイリアス ○……新規定義

=end

module Gradation
  # 設定項目:グラデーションの初期設定
  # DEF_C1  :グラデーションの上(左)のほうの色
  # DEF_C2  :グラデーションの下(右)のほうの色
  # DEF_VERT:グラデーションの縦横(true:縦, false:横)
  # DEF_CONT:グラデーションの継続(true:継続する, false:継続しない)
  DEF_C1 = Color.new(0, 0, 0, 255)
  DEF_C2 = Color.new(0, 0, 0, 96)
  DEF_VERT = true
  DEF_CONT = false
  
  # 設定項目:顔グラフィックのサイズ(一応)
  SIZE = 96
end

#==============================================================================
# ■ Game_Message
#==============================================================================

class Game_Message
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :gradation_set            # グラデーションセット
  #--------------------------------------------------------------------------
  # ★ クリア
  #--------------------------------------------------------------------------
  alias clear_grad clear
  def clear
    clear_grad
    @gradation_set = nil if !@gradation_set || !@gradation_set[3]
  end
end

#==============================================================================
# ■ Game_Interpreter
#==============================================================================

class Game_Interpreter
  include Gradation
  #--------------------------------------------------------------------------
  # ○ イベントコマンド
  #--------------------------------------------------------------------------
  def set_gradation(c1 = DEF_C1, c2 = DEF_C2, vert = DEF_VERT, cont = DEF_CONT)
    $game_message.gradation_set = [c1, c2, vert, cont]
  end
end

#==============================================================================
# ■ Window_Message
#==============================================================================

class Window_Message < Window_Base
  include Gradation
  #--------------------------------------------------------------------------
  # ★ 顔グラフィックの描画
  #--------------------------------------------------------------------------
  alias draw_face_grad draw_face
  def draw_face(face_name, face_index, x, y, enabled = true)
    draw_face_grad(face_name, face_index, x, y, enabled)
    if $game_message.gradation_set
      c1 = $game_message.gradation_set[0] || DEF_C1
      c2 = $game_message.gradation_set[1] || DEF_C2
      vert = $game_message.gradation_set[2]
      vert = DEF_VERT if vert.nil?
      cont = $game_message.gradation_set[3]
      cont = DEF_CONT if cont.nil?
      bitmap = Bitmap.new(SIZE, SIZE)
      bitmap.gradient_fill_rect(x, y, SIZE, SIZE, c1, c2, vert)
      rect = Rect.new(0, 0, SIZE, SIZE)
      contents.blt(x, y, bitmap, rect)
      bitmap.dispose
      $game_message.gradation_set = nil if !cont
    end
  end
end

Re: 顔グラにグラデーション

Posted: 2016年1月11日(月) 10:17
by ホノルメイド
faida様、初めまして。
いえ、これでも大丈夫です。
無事競合せず動きましたので締め切らせてもらいます。
規約はfaida様の名前でよろしいでしょうか?

Re: 顔グラにグラデーション

Posted: 2016年1月11日(月) 10:41
by faida
はい、問題ありません。
(サイン機能を使ってみました。)