• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CGShading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGShading


  • Subject: Re: CGShading
  • From: Perry Clarke <email@hidden>
  • Date: Sat, 31 Jul 2004 20:16:23 -0700

The best sample code I found for CGShading was "CalendarView": http://developer.apple.com/samplecode/CalendarView/CalendarView.html

All you really need is the code from "ShadeRect.c" and a drawRect (assuming you are using Cocoa) that looks something like:

// Include the code from ShadeRect.c

- (void) drawRect:(NSRect)rect
{
// Shading only works on 10.3 and above (with opacity, at least) and is rather slow unless
// the machine has Quartz Extreme
if (GetOSVersion() >= MAC_OS_X_VERSION_10_3 && hasQuartzExtreme) // or something similar
{
NSRect frame = [self frame];
CGRect cgRect = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);

#ifdef COLOR_SHADING

// Color shading
CGRGB start = { 0.1959, 0.0854, 0.0954 }; // for example
CGRGB end = { 0, 0, 0 };
ShadeRectColor( &start, &end, &cgRect, (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]);

#else

// Grayscale shading
ShadeRect(1.0, 0.0, &cgRect, (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]);

#endif // COLOR_SHADING
}
}

Perry
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Password encryption
  • Next by Date: Re: Password encryption
  • Previous by thread: Re: CGShading
  • Next by thread: Re: Why the rules concerning release?
  • Index(es):
    • Date
    • Thread