Home / Coracle / Drawings / Colonoscopy
import coracle.Color
import coracle.Drawing
import coracle.Math.map
import kotlin.math.cos
import kotlin.math.sin
class Colonoscopy: Drawing() {
val bg = 0x000000
val maxZ = 1100f
override fun setup() {
size(750, 750)
noStroke()
fill(0xffffff)
}
override fun draw() {
background(bg)
for(i in 1600 downTo 0){
val z = width * 40/i
val a = i + frame * 2
val x = sin(a.toDouble()) * z + (sin(a/(width.toFloat()) * 1.2) + 2) * 200
val y = cos(a.toDouble()) * z + (sin(a/(width.toFloat()) / 1.2) + 2) * 200
val r = map(z.toFloat(), 1f, maxZ, 0f, 255f).toInt()
val g = map(z.toFloat(), 1f, maxZ, 0f, 155f).toInt()
val b = map(z.toFloat(), 1f, maxZ, 0f, 155f).toInt()
fill(Color(r, g, b))
circle(x, y, z * 0.3)
}
}
}