Re: NSAttributedString fill with gradient

2009-12-21 Thread David Duncan
On Dec 19, 2009, at 6:21 PM, BravoBug Software wrote: > [[NSColor selectedMenuItemColor] set]; > NSRectFill(someRect); This works because the selectedMenuItemColor is a pattern that happens to draw a gradient. You could just as easily draw nearly anything with a pattern, and Quartz treats patte

Re: NSAttributedString fill with gradient

2009-12-19 Thread Dave Keck
The method I use goes like this: 1. Create a CGContext (maskContext); 2. Draw the original text into maskContext; 3. Create another CGContext (gradientContext); 4. Use CGContextClipToMask() to mask gradientContext using the CGImage generated from CGBitmapContextCreateImage(maskContext)

Re: NSAttributedString fill with gradient

2009-12-19 Thread Graham Cox
On 20/12/2009, at 1:21 PM, BravoBug Software wrote: >> Why would you even expect that to work? NSGradient is not a colour. At >> present there is no supported attribute for gradients. > > Oh? You might want to let the folks at Apple know that ;) > > [[NSColor selectedMenuItemColor] set]; > NSR

Re: NSAttributedString fill with gradient

2009-12-19 Thread BravoBug Software
> Why would you even expect that to work? NSGradient is not a colour. At > present there is no supported attribute for gradients. Oh? You might want to let the folks at Apple know that ;) [[NSColor selectedMenuItemColor] set]; NSRectFill(someRect); -matt On Thu, Dec 17, 2009 at 3:50 PM, Grah

Re: NSAttributedString fill with gradient

2009-12-19 Thread John C. Randolph
There's a far easier way to do it than that, which is to use compositing instead of clipping. On Dec 17, 2009, at 9:49 PM, Gordon Apple wrote: If you capture the entire laid-out text string as a single Bezier path, then you can fill it with whatever you want -- gradient, image, burning fir

Re: NSAttributedString fill with gradient

2009-12-17 Thread Gordon Apple
If you capture the entire laid-out text string as a single Bezier path, then you can fill it with whatever you want -- gradient, image, burning fire QTMovie, more text, etc. I've done it and it works. Of course, all of that takes a significant amount of effort. In my case, I already had all the

Re: NSAttributedString fill with gradient

2009-12-17 Thread Graham Cox
On 18/12/2009, at 4:31 AM, Chris Purcell wrote: > I've tried setting the gradient as NSForegroundColorAttributeName in the > attributes dictionary when creating the string but as I expected that didn't > work. How would I go about filling the string with a gradient? Why would you even expect t

NSAttributedString fill with gradient

2009-12-17 Thread Chris Purcell
I've tried setting the gradient as NSForegroundColorAttributeName in the attributes dictionary when creating the string but as I expected that didn't work. How would I go about filling the string with a gradient? Thanks! --Chris ___ Cocoa-dev mailing