Announcement

Collapse
No announcement yet.

Color definition

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Frank Kestens
    replied
    Color definition

    Thanks for the codes here !
    I was able to convert the color definition in RGB using :
    color&=val("H0RRGGBB") , where RR...BB are the hexadecimal values.
    This can be used fi. in the Graphic Ellipse commands ...

    Leave a comment:


  • Frank Kestens
    replied
    color conversion

    Originally posted by Eddy Van Esch View Post
    You 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
    Ah ... I meant the colordefinition as in the HelpSection : DIALOG SET COLOR statement where predefined colors may be used as %BLACK ,
    %WHITE ...
    out of RGB(r%,g%,b%) values .

    Leave a comment:


  • Frank Kestens
    replied
    color and Arctan2

    Thanks for the useful conversion formulae ...
    ArcTan2 works fine .

    Leave a comment:


  • William Burns
    replied
    Originally posted by Eddy Van Esch View Post
    Ah, he meant 'percentage' with '..%' ... I thought he meant a 16 bit integer variable by it ..
    How funny. I on the other hand, thought he is talking about defining a constant that he can use for anything in his program that needs a color definition. Such as: %MYCOLOR = &H03A475F

    Leave a comment:


  • Paul Dixon
    replied
    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 ...
    Check out this: http://www.powerbasic.com/support/pb...ead.php?t=8959

    Paul.

    Leave a comment:


  • Erik Christensen
    replied
    Similar to the above I found this function in my previous 3D-Graphics Demonstration Program:

    http://www.powerbasic.com/support/pb...ad.php?t=23341
    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
    Is this useful to you?

    Best regards,

    Erik

    Leave a comment:


  • Aldo Vitagliano
    replied
    Originally posted by Frank Kestens View Post
    Thanks 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 ...
    Something like this ?

    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

    Leave a comment:


  • Eddy Van Esch
    replied
    Originally posted by Erik Christensen View Post
    ... would give percentage.
    Ah, he meant 'percentage' with '..%' ... I thought he meant a 16 bit integer variable by it ..

    Leave a comment:


  • Erik Christensen
    replied
    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:

    http://msdn2.microsoft.com/en-us/library/bb980062.aspx

    Best regards,

    Erik

    Leave a comment:


  • William Burns
    replied
    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.

    Leave a comment:


  • Pierre Bellisle
    replied
    Nuance...

    Leave a comment:


  • Michael Mattias
    replied
    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.

    Leave a comment:


  • Frank Kestens
    replied
    color description

    Thanks 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 ...

    Leave a comment:


  • Michael Mattias
    replied
    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

    Leave a comment:


  • Michael Mattias
    replied
    Code:
    %MYCOLOR = RGB(myRed, mygreen, myblue)
    If that doesn't work (but I think it does)...try ...
    Code:
    %MYCOLOR =   &h00rrggbb
    .. that I have exactly zero faith that I have the bytes ordered correctly but you get the idea.

    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.

    MCM

    Leave a comment:


  • Eddy Van Esch
    replied
    You 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

    Leave a comment:


  • Frank Kestens
    started a topic Color definition

    Color definition

    Someone in this forum knows how to transform the RGB(x,y,z) color to a ...% needed for colordefinition ?
Working...
X