RPGツクールXP/VX用のRGSS素材です。
一部英語版対応です。
(A few materials can be used for English RPG MAKER XP/VX.)
競合率はルファーの独断と偏見なのでたまにハズレます。
#==============================================================================
# ■ 色の合成
#------------------------------------------------------------------------------
# Color クラスの四則演算を可能にします。
# (C) ルファー
# WebSite https://tkoolerlufar.pages.dev/
#==============================================================================
=begin
=対応RGSS
1 2
=他の素材との競合の可能性
... おそらくない
=更新履歴
2013/02/08 公開
=新規定義しているメソッド
Color#+@
Color#-@
Color#+
Color#-
Color#*
Color#/
=RPGツクールXPでの導入方法
Main より上に新セクションを作成して、このプログラムをそこにコピーする
=end
#----------------------------------------------------------------------------
# ◆ Color クラス
#----------------------------------------------------------------------------
class Color
#--------------------------------------------------------------------------
# ● そのままの色
#--------------------------------------------------------------------------
def +@
self
end
#--------------------------------------------------------------------------
# ● 反転色
#--------------------------------------------------------------------------
def -@
self.class.new(255.0 - red, 255.0 - green, 255.0 - blue, alpha)
end
#--------------------------------------------------------------------------
# ● 加算合成
#--------------------------------------------------------------------------
def +(other)
unless other.is_a?(Color)
raise(
TypeError,
"cannot convert #{other.class} into #{self.class}",
caller)
end
rate = other.alpha / 255.0
self.class.new(
self.red + other.red * rate,
self.green + other.green * rate,
self.blue + other.blue * rate,
self.alpha )
end
#--------------------------------------------------------------------------
# ● 減算合成
#--------------------------------------------------------------------------
def -(other)
unless other.is_a?(Color)
raise(
TypeError,
"cannot convert #{other.class} into #{self.class}",
caller)
end
rate = other.alpha / 255.0
self.class.new(
self.red - other.red * rate,
self.green - other.green * rate,
self.blue - other.blue * rate,
self.alpha )
end
#--------------------------------------------------------------------------
# ● 乗算合成、または明るさの乗算
#--------------------------------------------------------------------------
def *(other)
case other
when Color
rate = other.alpha / 255.0
self.class.new(
self.red * other.red * rate / 255.0,
self.green * other.green * rate / 255.0,
self.blue * other.blue * rate / 255.0,
self.alpha )
when Numeric
self.class.new(
self.red * other,
self.green * other,
self.blue * other,
self.alpha )
else
raise(
TypeError,
"cannot convert #{other.class} into #{self.class}",
caller)
end
end
#--------------------------------------------------------------------------
# ● 明るさの除算
#--------------------------------------------------------------------------
def /(other)
unless other.is_a?(Numeric)
raise(
TypeError,
"cannot convert #{other.class} into #{self.class}",
caller)
end
self.class.new(
self.red / other,
self.green / other,
self.blue / other,
self.alpha )
end
end
戻る