Sha256: 9c2e39f32748319d6ab382335d49c5a85806e11851ebfbd0e3e33c6aa0be75f0

Contents?: true

Size: 485 Bytes

Versions: 8

Compression:

Stored size: 485 Bytes

Contents

class Fixnum

  #     0xffffff.uicolor
  #     0xffffff.uicolor(0.33)
  # =>
  #     UIColor.colorWithRed(1.0, green:1.0, red: 1.0, alpha:1.0)
  #     UIColor.colorWithRed(1.0, green:1.0, red: 1.0, alpha:0.33)
  def uicolor(alpha=nil)
    alpha = 1.0 if alpha.nil?

    red = ((self & 0xFF0000) >> 16).to_f / 255.0
    green = ((self & 0xFF00) >> 8).to_f / 255.0
    blue = (self & 0xFF).to_f / 255.0

    UIColor.colorWithRed(red, green:green, blue:blue, alpha:alpha.to_f)
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sugarcube-0.5 lib/sugarcube/fixnum.rb
sugarcube-0.4.2 lib/sugarcube/fixnum.rb
sugarcube-0.4.1 lib/sugarcube/fixnum.rb
sugarcube-0.4 lib/sugarcube/fixnum.rb
sugarcube-0.3.2 lib/sugarcube/fixnum.rb
sugarcube-0.3.1 lib/sugarcube/fixnum.rb
sugarcube-0.3.0 lib/sugarcube/fixnum.rb
sugarcube-0.2.5 lib/sugarcube/fixnum.rb