Announcement

Collapse
No announcement yet.

Graphic Color Assignment Misunderstanding?

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

  • Graphic Color Assignment Misunderstanding?

    I'm either not understanding something, or not getting the results according to what I'm reading with the command GRAPHIC COLOR. I read:
    GRAPHIC COLOR statement
    Purpose
    Set the foreground color and optionally the background color for various statements.
    Remarks
    The graphic target must first be selected with GRAPHIC ATTACH. If either parameter is -1, the default foreground/background color is used. If the background parameter is -2, the background is not painted, allowing the content behind to become visible. Otherwise, the specified RGB color is used.
    So I set up my graphic control:
    CONTROL ADD GRAPHIC, CB.HNDL, idGraphic + 1000, "", 10, 10, 80, 60, _
    %WS_CHILD OR %WS_VISIBLE OR %SS_NOTIFY
    Attach it:
    GRAPHIC ATTACH CB.HNDL, idGraphic + 1000
    Then apply the following attempts:
    GRAPHIC COLOR %RED, -2
    GRAPHIC ELLIPSE (5,5)-(75,55)

    GRAPHIC COLOR %RED, RGB(Colors(95).rgbRed, Colors(95).rgbGreen, Colors(95).rgbBlue)
    GRAPHIC ELLIPSE (5,5)-(75,55)
    (Colors is an internal RGB array.) But in either case, the background is default dialog gray. With a red Ellipse drawn on it.

    What am I not seeing / doing?
    Furcadia, an interesting online MMORPG in which you can create and program your own content.

  • #2
    For what item are you trying change the background? the dialog or the ellipse?

    Is something like this more like what you want?

    GRAPHIC ELLIPSE (5,5)-(75,55), %Red, %Blue

    Or, have you tried GRAPHIC PAINT over the area?

    Comment


    • #3
      The ellipse is unimportant, it's there for testing, the questions are:
      1. Should not the graphic control become "invisible" against whatever background the dialog is when the background color is set to -2
      2. If not, then should not the graphic control's background be rendered the set RGB color from my Colors()
      And no, have not tried paint yet.
      Furcadia, an interesting online MMORPG in which you can create and program your own content.

      Comment


      • #4
        Colin,
        your code behaves as I'd expect it to.
        What result did you expect?

        The default background is dialog grey and you never change that. If you want other than the default dialog grey as a background then you need to set the background colour then use GRAHIC CLEAR to clear the background to your desired colour. Then you can draw your red elipse on it.


        The ellipses are drawn in the current foreground colour, red, and leave the background unchanged at whatever was last drawn, in your case that's the default grey.

        Paul.

        Comment


        • #5
          Need to learn that PB's graphic controls are passive reactors, ...

          Code:
          CONTROL ADD GRAPHIC, CB.HNDL, idGraphic + 1000, "", 10, 10, 80, 60, _
              %WS_CHILD OR %WS_VISIBLE OR %SS_NOTIFY
          GRAPHIC ATTACH CB.HNDL, idGraphic + 1000
          GRAPHIC COLOR %RED, -2
          GRAPHIC CLEAR
          GRAPHIC ELLIPSE (5,5)-(75,55)
          Background remains gray, so what does the manual mean when it says:

          "If the background parameter is -2, the background is not painted, allowing the content behind to become visible"

          The background is NOT gray! Matter of fact, it happens to be Colors(95).

          Code:
          CONTROL ADD GRAPHIC, CB.HNDL, idGraphic + 1000, "", 10, 10, 80, 60, _
              %WS_CHILD OR %WS_VISIBLE OR %SS_NOTIFY
          GRAPHIC ATTACH CB.HNDL, idGraphic + 1000
          GRAPHIC COLOR %RED, RGB(Colors(95).rgbRed, Colors(95).rgbGreen, Colors(95).rgbBlue)
          GRAPHIC CLEAR
          GRAPHIC ELLIPSE (5,5)-(75,55)
          Essentially, this works, but leaves me in need to use something else should I happen to switch modes into Alpha Transparency blending against a background image. Along with hit testing for when the user clicks on the image(s) which are supposed to be movable within that background image.
          Furcadia, an interesting online MMORPG in which you can create and program your own content.

          Comment


          • #6
            Perhaps if we had compilable code that shows the issue we could be more specific in our assistance.
            Rod
            In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

            Comment


            • #7
              GRAPHIC ELLIPSE draws only a foreground image on the background which currently exists. When the current background is grey, you end up with a red ellipse on a grey background. If you want a different background, you must create it before you draw the ellipse. That's what you did in the second example.

              GRAPHIC COLOR sets the default colors, to be used in the future, as they are needed. Some GRAPHIC functions (like Ellipse) use only a foreground color. Some GRAPHIC functions (like Clear) use only a background color. Some GRAPHIC functions (like Print) use both.

              GRAPHIC ELLIPSE does not erase the entire previous background when it executes. That would make graphic statements practically useless, because you could never draw 2 ellipses, or 3, or 427 of them. Each new ellipse would erase the previous ones.

              Bob Zale
              PowerBASIC Inc.

              Comment


              • #8
                Originally posted by Bob Zale View Post
                GRAPHIC ELLIPSE does not erase the entire previous background when it executes. That would make graphic statements practically useless, because you could never draw 2 ellipses, or 3, or 427 of them. Each new ellipse would erase the previous ones.
                I would expect that behavior, that's how a DC drawing surface should behave.

                "If the background parameter is -2, the background is not painted, allowing the content behind to become visible."

                So in the attached source code, the left graphic control does:
                Code:
                GRAPHIC COLOR nColor, -2
                GRAPHIC CLEAR
                GRAPHIC ELLIPSE (5, 5) - (95, 95)
                While the right graphic control does full foreground / background setting. The left graphic control remains "default dialog background".
                Attached Files
                Furcadia, an interesting online MMORPG in which you can create and program your own content.

                Comment


                • #9
                  I'm sorry, Colin, but at this point I have no idea of your current question. You attached a very nice little program, but it doesn't seem to have much relation to the messages posted.

                  Best regards,

                  Bob Zale
                  PowerBASIC Inc.

                  Comment


                  • #10
                    Colin,

                    Are you expecting the ellipse to be drawn filled with the background& colour set by GRAPHIC COLOR foreground& [, background&] ?
                    Ellipses don't work that way ..
                    Code:
                    #Compile Exe
                    #Dim All
                    Function PBMain() As Long
                     Local hDlg As Dword
                      Dialog New Pixels, 0, "Colours", 300, 300, 200, 200, %WS_OverlappedWindow To hDlg
                        Control Add Button, hDlg, 100, "Paint", 50, 10, 100, 20
                      Dialog Show Modal hDlg Call DlgProc
                    End Function 
                    '------------------/
                    CallBack Function DlgProc() As Long
                       If Cb.Msg = %WM_Command And Cb.Ctl = 100 And Cb.CtlMsg = %BN_Clicked Then
                          CONTROL ADD GRAPHIC, CB.HNDL, 101, "", 10, 40, 180, 150, _
                                               %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %SS_NOTIFY
                          'Attach it:
                          GRAPHIC ATTACH CB.HNDL, 101
                          'Then apply the following attempts:
                          Graphic Set Pos (25, 5)
                          GRAPHIC COLOR %RED, -2
                          GRAPHIC ELLIPSE (25,25)-(150,55)
                          GRAPHIC PRINT "Red transp"
                     
                          Graphic Set Pos (25, 60)
                          GRAPHIC COLOR %RED, RGB(120, 120, 220)
                          GRAPHIC ELLIPSE (25,75)-(150,110)
                          GRAPHIC Print "Red Blue"
                     
                          'NB:
                          'GRAPHIC ELLIPSE (x1!, y1!) - (x2!, y2!) [, [rgbColor&] [,[fillcolor&] [, [fillstyle&]]]]
                          'rgbColor& - Optional RGB color of the ellipse edge.  
                          '            If omitted (or -1), the edge color defaults to the current foreground color for 
                          '            the selected graphic window.
                          'fillcolor& - Optional RGB color of the ellipse interior.  
                          '            If fillcolor& is omitted (or -2), the interior of the ellipse is not filled, 
                          '            allowing the background to show through. 
                     
                          GRAPHIC ELLIPSE (25,120)-(100,140), , %Yellow
                       End If
                    End Function 
                    '------------------/
                    Rgds, Dave

                    Comment


                    • #11
                      The ELLIPSE's are not the issue.
                      Originally posted by colin glenn View Post
                      RE: GRAPHIC COLOR STATEMENT
                      "If the background parameter is -2, the background is not painted, allowing the content behind to become visible."
                      I'm asking what is meant by this when you actually use this format:
                      Code:
                      GRAPHIC COLOR %RED, -2
                      And the background of the GRAPHIC CONTROL is STILL visible? Regardless of whether it's a pixel or a cyclic quadrilateral being drawn, the background of the control is still visible, that is, it's still being painted "default dialog color".
                      Furcadia, an interesting online MMORPG in which you can create and program your own content.

                      Comment


                      • #12
                        In Dave's program above, make the following change:


                        Code:
                        Function PBMain() As Long
                        Local hDlg As Dword
                           Dialog New Pixels, 0, "Colours", 300, 300, 200, 200, %WS_OverlappedWindow To hDlg
                           Control Add Button, hDlg, 100, "Paint", 50, 10, 100, 20
                        
                        [B]   Dialog Set Color hDlg, 0, -2&[/B]
                        
                           Dialog Show Modal hDlg Call DlgProc
                        End Function
                        Drag the window around. Does this help explain the -2 param?
                        Last edited by John Montenigro; 27 Mar 2009, 01:57 PM.

                        Comment


                        • #13
                          With the dialog set color, it does, it causes the dialog to assume a "transparent" state, or kin to when you use a hollow brush for a WinClass hbrBackground.

                          Why won't that work with a graphic control?
                          Furcadia, an interesting online MMORPG in which you can create and program your own content.

                          Comment


                          • #14
                            Sorry I can't give you the proper explanation - I stumbled on this while experimenting but I don't understand the technical underpinnings. I'll defer to more knowledgable people.


                            Added: I've been playing a bit more, using the summary in Bob's message #7 (it would be great if the Help file contained that info in a summary or overview...).

                            I tried a GRAPHICS CLEAR %green just before the first ellipse in the callback of Dave's sample, and it changed the background of the drawing area, and not the rest of the dialog....

                            I think you may be expecting the color statement to affect graphic objects that get drawn afterward, but I think (guessing?) that it applies only to the target of the last ATTACH...
                            Last edited by John Montenigro; 27 Mar 2009, 04:14 PM. Reason: Added result of more experimenting...

                            Comment

                            Working...
                            X