Sha256: 44c9562f4fd47191c313e63e5d6320285bc56c418428b0f9c9135056d915bd15

Contents?: true

Size: 448 Bytes

Versions: 54

Compression:

Stored size: 448 Bytes

Contents

class NSString

  # @return [NSColor]
  def nscolor(alpha=nil)
    if self[0,1] == '#'
      if self.length == 4
        return (self[1] * 2 + self[2] * 2 + self[3] * 2).to_i(16).nscolor(alpha)
      end
      return self[1..-1].to_i(16).nscolor(alpha)
    end

    img = NSImage.imageNamed(self)
    img && img.nscolor(alpha)
  end

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

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

end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
sugarcube-2.4.2 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.4.1 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.4.0 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.3.0 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.2.0 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.1.5 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.1.4 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.1.3 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.1.2 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.1.1 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.1.0 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.0.2 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.0.1 lib/osx/sugarcube-color/nsstring.rb
sugarcube-2.0.0 lib/osx/sugarcube-color/nsstring.rb