[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scrolling text



  Peter Mason <menakkis@my-deja.com> wrote:
> (..without really thinking..)

Oops, sorry Kelly I really botched the DEVICE calls graphics scroll
method there.   I have appended a little test program that demonstrates
this technique, in case you'd like to try it out.   (It does the
honours with a text file.)   The scrolling speed will be affected by
your computer's hardware and will go faster with 8-bit colour depth than
24-bit.   If it scrolls too slowly you could try creating the main
window with RETAIN=0 (always a speed-up) and/or knocking out the WAIT.
I tried it with IDL's true-type fonts and, to my surprise, this slowed
things down a lot on my P2/300 machine - there's a noticeable delay
while each line is rendered with XYOUTS.   But perhaps try this as well
and see what you think.

Cheers
Peter Mason

; ==============================================================
; A little program to demonstrate smooth text scrolling.
; Peter Mason, Dec. 99
; The one and only parameter is the filename of an ASCII
; file - this file gets read and displayed.
pro tscroll,tfile
  if n_elements(tfile) eq 0 then tfile='tscroll.pro'
  t=''
  openr,u,tfile,/get_lun,err=e
  if e ne 0 then return
  gx=512L &gy=320L                   ;main window size
  ty=16L                             ;pixmap window height
  window,0,xsiz=gx,ysiz=gy,retain=1  ;retain=0 for max speed
  window,1,xsiz=gx,ysiz=ty,/pixmap   ;room for 1 line of text
  while not eof(u) do begin
    readf,u,t
    wset,1 &erase
    xyouts,0,3,t,/dev,font=0             ;render the next line
    wset,0
    for j=0L,ty-1L do begin              ;copy the text-line to
      device,copy=[0,0,gx,gy-1,0,1]      ;the main window one
      device,copy=[0,ty-j-1,gx,1,0,0,1]  ;pixel-line at a time
      ;wait,0.02
    endfor
    j=get_kbrd(0)
    if keyword_set(j) then goto,bye      ;escape hatch
  endwhile
bye:
  free_lun,u
  wdelete,1
  return
end


Sent via Deja.com http://www.deja.com/
Before you buy.