What color is that text?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Menotu

What color is that text?

Post by Menotu »

Is there a way to tell what color a certain letter is. For example, if I printed a sentence like "Hello World!" (for lack of imagintaion) with "Hel" being one color, "lo Wo" another, and "rld!" a third color, would I be able to figure out which string was, let's say, red?
User avatar
Levi
Veteran
Posts: 79
Joined: Tue Jul 27, 2004 11:44 pm
Location: Alone and forgotten
Contact:

Yes...

Post by Levi »

actually I believe you good. Using the screen function you can get the characters from any position on the screen using rows and columns of course. Now knowing what screen you are using, 12 13 ect. you can know how big in pixles the character boxes are. Then knowing the position in rows and columns of text you want to look at you can caluclate the pixels of the letters. From there there is a function of sometype that gets a single pixel color. I haven't used it in a long time so I don't know the name. but that is the general idea that I came up with to do it. Good luck.
Later days,
Matthew

May those who love us love us
And those who don't
May the good Lord turn their hearts
And if he doesn't
May he turn their ankles
So we'll know them by their limping
-Irish prayer
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Re: Yes...

Post by Nodtveidt »

Levi wrote:From there there is a function of sometype that gets a single pixel color. I haven't used it in a long time so I don't know the name.
There are two ways of doing this:

BIOS method (POINT routine) [slow]
Direct video memory method (PEEK routine, with DEF SEG to &HA000) [faster]
User avatar
Pete
Site Admin
Posts: 887
Joined: Sun Dec 07, 2003 9:10 pm
Location: Candor, NY
Contact:

Post by Pete »

Even if you know the (x,y) position of the ASCII character, you're gonna have to check several different points before you actually hit one that is colored rather than the black background. In the characters that show up on screen, there's generally more empty space than actual "character." It's pretty hit and miss...kinda like playing Battleship or something.

The best way is probably to start in the upper left and just check through each point, one by one. (Or maybe start at the bottom left corner, since a ton of characters--commas, lowercase letters, periods, etc.--are mostly in the lower region of the ASCII character's "sprite".


It seems to me like there's an easier way to do this...the color data for every letter has to be stored in the memory somewhere...though I can't think of an alternate method.
Post Reply