User Tools

Site Tools


speeding_20up_20graphics_20plotting

Speeding up graphics plotting

by Richard Russell, December 2013

You may occasionally find that plotting graphics in LBB is a little slower than in LB 4.04; this results from the overhead of the emulator. This can often be resolved by sending fewer, longer, graphics commands.

For example this code runs noticeably more slowly in LBB:

      #gr "place ";x;" ";y
      for i = 1 to len(rest$) step 2
          x1=asc(mid$(rest$,i,  1))-34-45
          y1=asc(mid$(rest$,i+1,1))-34-45
          x=x+x1
          y=y+y1
          #gr "goto ";x;" ";y
      next

But this simple modification makes it run more quickly in LBB than in LB4.04:

      gr$ = "place ";x;" ";y;";"
      for i = 1 to len(rest$) step 2
          x1=asc(mid$(rest$,i,  1))-34-45
          y1=asc(mid$(rest$,i+1,1))-34-45
          x=x+x1
          y=y+y1
          gr$ = gr$;"goto ";x;" ";y;";"
      next
      #gr gr$

Here the graphics commands have been concatenated into a single string gr$ which is then output as a single statement.

Any number of graphics commands, within reason, can be concatenated into a single string, with the exception that a text output command (if any) must be the last thing in the string. So, when possible, the best performance will be achieved by outputting text only after everything else has been drawn, to maximise the number of commands than can be combined in a single string.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
speeding_20up_20graphics_20plotting.txt · Last modified: 2024/01/05 00:21 by 127.0.0.1