RgbDepthCue
ShadedColour = RgbDepthCue(InputColour, DepthColour, Position, Min, Max)
 
Parameters:

    InputColour = The RGB colour you wish to shade
    DepthColour = The colour we're shading with
    Position = The position/depth the InputColour is within the range limits
    Min = The near range to shade the input colour within. If Position is less than this the output colour will be InputColour
    Max = The far range to shade the input colour within. If Position is greater than MAX, the output colour will be DepthColour
Returns:

    ShadedColour = The resulting colour after this operation
 

      The RgbDepthCue() function performs alpha blend between the users Input colour and the Depth colour. You supply the function with a position within a range (Min (near) / Max (Far), the input colour is blended into the depth colour depending upon the position within that range.

      So if the position is equal or less than the Min value, RgbDepthCue will return the InputColour. If the position is greater than Max range then, RgbDepthCue will return the DepthColour. If position is in the middle of the Min & Max ranges, then RgbDepthCue will return a 50 / 50 blend of the InputColour and Depth colour.




FACTS:


      * You can find some more detailed examples in the Projects/Examples/Colours folder of your PlayBASIC installation.




Mini Tutorial:


      This example shows the effect of the Rgb Depth Cue colour operation.

  
  
  MyColour=RGB(255,110,120)
  DepthColour=RGB(50,60,70)
  Cls DepthColour
  
  Size=GetTextHeight("Y")
  
  // Define the Min range for shading to effect My Colour
  Min=100
  
  // Define the max range for colour to be completely faded out
  Max=GetScreenHeight()
  
  For POsition=0 To Max Step Size
     
     // Calc the shade this colour would be at this position
     DepthShadedColour=rgbdepthcue(MyColour,DepthColour,Position,Min,Max)
     
     BoxC 0,Position,200,Position+Size,true,DepthShadedColour
     
  Next
  
  Sync
  WaitKey
  
  
  
  



 
Example Source: Download This Example
;Tell PB to limit the speed of this program to a max of 60
; frames (syncs) per second
  SetFPS 60
  
; define the type structure to hold all the info about each box
  Type tBox
     X,Y,Z,Width#,Height#,col
  EndType
  
; Dimension an array to hold all the zooming box objects
  Dim Objs(150As tBox
  
  
; Run through and init (randomly) in the World Space
  r=500
  For lp=0 To GetArrayElements(objs().tbox,1)
     Objs(lp).X = RndRange(-r,r)
     Objs(lp).y = RndRange(-r,r)
     Objs(lp).z = RndRange(100,r*2)
     Objs(lp).width = Rnd(150)
     Objs(lp).height = Rnd(150)
     Objs(lp).Col = RndRGB()
  Next
  
  
; CReate camera so we can view the scene correctly ordered
  CreateCamera 1
  
; Calc the center of the Camera
  CameraCenterX#=(GetCameraWidth(1)/2)
  CameraCenterY#=(GetCameraHeight(1)/2)
  
; ---------------------------------------
; Start of Main DO / LOOP
; ---------------------------------------
  Do
     
     
     If Angle#<1
        BackDropColour=RndRGB()
        CameraClsColour 1,BackDropColour
     EndIf
     
     Angle#=WrapAngle(angle#,0.5)
     CamZ=Cos(Angle#)*1000
     
     
   ; redirect all drawing To PB scene buffer
     CaptureToScene
     
   ; Clear the scene buffer (so there's no old data in it)
     ClsScene
     
     
   ; Transform And render Boxes (with Z To the screen)
     For lp=0 To GetArrayElements(objs().tbox,1)
        
      ; Translate the Obejcts Z To the cameras Z
        Z#=Objs(lp).Z-CamZ
        
      ; Check if the Object is in front of the camera (positive)
        If Z#>0
           
         ; Depth Cue the Colour
           Col=rgbdepthcue(Objs(lp).Col,BackDropColour,z#,0,1000)
           
         ; Translate the X# / Y# cooords object To the camera
           X#=Objs(lp).X
           Y#=Objs(lp).Y
           
         ; Calc projected X /Y coords
           PX#=CameraCenterX#+((x#*400)/Z#)
           PY#=CameraCenterY#+((y#*300)/Z#)
           
         ; Calc perspective sizing
           Width#=(Objs(lp).Width*400)/Z#
           Height#=(Objs(lp).Height*300)/Z#
           
         ; Set PB To capture the Next drawing operations at
         ; this Z# depth in the scene buffer
           CaptureDepth Z#
           
         ; Draw the object To the scene buffer
           x2#=px#-(width#/2)
           Y2#=pY#-(Height#/2)
           
           BoxC X2#,y2#,x2#+width#,y2#+height#,1,Col
        EndIf
        
     Next
     
     
   ; DRaw what the camera #1 sees in the scene buffer
     DrawCamera 1
     
   ; Refresh the screen display
     Sync
     
   ;loop back to the start
  Loop
  
  
  
 
Related Info: RGB | RgbAlpha50 | RgbAlphaAdd | RgbAlphaAnd | RGBAlphaBlend | RgbAlphaMult | RgbAlphaOr | RgbAlphaSub | RgbAlphaXOr | RGBB | RGBFade | RGBG | RGBGreyScale | RGBR | RndRGB :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com