DAY 015: PRESET - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Official Links (https://qb64phoenix.com/forum/forumdisplay.php?fid=16) +--- Forum: Learning Resources and Archives (https://qb64phoenix.com/forum/forumdisplay.php?fid=13) +---- Forum: Keyword of the Day! (https://qb64phoenix.com/forum/forumdisplay.php?fid=49) +---- Thread: DAY 015: PRESET (/showthread.php?tid=1157) |
DAY 015: PRESET - SMcNeill - 11-20-2022 Everyone who knows graphics knows PSET. Right? Now, let's be honest -- How many of you guys think that PRESET is just a longhand version of PSET? Same command, just with more typing! After all, what's the difference between these two programs: Code: (Select All) $Color:32 And code 2: Code: (Select All) $Color:32 Stare at both those screens for a while -- try to focus one eye one each of them -- and see how long you can hold out before your brain melts. That's got to be two of the most annoying tiling patterns possible for the human eyes to have to deal with... Just looking at them, I somehow find them jarring and annoying. Yet, as annoying as those two tiling patterns are, they're exactly the same pattern. So how the heck did PRESET behave any different at all from PSET? Quick answer: It didn't. And for most folks, with the way they tend to code explicitly nowadays, it never will. Most folks? Code nowadays?? WTH is Steve talking about now?? Good question! Today's modern coding practices have evolved quite a bit from back in the original days of computing. Variable names are now long and descriptive, whereas in the past they were kept as short as possible to reduce memory usage. Gotos are no longer in widespread use, as modern convention says to structure your programs better with DO..LOOPs and such. Line numbers have faded from the wayside of coding practices... ...and so has the practice of writing code that relies implicitly upon previous settings. For example: Code: (Select All) $Color:32 Most modern programmers would set that PSET to become PSET (x, y), Pink, defining it explicitly in their code. Old code used to use the style above, just to save a few bytes of memory when possible (not something we're so obsessed over with modern machines running 32GB+ of ram). Don't specify a color -- just use the default color... But, now that we have this older style in mind, let's take a look at PRESET: Code: (Select All) $Color:32 If you notice, I cleared the whole screen white. Specified my color to be Pink... and somehow I drew a BLACK box?? WTH?? How'd that happen?? PSET, when no color is specified, defaults to your _DEFAULTCOLOR. PRESET, when no color is specified, defaults to your _BACKGROUNDCOLOR. Add a simple Print "Hello World" to the last program and see what you get -- pink text on a black background. Black is the background color, and thus PRESET plots the points specified in black. And that's the difference in the two commands in a nutshell: PSET defaults to your primary color; PRESET defaults to your background color. As long as you specify the color yourself, they both perform exactly the same. It's only when no color is specified that you'll see the difference in the two commands. RE: DAY 015: PRESET - bplus - 11-20-2022 Fun with Day 015 word: Code: (Select All) _Title "PSet or PReset" ' b+ 2022-11-20 RE: DAY 015: PRESET - mnrvovrfc - 11-20-2022 This is something I had considered a side-effect but could be put to good use, to reduce the number of "COLOR" statements. When I started using GIMP, I was uncomfortable because "X" key has to be pressed to switch back and forth between "foreground" and "background" color, and I never liked its eraser. Only a few days ago that I used that program, the eraser worked like I think it should have; previously, it just ate all color leaving alpha channel alone. I would have liked to know if old computers were as forgiving only about setting points in graphics although there was a tiny amount of memory available for it. The Radio Shack TRS-80 Color Computer, "SET" was the counterpart to "PSET" and held three parameters. But "RESET" (like "PRESET" in Q(uick)BASIC/QB64(PE)) was allowed only two parameters and always set dots to black color. No way around it until the Coco3 was devised and color attributes could be changed with "PALETTE". I'm not familiar with the Extended BASIC graphic modes offered on that computer which had a combination of statements to set up a screen. The "high-resolution" graphics of the Coco3 had statements to set and unset points that followed along that line. It had "HCIRCLE", "HLINE" and others that supported color attribute zero for background color, though. RE: DAY 015: PRESET - PhilOfPerth - 11-20-2022 Thanks Steve, that clarified things for me. I've never really thought deeply about these two, but got the idea that "pset" meant "set" or "turn on" a pixel, while "preset" meant "reset" or turn off a pixel. I guess this is a safe enough assumption for most cases, but it's good to be aware of what's really going on (or off). |