327 posts
Location
Julfander Squad Studio
Posted 19 October 2017 - 03:38 PM
I just thought about which function I would use to draw some textures; term.blit or something like
paintutils.setBackgroundColor()
paintutils.setTextureColor()
term.write()
the wiki says
Although it is no faster than term.write() in its own right, in some circumstances it can reduce code length and speed execution by removing the need to make multiple term.setTextColor() / term.setBackgroundColor() calls.
but what are the 'circumstances'?
I loop through 100 draws.
Edited on 19 October 2017 - 01:43 PM
3057 posts
Location
United States of America
Posted 19 October 2017 - 04:14 PM
blit is (IIRC) slightly slower than term.write. The ratio of setBackgroundColor / setTextColor calls to term.write calls will determine at what point it is faster to use setBackgroundColor / setTextColor vs term.blit.
For example, blit would be a terrible way to clear the screen whereas the other method would be a terrible way to draw a buffer with unknown content.
7083 posts
Location
Tasmania (AU)
Posted 20 October 2017 - 01:43 AM
I couldn't spot any measurable speed difference between write / blit. It wouldn't greatly surprise me if using blit to clear the screen is faster than using write, simply because it'd make a single setBackgroundColour call redundant.
(clear is obviously the "best" choice for that particular goal, but hey.)
467 posts
Location
Van Diemen's Land
Posted 20 October 2017 - 05:52 AM
The worst thing when it comes to 100 draws in an indefinite loop is having the frame constantly flash with screen updates, so it makes sense to look for the fastest way. I'm trying my hardest to make my web browser only updates certain parts of the screen by either clearing a whole line at one time or clearing just a bit with 'print()' or something like that. Looks way nicer, especially if you have multiple windows (I have one for the web browser itself and another for the page, because the page is obviously a 'separate' bit of code that's a UI).