converting_20graphics_20coordinates
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
converting_20graphics_20coordinates [2018/03/31 13:19] – external edit 127.0.0.1 | converting_20graphics_20coordinates [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
=====Converting graphics coordinates===== | =====Converting graphics coordinates===== | ||
- | //by Richard Russell, January 2007//\\ \\ If your program outputs its graphics using only BBC BASIC graphics statements then all the coordinates need to be supplied in BBC BASIC units, that is (0,0) is at the bottom left-hand corner of the graphics viewport and each pixel corresponds to //two// graphics units. Positive X is to the right and positive Y is upwards, as is conventional for graphs.\\ \\ If your program outputs its graphics using only Windows API (GDI) functions then all the coordinates need to be supplied in Windows units, that is (0,0) is at the top left-hand corner of your window' | + | //by Richard Russell, January 2007//\\ \\ If your program outputs its graphics using only BBC BASIC graphics statements then all the coordinates need to be supplied in BBC BASIC units, that is (0,0) is at the bottom left-hand corner of the graphics viewport and each pixel corresponds to //two// graphics units. Positive X is to the right and positive Y is upwards, as is conventional for graphs.\\ \\ If your program outputs its graphics using only Windows API (GDI) functions then all the coordinates need to be supplied in Windows units, that is (0,0) is at the top left-hand corner of your window' |
+ | |||
+ | <code bb4w> | ||
DEF PROCconvertBBCtoGDI(RETURN X%,RETURN Y%) | DEF PROCconvertBBCtoGDI(RETURN X%,RETURN Y%) | ||
+ | IF POS REM SDL thread sync (needed in BBCSDL only) | ||
X%=(X%+@vdu%!0)DIV2: | X%=(X%+@vdu%!0)DIV2: | ||
ENDPROC | ENDPROC | ||
DEF PROCconvertGDItoBBC(RETURN X%,RETURN Y%) | DEF PROCconvertGDItoBBC(RETURN X%,RETURN Y%) | ||
+ | IF POS REM SDL thread sync (needed in BBCSDL only) | ||
X%=X%*2-@vdu%!0: | X%=X%*2-@vdu%!0: | ||
ENDPROC | ENDPROC | ||
- | For consistent results you should ensure that the BBC BASIC graphics coordinates (and the ORIGIN coordinates) are //even// numbers.\\ \\ An alternative approach to converting BBC BASIC units to Windows units, if you don't mind moving the current ' | + | </ |
+ | |||
+ | For consistent results you should ensure that the BBC BASIC graphics coordinates (and the ORIGIN coordinates) are //even// numbers.\\ \\ An alternative approach to converting BBC BASIC units to Windows units, if you don't mind moving the current ' | ||
+ | |||
+ | <code bb4w> | ||
MOVE xBBC%,yBBC% | MOVE xBBC%,yBBC% | ||
+ | IF POS REM SDL thread sync (needed in BBCSDL only) | ||
xGDI% = @vdu.l.x% | xGDI% = @vdu.l.x% | ||
yGDI% = @vdu.l.y% | yGDI% = @vdu.l.y% | ||
+ | </ | ||
+ | |||
\\ Note that these routines are appropriate for use with GDI functions which take integer (pixel) coordinates. They should not be used with **GDI Plus** antialiased graphics, which can take non-integer coordinates. The [[http:// | \\ Note that these routines are appropriate for use with GDI functions which take integer (pixel) coordinates. They should not be used with **GDI Plus** antialiased graphics, which can take non-integer coordinates. The [[http:// |
converting_20graphics_20coordinates.1522502351.txt.gz · Last modified: 2024/01/05 00:18 (external edit)