title: Creating reusable draw functions in Jetpack Compose Canvas
body: <p>I'm drawing multiple rings in a Compose Canvas by using the <code>drawArc()</code> function</p>
  <p><a href="https://i.stack.imgur.com/RzG1Qm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RzG1Qm.png" alt="enter image description here" /></a></p>
  <p>Most of values being passed into <code>drawArc()</code> are the same apart from <code>colour</code>, <code>sweepAngle</code> and a radius value for controlling the ring size. I would like to abstract most of the drawArc code into a external, reusable function and just pass in those customizable values so I can keep my Canvas code small and easier to read, but I'm struggling trying to provide the Drawscope exposed by the Canvas composable.</p>
  <p>Is it possible to do something along the lines of -</p>
  <pre><code>Canvas() {
      drawRing(Color.Red, 360f, 200f)
      drawRing(Color.Blue, 180f, 400f) 
  }
  
  //ComposeUtils.kt
  fun drawRing(color: Color, sweepAngle: Float, arcRadius: Float) {
      
      //Drawscope here?
     
      val canvasWidth = size.width
      val canvasHeight = size.height
  
      drawArc(
          color = color,
          startAngle = 0f,
          sweepAngle = sweepAngle,
          useCenter = false,
          topLeft = Offset(
             (canvasWidth / 2) - (arcRadius / 2),
              canvasHeight / 2 - (arcRadius / 2)
          ),
          size = Size(arcRadius,
          arcRadius),
          style = Stroke(10.0f))
  }
  </code></pre>