Sha256: 9f167281f93364fb024451925513ce03d45e9d7c874ba6f271fb3d9fa0bd782c

Contents?: true

Size: 486 Bytes

Versions: 54

Compression:

Stored size: 486 Bytes

Contents

class NSArray

  # [160, 210, 242].uicolor => 0xA0D2F2.uicolor
  # [160, 210, 242, 0.5].uicolor => 0xA0D2F2.uicolor(0.5)
  def uicolor(alpha=nil)
    red = self[0] / 255.0
    green = self[1] / 255.0
    blue = self[2] / 255.0
    if self[3]
      alpha = self[3]
    end
    alpha ||= 1.0
    UIColor.colorWithRed(red, green: green, blue: blue, alpha: alpha.to_f)
  end

  def cgcolor(alpha=nil)
    uicolor(alpha).CGColor
  end

  def skcolor(alpha=nil)
    uicolor(alpha)
  end

end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
sugarcube-4.0.0 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.5.0 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.4.2 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.4.1 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.4.0 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.3.7 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.3.6 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.3.5 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.3.4 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.3.3 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.3.2 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.3.1 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.3.0 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.2.0 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.1.1 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.1.0 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.0.8 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.0.7 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.0.6 lib/ios/sugarcube-color/nsarray.rb
sugarcube-3.0.5 lib/ios/sugarcube-color/nsarray.rb