Member-only story
Create Beautiful Programmatic Random Drawing Easily With Perlin Noise in Jetpack Compose
Making beautiful art under 40 lines of code using Perlin Noise
Random numbers are useful for many things. However, sometimes they are too random. We want to draw something which is smooth programmatically like below:

Here I will try to explain what Perlin Noise is, and also explore the code that generates the above wavey animation above.
What is Perlin Noise?
A random value is having a parameter of min and max. If we plot it, between 0 and height, 1 for each X pixel, it will look like below, all over the place.
for (x in 0 until width) {
val drawHeight = height - (0..height)
drawPoints(
listOf(Offset(x, drawHeight)),
PointMode.Points,
Color.WHITE,
2f
)
}

Perlin Noise is a function with 1, 2, or 3 parameters, depending on how many…