https://kotlinlang.org logo
e

efemoney

09/13/2020, 3:20 AM
Algorithm is simple-ish, I want to track the offset of the current painter and draw it into the containers canvas, translating the canvas as necessary. With the
View
system I think it’ll be something like
Copy code
painters.forEach {
  canvas.withTranslate(offset.x, offset.y) {
    it.draw(canvas)
  }
  offset.y += it.heightRespectingAspectRatio
}
Not sure the equivalent in compose
n

Nader Jawad

09/16/2020, 1:02 AM
Painters are by default already translates such that the origin is always at (0, 0). This already happens by default within compose. If you want you can create a Painter implementation that wraps another Painter and translate the canvas accordingly for it as part of its onDraw implementation