Re: How to draw text with fade out effect?

2009-02-08 Thread Oleg Krupnov
Wow, Ken! It works like magic (the second method I mean). Thank you very much. I think I would never guess it myself. For those who will reuse this code, don't forget to save/restore the graphics context because CGContextClipToMask modified the clipping region. Sorry for late thanking, I had to p

Re: How to draw text with fade out effect?

2009-02-01 Thread Kyle Sluder
On Sun, Feb 1, 2009 at 4:35 AM, Benjamin Dobson wrote: > Am I missing something or could you use an NSGradient object to do this? Sure, if you used a gradient or solid color to draw the background in the first place. Just give the starting color an alpha of 0 and the ending color an alpha of 1.

Re: How to draw text with fade out effect?

2009-02-01 Thread Benjamin Dobson
On 29 Jan 2009, at 06:32:45, Kyle Sluder wrote: Perhaps the better solution is to draw the text as normal and then re-draw the background with the appropriate alpha on top. Am I missing something or could you use an NSGradient object to do this? ___

Re: How to draw text with fade out effect?

2009-01-31 Thread Ken Ferry
All else aside, yes you can do this in Cocoa and/or Quartz. Here are a couple different ways. For instruction's sake, here's it done with a compositing operation, NSCompositeDestinationIn. Result color = what's already in the context but with additional alpha taken from the new drawing. - (void)

Re: How to draw text with fade out effect?

2009-01-30 Thread Douglas Davidson
On Jan 29, 2009, at 5:08 PM, Peter N Lewis wrote: One option is to draw the end of the string character by character with varying alphas. Glyph by glyph, really, in the general case. You can take a look at the CircleView example for one case of drawing strings glyph by glyph-- with diffe

Re: How to draw text with fade out effect?

2009-01-29 Thread Peter N Lewis
At 17:38 +0200 28/1/09, Oleg Krupnov wrote: I want to produce the effect of a text string fading out when it's too long to be displayed in a rect. This kind of effect is used in many apps. One option is to draw the end of the string character by character with varying alphas. Ie, instead of

Re: How to draw text with fade out effect?

2009-01-29 Thread matt . gough
On 29 Jan 2009, at 09:33, Rob Keniger wrote: On 29/01/2009, at 6:27 PM, Oleg Krupnov wrote: Yeah, the question is however how do I technically (e.g. in Cocoa) composite the "appropriate alpha" with an image, whether the background image, as you suggest, or with text image, as Ricky suggested

Re: How to draw text with fade out effect?

2009-01-29 Thread Rob Keniger
On 29/01/2009, at 6:27 PM, Oleg Krupnov wrote: Yeah, the question is however how do I technically (e.g. in Cocoa) composite the "appropriate alpha" with an image, whether the background image, as you suggest, or with text image, as Ricky suggested. AFAIU, there is not such NSCompositingOperati

Re: How to draw text with fade out effect?

2009-01-29 Thread Oleg Krupnov
Yeah, the question is however how do I technically (e.g. in Cocoa) composite the "appropriate alpha" with an image, whether the background image, as you suggest, or with text image, as Ricky suggested. AFAIU, there is not such NSCompositingOperation to do this trick. It appears that I need to iter

Re: How to draw text with fade out effect?

2009-01-28 Thread Quincey Morris
On Jan 28, 2009, at 22:32, Kyle Sluder wrote: On Wed, Jan 28, 2009 at 10:57 AM, Thomas Davie wrote: This solution will also throw sub-pixel anti-aliasing in the bin. Perhaps the better solution is to draw the text as normal and then re-draw the background with the appropriate alpha on top.

Re: How to draw text with fade out effect?

2009-01-28 Thread Kyle Sluder
On Wed, Jan 28, 2009 at 10:57 AM, Thomas Davie wrote: > This solution will also throw sub-pixel anti-aliasing in the bin. Perhaps the better solution is to draw the text as normal and then re-draw the background with the appropriate alpha on top. --Kyle Sluder ___

Re: How to draw text with fade out effect?

2009-01-28 Thread Oleg Krupnov
Sounds interesting, but how do I technically "composite the image with the mask"? Also I'm not sure I understand the resolution issues you mentioned. Could you please give a little bit more detail? Thanks! On Wed, Jan 28, 2009 at 5:49 PM, Ricky Sharp wrote: > You could render your text to an i

Re: How to draw text with fade out effect?

2009-01-28 Thread Thomas Davie
On 28 Jan 2009, at 16:49, Ricky Sharp wrote: You could render your text to an image first, composite it with the opaque-to-transparent mask and finally draw the result. I used to create images from text, but I ended up with issues regarding resolution independence for some reason. So, you

Re: How to draw text with fade out effect?

2009-01-28 Thread Ricky Sharp
You could render your text to an image first, composite it with the opaque-to-transparent mask and finally draw the result. I used to create images from text, but I ended up with issues regarding resolution independence for some reason. So, you may need to test this solution with RI if need

How to draw text with fade out effect?

2009-01-28 Thread Oleg Krupnov
I want to produce the effect of a text string fading out when it's too long to be displayed in a rect. This kind of effect is used in many apps. My first solution was to simply draw the text and then on top of it draw a gradient fill ranging from the fully transparent color to the background color