Class: Colour

Inherits:
Object
  • Object
show all
Defined in:
src/ruby/models/colour.rb,
mrb_doc/models/colour.rb

Overview

The Colour class is used for setting the colour of basic primatives (Circle, Rectangle, etc) but also for setting transparency on Texture2D objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(red, green, blue, alpha) ⇒ Colour

Creates a new instance of Colour

Parameters:

  • red (Integer)

    a value between 0 and 255

  • blue (Integer)

    a value between 0 and 255

  • green (Integer)

    a value between 0 and 255

  • alpha (Integer)

    a value between 0 and 255



8
9
10
11
12
# File 'mrb_doc/models/colour.rb', line 8

def initialize(red, green, blue, alpha)
  # mrb_Colour_initialize
  # src/mruby_integration/models/colour.cpp
  Colour.new
end

Instance Attribute Details

#alphaInteger

Returns:

  • (Integer)


5
6
7
# File 'src/ruby/models/colour.rb', line 5

def alpha
  @alpha
end

#blueInteger

Returns:

  • (Integer)


5
6
7
# File 'src/ruby/models/colour.rb', line 5

def blue
  @blue
end

#greenInteger

Returns:

  • (Integer)


5
6
7
# File 'src/ruby/models/colour.rb', line 5

def green
  @green
end

#redInteger

Returns:

  • (Integer)


5
6
7
# File 'src/ruby/models/colour.rb', line 5

def red
  @red
end

Instance Method Details

#==(other) ⇒ Boolean

Compares the values of two Colours

Parameters:

Returns:

  • (Boolean)


10
11
12
13
14
15
# File 'src/ruby/models/colour.rb', line 10

def ==(other)
  self.red == other.red &&
    self.green == other.green &&
    self.blue == other.blue &&
    self.alpha == other.alpha
end

#to_hHash

Return the object represented by a Hash

Returns:

  • (Hash)


20
21
22
23
24
25
26
27
# File 'src/ruby/models/colour.rb', line 20

def to_h
  {
    red: red,
    green: green,
    blue: blue,
    alpha: alpha,
  }
end