Sha256: c2ecc3b1fe68ef73f5e4e4a96a742f019d21efa2fbbaf31b40d66170f51432eb

Contents?: true

Size: 982 Bytes

Versions: 4

Compression:

Stored size: 982 Bytes

Contents

class UIColor
  def uicolor ; self ; end

  def red
    _sugarcube_colors && _sugarcube_colors[:red]
  end

  def cgcolor
    self.CGColor
  end

  def green
    _sugarcube_colors && _sugarcube_colors[:green]
  end

  def blue
    _sugarcube_colors && _sugarcube_colors[:blue]
  end

  def alpha
    _sugarcube_colors && _sugarcube_colors[:alpha]
  end

private
  def _sugarcube_colors
    @color ||= begin
      red = Pointer.new(:float)
      green = Pointer.new(:float)
      blue = Pointer.new(:float)
      white = Pointer.new(:float)
      alpha = Pointer.new(:float)
      if self.getRed(red, green:green, blue:blue, alpha:alpha)
        {
          red: red[0],
          green: green[0],
          blue: blue[0],
          alpha: alpha[0],
        }
      elsif self.getWhite(white, alpha:alpha)
        {
          red: white[0],
          green: white[0],
          blue: white[0],
          alpha: alpha[0],
        }
      else
        nil
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sugarcube-0.13.7 lib/sugarcube/uicolor.rb
sugarcube-0.13.5 lib/sugarcube/uicolor.rb
sugarcube-0.13.4 lib/sugarcube/uicolor.rb
sugarcube-0.13.3 lib/sugarcube/uicolor.rb