title: Fast alternatives for UIBezierPath
body: <p>I'm making app, that can build graphs. 
  I'm working with UIBezierPath, and everything was fine until I decided to make it possible to move and scale the graph using gestures.</p>
  
  <p>here's how i'm drawing:</p>
  
  <pre class="lang-swift prettyprint-override"><code>var isFirstPoint = true
          color.set()
          funcPath.lineWidth = width
  
          for i in 0...Int(bounds.size.width * contentScaleFactor) {
              let cgX = CGFloat(i) / contentScaleFactor
              let funcX = Double ((cgX - bounds.width / 2) / scale)
  
              let funcY = function(funcX) * Double(scale)
  
              guard !funcY.isNaN else { continue }
              let cgY = -( CGFloat(funcY) - bounds.height / 2)
  
              if isFirstPoint {
                  funcPath.move(to: CGPoint(x: cgX, y: cgY))
                  isFirstPoint = false
              } else {
                  if cgY &gt; max(bounds.size.width, bounds.size.height) * 2 {
                      isFirstPoint = true
                  } else {
                      funcPath.addLine(to: CGPoint(x: cgX, y: cgY) )
                  }
              }
          }
  funcPath.stroke()
  </code></pre>
  
  <p>is there is a faster way to do it? </p>