Method: UIColor#<<

Defined in:
lib/ios/sugarcube-color/uicolor.rb

#<<(color) ⇒ Object

blends two colors by adding the colors, with an upper maximum of 255. Adding white to any color will create white, adding black will do nothing. Also takes transparency into account; adding a transparent color has no effect, adding an opaque color has the most effect.

Examples:

:red.uicolor << :blue.uicolor == '#ff00ff'.uicolor (:magenta)
:red.uicolor << :blue.uicolor(0.5) == '#ff0080'.uicolor (pinkish)


33
34
35
36
37
38
39
# File 'lib/ios/sugarcube-color/uicolor.rb', line 33

def <<(color)
  r = [1.0, color.red * color.alpha + self.red].min
  g = [1.0, color.green * color.alpha + self.green].min
  b = [1.0, color.blue * color.alpha + self.blue].min
  a = self.alpha
  UIColor.colorWithRed(r, green:g, blue:b, alpha:a)
end