Class: Tone

Inherits:
Object
  • Object
show all
Extended by:
RgssDb::JsonableConstructor
Includes:
RgssDb::Jsonable
Defined in:
lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb,
lib/rgss_db/model/rpg_maker_data/xp/rgss/tone.rb,
lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/tone.rb

Overview

The color tone class.

Each component is handled with a floating-point value (Float).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RgssDb::JsonableConstructor

json_create, json_new

Methods included from RgssDb::Jsonable

#as_json, #to_json

Constructor Details

#initialize(red = 0, green = 0, blue = 0, gray = 0) ⇒ Tone

Creates a Tone object. If gray is omitted, it is assumed to be 0.

The default values when no arguments are specified are (0, 0, 0, 0).

Parameters:

  • red (Integer) (defaults to: 0)
  • green (Integer) (defaults to: 0)
  • blue (Integer) (defaults to: 0)
  • gray (Integer) (defaults to: 0)


22
23
24
25
26
27
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 22

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

Instance Attribute Details

#blueObject

Returns the value of attribute blue.



71
72
73
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 71

def blue
  @blue
end

#grayObject

Returns the value of attribute gray.



71
72
73
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 71

def gray
  @gray
end

#greenObject

Returns the value of attribute green.



71
72
73
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 71

def green
  @green
end

#redObject

Returns the value of attribute red.



71
72
73
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 71

def red
  @red
end

Class Method Details

._load(serialized_string) ⇒ Tone

Creates a new instance using the given binary data

Note: needed for Marshal module support

Parameters:

  • serialized_string (String)

Returns:



50
51
52
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 50

def self._load(serialized_string)
  Tone.new_serialized(serialized_string)
end

.new_serialized(serialized_string) ⇒ Tone

Creates a new instance from a serialized string

Note: needed for Marshal module support

Parameters:

  • serialized_string (String)

Returns:



63
64
65
66
67
68
69
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 63

def self.new_serialized(serialized_string)
  # double, double, double, double (double-precision)
  red, green, blue, gray = serialized_string.unpack("dddd")

  # Creates the instance
  Tone.new(red, green, blue, gray)
end

Instance Method Details

#_dumpString

Dumps this instance into a binary string

Note: needed for Marshal module support

Returns:

  • (String)


36
37
38
39
# File 'lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb', line 36

def _dump(*)
  # double, double, double, double (double-precision)
  [@red, @green, @blue, @gray].pack("dddd")
end