Someone in this forum knows how to transform the RGB(x,y,z) color to a ...% needed for colordefinition ?
Announcement
Collapse
No announcement yet.
Color definition
Collapse
X
-
Code:%MYCOLOR = RGB(myRed, mygreen, myblue)
Code:%MYCOLOR = &h00rrggbb
If "%EQUATE= RGB(red, blue, green)" does not work, I know I have previously submitted a NFS to make it supported. BUt you can send it in too; the more who ask, the more likely the NFS will be adopted, or so they say.
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
Or, you could just reverse-engineer these..
Code:' ------------------------------------------------- ' MACROS TO GET R, G, B values from RGB dword ' ------------------------------------------------- MACRO mGetRed (Rgbvalue) = Rgbvalue AND &h0FF MACRO mGetGreen (rgbvalue) = (Rgbvalue AND &h0FF00) \ &h100 MACRO mGetBlue (rgbvalue) = (rgbvalue AND &h0FF0000) \ &h10000
Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
Duh. This will ALWAYS work:
Code:' custom color for this application %MYRED = 5 %MYGREEN = 110 %MYBLUE = 77 MACRO MyColor = RGB(%MYRED, %MYGREEN, %MYBLUE) ... hBrush = CreateSolidBrush (MyColor)
That HAS to work.Michael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
-
MCM was correct about using the &H0 method, but the order is wrong. I use this format: &H0bbggrr (where bb is the blue value in Hex format, gg=green, rr=red )
Or if you just want something that can calc the value for you to hard code in to a program, I set this small tool up several years back (it is even kinda fun to watch and play with)
http://www.powerbasic.com/support/pb...ad.php?t=23678
There is also a handy button to copy the values to the clipboard so you can easily paste them in your programs."I haven't lost my mind... its backed up on tape... I think??" :D
Comment
-
Frank,
I think you could use the following WinAPI macros, which retrieve intensity values for the blue, green and red components, respectively, of a 32-bit red, green, blue (RGB) value:
GetRValue
GetGValue
GetBValue
The values you obtain are in the range 0-255. Dividing by 255 and multiplying by 100 would give percentage.
Here is some more information on colors:
Best regards,
Erik
Comment
-
Originally posted by Frank Kestens View PostThanks both of you !
I'll try.
BTW another feature which is interesting to have is arctg2(y;x) instead of arctg(x) , which returns values between 0-2pi instead of ...
Code:GLOBAL Pi AS DOUBLE, Pi_2 AS DOUBLE .... Pi = 4*ATN(1): Pi_2 = Pi/2 .... FUNCTION ATN2 (YW AS DOUBLE, XW AS DOUBLE) AS DOUBLE DIM ZZZ AS DOUBLE SY&=SGN(YW): IF SY&=0 THEN SY&=1 IF XW = 0 THEN ZZZ = Pi_2 * SY& ELSE ZZZ = ATN(YW / XW) IF XW < 0 THEN ZZZ = ZZZ + Pi * SY& ATN2 = ZZZ END FUNCTION
Aldo Vitagliano
alvitagl at unina it
Comment
-
Similar to the above I found this function in my previous 3D-Graphics Demonstration Program:
Code:FUNCTION CalculatePhi(EX AS SINGLE, EZ AS SINGLE) AS SINGLE ‘ EX and EZ are X and Z coordinates, respectively ' These corrections are needed to make Phi take a full ' circle i.e. 360 degrees. ' Without the corrections Phi will only vary 180 degrees ' (-90 to 90) corresponding to the range for arcus tangens (ATN). LOCAL Ph AS SINGLE IF ABS(EX) < EZ*1E-36! THEN EX = EZ*1E-36! Ph = ATN(EZ/EX) IF Ph < 0! THEN Ph=Ph+3.141593! IF EZ < 0! THEN Ph=Ph+3.141593! FUNCTION = Ph END FUNCTION
Best regards,
Erik
Comment
-
Frank,
BTW another feature which is interesting to have is arctg2(y;x) instead of arctg(x) , which returns values between 0-2pi instead of ...
Paul.
Comment
-
Originally posted by Eddy Van Esch View PostAh, he meant 'percentage' with '..%' ... I thought he meant a 16 bit integer variable by it .."I haven't lost my mind... its backed up on tape... I think??" :D
Comment
-
color conversion
Originally posted by Eddy Van Esch View PostYou mean "%" as in a 16 bits integer ?
x, y, z are each 8 bits, that makes 24 bits ....
The PB RGB() function returns a 32 bits long ...
Kind regards
%WHITE ...
out of RGB(r%,g%,b%) values .
Comment
Comment