• 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: How to draw text with fade out effect?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to draw text with fade out effect?


  • Subject: Re: How to draw text with fade out effect?
  • From: Peter N Lewis <email@hidden>
  • Date: Fri, 30 Jan 2009 10:08:33 +0900

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

Hello Cruel Wo...

draw

Hello Cruel Wo

then draw r at 75% alpha
then draw l at 50% alpha
then draw d at 25% alpha.

If you really want finer control, you could use a narrow clipping rect, which would also let you draw the entire string ten times with different alphs and different clipping rects, assuming that performance did not become a problem. The code would actually be pretty straight forward:

Clip to width -20
Draw string
Clip from width-20 to width -18
Draw string at Alpha 90%
Clip from width-18 to width-16
Draw string at Alpha 80%
...

Your code doesn't even have to consider if the string is long enough to need truncating.

Enjoy,
   Peter.

--
              Keyboard Maestro 3 Now Available!
   Now run macros from your iPhone with Keyboard Maestro Control!

Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/>           <http://download.stairways.com/>
_______________________________________________

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


  • Follow-Ups:
    • Re: How to draw text with fade out effect?
      • From: Douglas Davidson <email@hidden>
References: 
 >How to draw text with fade out effect? (From: Oleg Krupnov <email@hidden>)

  • Prev by Date: Re: URL Parsing
  • Next by Date: Newbie question.
  • Previous by thread: Re: How to draw text with fade out effect?
  • Next by thread: Re: How to draw text with fade out effect?
  • Index(es):
    • Date
    • Thread