title: Android Jetpack Composable Draw Large List of coordinates
body: <p>I have a list of 36000 coordinates i need to plot on a canvas as dots.  Coordinates keep changing so i keep them in a map as part of my viewmodel as</p>
  <p><code>mutableStateOf(HashMap&lt;Int, AtomicInteger&gt;())</code> and the AtomicIntegers are being constantly updated.</p>
  <p>The map is of angles and distance which i convert to coords on the canvas.  This works but my question is if this is the most efficient way to draw this - iterating through the map continuously seems inefficient</p>
  <pre><code>@Composable
  fun lidarComposable(vm: MainViewModel) {
      MaterialTheme {
          Column {
              Canvas(modifier = Modifier.size(500.dp, 500.dp)) {
                  drawRect(Color.LightGray, topLeft = Offset(0f, 0f), size = Size(this.size.width, this.size.height))
                  drawCircle(Color.Blue, 20F, this.center)
                  vm.lidardata.data.forEach { (a, d) -&gt;
                          val angle: Double = a.toDouble() / Lidar.relevence
                          val distance: Double = (d.get() / Lidar.relevence).toDouble()
                          val fixed = angle - vm.compass
                          val rad = fixed * PI / 180
                          val xx = this.center.x + (distance * cos(rad))
                          val yy = this.center.y + (distance * sin(rad))
                          drawCircle(Color.Red, 5F, Offset(xx.toFloat(), yy.toFloat()))
                  }
              }
          }
      }
  }
  </code></pre>
  <p>Result is a gray canvas with a blue circle at center and the dots where i want them, just seems like there must be a better way.</p>
  <p>After a while of collecting data from a spinning LIDAR I end up with a pretty good picture of the room but i'm new to compose and wonder if there is a better way to push changes to the canvas.<a href="https://i.stack.imgur.com/6LMoA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6LMoA.png" alt="enter image description here" /></a></p>