Class: UIColor
- Inherits:
-
Object
- Object
- UIColor
- Defined in:
- lib/sugarcube/uicolor.rb
Instance Method Summary collapse
- #alpha ⇒ Object
- #blue ⇒ Object
- #color ⇒ Object
- #green ⇒ Object
- #red ⇒ Object
- #to_s ⇒ Object
- #uicolor ⇒ Object
Instance Method Details
#alpha ⇒ Object
56 57 58 |
# File 'lib/sugarcube/uicolor.rb', line 56 def alpha self.color[:alpha] end |
#blue ⇒ Object
52 53 54 |
# File 'lib/sugarcube/uicolor.rb', line 52 def blue self.color[:blue] end |
#color ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sugarcube/uicolor.rb', line 27 def color if not @color red = Pointer.new(:float) green = Pointer.new(:float) blue = Pointer.new(:float) alpha = Pointer.new(:float) self.getRed(red, green:green, blue:blue, alpha:alpha) @color = { red: red[0], green: green[0], blue: blue[0], alpha: alpha[0], } end @color end |
#green ⇒ Object
48 49 50 |
# File 'lib/sugarcube/uicolor.rb', line 48 def green self.color[:green] end |
#red ⇒ Object
44 45 46 |
# File 'lib/sugarcube/uicolor.rb', line 44 def red self.color[:red] end |
#to_s ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sugarcube/uicolor.rb', line 6 def to_s alpha = self.alpha.to_s Symbol.uicolors.each_pair do |color, method| if UIColor.send(method) == self return "UIColor.#{method}(#{alpha})" end end red = (self.red * 255).to_i << 16 green = (self.green * 255).to_i << 8 blue = (self.blue * 255).to_i my_color = red + green + blue Symbol.css_colors.each_pair do |color, hex| if hex == my_color return "UIColor.color(#{color.inspect}, #{alpha})" end end return "UIColor.color(#{red}, #{green}, #{blue}, #{alpha})" end |
#uicolor ⇒ Object
3 |
# File 'lib/sugarcube/uicolor.rb', line 3 def uicolor ; self ; end |