Skip navigation.
 
mlRe: Basic Core Animation question
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>

Related mailsAuthorDate
mlBasic Core Animation question Greg Sabo Apr 13, 01:58
mlRe: Basic Core Animation question Michael Vannorsdel Apr 13, 02:36
mlRe: Basic Core Animation question Greg Sabo Apr 13, 08:17
mlRe: Basic Core Animation question Michael Watson Apr 13, 08:29
mlRe: Basic Core Animation question Michael Watson Apr 13, 08:51
mlRe: Basic Core Animation question Greg Sabo Apr 13, 09:01
mlRe: Basic Core Animation question Michael Vannorsdel Apr 13, 10:27
mlRe: Basic Core Animation question Scott Anguish Apr 14, 01:13
mlRe: Basic Core Animation question David Duncan Apr 14, 21:24
mlRe: Basic Core Animation question Greg Sabo Apr 15, 02:22
mlRe: Basic Core Animation question Greg Sabo Apr 15, 02:26
mlRe: Basic Core Animation question Michael Vannorsdel Apr 15, 04:23
mlRe: Basic Core Animation question Greg Sabo Apr 16, 00:49
mlRe: Basic Core Animation question Michael Vannorsdel Apr 16, 00:58
mlRe: Basic Core Animation question Scott Anguish Apr 16, 07:17