# Class RadialGradient

java.lang.Object
com.codename1.ui.Gradient
com.codename1.ui.RadialGradient

All Implemented Interfaces:
  `Paint`

public final class RadialGradient extends Gradient
Multi-stop radial gradient with CSS shape / extent / center / radius support. Mirrors CSS `radial-gradient([shape] [extent] [at <pos>], <stops>)`.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final byte`
  `EXTENT_CLOSEST_CORNER`
  `static final byte`
  `EXTENT_CLOSEST_SIDE`
  CSS radial extents.
  `static final byte`
  `EXTENT_EXPLICIT`
  Use the configured relativeRadiusX/Y verbatim (times the rectangle's larger dimension).
  `static final byte`
  `EXTENT_FARTHEST_CORNER`
  `static final byte`
  `EXTENT_FARTHEST_SIDE`
  `static final byte`
  `SHAPE_CIRCLE`
  Radial shape: circular (single radius).
  `static final byte`
  `SHAPE_ELLIPSE`
  Radial shape: elliptical (separate x/y radii).

  ### Fields inherited from class Gradient

  `CYCLE_NONE, CYCLE_REFLECT, CYCLE_REPEAT, KIND_CONIC, KIND_LINEAR, KIND_RADIAL`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RadialGradient(int[] colors, float[] positions)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `computeRadii(int width, int height, float[] out)`
  Computes (cx, cy, rx, ry) in pixel coordinates for a rectangle of the given width / height, applying the configured CSS extent.
  `void`
  `computeShaderRadii(int width, int height, float[] out)`
  Computes shader-ready (cx, cy, rx, ry) for native APIs like Android's `RadialGradient` and Java2D's `RadialGradientPaint`.
  `RadialGradient`
  `copy()`
  Returns a defensive deep copy.
  `byte`
  `getExtent()`
  `byte`
  `getKind()`
  Returns one of `KIND_LINEAR`, `KIND_RADIAL`, `KIND_CONIC`.
  `float[]`
  `getNormalizedPositions()`
  Returns stop positions rescaled to `[0, 1]` within the `[first_stop, last_stop]` range.
  `float`
  `getRelativeCenterX()`
  `float`
  `getRelativeCenterY()`
  `float`
  `getRelativeRadiusX()`
  `float`
  `getRelativeRadiusY()`
  `byte`
  `getShape()`
  `int`
  `sampleArgb(int px, int py, int width, int height)`
  Software-rasterizer hook used by the default port implementation when no native gradient shader is available.
  `RadialGradient`
  `setExtent(byte extent)`
  `RadialGradient`
  `setRelativeCenterX(float relativeCenterX)`
  `RadialGradient`
  `setRelativeCenterY(float relativeCenterY)`
  `RadialGradient`
  `setRelativeRadiusX(float relativeRadiusX)`
  `RadialGradient`
  `setRelativeRadiusY(float relativeRadiusY)`
  `RadialGradient`
  `setShape(byte shape)`

  ### Methods inherited from class Gradient

  `getCachedRaster, getColors, getCycleMethod, getPositions, invalidateRasterCache, paint, paint, parseCss, sampleStops, setCycleMethod`

  ### Methods inherited from class Object

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

- ## Field Details

  - ### SHAPE_CIRCLE

    public static final byte SHAPE_CIRCLE
    Radial shape: circular (single radius).
    See Also:
      - Constant Field Values

  - ### SHAPE_ELLIPSE

    public static final byte SHAPE_ELLIPSE
    Radial shape: elliptical (separate x/y radii).
    See Also:
      - Constant Field Values

  - ### EXTENT_CLOSEST_SIDE

    public static final byte EXTENT_CLOSEST_SIDE
    CSS radial extents.
    See Also:
      - Constant Field Values

  - ### EXTENT_CLOSEST_CORNER

    public static final byte EXTENT_CLOSEST_CORNER
    See Also:
      - Constant Field Values

  - ### EXTENT_FARTHEST_SIDE

    public static final byte EXTENT_FARTHEST_SIDE
    See Also:
      - Constant Field Values

  - ### EXTENT_FARTHEST_CORNER

    public static final byte EXTENT_FARTHEST_CORNER
    See Also:
      - Constant Field Values

  - ### EXTENT_EXPLICIT

    public static final byte EXTENT_EXPLICIT
    Use the configured relativeRadiusX/Y verbatim (times the rectangle's larger dimension).
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### RadialGradient

    public RadialGradient(int[] colors, float[] positions)

- ## Method Details

  - ### getKind

    public byte getKind()
    Description copied from class: `Gradient`
    Returns one of `KIND_LINEAR`, `KIND_RADIAL`, `KIND_CONIC`.
    Specified by:
      `getKind` in class `Gradient`

  - ### getShape

    public byte getShape()

  - ### setShape

    public RadialGradient setShape(byte shape)

  - ### getExtent

    public byte getExtent()

  - ### setExtent

    public RadialGradient setExtent(byte extent)

  - ### getRelativeCenterX

    public float getRelativeCenterX()

  - ### setRelativeCenterX

    public RadialGradient setRelativeCenterX(float relativeCenterX)

  - ### getRelativeCenterY

    public float getRelativeCenterY()

  - ### setRelativeCenterY

    public RadialGradient setRelativeCenterY(float relativeCenterY)

  - ### getRelativeRadiusX

    public float getRelativeRadiusX()

  - ### setRelativeRadiusX

    public RadialGradient setRelativeRadiusX(float relativeRadiusX)

  - ### getRelativeRadiusY

    public float getRelativeRadiusY()

  - ### setRelativeRadiusY

    public RadialGradient setRelativeRadiusY(float relativeRadiusY)

  - ### computeRadii

    public void computeRadii(int width, int height, float[] out)
    Computes (cx, cy, rx, ry) in pixel coordinates for a rectangle of the given width / height, applying the configured CSS extent.

  - ### computeShaderRadii

    public void computeShaderRadii(int width, int height, float[] out)

    Computes shader-ready (cx, cy, rx, ry) for native APIs like Android's `RadialGradient` and Java2D's `RadialGradientPaint`. For NO_CYCLE this is the same as `computeRadii`. For REPEAT / REFLECT it scales the radii so the [0, 1] shader range corresponds to exactly one stop-list period (`getPositions()[0]` to `getPositions()[N-1]`), matching the CSS `repeating-radial-gradient` semantic.

    Use `getNormalizedPositions()` for the matching stop array when using these radii with REPEAT/REFLECT.

  - ### getNormalizedPositions

    public float[] getNormalizedPositions()
    Returns stop positions rescaled to `[0, 1]` within the `[first_stop, last_stop]` range. Use alongside `computeShaderRadii` when feeding the native shader API.

  - ### sampleArgb

    public int sampleArgb(int px, int py, int width, int height)
    Description copied from class: `Gradient`
    Software-rasterizer hook used by the default port implementation when no native gradient shader is available. Samples an ARGB color for the pixel at (px, py) within a rectangle of the given width / height. Ports overriding `fillGradient` directly do not call this.
    Specified by:
      `sampleArgb` in class `Gradient`

  - ### copy

    public RadialGradient copy()
    Description copied from class: `Gradient`
    Returns a defensive deep copy. Implemented by each concrete subclass so async-paint queues can capture an immutable snapshot.
    Specified by:
      `copy` in class `Gradient`