Announcement

Collapse
No announcement yet.

color superposition

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

  • color superposition

    I'm writing a program in which I need to superimpose two or more colors.
    Is this possible ? and with which instructions ?
    For example : I draw a circle in red and nearby a circle in green . The intersected region should appear in red+green = yellow . Adding also blue should give white .
    ??
    Last edited by Frank Kestens; 17 May 2008, 07:27 AM.

  • #2
    Hi,

    if you have latest PB/WIN or PB/CC, you can try to use GRAPHIC commands and %MIX_MERGESRC mode for rendering the image.

    Here is minimal sample:
    Code:
    FUNCTION PBMAIN () AS LONG
    
      LOCAL hWin AS DWORD
    
      GRAPHIC WINDOW "Demo", -1, -1, 240, 240 TO hWin
    
      GRAPHIC ATTACH hWin, 0
      GRAPHIC CLEAR %BLACK
      GRAPHIC SET MIX %MIX_MERGESRC
      GRAPHIC ELLIPSE (10, 10) - (110, 110),%RED, %RED
      GRAPHIC ELLIPSE (30, 30) - (130, 130),%GREEN, %GREEN
      GRAPHIC ELLIPSE (60, 60) - (160, 160),%BLUE, %BLUE
    
      SLEEP 5000  ' show it for 5 seconds, then end
    
    END FUNCTION
    You could also use additive blending in OpenGL or Direct3D.

    And the most straightforward way is to just extract Red, Green, Blue components of the two fragments, combine them to create new one ( just check to not go over 255 in each component ).

    You can use GetRValue, GetGValue, GetBValue from Win32 API to get the components, or use other way.


    Petr
    [email protected]

    Comment


    • #3
      color superposition

      This works ! Thank you very much !
      I've never heard before of the Merge function and wasn't aware of all the nice possibilities !
      BTW : is the ThinBasic really written entirely in PBasic ?
      Last edited by Frank Kestens; 18 May 2008, 05:02 AM.

      Comment


      • #4
        Originally posted by Frank Kestens View Post
        BTW : is the ThinBasic really written entirely in PBasic ?
        A bit late
        Yes it is 95% written using PowerBasic for Windows.
        The 5% remaining is in MS C.
        Last edited by Eros Olmi; 4 Jul 2008, 10:05 AM.
        thinBasic programming language
        Win10 64bit - 8GB Ram - i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

        Comment

        Working...
        X