0

Im working on rendering a graph in app. Working with the data (drawing the dots, and lines between dots) is covered, what I am interested in is mapping this data ontop of a graphic.

Firstly, let me show you what I want to do (see below), the solution is that the graph base has a gradient.

I presume the solution is to just take a block image of the gradient, and just cut the edges in code (somehow).

Is there an existing algorithm (Objective-C) that will do this?

Thanks

let me show you what I want to do

oberbaum
  • 2,451
  • 7
  • 36
  • 52

2 Answers2

0

while you can composite images any way you want by working with the bitmap data. another easy way to do a lot of this is to create a UIView add all of the images you want to it and then create an image from that uiview.

how to create an image form a UIView:

How to create an image from a UIView / UIScrollView

Community
  • 1
  • 1
madmik3
  • 6,975
  • 3
  • 38
  • 60
0

My solution was to map an image to a path with the use of a bezierPath. See the example code below

UIBezierPath* beizerPath2 = [UIBezierPath bezierPath];
[beizerPath2 moveToPoint:CGPointMake(0.0, 167)];       //Starting Point
[beizerPath2 addLineToPoint:CGPointMake(100, 40)];  
[beizerPath2 addLineToPoint:CGPointMake(200, 70)];    
[beizerPath2 addLineToPoint:CGPointMake(300, 30)];    
[beizerPath2 addLineToPoint:CGPointMake(320, 30)];    
[beizerPath2 addLineToPoint:CGPointMake(320, 167)];     //Finishing Point
[beizerPath2 closePath];                                //Close Path


NSLog(@"Masking Feedstock with Bezier");
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.path = [beizerPath2 CGPath];
graphFeedStock.layer.mask = maskLayer;     
oberbaum
  • 2,451
  • 7
  • 36
  • 52