Thread
#compose
    e

    efemoney

    2 years ago
    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
    painters.forEach {
      canvas.withTranslate(offset.x, offset.y) {
        it.draw(canvas)
      }
      offset.y += it.heightRespectingAspectRatio
    }
    Not sure the equivalent in compose
    Nader Jawad

    Nader Jawad

    2 years ago
    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