|
Post by MrHiggins on Aug 24, 2021 13:48:55 GMT
Hi, I'm experimenting with JustBasic and have been playing around with the graphics window. I have this basic example from the documentation. open "I'm a graphics window!" for graphics as #g print #g, "home ; down" print #g, "fill green" print #g, "circle 100" wait
This shows a graphics window in a green colour and a circle. I have noticed when the window is resized it clears the drawn content? I have also noticed when the window is moved partially off screen then brought back into view, the obscured area of the window is cleared?
I am guessing I need to handle these conditions in my code? Many Thanks
|
|
|
Post by tsh73 on Aug 24, 2021 14:08:16 GMT
You need to add #g "flush" after drawing stuff. alycesrestaurant.com/lbpe/FastFAQ.htmlGraphics I am not going to explain this "long and sad tail", but: * drawind ln JB/LB stores graphic commands issued (and it could exhaust the memory) * if you draw a lot you will see it slows down (you will likely see it if you fill graphicbox point by point) * if you do "flush" it kind of "stored" ' then after minimising/restoring windows it will be redrawn 'else it disappear (as you just have seen) Issuing "discard" leaves picture on-screen but clears that memory (no redraw possible) (issuing Discard every few hundred of graphic ops speed things up, but at cost of possible redraw) Issuing "cls" clears memory and picture If you grab screen (getbmp) then (cls) (drawbmp) (flush), you could have redraw-able picture with only BMP-worth memory used One more tip - then issuing drawing command in JB/LB, you actually send text string with a command 1) if you omit handle, you will print it to a mainwin and see what's up (typoos, missing spaces) 2) obviously that text string is deciphered back by graphicbox. If you have fractional x - and you pass numbers in the command as int(x) instead of x, drawing works a bit FASTER I believe details are here alycesrestaurant.com/lbpe/Graphic%20Segments.htmlSegments concept is unique to LB as I've seen.
|
|
|
Post by MrHiggins on Aug 24, 2021 14:14:50 GMT
Thanks tsh73 that seems to fix it.
|
|
|
Post by Rod on Aug 24, 2021 18:54:09 GMT
Without getting too involved, a simple flush command “fixes” the graphics. You just need to be aware that you cannot keep flushing if you are drawing repetitively. A one off flush is nice and easy. If you plan to redraw repetitively you need to think about deleting obsolete or unused segments. Again easy with delsegment.
|
|
|
Post by MrHiggins on Aug 25, 2021 5:53:15 GMT
Thanks Rod for the tip. I been learning JustBasic a bit all over the place by reading mostly the main documentation instead of the tutorial and then experimenting. I noticed there is also a section in the tutorial that mentions flush, so I probably should have started with the tutorial
|
|