• 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: Scrolling Text Algorithm for a Screen Saver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scrolling Text Algorithm for a Screen Saver


  • Subject: Re: Scrolling Text Algorithm for a Screen Saver
  • From: Alastair Houghton <email@hidden>
  • Date: Mon, 30 Oct 2006 12:26:54 +0000

On 30 Oct 2006, at 09:34, Doug Fort wrote:

Hi,

I'm working on a screen saver. It involves scrolling text across the
screen. I'm using the simplest algorithm I could  think of: calls to
NSString drawAtPoint:withAttributes: with the point moving a fixed
offset at each call to animateOneFrame. This works Ok at low scrolling
speeds, but at higher speeds (i.e. a larger offset), the motion
appears jerky.

I'm working on improving my code to minimize the amount of computation
in animateOneFrame. However, if anyone can suggest a better algorithm
for scrolling text, I'd appreciate it.

Using NSString's drawing methods will be inefficient because it will re-do the text layout every time. You should probably look at using the Cocoa Text system's NSLayoutManager object to do the layout once and then you can render the string over and over again with much lower overhead.


An alternative to that might be to render it once into a bitmap, and scroll the bitmap across the display instead. That approach would also mean you could use OpenGL if you wanted rather than Quartz.

Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Scrolling Text Algorithm for a Screen Saver
      • From: Ricky Sharp <email@hidden>
References: 
 >Scrolling Text Algorithm for a Screen Saver (From: "Doug Fort" <email@hidden>)

  • Prev by Date: Re: Object allocation question
  • Next by Date: Re: Question regarding NSView's drawRect
  • Previous by thread: Scrolling Text Algorithm for a Screen Saver
  • Next by thread: Re: Scrolling Text Algorithm for a Screen Saver
  • Index(es):
    • Date
    • Thread