Sha256: 66e5470e4587a748cdbce09d19579f0125a0acdfe76a83098c8d85cf0432b3be

Contents?: true

Size: 487 Bytes

Versions: 63

Compression:

Stored size: 487 Bytes

Contents

class Fixnum

  #     0xffffff.uicolor
  #     0xffffff.uicolor(0.33)
  # =>
  #     UIColor.colorWithRed(1.0, green:1.0, blue: 1.0, alpha:1.0)
  #     UIColor.colorWithRed(1.0, green:1.0, blue: 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

63 entries across 63 versions & 1 rubygems

Version Path
sugarcube-1.5.9 lib/sugarcube-color/fixnum.rb
sugarcube-1.5.8 lib/sugarcube-color/fixnum.rb
sugarcube-1.5.7 lib/sugarcube-color/fixnum.rb
sugarcube-1.5.6 lib/sugarcube-color/fixnum.rb
sugarcube-1.5.5 lib/sugarcube-color/fixnum.rb
sugarcube-1.5.4 lib/sugarcube-color/fixnum.rb
sugarcube-1.5.3 lib/sugarcube-color/fixnum.rb
sugarcube-1.5.2 lib/sugarcube-color/fixnum.rb
sugarcube-1.5.1 lib/sugarcube-color/fixnum.rb
sugarcube-1.5.0 lib/sugarcube-color/fixnum.rb
sugarcube-1.4.6 lib/sugarcube-color/fixnum.rb
sugarcube-1.4.5 lib/sugarcube-color/fixnum.rb
sugarcube-1.4.4 lib/sugarcube-color/fixnum.rb
sugarcube-1.4.3 lib/sugarcube-color/fixnum.rb
sugarcube-1.4.2 lib/sugarcube-color/fixnum.rb
sugarcube-1.4.1 lib/sugarcube-color/fixnum.rb
sugarcube-1.4.0 lib/sugarcube-color/fixnum.rb
sugarcube-1.3.11 lib/sugarcube-color/fixnum.rb
sugarcube-1.3.10 lib/sugarcube-color/fixnum.rb
sugarcube-1.3.9 lib/sugarcube-color/fixnum.rb