Class: Tone

Inherits:
Object
  • Object
show all
Defined in:
lib/R3EXS/RGSS3.rb

Overview

RPG Maker VX Ace Tone 类

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(red, green, blue, gray) ⇒ Color

初始化 Tone 对象

Parameters:

  • red (Integer)

    红色通道的值 (0-255)

  • green (Integer)

    绿色通道的值 (0-255)

  • blue (Integer)

    蓝色通道的值 (0-255)

  • gray (Integer)

    灰度通道的值 (0-255)



48
49
50
51
52
53
# File 'lib/R3EXS/RGSS3.rb', line 48

def initialize(red, green, blue, gray)
  @red = red
  @green = green
  @blue = blue
  @gray = gray
end

Instance Attribute Details

#blueObject

Returns the value of attribute blue.



35
36
37
# File 'lib/R3EXS/RGSS3.rb', line 35

def blue
  @blue
end

#grayObject

Returns the value of attribute gray.



35
36
37
# File 'lib/R3EXS/RGSS3.rb', line 35

def gray
  @gray
end

#greenObject

Returns the value of attribute green.



35
36
37
# File 'lib/R3EXS/RGSS3.rb', line 35

def green
  @green
end

#redObject

Returns the value of attribute red.



35
36
37
# File 'lib/R3EXS/RGSS3.rb', line 35

def red
  @red
end

Class Method Details

._load(obj) ⇒ Tone

反序列化 Tone 对象

Parameters:

  • obj (String)

    序列化后的字符串

Returns:



67
68
69
70
71
72
73
74
75
# File 'lib/R3EXS/RGSS3.rb', line 67

def self._load(obj)
  r, g, b, y = obj.unpack('D4')
  instance = Tone.allocate
  instance.red = r
  instance.green = g
  instance.blue = b
  instance.gray = y
  instance
end

Instance Method Details

#_dump(_level) ⇒ String

序列化 Tone 对象

Returns:



58
59
60
# File 'lib/R3EXS/RGSS3.rb', line 58

def _dump(_level)
  [@red, @green, @blue, @gray].pack('D4')
end