Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Day 001: _GREEN32
#1
Perhaps not the greatest of keywords to start with, but that's the nature of randomness.  It is what it is, so with no further ado, here's _GREEN32 explained and showcased.

What is _GREEN32?  It's a simple command that takes a color value and returns the green component back to you from it.

When would you use it?  Basically when you have a color (perhaps taken from one of the color names), and you need to know what the green value is in it.

Example:

Code: (Select All)
Screen _NewImage(640, 480, 32)
$Color:32

Print "Lime : "; Hex$(Lime)
Print "======"
Print "Alpha: "; Hex$(_Alpha32(Lime)), _Alpha32(Lime)
Print "Red  : "; Hex$(_Red32(Lime)), _Red32(Lime)
Print "Green: "; Hex$(_Green32(Lime)), _Green32(Lime)
Print "Blue : "; Hex$(_Blue32(Lime)), _Blue32(Lime)


As you can see from the simple example above, _GREEN32 can be used to easily get back the green color values from whatever 32-bit color you send to it.  Used in conjection with _ALPHA32, _RED32, and _BLUE32, you can quickly and easily break down a complex color value into its component parts with almost no effort on your part.  Smile
Reply
#2
And here all this time I thought _GREEN32 was a Packers quarterback signal to initiate a running back handoff to the tight end side.

Learn something new every day. If I didn't also forget that, plus something old, I'd be in mighty fine shape pushing 70!

Kidding aside, I hardly ever use these color keywords, but my current perception is we have grown to more than just a couple of ways to apply color in our apps. Perhaps it would also be valuable to do a piece on advantages and disadvantages for different kinds of apps when designing the best color system to employ.

Pete
Reply
#3
(11-06-2022, 02:33 PM)SMcNeill Wrote: Perhaps not the greatest of keywords to start with, but that's the nature of randomness.  It is what it is, so with no further ado, here's _GREEN32 explained and showcased.

What is _GREEN32?  It's a simple command that takes a color value and returns the green component back to you from it.

When would you use it?  Basically when you have a color (perhaps taken from one of the color names), and you need to know what the green value is in it.

Example:

Code: (Select All)
Screen _NewImage(640, 480, 32)
$Color:32

Print "Lime : "; Hex$(Lime)
Print "======"
Print "Alpha: "; Hex$(_Alpha32(Lime)), _Alpha32(Lime)
Print "Red  : "; Hex$(_Red32(Lime)), _Red32(Lime)
Print "Green: "; Hex$(_Green32(Lime)), _Green32(Lime)
Print "Blue : "; Hex$(_Blue32(Lime)), _Blue32(Lime)


As you can see from the simple example above, _GREEN32 can be used to easily get back the green color values from whatever 32-bit color you send to it.  Used in conjection with _ALPHA32, _RED32, and _BLUE32, you can quickly and easily break down a complex color value into its component parts with almost no effort on your part.  Smile
Agreed, that's probably not the most sought-after function explanation we have, but it's one I had never heard of, and adds another little toy (actually, four toys) to my toybox.
And if you intend, as it appears, to cover one more keyword each day/week/month, I'm keen to see the next edition! Great idea!
(although I would prefer non-randomness, with ascending order of usefulness)
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#4
A couple of very handy subs use _Green32 ( and red and blue and alpha), Ink~& is finding in-between colors between 2 color ranges :
Code: (Select All)
Sub cAnalysis (c As _Unsigned Long, outRed, outGrn, outBlu, outAlp)
    outRed = _Red32(c): outGrn = _Green32(c): outBlu = _Blue32(c): outAlp = _Alpha32(c)
End Sub

Function Ink~& (c1 As _Unsigned Long, c2 As _Unsigned Long, fr##)
    Dim R1, G1, B1, A1, R2, G2, B2, A2
    cAnalysis c1, R1, G1, B1, A1
    cAnalysis c2, R2, G2, B2, A2
    Ink~& = _RGB32(R1 + (R2 - R1) * fr##, G1 + (G2 - G1) * fr##, B1 + (B2 - B1) * fr##, A1 + (A2 - A1) * fr##)
End Function

Used in most recent Winter Banner posts!
b = b + ...
Reply




Users browsing this thread: 3 Guest(s)