Is it possible to check color code of chars on the text screen?
Root / Programming Questions / [.]
MZ952Created:
If you don't mind using the Graphics layer instead of a Text layer, you could use GPUTCHR to write text and GPGET in conjunction with a 2D loop to tell what color it is
You CAN in SB4, but for some reason it's more complicated than it needs to be. They expanded CHKCHR to also return display attributes, but not color, so you have to refer to TSAVE or TARRAY to do that.
'option 1 DEF CHRCOL(S%, X%, Y%) RETURN TARRAY(S%)[Y%,X%*2+1] END 'option 2 DEF CHRCOL(S%, X%, Y%) DIM T%[2] TSAVE S%, X%, Y%, 1, 1, T% RETURN T%[1] END
This might be a bit over the top for a text editor... But you could use a screen full of 8x8 sprites instead of the text layer. Where each sprite can be any character or blank space.
Probably too ridiculous, but it would mean that you could animate each letter individually, as well as get and set their color on the fly.
This might be a bit over the top for a text editor... But you could use a screen full of 8x8 sprites instead of the text layer. Where each sprite can be any character or blank space. Probably too ridiculous, but it would mean that you could animate each letter individually, as well as get and set their color on the fly.I... was just thinking about this. It might be worth exploring. I would need to create a mock text screen using either:
- Individual 8x8 sprites or;
- A 400x240 sprite displaying part of the sprite page
- Of the 512 available sprites, dynamically allocate sprite management numbers to represent certain common chars visible on screen
Other than that, you could build a 2D array in which the RGB values are arranged in a grid. And every time you update the text screen you update the array with the color values.
I know that doesn't satisfy the "without storing it" requirement but it might give you the most functionality for the least amount of work
That's what I started doing. I created a pseudo COLOR function that updated values in an array, based on previous LOCATE params from CSRX, CSRY. But... What I was trying to do was sort of silly in the first place. (I'm not even going to mention it.) So I don't have much use for it anymore.
Spoiler
okay, fine, I was going to use it to take text "screenshots" that my program (text editor) could use to make a cool uh window changing animation.Polish is important, never doubt that. Sometimes a good transition can even help maintain a user's train of thought.
If remembering the colors doesn't work out, you could still have a transition but perhaps immediately on activation it goes grayscale, or bright yellow, or cyan - depending on existing color scheme