Class: UIColor
- Inherits:
-
Object
- Object
- UIColor
- Defined in:
- lib/purplish-red/non-ui/ui_color.rb
Instance Method Summary collapse
- #alpha ⇒ Object
- #blue ⇒ Object
- #color_with_alpha(a) ⇒ Object
- #components ⇒ Object
- #grayscale_colorspace? ⇒ Boolean
- #green ⇒ Object
- #red ⇒ Object
- #white ⇒ Object
Instance Method Details
#alpha ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/purplish-red/non-ui/ui_color.rb', line 39 def alpha if grayscale_colorspace? components[1] else components[3] end end |
#blue ⇒ Object
34 35 36 |
# File 'lib/purplish-red/non-ui/ui_color.rb', line 34 def blue (components[2]*255).round end |
#color_with_alpha(a) ⇒ Object
53 54 55 56 |
# File 'lib/purplish-red/non-ui/ui_color.rb', line 53 def color_with_alpha(a) comps = components UIColor.alloc.initWithRed(comps[0], green:comps[1], blue:comps[2], alpha:a) end |
#components ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/purplish-red/non-ui/ui_color.rb', line 7 def components if grayscale_colorspace? white = Pointer.new(:float) alpha = Pointer.new(:float) self.getWhite(white, alpha:alpha) [white[0], alpha[0]] else 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) [red[0], green[0], blue[0], alpha[0]] end end |
#grayscale_colorspace? ⇒ Boolean
2 3 4 |
# File 'lib/purplish-red/non-ui/ui_color.rb', line 2 def grayscale_colorspace? CGColorGetNumberOfComponents(self.CGColor) == 2 end |
#green ⇒ Object
29 30 31 |
# File 'lib/purplish-red/non-ui/ui_color.rb', line 29 def green (components[1]*255).round end |
#red ⇒ Object
24 25 26 |
# File 'lib/purplish-red/non-ui/ui_color.rb', line 24 def red (components[0]*255).round end |
#white ⇒ Object
48 49 50 |
# File 'lib/purplish-red/non-ui/ui_color.rb', line 48 def white components[0] end |