Re: Colored Pattern example problems
Re: Colored Pattern example problems
- Subject: Re: Colored Pattern example problems
- From: David Duncan <email@hidden>
- Date: Thu, 23 Dec 2010 09:56:27 -0800
On Dec 23, 2010, at 5:58 AM, FF wrote:
> I copied this example from Apple docs.
Generally the examples are there to show you how to use an API, not necessarily to be complete standalone code. You shouldn't necessarily expect doc examples to compile without doing extra work or cross referencing with another example.
> width, height; //Error: unused variables
I would expect that this is obvious :). Also this isn't an error, its a warning (unless you have warnings are errors turned on).
> static const CGPatternCallbacks callbacks = { 0, &MyDrawPattern, NULL }; //Error: MyDrawPattern undeclared
You need to define the pattern drawing function. This is show in another code example, but for your own purposes you would need to define your own.
> CGContextSetFillPattern (myContext, pattern, &alpha); //Error: arg 3 from incompatible pointer
This is an error in the example, as it declares alpha as a 'float' but the parameter is a CGFloat. This would only come up on 64-bit, where CGFloat is a double, but thats the default configuration now so no surprise you hit it. Looking at the prototype for CGContextSetFillPattern (either in the docs or in the header) would explain what is wrong here however.
If your new to CG, then I would recommend you start with the drawing functions, as patterns are relatively advanced and are based upon those functions.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden