# Class LinearGradientPaint

java.lang.Object
com.codename1.ui.MultipleGradientPaint
com.codename1.ui.LinearGradientPaint

All Implemented Interfaces:
  `Paint`

public class LinearGradientPaint extends MultipleGradientPaint
LinearGradientPaint provides a way to fill a `Shape` with a linear gradient.

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from class MultipleGradientPaint

  `MultipleGradientPaint.ColorSpaceType, MultipleGradientPaint.CycleMethod`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LinearGradientPaint(double startX, double startY, double endX, double endY, float[] fractions, int[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, Transform gradientTransform)`
  Creates a LinearGradientPaint with the specified settings.
  `LinearGradientPaint(float startX, float startY, float endX, float endY, float[] fractions, int[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, Transform gradientTransform)`
  Creates a LinearGradientPaint with the specified settings.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `paint(Graphics g, double x, double y, double w, double h)`
  Painds the linear gradient in the given bounds.
  `final void`
  `paint(Graphics g, Rectangle2D bounds)`
  Paints linear gradient in the given bounds.

  ### Methods inherited from class MultipleGradientPaint

  `getColors, getColorSpace, getCycleMethod, getFractions, getTransform, getTransparency, setColors, setColorSpace, setCycleMethod, setFractions, setTransform, setTransparency`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LinearGradientPaint

    public LinearGradientPaint(float startX, float startY, float endX, float endY, float[] fractions, int[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, Transform gradientTransform)

    Creates a LinearGradientPaint with the specified settings.

    ###### Parameters

    - `startX`: The startX coordinate of the gradient in user space.

    - `startY`: The startY coordinate of the gradient in user space.

    - `endX`: The endX coordinate of the gradient in user space.

    - `endY`: THe endY coordinate of the gradient in user space.

    - `fractions`: Fractional positions of where gradient colors begin. Each value should be between 0 and 1.

    - `colors`: The colors to use in the gradient. There should be the same number of colors as there are fractions.

    - `cycleMethod`: The cycle method to use.

    - `colorSpace`: The color space to use.

    - `gradientTransform`: Transform to use for the gradient. Not used right now.

  - ### LinearGradientPaint

    public LinearGradientPaint(double startX, double startY, double endX, double endY, float[] fractions, int[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, Transform gradientTransform)

    Creates a LinearGradientPaint with the specified settings.

    ###### Parameters

    - `startX`: The startX coordinate of the gradient in user space.

    - `startY`: The startY coordinate of the gradient in user space.

    - `endX`: The endX coordinate of the gradient in user space.

    - `endY`: THe endY coordinate of the gradient in user space.

    - `fractions`: Fractional positions of where gradient colors begin. Each value should be between 0 and 1.

    - `colors`: The colors to use in the gradient. There should be the same number of colors as there are fractions.

    - `cycleMethod`: The cycle method to use.

    - `colorSpace`: The color space to use.

    - `gradientTransform`: Transform to use for the gradient. Not used right now.

- ## Method Details

  - ### paint

    public final void paint(Graphics g, Rectangle2D bounds)

    Paints linear gradient in the given bounds.

    ###### Parameters

    - `g`

    - `bounds`

  - ### paint

    public void paint(Graphics g, double x, double y, double w, double h)

    Painds the linear gradient in the given bounds.

    ###### Parameters

    - `g`

    - `x`

    - `y`

    - `w`

    - `h`