User Tools

Site Tools


centering_20the_20graphics_20origin

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
centering_20the_20graphics_20origin [2018/03/31 13:19] – external edit 127.0.0.1centering_20the_20graphics_20origin [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 1: Line 1:
 =====Centering the graphics origin===== =====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:\\ +//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: 
 + 
 +<code bb4w>
         VDU 26         VDU 26
 +        IF POS REM SDL thread sync (needed in BBCSDL only)
         ORIGIN @vdu.tr%,@vdu.tb%         ORIGIN @vdu.tr%,@vdu.tb%
 +</code>
 +
 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 **@vdu.tr%** 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. 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 **@vdu.tr%** 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.
centering_20the_20graphics_20origin.1522502347.txt.gz · Last modified: 2024/01/05 00:18 (external edit)