I was having some difficulties understanding the contour { ... arcTo }
method, so I wrote this helper program which uses a GUI to change the arc parameters:
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.extra.gui.GUI
import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.shape.contour
fun main() = application {
configure { }
program {
val gui = GUI()
val conf = @Description("Arc") object {
@DoubleParameter("crx", 0.0, 640.0, order = 5)
var crx = 0.0
@DoubleParameter("cry", 0.0, 480.0, order = 10)
var cry = 0.0
@DoubleParameter("angle", -180.0, 180.0, order = 15)
var angle = 0.0
@BooleanParameter("largeArcFlag", order = 20)
var largeArcFlag = true
@BooleanParameter("sweepFlag", order = 25)
var sweepFlag = true
@DoubleParameter("tx", 0.0, 640.0, order = 30)
var tx = 0.0
@DoubleParameter("ty", 0.0, 480.0, order = 35)
var ty = 0.0
}
extend(gui) {
compartmentsCollapsedByDefault = false
add(conf)
}
extend {
drawer.clear(ColorRGBa.WHITE)
drawer.contour(
contour {
moveTo(drawer.bounds.center)
arcTo(conf.crx, conf.cry, conf.angle, conf.largeArcFlag, conf.sweepFlag, conf.tx, conf.ty)
}
)
}
}
}
The arcTo
method is based on this code.
I realized that in my case I always want crx
to be equal to cry
. In that case angle
seems to have no effect.
I’ll share a function to draw an arc with a center
, a start
point and an end
point soon.