Skip to content

Instantly share code, notes, and snippets.

@tehprofessor
Last active August 29, 2015 13:56
Show Gist options
  • Save tehprofessor/9175465 to your computer and use it in GitHub Desktop.
Save tehprofessor/9175465 to your computer and use it in GitHub Desktop.
NSGradient.alloc.initWithColorsAndLocations -- RubyMotion (OS X)
def make_stepped_gradient
@grad = NSGradient.alloc.initWithColorsAndLocations(start_color, 0.0, middle_color, 0.015, end_color, 1.0, nil)
# Explodes with:
# 2014-02-23 10:52:01.323 my_app[86365:303] -[__NSCFNumber colorUsingColorSpace:]: unrecognized selector sent to instance 0x7f8764169b20
# 2014-02-23 10:52:01.416 my_app[86365:303] -[__NSCFNumber colorUsingColorSpace:]: unrecognized selector sent to instance 0x7f8764169b20
end
def start_color
@start_color ||= BW.rgba_color(100,100,100,1.0)
end
def middle_color
@middle_color ||= BW.rgba_color(92,92,92,1.0)
end
def end_color
@end_color ||= BW.rgba_color(85,85,85,1.0)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment