FROM : David Duncan
DATE : Mon Apr 14 21:24:00 2008
On Apr 13, 2008, at 12:01 AM, Greg Sabo wrote:
> Ah! It compiled. Thank you very much! And thanks to Michael for
> putting
> together the sample project.
>
> Now to get the CALayer to draw a path. Most of the documentation
> I've seen
> suggest to do this with a delegate function, is that correct? Here
> is the
> delegate function I've written (a.k.a. copied from another program):
>
> //
> ********************************************************************************
> - (void)drawLayer:(CALayer *)theLayer
> inContext:(CGContextRef)theContext {
> CGMutablePathRef thePath = CGPathCreateMutable();
>
> CGPathMoveToPoint(thePath,NULL,15.0f,15.f);
> CGPathAddCurveToPoint(thePath,
> NULL,
> 15.f,250.0f,
> 295.0f,250.0f,
> 295.0f,15.0f);
>
> CGContextBeginPath(theContext);
> CGContextAddPath(theContext, thePath );
>
> CGContextSetLineWidth(theContext, 1);
>
> CGContextSetRGBStrokeColor(theContext,0.0,0.0,1.0,1.0);
>
>
> CGContextStrokePath(theContext);
> }
> //******************************************************
>
> I'm just seeing the black background right now.
> Again, thanks for your help and sorry I'm such a pain :)
Note that this code (by itself) leaks, the mutable path your creating
is never released (in this snippet). You actually don't need to do
this anyway, you can use CGContextMoveToPoint/CGContextAddCurveToPoint/
etc instead and not have to worry about the memory management issue
that using CGPath brings up.
--
David Duncan
Apple DTS Animation and Printing
david.<email_removed>
DATE : Mon Apr 14 21:24:00 2008
On Apr 13, 2008, at 12:01 AM, Greg Sabo wrote:
> Ah! It compiled. Thank you very much! And thanks to Michael for
> putting
> together the sample project.
>
> Now to get the CALayer to draw a path. Most of the documentation
> I've seen
> suggest to do this with a delegate function, is that correct? Here
> is the
> delegate function I've written (a.k.a. copied from another program):
>
> //
> ********************************************************************************
> - (void)drawLayer:(CALayer *)theLayer
> inContext:(CGContextRef)theContext {
> CGMutablePathRef thePath = CGPathCreateMutable();
>
> CGPathMoveToPoint(thePath,NULL,15.0f,15.f);
> CGPathAddCurveToPoint(thePath,
> NULL,
> 15.f,250.0f,
> 295.0f,250.0f,
> 295.0f,15.0f);
>
> CGContextBeginPath(theContext);
> CGContextAddPath(theContext, thePath );
>
> CGContextSetLineWidth(theContext, 1);
>
> CGContextSetRGBStrokeColor(theContext,0.0,0.0,1.0,1.0);
>
>
> CGContextStrokePath(theContext);
> }
> //******************************************************
>
> I'm just seeing the black background right now.
> Again, thanks for your help and sorry I'm such a pain :)
Note that this code (by itself) leaks, the mutable path your creating
is never released (in this snippet). You actually don't need to do
this anyway, you can use CGContextMoveToPoint/CGContextAddCurveToPoint/
etc instead and not have to worry about the memory management issue
that using CGPath brings up.
--
David Duncan
Apple DTS Animation and Printing
david.<email_removed>
| Related mails | Author | Date |
|---|---|---|
| Greg Sabo | Apr 13, 01:58 | |
| Michael Vannorsdel | Apr 13, 02:36 | |
| Greg Sabo | Apr 13, 08:17 | |
| Michael Watson | Apr 13, 08:29 | |
| Michael Watson | Apr 13, 08:51 | |
| Greg Sabo | Apr 13, 09:01 | |
| Michael Vannorsdel | Apr 13, 10:27 | |
| Scott Anguish | Apr 14, 01:13 | |
| David Duncan | Apr 14, 21:24 | |
| Greg Sabo | Apr 15, 02:22 | |
| Greg Sabo | Apr 15, 02:26 | |
| Michael Vannorsdel | Apr 15, 04:23 | |
| Greg Sabo | Apr 16, 00:49 | |
| Michael Vannorsdel | Apr 16, 00:58 | |
| Scott Anguish | Apr 16, 07:17 |






Cocoa mail archive

