I am trying to color the image below using Objective C in iOS.
I want to color the image based on height. For example the first 10 pixels with red, the next 20 with blue and the next 20 with green. I want the image to be colored like this.
I have searched in Stack overflow but I am not able find a way to do it.
Thanks
Edit:
This is how I have drawn the image
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextMoveToPoint(context, 0, 300);
CGContextAddLineToPoint(context, 20, 230);
CGContextAddLineToPoint(context, 80, 230);
CGContextAddLineToPoint(context, 120, 150);
CGContextAddLineToPoint(context, 140, 230);
CGContextAddLineToPoint(context, 300, 300);
CGContextClosePath(context);
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
CGContextStrokePath(context);
This is a terrain graph. The points in the graph will be dynamic. So based on the height of the terrain, it has to be colored. So I will not be able to create separate paths for the individual colors as I only get the heights. I do not have any point information for the individual color paths in the graph.