User Tools

Site Tools


drawing_20outside_20the_20window

Drawing outside the window

by Richard Russell, December 2006

When you initialise BBC BASIC's output window using MODE or VDU 23,22 not only is the window's size set to the appropriate dimensions but the graphics viewport is also initialised to the same area. This is done for reasons of efficiency, so BB4W doesn't waste time drawing graphics outside of the window where they cannot be seen. This is particularly true of statements like CLG and FILL which could otherwise spend a considerable amount of time unnecessarily clearing or filling large areas outside the window.

However this may not always be what you want. The user can (usually) resize the window by dragging a side or corner, or by clicking on the maximise button. In normal circumstances if he does so he will simply reveal areas of black, because the graphics viewport will have prevented anything being drawn in those areas. If you want him to be able to reveal more graphics it is necessary to change the viewport to make it possible to draw there.

In principle this is straightforward, using the VDU 24 command, but it is quite easy to get the coordinates wrong. Suppose you have selected “MODE 8” but you want to be able to draw graphics over an area corresponding to a 1024 x 768 pixel display. Since you can only enlarge BBC BASIC's window by extending it at the right or the bottom (i.e. the displayed region must be in the top left corner of the larger area) this is the situation you end up with:



The shaded area corresponds to the “MODE 8” window, with its normal range of graphics coordinates from 0,0 in the bottom left corner to 1278,1022 in the top right corner. The unshaded area corresponds to the maximum size to which the window could be enlarged by the user, assuming a 1024 x 768 display (remember that there are two BBC BASIC graphics coordinates per pixel).

Therefore the appropriate command for enlarging the graphics viewport, to allow drawing over the entire area, is:

        VDU 24,0;-512;2046;1022;

which might not have been obvious at first sight.

If you prefer that the origin of the graphics coordinates should be at the bottom left corner of the unshaded area you can achieve that using the ORIGIN statement:

        ORIGIN 0,-512
        VDU 24,0;0;2046;1534;
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
drawing_20outside_20the_20window.txt · Last modified: 2024/01/05 00:22 by 127.0.0.1