Sha256: 4e46d7d6c5a1b048b767be14e9595733633af671f7fb47ae42d215b04f93fbb2

Contents?: true

Size: 382 Bytes

Versions: 6

Compression:

Stored size: 382 Bytes

Contents

class NSArray

  # [160, 210, 242].nscolor => 0xA0D2F2.nscolor
  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.rgba(red, green, blue, alpha.to_f)
  end

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

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

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sugarcube-4.0.0 lib/osx/sugarcube-color/nsarray.rb
sugarcube-3.5.0 lib/osx/sugarcube-color/nsarray.rb
sugarcube-3.4.2 lib/osx/sugarcube-color/nsarray.rb
sugarcube-3.4.1 lib/osx/sugarcube-color/nsarray.rb
sugarcube-3.4.0 lib/osx/sugarcube-color/nsarray.rb
sugarcube-3.3.7 lib/osx/sugarcube-color/nsarray.rb