title: Compositing millions of images on a canvas
body: <p>I'm trying to render a series of isometric blocks on a blank canvas. This however is taking up an enormous number of resources and execution time. Is there any way to efficiently render albeit similiar images to canvas?</p>
  <p>Here's the code (For representative purposes):</p>
  <pre><code>var iso = image.NewRGBA(image.Rectangle{Min: image.Point{X: 0, Y: 0}, Max: image.Point{X: 32 * 16, Y: 383*17+274}})
  
  t,err := os.Open(&quot;stone.png&quot;) // Is a 16x16 png
  if err != nil {
      log.Println(err)
  }
  
  texture, _  := png.Decode(t)
  
  x, y, z := 0,0,0
  for i:=0; i&lt;=16*16*16; i++ {
      if x == 16 {
          x=0
          z+=1
      }
  
      if z == 16 {
          z=0
          y+=1
      }
  
      draw.Draw(iso, texture.Bounds().Add(image.Point{Y: iso.Bounds().Dy() - 152 - x*8 + z*8 - y*17, X: z*16 + x*16}), texture, image.Point{X: 0, Y: 0}, draw.Over)
  
  
      x+=1
     
  }
  
  f, _ := os.Create(&quot;output.png&quot;)
  png.Encode(f,iso)
  </code></pre>
  <ul>
  <li><a href="https://i.stack.imgur.com/P4bnS.png" rel="nofollow noreferrer">CPU Profile Screenshots</a></li>
  <li><a href="https://i.stack.imgur.com/2pKAZ.png" rel="nofollow noreferrer">Memory Profile Screenshots</a></li>
  </ul>
  <p>Thanks!</p>