GradientColor()

Syntax

GradientColor(Position.f, Color)
Description
Adds the given Color at the given Position to the spectrum of the drawing gradient.

Parameters

Position.f The position for the color in the gradient. It must be a float value between 0.0 and 1.0.
Color The color to be used. This color can be in RGB or RGBA format.

Return value

None.

Remarks

By default, the drawing gradient ranges from the current background color at position 0.0 to the current front color at position 1.0. With this command, additional colors can be added Inbetween, or the colors at 0.0 and 1.0 can be overwritten.

The ResetGradientColors() command can be used to revert back to the default gradient.

The following commands can be used to specify the shape of the drawing gradient:
- LinearGradient()
- CircularGradient()
- EllipticalGradient()
- BoxedGradient()
- ConicalGradient()
- CustomGradient()

Note: This command only has an effect with ImageOutput() and CanvasOutput(). The gradient only affects the drawing commands when #PB_2DDrawing_Gradient is set with the DrawingMode() command.

Example

  If OpenWindow(0, 0, 0, 400, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If CreateImage(0, 400, 200) And StartDrawing(ImageOutput(0))
      Box(0, 0, 400, 200, $FFFFFF)
      
      DrawingMode(#PB_2DDrawing_Gradient)      
      BackColor($0000FF)
      GradientColor(0.4, $00FFFF)
      GradientColor(0.6, $FFFF00)
      FrontColor($FF0000)
      
      LinearGradient(0, 0, 200, 200)    
      Circle(100, 100, 100)   
      LinearGradient(350, 100, 250, 100)
      Circle(300, 100, 100)
      
      StopDrawing() 
      ImageGadget(0, 0, 0, 400, 200, ImageID(0))
    EndIf
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf

See Also

ResetGradientColors(), LinearGradient(), CircularGradient(), EllipticalGradient(), BoxedGradient(), ConicalGradient(), CustomGradient(), DrawingMode()

Supported OS

All

<- GrabDrawingImage() - 2DDrawing Index - Green() ->