User Tools

Site Tools


Centering the graphics origin

by Richard Russell, October 2010

The following code will centre the graphics origin both horizontally and vertically, irrespective of the size and shape of the window:

        VDU 26
        IF POS REM SDL thread sync (needed in BBCSDL only)

The reason it works is that after a VDU 26 both the text and graphics viewports fill the entire window (client area). In that case and @vdu.tb% return the width and height of the text viewport in pixels, and since one pixel is equivalent to two BBC BASIC graphics units they also correspond to half the width and half the height of the graphics viewport, respectively. Therefore they are the correct values to use for centering the origin.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
centering_20the_20graphics_20origin.txt · Last modified: 2018/04/13 15:54 by richardrussell