Class: Colour

Inherits:
Object
  • Object
show all
Defined in:
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



67
68
69
70
71
# File 'mrb_doc/models/colour.rb', line 67

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

Instance Attribute Details

#alphaInteger

Returns:

  • (Integer)


59
60
61
# File 'mrb_doc/models/colour.rb', line 59

def alpha
  @alpha
end

#blueInteger

Returns:

  • (Integer)


59
60
61
# File 'mrb_doc/models/colour.rb', line 59

def blue
  @blue
end

#greenInteger

Returns:

  • (Integer)


59
60
61
# File 'mrb_doc/models/colour.rb', line 59

def green
  @green
end

#redInteger

Returns:

  • (Integer)


59
60
61
# File 'mrb_doc/models/colour.rb', line 59

def red
  @red
end

Instance Method Details

#==(other) ⇒ Boolean

Compares the values of two Colours

Parameters:

Returns:

  • (Boolean)


100
101
102
103
104
105
106
# File 'mrb_doc/models/colour.rb', line 100

def ==(other)
  # src/mruby_integration/models/colour.cpp
  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)


110
111
112
113
114
115
116
117
118
# File 'mrb_doc/models/colour.rb', line 110

def to_h
  # src/mruby_integration/models/colour.cpp
  {
    red: red,
    green: green,
    blue: blue,
    alpha: alpha,
  }
end