Class: UIColor
- Inherits:
-
Object
- Object
- UIColor
- Defined in:
- lib/isd-color-palette/model/uicolor_isd_extention.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.color_by_serialize(s) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/isd-color-palette/model/uicolor_isd_extention.rb', line 6 def color_by_serialize s begin a = s.split(",") case a[0] when "RGBA" UIColor.colorWithRed a[1].to_f, green:a[2].to_f, blue:a[3].to_f, alpha:a[4].to_f else nil end rescue end end |
Instance Method Details
#color_name ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/isd-color-palette/model/uicolor_isd_extention.rb', line 28 def color_name return "Clear"._ if self.alpha == 0 name = system_name || css_name || hex name = name.to_s unless name.is_a? String name.underscore.gsub(/_color/, "").gsub(/_/, " ").capitalize end |
#monochrome ⇒ Object
36 37 38 39 |
# File 'lib/isd-color-palette/model/uicolor_isd_extention.rb', line 36 def monochrome y = 0.299 * self.red + 0.587 * self.green + 0.114 * self.blue UIColor.alloc.initWithWhite y, alpha:self.alpha end |
#to_serialize ⇒ Object
24 25 26 |
# File 'lib/isd-color-palette/model/uicolor_isd_extention.rb', line 24 def to_serialize "RGBA,#{self.red},#{self.green},#{self.blue},#{self.alpha}" end |