Class: Resedit::Color
- Inherits:
-
Object
- Object
- Resedit::Color
- Defined in:
- lib/resedit/convert/colors.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#amath ⇒ Object
Returns the value of attribute amath.
-
#b ⇒ Object
Returns the value of attribute b.
-
#g ⇒ Object
Returns the value of attribute g.
-
#r ⇒ Object
Returns the value of attribute r.
Instance Method Summary collapse
- #*(m) ⇒ Object
- #+(col) ⇒ Object
- #add(col) ⇒ Object
-
#initialize(valOrR, g = nil, b = nil, a = 0xFF) ⇒ Color
constructor
A new instance of Color.
- #mul(m) ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(valOrR, g = nil, b = nil, a = 0xFF) ⇒ Color
Returns a new instance of Color.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/resedit/convert/colors.rb', line 7 def initialize(valOrR, g=nil, b=nil, a=0xFF) @amath = false if g == nil @r = (valOrR >> 16) & 0xFF @g = (valOrR >> 8) & 0xFF @b = valOrR & 0xFF @a = (valOrR >> 24) & 0xFF else @r, @g, @b, @a = valOrR, g, b, a end end |
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
5 6 7 |
# File 'lib/resedit/convert/colors.rb', line 5 def a @a end |
#amath ⇒ Object
Returns the value of attribute amath.
5 6 7 |
# File 'lib/resedit/convert/colors.rb', line 5 def amath @amath end |
#b ⇒ Object
Returns the value of attribute b.
5 6 7 |
# File 'lib/resedit/convert/colors.rb', line 5 def b @b end |
#g ⇒ Object
Returns the value of attribute g.
5 6 7 |
# File 'lib/resedit/convert/colors.rb', line 5 def g @g end |
#r ⇒ Object
Returns the value of attribute r.
5 6 7 |
# File 'lib/resedit/convert/colors.rb', line 5 def r @r end |
Instance Method Details
#*(m) ⇒ Object
43 |
# File 'lib/resedit/convert/colors.rb', line 43 def *(m); Color.new(@r,@g,@b,@a).mul(m) end |
#+(col) ⇒ Object
45 |
# File 'lib/resedit/convert/colors.rb', line 45 def +(col); Color.new(@r,@g,@b,@a).add(col) end |
#add(col) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/resedit/convert/colors.rb', line 27 def add(col) @a = [0xFF, @a + col.a].min if @amath @r = [0xFF, @r + col.r].min @g = [0xFF, @g + col.g].min @b = [0xFF, @b + col.b].min return self end |
#mul(m) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/resedit/convert/colors.rb', line 35 def mul(m) @a = [0xFF, (@a * m).to_i()].min if @amath @r = [0xFF, (@r * m).to_i()].min @g = [0xFF, (@g * m).to_i()].min @b = [0xFF, (@b * m).to_i()].min return self end |
#to_i ⇒ Object
23 24 25 |
# File 'lib/resedit/convert/colors.rb', line 23 def to_i() return (@a<<24)|(@r<<16)|(@g<<8)|@b end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/resedit/convert/colors.rb', line 19 def to_s() return "[#{@a.to_s(16)} #{@r.to_s(16)} #{@g.to_s(16)} #{@b.to_s(16)}]" end |