cocoa touch - Changing colors with CGContextStrokePath -
I am trying to draw some simple lines with the iPhone / Touch SDK. I want to be able to change the colors of the lines, but CGContextSetRGBStrokeColor does not affect the lines created with CGContextAddLineToPoint to make the actual call to the CGContactStroke path to call. So if I make more than one call to change the color, then only the CCCTontaxStrakatha has any effect. Here's what I mean:
- (zero) direct: (CGRText) {CGContextRef ctx = UIGraphicsGetCurrentContext (); CGContextMoveToPoint (CTX, 0, 0); CGContextSetRGBStrokeColor (ctx, 1,0,0,1); CGContextAddLineToPoint (CTX, 100, 100); // CGContextStrokePath (ctx); CGContextSetRGBStrokeColor (ctx, 0,1,0,1); CGContextAddLineToPoint (CTX, 200, 300); // CGContextStrokePath (ctx); CGContextSetRGBStrokeColor (ctx, 0,0,1,1); CGContextStrokePath (ctx); } I think I am doing something wrong, I just do not know what happened. I thought if I have added CGCTXTrackpath calls, then it would be helpful, it is not so.
How did the discussion given below be found for the right code:
- (zero) direct: (cgttect) rect {CGCTtext RF CTX = UIGACTAT CONTENT CONCESSEX (); CGContextBeginPath (ctx); CGContextMoveToPoint (CTX, 0, 0); CGContextSetRGBStrokeColor (ctx, 1,0,0,1); CGContextAddLineToPoint (CTX, 100, 100); CGContextStrokePath (ctx); CGContextClosePath (ctx); CGContextBeginPath (ctx); CGContextMoveToPoint (CTX, 100, 100); CGContextSetRGBStrokeColor (ctx, 0,1,0,1); CGContextAddLineToPoint (CTX, 200, 300); CGContextStrokePath (ctx); } I do not think you are doing anything wrong, just CGContextStrokePath given a given date. For a given graphics context, there may be only one RGBTR recordrock at a time. As a result, CGContextStrokePath needs to make many calls, once for each color. The reference (not a copy) for graphic reference is added to that stack of drawing functions with each call CGContextAddLineToPoint (). When you finally call CGContextStrokePath (), the last value is used for the RGBT stroke collar.
If you want to use multiple colors with the same graphics context, then it seems that you make many calls to CGContextStrokePath () by changing the value of RGBTROCELL () on the graphics reference between calls Is required. The Apple sample code in the excelmeter graph / graphview.m shows this also.
Comments
Post a Comment