openrndr
openrndr copied to clipboard
Batch Mode individual draw style
Describe the bug
The batch mode methods like drawer.circles and drawer.rectangles lock in on the style that was set before the method call. The individual classes should have a way to set them before rendering.
To Reproduce
drawer.circles((0 until 100).map{
drawer.fill = ColorRgba(Random.nextDouble(1.0), Random.nextDouble(1.0), Random.nextDouble(1.0)
Circle(Random.nextDouble(width), Random.nextDouble(height), 10.0)
})
Expected behavior All circles should have a random colour
Context:
- macOS 10.14.6
- OpenRNDR 0.3.35
- 1.8
Hi @mhaqs while I understand the intention and the need for drawing methods that allow a way of working similar to what you propose, it is not exactly a bug. Drawer.circles uses one fill and stroke color for the entire list. Your code changes the fill color while constructing the list (in strict evaluation order), at the time circles is invoked it only sees the last color set and continues to draw with that.
Thanks for responding @edwinRNDR. I may have made an error in expressing the intent here:
val circles = ArrayList<Circle>
for (i in 0 until 100) {
drawer.fill = ColorRgba(Random.nextDouble(1.0), Random.nextDouble(1.0), Random.nextDouble(1.0)
arrayList.add(Circle(Random.nextDouble(width), Random.nextDouble(height), 10.0))
}
drawer.circles(circles)
I'm not reporting a bug, but a feature request where I want each Circle to have a different color but still use the batch circles method.
I see that circles has overloads for accepting radii for all individual circles in the list. A similar approach for styles could be taken? Although, I see how that would require a bit of work.
@edwinRNDR I believe this has been addressed with drawer.circleBatch?
As @ricardomatias mentioned, two examples of circle batches with unique fill and stroke properties:
- https://github.com/openrndr/orx/blob/master/openrndr-demos/src/demo/kotlin/DemoCircleBatch02.kt
- https://github.com/openrndr/orx/blob/master/openrndr-demos/src/demo/kotlin/DemoCircleBatch03.kt
There is drawer.circleBatch, drawer.pointBatch and drawer.rectangleBatch.
Issue can be closed?