Attractor
Ported to Coracle from www.dwitter.net/d/12129
import coracle.Colour
import coracle.Drawing
import kotlin.math.cos
import kotlin.math.sin
class Attractor: Drawing() {
private val bg = Colour(0x1d1d1d)
var X = 0.0
var Y = 0.0
sealed class Mode{
object Realtime: Mode()
object Ghost: Mode()
}
val mode: Mode = Mode.Realtime
override fun setup() {
(900, 550)
size
when(mode){
.Realtime -> stroke(0xffffff)
Mode.Ghost -> stroke(0xffffff, 0.110)
Mode}
(0x000000)
background}
override fun draw() {
if(mode == Mode.Realtime) background(bg)
val f = frame/100.0
for (i in 0..15000 ){
= X * cos(4 * (f / 2 ) + Y * 2) + Y / 4
X = cos(X+Y+X+f/3) - sin(i+X+f) / 4
Y ( (width/2) + (X * (width/2.5)), (height/2) + (Y * (height/3)))
point}
}
}