赞 | 5 |
VIP | 71 |
好人卡 | 22 |
积分 | 6 |
经验 | 32145 |
最后登录 | 2013-8-9 |
在线时间 | 184 小时 |
Lv2.观梦者 天仙
- 梦石
- 0
- 星屑
- 620
- 在线时间
- 184 小时
- 注册时间
- 2008-4-15
- 帖子
- 5023
|
我尝试做了VX版
但是未完成
有人有兴趣继续做下去吧
剩餘部分:
Scene_Battle部分
Game_Battler回復部分
Window繪製血條部分
PS:
把名称定义SP改成使用备注
把SP改成MP
- # 不同种类的MP分开用 改进版 V1.02
- # 制作 SLICK
- # 技术指导/测试 禾西
- # 修正了几个BUG
- # 修正了V1.01版中卸掉武器就会出脚本错
- # 修正了V1.01版中特定药物使用后MP超上限的BUG
- class RPG::Weapon < RPG::BaseItem
- # 武器名称所能决定MP种类及属性的定义方法
- # 格式: MP種類 [w_maxmp 2000]
- # MP種類 [w_akind 0]
- attr_writer :w_maxmp
- attr_writer :w_akind
- def w_maxmp
- self.note.mplit(/[\r\n]+/).each { |line|
- if line =~ /\[w_maxmp \d+\]/
- a = line.mplit(/ /)[1]
- d = ""
- while ((c = a.slice!(/./m)) != nil)
- d += c if c.is_a?(Integer)
- end
- end
- }
- return d ? d.to_i : nil
- end
- def w_akind
- self.note.mplit(/[\r\n]+/).each { |line|
- if line =~ /\[w_akind \d+\]/
- a = line.mplit(/ /)[1]
- d = ""
- while ((c = a.slice!(/./m)) != nil)
- d += c if c.is_a?(Integer)
- end
- end
- }
- return d ? d.to_i : nil
- end
- end
- class RPG::Item < RPG::UsableItem
- # 定义某种物品能回复哪种MP
- # 格式: MP種類 [i_rkind 2000]
- attr_writer :i_rkind
- self.note.mplit(/[\r\n]+/).each { |line|
- if line =~ /\[i_rkind \d+\]/
- a = line.mplit(/ /)[1]
- d = ""
- while ((c = a.slice!(/./m)) != nil)
- d += c if c.is_a?(Integer)
- end
- end
- }
- return d ? d.to_i : nil
- end
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ● 公開インスタンス変数
- #--------------------------------------------------------------------------
- #这里做修改==================================
- attr_accessor :ammo # MP残留量
- attr_accessor :akind # 使用何种MP
- attr_accessor :cta # MP最大容量
- #=======================================
- #感谢禾大人帮助精简==============================
- #--------------------------------------------------------------------------
- # ● セットアップ
- # actor_id : アクター ID
- #--------------------------------------------------------------------------
- alias ooo_setup setup
- def setup(actor_id)
- #=======================================
- #这里做修改==================================
- @ammo = [0,0,0,0,0,0,0,0,0]# 目前只使用九种能量
- @akind = 1 # 缺省情况下使用格斗技能量
- @cta = [0,0,0,0,0,0,0,0,0]# 这个新版本中每一种能量的最大值都要设定
- #=======================================
- ooo_setup(actor_id)
- end
- end
- class Scene_Equip < Scene_Base
- #--------------------------------------------------------------------------
- # ● 更新裝備區域選擇
- #--------------------------------------------------------------------------
- def update_equip_selection
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- Sound.play_cancel
- #装备结束时再次判断一下属性MP值========================
- neomaxmp=0
- if @actor.weapon_id !=0
- @actor.akind=$data_weapons[@actor.weapon_id].w_akind
- neomaxmp+=$data_weapons[@actor.weapon_id].w_maxmp
- @actor.cta[@actor.akind]=neomaxmp
- @actor.ammo[@actor.akind] = [$lammo[@actor.akind],@actor.cta[@actor.akind]].min#弹药种类相同取弹匣小值
- else #如果扔掉武器,MP就是0
- @actor.akind=1
- @actor.cta[@actor.akind]=0
- @actor.ammo[@actor.akind]=0
- end
- #=======================================
- # 切换到菜单画面
- return_scene
- end
- # 按下 R 键的情况下
- elsif Input.trigger?(Input::R)
- Sound.play_cursor # 演奏光标 SE
- next_actor # 移至下一位角色
- # 按下 L 键的情况下
- elsif Input.trigger?(Input::L)
- Sound.play_cursor # 演奏光标 SE
- prev_actor # 移至上一位角色
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 固定装备的情况下
- if @actor.fix_equipment
- Sound.play_buzzer
- else
- # 演奏确定 SE
- Sound.play_decision
- # 激活物品窗口
- @equip_window.active = false
- @item_window.active = true
- @item_window.index = 0
- #开始装备武器时判断一下属性MP值========================
- $lkind = @actor.akind #弹药种类是否与以前相同?
- $lammo = []
- for ii in [email protected]
- $lammo[ii][email protected][ii]
- end
- #=======================================
- return
- end
- end
- end
- # 需要在Game_Battler內修改
- class Scene_Battle < Scene_Base
-
- def make_skill_action_result
- # 获取特技
- @skill = $data_skills[@active_battler.current_action.skill_id]
- # 如果不是强制行动
- unless @active_battler.current_action.forcing
- # 因为 MP 耗尽而无法使用的情况下
- unless @active_battler.skill_can_use?(@skill.id)
- # 清除强制行动对像的战斗者
- $game_temp.forcing_battler = nil
- # 移至步骤 1
- @phase4_step = 1
- return
- end
- end
- # 消耗 MP(区分不同种类)===========================
- if @active_battler.is_a?(Game_Actor)
- @active_battler.ammo[@active_battler.akind] -= @skill.mp_cost
- else
- @active_battler.mp -= @skill.mp_cost
- end if
- #=======================================
- # 刷新状态窗口
- @status_window.refresh
- # 在帮助窗口显示特技名
- @help_window.set_text(@skill.name, 1)
- # 设置动画 ID
- @animation1_id = @skill.animation1_id
- @animation2_id = @skill.animation2_id
- # 设置公共事件 ID
- @common_event_id = @skill.common_event_id
- # 设置对像侧战斗者
- set_target_battlers(@skill.scope)
- # 应用特技效果
- for target in @target_battlers
- target.skill_effect(@active_battler, @skill)
- end
- end
- end
- #==============================================================================
- # 物品对不同MP分别起作用
- #==============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- SW_SET = [1,2,3,4,5,6,7,8,9] # 此处设定武器和技能关联的属性id
- #--------------------------------------------------------------------------
- def skill_can_use?(skill)
- return false unless skill.is_a?(RPG::Skill)
- return false unless movable?
- if self.is_a?(Game_Actor) and self.weapon_id > 0
- sw_boolean = false # 判断武器和技能关联
- s = SW_SET & skill.element_set
- if s.empty?
- sw_boolean = true
- else
- for i in s
- if $data_weapons[self.weapon_id].element_set .include?(i)
- sw_boolean = true
- break
- end
- end
- end
- if sw_boolean == false
- return false
- end
- #这里修改为对各种MP的判断===========================
- current_mp=self.ammo[self.akind]
- current_maxmp=self.cta[self.akind]
- #=======================================
- return false if calc_mp_cost(skill) > current_mp
- end
-
- return false if dead?
- return false if silent? and skill.mpi_f > 0
- occasion = skill.occasion
- if $game_temp.in_battle
- return skill.battle_ok?
- else
- return skill.menu_ok?
- end
- end
-
-
- #--------------------------------------------------------------------------
- # ● 發動物品效果
- # user : 物品使用者
- # item : 物品
- #--------------------------------------------------------------------------
- def item_effect(user, item)
- clear_action_results
- unless item_effective?(user, item)
- @skipped = true
- return
- end
- if rand(100) >= calc_hit(user, item) # 計算命中率
- @missed = true
- return
- end
- if rand(100) < calc_eva(user, item) # 計算閃躲率
- @evaded = true
- return
- end
- hp_recovery = calc_hp_recovery(user, item) # 計算體力回復量
- mp_recovery = calc_mp_recovery(user, item) # 計算魔力回復量
- make_obj_damage_value(user, item) # 計算傷害
- @hp_damage -= hp_recovery # 體力傷害減去回復量
- @mp_damage -= mp_recovery # 魔力傷害減去回復量
- make_obj_absorb_effect(user, item) # 計算吸收效果
- execute_damage(user) # 傷害效果
- item_growth_effect(user, item) # 能力值提升效果
- if item.physical_attack and @hp_damage == 0 # 判斷是否物理傷害
- return
- end
- apply_state_changes(item) # 增減狀態
- end
- # 未修改
- #--------------------------------------------------------------------------
- # ● 应用物品效果
- # item : 物品
- #--------------------------------------------------------------------------
- def item_effect(user, item)
- clear_action_results
- unless item_effective?(user, item)
- @skipped = true
- return
- end
- if rand(100) >= calc_hit(user, item) # 計算命中率
- @missed = true
- return
- end
- if rand(100) < calc_eva(user, item) # 計算閃躲率
- @evaded = true
- return
- end
- # 计算回复量
- hp_recovery = calc_hp_recovery(user, item) # 計算體力回復量
- make_obj_damage_value(user, item) # 計算傷害
- @hp_damage -= hp_recovery # 體力傷害減去回復量
- @mp_damage -= mp_recovery # 魔力傷害減去回復量
- make_obj_absorb_effect(user, item) # 計算吸收效果
- execute_damage(user) # 傷害效果
- #这里修改了对MP回复率的判断==========================
- recover_mp = self.cta[self.akind] * item.recover_mp_rate / 100 + item.recover_mp
- #=======================================
- recover_mp *= elements_correct(item.element_set)
- recover_mp /= 100
- # 分散
- if item.variance > 0 and recover_hp.abs > 0
- amp = [recover_hp.abs * item.variance / 100, 1].max
- recover_hp += rand(amp+1) + rand(amp+1) - amp
- end
- if item.variance > 0 and recover_mp.abs > 0
- amp = [recover_mp.abs * item.variance / 100, 1].max
- recover_mp += rand(amp+1) + rand(amp+1) - amp
- end
- # 回复量符号为负的情况下
- if recover_hp < 0
- # 防御修正
- if self.guarding?
- recover_hp /= 2
- end
- end
- # HP 回复量符号的反转、设置伤害值
- self.damage = -recover_hp
- # HP 以及 MP 的回复
- last_hp = self.hp
- self.hp += recover_hp
-
-
- #这里修改为对各种属性MP的判断=========================
- if self.is_a?(Game_Actor)
- case item.i_rkind
- when 255 #对自己所有的MP都起作用
- for ii in 0...self.cta.size
- current_mp = self.ammo[ii]
- if ii==self.akind #最大MP值的限制只对当前MP起作用
- current_maxmp=self.cta[ii]
- current_mp += recover_mp
- if current_mp > current_maxmp
- current_mp = current_maxmp
- end
- else
- current_mp += recover_mp
- end
- self.ammo[ii] = current_mp
- end
- when nil #对自己当前正在使用的MP起作用
- current_mp=self.ammo[self.akind]
- current_maxmp=self.cta[self.akind] #最大MP值的限制只对当前MP起作用
- current_mp += recover_mp
- if current_mp > current_maxmp
- current_mp = current_maxmp
- end
- self.ammo[self.akind] = current_mp
- else #对自己某种特定属性的MP起作用
- current_mp=self.ammo[item.i_rkind]
- current_mp += recover_mp
- if item.i_rkind==self.akind #对不可见的MP就不加限制以防出错
- current_maxmp=self.cta[self.akind] #对可见的MP就规定上限
- if current_mp > current_maxmp
- current_mp = current_maxmp
- end
- end
- self.ammo[item.i_rkind] = current_mp
- end
- last_mp = current_mp
- effective =true
- else
- last_mp = self.mp
- self.mp += recover_mp
- effective |= self.mp != last_mp
- end
- # ======================================
- item_growth_effect(user, item) # 能力值提升效果
- # HP 回复率与回复量为 0 的情况下
- if item.recover_hp_rate == 0 and item.recover_hp == 0
- # 设置伤害为空的字符串
- self.damage = ""
- # MP 回复率与回复量为 0、能力上升值无效的情况下
- if item.recover_mp_rate == 0 and item.recover_mp == 0 and
- (item.parameter_type == 0 or item.parameter_points == 0)
- # 状态没有变化的情况下
- unless @state_changed
- # 伤害设置为 "Miss"
- self.damage = "Miss"
- end
- end
- end
- # 不在战斗中的情况下
- unless $game_temp.in_battle
- # 伤害设置为 nil
- self.damage = nil
- end
- # 过程结束
- return effective
- end
- end
- class Game_Actor < Game_Battler
- def now_exp
- return @exp - @exp_list[@level]
- end
- def next_exp
- return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
- end
- end
- #==============================================================================
- # ■ Window_Base
- #------------------------------------------------------------------------------
- # 血条的绘制
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ● 繪製角色魔力
- # actor : 角色
- # x : 描畫目標 X 坐標
- # y : 描畫目標 Y 坐標
- # width : 描畫目標寬度
- #--------------------------------------------------------------------------
- def draw_actor_mp(actor, x, y, width = 120)
- draw_actor_mp_gauge(actor, x, y, width)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 30, WLH, Vocab::mp_a)
- self.contents.font.color = mp_color(actor)
- last_font_size = self.contents.font.size
- xr = x + width
- if width < 120
- self.contents.draw_text(xr - 44, y, 44, WLH, actor.ammo[actor.akind], 2)
- else
- self.contents.draw_text(xr - 99, y, 44, WLH, actor.ammo[actor.akind], 2)
- self.contents.font.color = normal_color
- self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
- self.contents.draw_text(xr - 44, y, 44, WLH, actor.cta[actor.akind], 2)
- end
- end
-
- def mp_color(actor)
- return crisis_color if actor.ammo[actor.akind] < actor.cta[actor.akind] / 4
- return normal_color
- end
-
-
- #--------------------------------------------------------------------------
- # ● HP ゲージの描画
- #--------------------------------------------------------------------------
- # オリジナルのHP描画を draw_actor_hp_original と名前変更
- alias :draw_actor_hp_original :draw_actor_hp
- def draw_actor_hp(actor, x, y, width = 144)
- # 変数rateに 現在のHP/MHPを代入
- if actor.maxhp != 0
- rate = actor.hp.to_f / actor.maxhp
- else
- rate = 0
- end
- # plus_x:X座標の位置補正 rate_x:X座標の位置補正(%) plus_y:Y座標の位置補正
- # plus_width:幅の補正 rate_width:幅の補正(%) height:縦幅
- # align1:描画タイプ1 0:左詰め 1:中央揃え 2:右詰め
- # align2:描画タイプ2 0:上詰め 1:中央揃え 2:下詰め
- # align3:ゲージタイプ 0:左詰め 1:右詰め
- plus_x = 0
- rate_x = 0
- plus_y = 25
- plus_width = 0
- rate_width = 100
- height = 10
- align1 = 1
- align2 = 2
- align3 = 0
- # グラデーション設定 grade1:空ゲージ grade2:実ゲージ
- # (0:横にグラデーション 1:縦にグラデーション 2:斜めにグラデーション(激重))
- grade1 = 1
- grade2 = 0
- # 色設定。color1:外枠,color2:中枠
- # color3:空ゲージダークカラー,color4:空ゲージライトカラー
- # color5:実ゲージダークカラー,color6:実ゲージライトカラー
- color1 = Color.new(0, 0, 0, 192)
- color2 = Color.new(255, 255, 192, 192)
- color3 = Color.new(0, 0, 0, 192)
- color4 = Color.new(64, 0, 0, 192)
- color5 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
- color6 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
- # 変数mpに描画するゲージの幅を代入
- if actor.maxhp != 0
- hp = (width + plus_width) * actor.hp * rate_width / 100 / actor.maxhp
- else
- hp = 0
- end
- # ゲージの描画
- gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
- width, plus_width + width * rate_width / 100,
- height, hp, align1, align2, align3,
- color1, color2, color3, color4, color5, color6, grade1, grade2)
- # オリジナルのHP描画処理を呼び出し
- draw_actor_hp_original(actor, x, y, width)
- end
- #--------------------------------------------------------------------------
- # ● MP ゲージの描画
- #--------------------------------------------------------------------------
- # オリジナルのMP描画を draw_actor_mp_original と名前変更
- alias :draw_actor_mp_original :draw_actor_mp
- def draw_actor_mp(actor, x, y, width = 144)
- # 変数rateに 現在のMP/MMPを代入
- if actor.maxmp != 0
- rate = actor.mp.to_f / actor.cta[actor.akind]
- else
- rate = 1
- end
- # plus_x:X座標の位置補正 rate_x:X座標の位置補正(%) plus_y:Y座標の位置補正
- # plus_width:幅の補正 rate_width:幅の補正(%) height:縦幅
- # align1:描画タイプ1 0:左詰め 1:中央揃え 2:右詰め
- # align2:描画タイプ2 0:上詰め 1:中央揃え 2:下詰め
- # align3:ゲージタイプ 0:左詰め 1:右詰め
- plus_x = 0
- rate_x = 0
- plus_y = 25
- plus_width = 0
- rate_width = 100
- height = 10
- align1 = 1
- align2 = 2
- align3 = 0
- # グラデーション設定 grade1:空ゲージ grade2:実ゲージ
- # (0:横にグラデーション 1:縦にグラデーション 2:斜めにグラデーション(激重))
- grade1 = 1
- grade2 = 0
- # 色設定。color1:外枠,color2:中枠
- # color3:空ゲージダークカラー,color4:空ゲージライトカラー
- # color5:実ゲージダークカラー,color6:実ゲージライトカラー
-
-
- #区分MP属性的颜色===============================
- case actor.akind
- when 0 # 火
- color1 = Color.new(0, 0, 0, 192)
- color2 = Color.new(255, 192, 192, 192)
- color3 = Color.new(0, 0, 0, 192)
- color4 = Color.new(0, 64, 64, 192)
- color5 = Color.new(128 * rate, 0, 0, 192)
- color6 = Color.new(255 * rate, 0, 0, 192)
- when 3 # 水
- color1 = Color.new(0, 0, 0, 192)
- color2 = Color.new(192, 192, 255, 192)
- color3 = Color.new(0, 0, 0, 192)
- color4 = Color.new(64, 64, 0, 192)
- color5 = Color.new(0, 0, 128 * rate, 192)
- color6 = Color.new(0, 0, 255 * rate, 192)
- when 5 # 风
- color1 = Color.new(0, 0, 0, 192)
- color2 = Color.new(192, 255, 224, 192)
- color3 = Color.new(0, 0, 0, 192)
- color4 = Color.new(64, 0, 0, 192)
- color5 = Color.new(0, 128 * rate, 96 * rate, 192)
- color6 = Color.new(0, 255 * rate, 192 * rate, 192)
- when 4 # 地
- color1 = Color.new(0, 0, 0, 192)
- color2 = Color.new(255, 224, 192, 192)
- color3 = Color.new(0, 0, 0, 192)
- color4 = Color.new(0, 0, 0, 192)
- color5 = Color.new(128 * rate, 64 * rate, 0, 192)
- color6 = Color.new(255 * rate, 128 * rate, 0, 192)
- when 2 # 雷
- color1 = Color.new(0, 0, 0, 192)
- color2 = Color.new(192, 224, 255, 192)
- color3 = Color.new(0, 0, 0, 192)
- color4 = Color.new(64, 0, 0, 192)
- color5 = Color.new(0, 96 * rate, 128 * rate, 192)
- color6 = Color.new(0, 192 * rate, 255 * rate, 192)
- when 6 # 光
- color1 = Color.new(0, 0, 0, 192)
- color2 = Color.new(255, 255, 192, 192)
- color3 = Color.new(0, 0, 0, 192)
- color4 = Color.new(0, 0, 64, 192)
- color5 = Color.new(128 * rate, 128 * rate, 64 * rate, 192)
- color6 = Color.new(255 * rate, 255 * rate, 96 * rate, 192)
- when 7 # 暗
- color1 = Color.new(0, 0, 0, 192)
- color2 = Color.new(160, 0, 224, 192)
- color3 = Color.new(0, 0, 0, 192)
- color4 = Color.new(0, 0, 0, 192)
- color5 = Color.new(32 * rate, 0, 64 * rate, 192)
- color6 = Color.new(128 * rate, 0 * rate, 192 * rate, 192)
- when 8 # 毒
- color1 = Color.new(0, 0, 0, 192)
- color2 = Color.new(128, 224, 128, 192)
- color3 = Color.new(0, 0, 0, 192)
- color4 = Color.new(0, 0, 0, 192)
- color5 = Color.new(0, 96 * rate, 0, 192)
- color6 = Color.new(0, 192 * rate, 0, 192)
- else
- color1 = Color.new(0, 0, 0, 192)
- color2 = Color.new(255, 255, 255, 192)
- color3 = Color.new(0, 0, 0, 192)
- color4 = Color.new(0, 0, 0, 192)
- color5 = Color.new(64 * rate, 64 * rate, 64 * rate, 192)
- color6 = Color.new(192 * rate, 192 * rate, 192 * rate, 192)
- end
- #=======================================
-
-
- # 変数mpに描画するゲージの幅を代入
- current_mp=actor.ammo[actor.akind]
- current_maxmp=actor.cta[actor.akind]
- if current_maxmp != 0
- mp = (width + plus_width) * current_mp * rate_width / 100 / current_maxmp
- else
- mp = (width + plus_width) * rate_width / 100
- end
- # ゲージの描画
- gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
- width, plus_width + width * rate_width / 100,
- height, mp, align1, align2, align3,
- color1, color2, color3, color4, color5, color6, grade1, grade2)
- # オリジナルのMP描画処理を呼び出し
- draw_actor_mp_original(actor, x, y, width)
- end
- #--------------------------------------------------------------------------
- # ● ゲージの描画
- #--------------------------------------------------------------------------
- def gauge_rect(x, y, rect_width, width, height, gauge, align1, align2, align3,
- color1, color2, color3, color4, color5, color6, grade1, grade2)
- case align1
- when 1
- x += (rect_width - width) / 2
- when 2
- x += rect_width - width
- end
- case align2
- when 1
- y -= height / 2
- when 2
- y -= height
- end
- # 枠描画
- self.contents.fill_rect(x, y, width, height, color1)
- self.contents.fill_rect(x + 1, y + 1, width - 2, height - 2, color2)
- if align3 == 0
- if grade1 == 2
- grade1 = 3
- end
- if grade2 == 2
- grade2 = 3
- end
- end
- if (align3 == 1 and grade1 == 0) or grade1 > 0
- color = color3
- color3 = color4
- color4 = color
- end
- if (align3 == 1 and grade2 == 0) or grade2 > 0
- color = color5
- color5 = color6
- color6 = color
- end
- # 空ゲージの描画
- self.contents.gradation_rect(x + 2, y + 2, width - 4, height - 4,
- color3, color4, grade1)
- if align3 == 1
- x += width - gauge
- end
- # 実ゲージの描画
- self.contents.gradation_rect(x + 2, y + 2, gauge - 4, height - 4,
- color5, color6, grade2)
- end
- end
- #------------------------------------------------------------------------------
- # Bitmapクラスに新たな機能を追加します。
- #==============================================================================
- class Bitmap
- #--------------------------------------------------------------------------
- # ● 矩形をグラデーション表示
- # color1 : スタートカラー
- # color2 : エンドカラー
- # align : 0:横にグラデーション
- # 1:縦にグラデーション
- # 2:斜めにグラデーション(激重につき注意)
- #--------------------------------------------------------------------------
- def gradation_rect(x, y, width, height, color1, color2, align = 0)
- if align == 0
- for i in x...x + width
- red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
- green = color1.green +
- (color2.green - color1.green) * (i - x) / (width - 1)
- blue = color1.blue +
- (color2.blue - color1.blue) * (i - x) / (width - 1)
- alpha = color1.alpha +
- (color2.alpha - color1.alpha) * (i - x) / (width - 1)
- color = Color.new(red, green, blue, alpha)
- fill_rect(i, y, 1, height, color)
- end
- elsif align == 1
- for i in y...y + height
- red = color1.red +
- (color2.red - color1.red) * (i - y) / (height - 1)
- green = color1.green +
- (color2.green - color1.green) * (i - y) / (height - 1)
- blue = color1.blue +
- (color2.blue - color1.blue) * (i - y) / (height - 1)
- alpha = color1.alpha +
- (color2.alpha - color1.alpha) * (i - y) / (height - 1)
- color = Color.new(red, green, blue, alpha)
- fill_rect(x, i, width, 1, color)
- end
- elsif align == 2
- for i in x...x + width
- for j in y...y + height
- red = color1.red + (color2.red - color1.red) *
- ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
- green = color1.green + (color2.green - color1.green) *
- ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
- blue = color1.blue + (color2.blue - color1.blue) *
- ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
- alpha = color1.alpha + (color2.alpha - color1.alpha) *
- ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
- color = Color.new(red, green, blue, alpha)
- set_pixel(i, j, color)
- end
- end
- elsif align == 3
- for i in x...x + width
- for j in y...y + height
- red = color1.red + (color2.red - color1.red) *
- ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
- green = color1.green + (color2.green - color1.green) *
- ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
- blue = color1.blue + (color2.blue - color1.blue) *
- ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
- alpha = color1.alpha + (color2.alpha - color1.alpha) *
- ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
- color = Color.new(red, green, blue, alpha)
- set_pixel(i, j, color)
- end
- end
- end
- end
- end
复制代码 |
|