I’m coming to Openrndr from Processing. Love to see that Openrndr supports 32-bit color and a comprehensive Shape library.
But, I have to admit that I’m not loving Kotlin. Or maybe I just don’t love how the code-block-centric style of Program makes it hard to follow the control flow.
Are there any examples of using Openrndr from Java?
OpenRNDR APIs make heavy use of Kotlin’s “DSL” style, but you have flexibility here.
For example, when building a ShapeContour, you can use the “blocks style”:
val contour1 = contour {
moveTo(Vector2.ZERO)
lineTo(100.0, 100.0)
}
or you can just call methods directly:
val builder = ContourBuilder(false)
builder.moveTo(Vector2.ZERO)
builder.lineTo(100.0, 100.0)
val contour2 = builder.result.first()
Thanks for sharing that. I find it useful to be able to compare how the Kotlin program would compare to the Java equivalent. I think the Kotlin version would look like this:
Is the issue with control flow related only to extend { }?
(equivalent to void draw() { } in Processing)
Or also to other cases?
ps. I remember that it did feel weird for me at the beginning of using OPENRNDR the apparent “magic” of that { ... } syntax (coming from Processing and openFrameworks) but got used to it. It’s totally fine to use Kotlin without that feature, but OPENRNDR uses it in many places. When I convert Processing programs from Java to Kotlin the code is just much shorter, but the structure stays the same (so how easy or hard is to follow the flow doesn’t change I think).