Sending Color to Specific Location - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Works in Progress (https://staging.qb64phoenix.com/forumdisplay.php?fid=9) +---- Thread: Sending Color to Specific Location (/showthread.php?tid=1287) |
Sending Color to Specific Location - Dimster - 12-16-2022 I was just wondering if there is way to change the color of a value which is displaying on a screen. For example, something like this Screen _NewImage(1900, 900, 32) $Color:32 A$ = "5" Color White _PrintString (100, 100), A$ Color Green _printstring (100,100), color green So the value 5 is displaying on the screen in white however, later on in the program I want that value to pop out if certain conditions apply. Present coding requires a complete repeat of the value plus the new color but if I just want to change the color only at that same location doesn't appear color only can be changed? or might there be a way??? RE: Sending Color to Specific Location - SMcNeill - 12-16-2022 Something simple like this? Code: (Select All) Screen _NewImage(640, 480, 32) RE: Sending Color to Specific Location - mnrvovrfc - 12-16-2022 That's in the spirit of the holiday season! I was going to change it so it drew a candy cane of text and changed from white to red and green. I was going to propose "POINT()" but that's unreliable. This program should be studied carefully by beginners before they have anything to do with the "_MEM" functions. RE: Sending Color to Specific Location - Dimster - 12-16-2022 Thank you RE: Sending Color to Specific Location - Pete - 12-16-2022 Stay in SCREEN 0 from now on. It has PALETTE, which makes doing these types of color alterations much more... PALETTEable. Pete RE: Sending Color to Specific Location - SMcNeill - 12-16-2022 (12-16-2022, 04:44 PM)mnrvovrfc Wrote: That's in the spirit of the holiday season! Here's the main thing people need to learn to do with _MEM: Code: (Select All) For y = y1 * _Width * 4 To y2 * _Width * 4 Step _Width Take the math OUT of the processing loop!! Most of the time, you see people with something such as: FOR y = y1 TO y2 FOR x = x1 TO x2 IF _MEMGET(m, m.offset + y * 4 * _WIDTH + x * 4, _UNSIGNED LONG) = OldColor THEN _MEMPUT m, m.offst + 4 * _WIDTH + x * 4, NewColor ... And that's a LOT of math to process inside that loop, which ends up making the mem routines get to the point where they're barely better than POINT and PSET with a plain x/y value. If you notice, my whole math formula is a simple: o = m.OFFSET + y + x That's a LOT less calculations than my previous example up there -- and it's going to be done over and over and over inside that loop! RE: Sending Color to Specific Location - SMcNeill - 12-16-2022 (12-16-2022, 05:12 PM)Pete Wrote: Stay in SCREEN 0 from now on. It has PALETTE, which makes doing these types of color alterations much more... PALETTEable. Problem with that is it changes *ALL* instances of that color on your screen, and not just a select few which you might want to "pop out" to highlight for others, for whatever reason. RE: Sending Color to Specific Location - Pete - 12-16-2022 That's why I reserve certain ugly ASCII colors like 5 for this purpose. Code: (Select All) PALETTE 5, 63 Pete I'm not only a genius on the Internet, I also play one in real life! |