Scrolled graphics become distorted
Description
When drawing in a graphic-box (or graphics window), the graphics become distorted beyond the default scrolled view. The default scrolled view is the viewable area opened by the scrollbars that do not have limits set in the program.
Example code to demonstrate the bug.
Note the two graphic windows. The left window uses the default vert and horiz limit settings of the vertscrollbar and horizscrollbar commands. The right window uses the optional height and width settings of the vertscrollbar and horizscrollbar commands. Scrolling the right graphic-box either across or down, beyond the default setting, results in distorted graphics and/or graphic text.
WindowWidth = 800
WindowHeight = 600
graphicbox #demo.g1, 20, 20, 350, 500
graphicbox #demo.g2, 410, 20, 350, 500
open "Graphics Glitch Demo" for window as #demo
#demo "trapclose [quit]"
#demo.g1 "vertscrollbar on"
#demo.g1 "horizscrollbar on"
#demo.g2 "vertscrollbar on 0 1350"
#demo.g2 "horizscrollbar on 0 2150"
for i = 1 to 2
h$ = "#demo.g";i
#h$ "down; color black; backcolor white"
' #h$ "place 0 0; boxfilled 2500 1850"
x = 10
for j = 0 to 2400 step 100
#h$ "place ";x;" 20"
#h$ "\";j
#h$ "place ";x + 15;" 50"
#h$ "circle 25"
x = x + 100
next j
y = 20
for j = 0 to 1800 step 100
#h$ "place 10 ";y
#h$ "\";j
#h$ "place 25 ";y + 30
#h$ "circle 25"
y = y + 100
next j
#h$ "flush"
next i
wait
[quit]
close #demo
end
Example to code work around the bug.
To prevent distorted graphics, use the boxfilled command to access the entire area to be viewed before drawing graphics or graphic text.
WindowWidth = 800
WindowHeight = 600
graphicbox #demo.g1, 20, 20, 350, 500
graphicbox #demo.g2, 410, 20, 350, 500
open "Graphics Glitch Workaround" for window as #demo
#demo "trapclose [quit]"
#demo.g1 "vertscrollbar on"
#demo.g1 "horizscrollbar on"
#demo.g2 "vertscrollbar on 0 1350"
#demo.g2 "horizscrollbar on 0 2150"
for i = 1 to 2
h$ = "#demo.g";i
#h$ "down; color black; backcolor white"
' Accessing the entire viewing area with the boxfilled command
' will prevent future drawn graphics from becoming distorted
#h$ "place 0 0; boxfilled 2500 1850"
x = 10
for j = 0 to 2400 step 100
#h$ "place ";x;" 20"
#h$ "\";j
#h$ "place ";x + 15;" 50"
#h$ "circle 25"
x = x + 100
next j
y = 20
for j = 0 to 1800 step 100
#h$ "place 10 ";y
#h$ "\";j
#h$ "place 25 ";y + 30
#h$ "circle 25"
y = y + 100
next j
#h$ "flush"
next i
wait
[quit]
close #demo
end