Is there a way to hot reload code from outside the oliveProgram block? For instance, hot reload a class in another file whenever I make changes to it.
I think @ricardo has more experience with olive. Was it possible to reload classes? I vaguely remember currently it’s not.
Okay, thanks for the info
Unfortunately it’s not possible to reload external classes via Olive.
Ok. Have a nice Christmas.
I haven’t tested with Olive, but in a normal OPENRNDR program the HotSwap option works for reloading classes without stopping the program.
I don’t know if these settings are required because I haven’t changed them in a very long time.
This is my main program:
package apps2.simpleTests
import org.openrndr.application
import org.openrndr.math.Polar
fun main() = application {
program {
val c = SimpleDrawingClass(drawer)
var angle = 0.0
extend {
angle += 1.0
drawer.run {
drawer.translate(
drawer.bounds.center +
Polar(angle, 200.0).cartesian
)
c.draw()
}
}
}
}
And this is the class I reload:
package apps2.simpleTests
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.Drawer
class SimpleDrawingClass(val drawer: Drawer) {
fun draw() {
with(drawer) {
strokeWeight = 8.0
stroke = ColorRGBa.GREEN
circle(0.0, 0.0, 100.0)
}
}
}
Then I Debug the main program, I make changes to SimpleDrawingClass
and click the hammer icon on the top bar.
The circle does not suddenly jump, so the main class is not reloaded. But the strokeWeight
or the stroke
do change after clicking the hammer.