Setting Line _RGB colours - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Setting Line _RGB colours (/showthread.php?tid=3192) Pages:
1
2
|
Setting Line _RGB colours - PhilOfPerth - 11-03-2024 How can I convert this line: Line (H, V)-(H+ 37, V+ 38), _RGB(200, 200, 200), BF to set the _RGB colour to a colour in a sub, instead of this fixed colour? (I'm using a _NewImage 32-bit screen) Sub Red might contain Color: _RGB(255,0,0) RE: Setting Line _RGB colours - bplus - 11-03-2024 Code: (Select All) Sub myBox (H, V, K As _Unsigned Long) demo Code: (Select All) Screen _NewImage(800, 600, 32) RE: Setting Line _RGB colours - ahenry3068 - 11-03-2024 (11-03-2024, 12:46 AM)PhilOfPerth Wrote: How can I convert this line: The _RGB(r,g,b) function returns a long. You can pass that in as a parameter to the function SUB Myline(MyColor&) Line (H, V)-(H+ 37, V+ 38), MyColor&, BF END SUB RE: Setting Line _RGB colours - PhilOfPerth - 11-03-2024 (11-03-2024, 12:53 AM)bplus Wrote:Thanks bplus; I knew you'd come through! RE: Setting Line _RGB colours - bplus - 11-03-2024 Henry is right for _RGB() you may only need long because you don't have transparent colors. _Unsigned Long covers all color bases _RGB() and _RGB32(). I recommend _RGB32() because it is very versatile. RE: Setting Line _RGB colours - PhilOfPerth - 11-03-2024 (11-03-2024, 12:54 AM)ahenry3068 Wrote:(11-03-2024, 12:46 AM)PhilOfPerth Wrote: How can I convert this line: Thank you. That looks pretty straightforward. I'll try that. RE: Setting Line _RGB colours - bplus - 11-03-2024 You will have to DIM Shared V and H in main because they are not passed as arguments to the sub. RE: Setting Line _RGB colours - bplus - 11-03-2024 Demo 2: Code: (Select All) Screen _NewImage(800, 600, 32) RE: Setting Line _RGB colours - PhilOfPerth - 11-03-2024 (11-03-2024, 01:08 AM)bplus Wrote: You will have to DIM Shared V and H in main because they are not passed as arguments to the sub. Yes, got that; thanks. (11-03-2024, 01:29 AM)bplus Wrote: Demo 2: You never cease to amaze me! RE: Setting Line _RGB colours - SMcNeill - 11-03-2024 (11-03-2024, 01:02 AM)bplus Wrote: Henry is right for _RGB() you may only need long because you don't have transparent colors. LONG and _UNSIGNED LONG both cover all your color valules. That said, you should *ALWAYS* use _UNSIGNED LONG, as several of the QB64 Functions return _UNSIGNED LONG values and your LONG colors won't match them. Let me give the simplest of demos here: Code: (Select All)
Now, in your SUB here, it doesn't matter as you're not making use of POINT or other color functions that return an unsigned long value to you. Still, I wouldn't recommend to use a LONG value for colors. *ALWAYS* use an _UNSIGNED LONG. Get in the habit of *always* using an unsigned long. *ALWAYS*, when using 32-bit colors. Otherwise, it will eventually come to bite you in the butt, and I will end up laughing at you and pointing to the 5217 posts like this one that I've repeated over and over and over, over the years. There's no reason to use LONG values. They save no memory. Don't process any faster. They have no bonus to efficiency or anything else. AND, they can break your code as QB64PE functions return UNSIGNED LONG values back to you, and not LONGs. |