Bezier

A Bézier Curve

Source code for above example

Syntax

val bezier = Bezier(anchor1, control1, control2, anchor2)

val bezier = Bezier(anchor1, control1, control2, anchor2, detail)

val bezier = Bezier(x1, y1, x2, y2, x3, y3, x4, y4)

val bezier = Bezier(x1, y1, x2, y2, x3, y3, x4, y4, detail)


Bezier has a builtin draw() method: bezier.draw()


The raw lines are also available if you want more control:


val colourA = Color.random()
val colourB = Color.random()
bezier.lines.forEachIndexed { index, line ->
    stroke(Color.lerp(colourA, colourB, (index.toFloat()/bezier.lines.size)))
    line(line)
}