? Is it possible to check color code of chars on the text screen? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Migrating to a new website for SmileBASIC 4

Is it possible to check color code of chars on the text screen?

  • #1 ✎ 405 MZ952 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Third Year My account is over 3 years old Website Reading I like to read books! Hobbies Basically the title. If I COLOR 15,0?"ABC" Is there any way, however extraordinary, to infer the color codes of those chars, or is it lost unless otherwise stored? Posted
  • #2 ✎ 548 HTV04 Forum Leader Hidden Achievements Third Year My account is over 3 years old Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength No, unfortunately you'll have to store the color code. Posted
  • #3 ✎ 405 MZ952 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Third Year My account is over 3 years old Website Reading I like to read books! Hobbies Shoot Posted
  • #4 ✎ 548 HTV04 Forum Leader Hidden Achievements Third Year My account is over 3 years old Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength What are you trying to make? Posted
  • #5 ✎ 98 kantackistan 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 Posted
  • #6 ✎ 405 MZ952 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Third Year My account is over 3 years old Website Reading I like to read books! Hobbies
    What are you trying to make?
    Probably nothing important
    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
    Yeah I know. I was looking for text-screen-specific.
    Posted
  • #7 ✎ 1130 snail_ Power User QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Helper Received for being very helpful around SmileBASIC Source Achievements Amazing Contributor Someone thinks I'm an awesome person who has done so much for the community! Achievements 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 Posted
  • #8 ✎ 98 kantackistan 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. Posted
  • #9 ✎ 405 MZ952 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Third Year My account is over 3 years old Website Reading I like to read books! Hobbies
    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:
    1. Individual 8x8 sprites or;
    2. A 400x240 sprite displaying part of the sprite page
    3. Of the 512 available sprites, dynamically allocate sprite management numbers to represent certain common chars visible on screen
    If you've got a screen full of random chars, that last one is likely to fail. To do the second, I'd need to like GPUTCHR on the sprite page, which, at that point, I might as well not even use sprites but instead regular graphics (which I don't). To do the first option, I'd need probably a combination of option 1 and two. I wouldn't be able to fill a screen full of random char values either way, though.
    Posted Edited by MZ952
  • #10 ✎ 98 kantackistan 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 Posted
  • #11 ✎ 405 MZ952 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Third Year My account is over 3 years old Website Reading I like to read books! Hobbies 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. 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. Posted
  • #12 ✎ 98 kantackistan 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 Posted