Sha256: 54739f71c3820013be4d060cb00e7ba145313a9dd9d0183552a5a6d0c347edca

Contents?: true

Size: 407 Bytes

Versions: 2

Compression:

Stored size: 407 Bytes

Contents

class NSArray

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

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

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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sugarcube-3.3.4 lib/osx/sugarcube-color/nsarray.rb
sugarcube-3.3.3 lib/osx/sugarcube-color/nsarray.rb