Class: MG::Color

Inherits:
Object
  • Object
show all
Defined in:
motion-game

Overview

A color represents the color, and sometimes opacity (alpha) of an object.

When calling a method that expects a Color object, a 3-element Array (red-green-blue) or 4-element Array (red-green-blue-alpha) can be passed instead, as a convenience shortcut. For example,

node.color = [0.2, 0.3, 0.4]

is the same as

color = MG::Color.new
color.red = 0.2
color.green = 0.3
color.blue = 0.4
node.color = color

Alternatively, a Symbol corresponding to a basic color name can be provided. For example,

node.color = :red

is the same as

color = MG::Color.new
color.red = 1.0
color.green = color.blue = 0
node.color = color

Currently, the following symbols are supported: :white, :black, :red, :green and :blue.

Properties (collapse)

Instance Attribute Details

- (Float) alpha

Returns the alpha portion of the color, from 0.0 to 1.0.

Returns:

  • (Float)

    the alpha portion of the color, from 0.0 to 1.0.



668
669
670
# File 'motion-game', line 668

def alpha
  @alpha
end

- (Float) blue

Returns the blue portion of the color, from 0.0 to 1.0.

Returns:

  • (Float)

    the blue portion of the color, from 0.0 to 1.0.



665
666
667
# File 'motion-game', line 665

def blue
  @blue
end

- (Float) green

Returns the green portion of the color, from 0.0 to 1.0.

Returns:

  • (Float)

    the green portion of the color, from 0.0 to 1.0.



662
663
664
# File 'motion-game', line 662

def green
  @green
end

- (Float) red

Returns the red portion of the color, from 0.0 to 1.0.

Returns:

  • (Float)

    the red portion of the color, from 0.0 to 1.0.



659
660
661
# File 'motion-game', line 659

def red
  @red
end