Sha256: 75d5d3e3274bfe7b9d502d6c0e3efc7575e72d9f8d04d749456022b345347354

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

class UIColor
  def uicolor ; self ; end
  alias cgcolor CGColor

  def red
    _sugarcube_colors[:red]
  end

  def green
    _sugarcube_colors[:green]
  end

  def blue
    _sugarcube_colors[:blue]
  end

  def alpha
    _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],
        }
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sugarcube-0.12 lib/sugarcube/uicolor.rb