BBC BASIC for Windows
Programming >> Graphics and Games >> Graphics Cursor Position
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1321708667

Graphics Cursor Position
Post by JB91 on Nov 19th, 2011, 12:17pm

How do you detect what character there is in a certain position, but the text is written at the graphics cursor position, not the text cursor position?
GET doesn't work... sad
Re: Graphics Cursor Position
Post by admin on Nov 19th, 2011, 4:40pm

on Nov 19th, 2011, 12:17pm, JB91 wrote:
How do you detect what character there is in a certain position, but the text is written at the graphics cursor position, not the text cursor position?
GET doesn't work... sad

Simple answer - you can't!

More complicated answer - sometimes you can, but not always! If you know the coordinates at which a character was plotted you can convert them to a text row and column (you need to take into account the current ORIGIN, the height of the graphics viewport, the average width and height of the currently selected font etc.). Having got a corresponding row and column you can use GET(x,y) which may return the character.

However it's not reliable, because (with a proportional-spaced font) at least two narrow characters (e.g. a lowercase ij) will fit in the width of a single text 'column'. So GET(x,y) can only return a single character, not both of them.

If you happen to be plotting a monospaced font in VDU 5 mode (which is not particularly common) then you should in principle be able to read the text back reliably using GET so long as you can calculate the corresponding row and column accurately (this assumes that the text viewport and the graphics viewport are overlapping).

Richard.