-
Notifications
You must be signed in to change notification settings - Fork 37
/
DemoNPointRadialGradient01.kt
40 lines (37 loc) · 1.3 KB
/
DemoNPointRadialGradient01.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.color.rgb
import org.openrndr.extra.shadestyles.NPointRadialGradient
import org.openrndr.shape.Circle
import kotlin.random.Random
/**
* Demonstrate using a multi color radial gradient.
* The gradient has 5 colors (first and last ones are transparent).
* Any of the properties can be animated, including colors and points.
* See DemoNPointLinearGradient01.kt for an example of animated properties.
*/
fun main() {
application {
program {
val gradient = NPointRadialGradient(arrayOf(
ColorRGBa.PINK.opacify(0.0),
ColorRGBa.PINK, ColorRGBa.WHITE, ColorRGBa.PINK,
ColorRGBa.PINK.opacify(0.0)
), arrayOf(0.0, 0.4, 0.5, 0.6, 1.0))
val circles = List(25) {
Circle(Random.nextDouble() * drawer.width,
Random.nextDouble() * drawer.height,
Random.nextDouble() * 150.0)
}
extend {
drawer.run {
clear(rgb(0.2))
shadeStyle = gradient
fill = ColorRGBa.WHITE
stroke = null
circles(circles)
}
}
}
}
}