Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/graphics/SweepGradient#pubctors) \| [Inherited Methods](https://developer.android.com/reference/android/graphics/SweepGradient#inhmethods)

# SweepGradient

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/graphics/SweepGradient "View this page in Kotlin") \|Java


`
public


class
SweepGradient
`


`


`

`

extends https://developer.android.com/reference/android/graphics/Shader


`

`


`

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.graphics.Shader](https://developer.android.com/reference/android/graphics/Shader) ||
|   | ↳ | android.graphics.SweepGradient |

<br />

*** ** * ** ***

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/graphics/SweepGradient#SweepGradient(float,%20float,%20int,%20int)(float cx, float cy, int color0, int color1) ` A Shader that draws a sweep gradient around a center point. |
| ` https://developer.android.com/reference/android/graphics/SweepGradient#SweepGradient(float,%20float,%20int[],%20float[])(float cx, float cy, int[] colors, float[] positions) ` A Shader that draws a sweep gradient around a center point. |
| ` https://developer.android.com/reference/android/graphics/SweepGradient#SweepGradient(float,%20float,%20long,%20long)(float cx, float cy, long color0, long color1) ` A Shader that draws a sweep gradient around a center point. |
| ` https://developer.android.com/reference/android/graphics/SweepGradient#SweepGradient(float,%20float,%20long[],%20float[])(float cx, float cy, long[] colors, float[] positions) ` A Shader that draws a sweep gradient around a center point. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/android/graphics/Shader ` |---|---| | ` boolean` | ` https://developer.android.com/reference/android/graphics/Shader#getLocalMatrix(android.graphics.Matrix)(https://developer.android.com/reference/android/graphics/Matrix localM) ` Return true if the shader has a non-identity local matrix. | | ` void` | ` https://developer.android.com/reference/android/graphics/Shader#setLocalMatrix(android.graphics.Matrix)(https://developer.android.com/reference/android/graphics/Matrix localM) ` Set the shader's local matrix. | ||
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### SweepGradient

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SweepGradient (float cx, 
                float cy, 
                int color0, 
                int color1)
```

A Shader that draws a sweep gradient around a center point.

<br />

| Parameters ||
|---|---|
| `cx` | `float`: The x-coordinate of the center <br /> |
| `cy` | `float`: The y-coordinate of the center <br /> |
| `color0` | `int`: The sRGB color to use at the start of the sweep <br /> |
| `color1` | `int`: The sRGB color to use at the end of the sweep <br /> |

### SweepGradient

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SweepGradient (float cx, 
                float cy, 
                int[] colors, 
                float[] positions)
```

A Shader that draws a sweep gradient around a center point.

<br />

| Parameters ||
|---|---|
| `cx` | `float`: The x-coordinate of the center <br /> |
| `cy` | `float`: The y-coordinate of the center <br /> |
| `colors` | `int`: The sRGB colors to be distributed between around the center. There must be at least 2 colors in the array. This value cannot be `null`. <br /> |
| `positions` | `float`: May be NULL. The relative position of each corresponding color in the colors array, beginning with 0 and ending with 1.0. If the values are not monotonic, the drawing may produce unexpected results. If positions is NULL, then the colors are automatically spaced evenly. This value may be `null`. <br /> |

### SweepGradient

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SweepGradient (float cx, 
                float cy, 
                long color0, 
                long color1)
```

A Shader that draws a sweep gradient around a center point.

<br />

| Parameters ||
|---|---|
| `cx` | `float`: The x-coordinate of the center <br /> |
| `cy` | `float`: The y-coordinate of the center <br /> |
| `color0` | `long`: The color to use at the start of the sweep <br /> |
| `color1` | `long`: The color to use at the end of the sweep <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the colors do not share the same `https://developer.android.com/reference/android/graphics/ColorSpace` or do not use a valid one. |

### SweepGradient

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SweepGradient (float cx, 
                float cy, 
                long[] colors, 
                float[] positions)
```

A Shader that draws a sweep gradient around a center point.

<br />

| Parameters ||
|---|---|
| `cx` | `float`: The x-coordinate of the center <br /> |
| `cy` | `float`: The y-coordinate of the center <br /> |
| `colors` | `long`: The colors to be distributed between around the center. There must be at least 2 colors in the array. This value cannot be `null`. <br /> |
| `positions` | `float`: May be NULL. The relative position of each corresponding color in the colors array, beginning with 0 and ending with 1.0. If the values are not monotonic, the drawing may produce unexpected results. If positions is NULL, then the colors are automatically spaced evenly. This value may be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if there are less than two colors, the colors do not share the same `https://developer.android.com/reference/android/graphics/ColorSpace` or do not use a valid one, or `positions` is not `null` and has a different length from `colors`. |