Class: RGSS::Tone
- Inherits:
-
Object
- Object
- RGSS::Tone
- Defined in:
- lib/rgss/stubs/tone.rb
Overview
All out of range values are automatically clamped to their respective limits.
Unlike RGSS Maker games, the grayscale has no negative performance effect to use, as the exact same
calculations are performed in the fragment shader with each draw, regardless of its value. Whether you use a value
of 0.0
or 1.0
, it will have absolutely no effect on FPS or resource usage.
All relevant methods implemented in Object
(i.e. #dup
, #clone
, Marshalling, equality) have also been
properly implemented/overridden, but have been omitted from the documentation for brevity.
A structure for altering the "balance" of colors and/or applying a grayscale effect. While it may appear similar to
color, it is not. It represents an alteration to a color, not the color itself. Internally this class is
represented as a typical 4 component vector, with 32-bit floating point values. Ruby uses a 64-bit double
for
floating point numbers, which have a higher precision (about 13 digits) compared to a 32-bit float
(about 7
digits), so bear this in mind and do not rely on any precision or accuracy of values beyond 6-7 digits, they should
be ignored beyond that point.
For the RGB components, it adjusts the output color by simply adding/subtracting on a component-wise basis, where a
value of 0.0
has no effect, -1.0
completely removes the component, and 1.0
is full output. The grayscale
component is calculated independently, and is a linear scaling factor on how strong the effect will be, where 0.0
is no effect, and 1.0
is fully "shades of gray", with no color.
Constant Summary collapse
- GRAY =
A full grayscale RGSS::Tone instance.
Tone.new(0.0, 0.0, 0.0, 1.0)
Instance Attribute Summary collapse
-
#b ⇒ Float
(also: #blue)
readonly
The value of the blue color component.
-
#g ⇒ Float
(also: #green)
readonly
The value of the green color component.
-
#gray ⇒ Float
(also: #grey)
readonly
The amount of grayscale that will be applied, where
0.0
is none, and1.0
is fully gray (i.e. "black & white"). -
#r ⇒ Float
(also: #red)
readonly
The value of the red color component.
Instance Method Summary collapse
-
#initialize(red, green, blue, gray = 0.0) ⇒ Tone
constructor
Creates a new instance of the Tone class.
Constructor Details
#initialize(red, green, blue, gray = 0.0) ⇒ Tone
Creates a new instance of the RGSS::Tone class.
52 53 |
# File 'lib/rgss/stubs/tone.rb', line 52 def initialize(red, green, blue, gray = 0.0) end |
Instance Attribute Details
#b ⇒ Float (readonly) Also known as: blue
The value of the blue color component.
38 39 40 |
# File 'lib/rgss/stubs/tone.rb', line 38 def b @b end |
#g ⇒ Float (readonly) Also known as: green
The value of the green color component.
33 34 35 |
# File 'lib/rgss/stubs/tone.rb', line 33 def g @g end |
#gray ⇒ Float (readonly) Also known as: grey
The amount of grayscale that will be applied, where 0.0
is none, and 1.0
is fully gray (i.e. "black & white").
43 44 45 |
# File 'lib/rgss/stubs/tone.rb', line 43 def gray @gray end |
#r ⇒ Float (readonly) Also known as: red
The value of the red color component.
28 29 30 |
# File 'lib/rgss/stubs/tone.rb', line 28 def r @r end |