replacementFunction = function replacementFunction() {
              var _this = this;
              // Uses the current preload counting mechanism for now.
              this._incrementPreload();
              // A variable for the callback function if specified
              var callback = null;
              // A variable for the errorCallback function if specified
              var errorCallback = null;
              for (
                var _len = arguments.length, args = new Array(_len), _key = 0;
                _key < _len;
                _key++
              ) {
                args[_key] = arguments[_key];
              }
              if (addCallbacks) {
                // Loop from the end of the args array, pulling up to two functions off of
                // the end and putting them in fns
                for (var i = args.length - 1; i >= 0 && !errorCallback; i--) {
                  if (typeof args[i] !== 'function') {
                    break;
                  }
                  errorCallback = callback;
                  callback = args.pop();
                }
              }
              // Call the underlying function and pass it to Promise.resolve,
              // so that even if it didn't return a promise we can still
              // act on the result as if it did.
              var promise = Promise.resolve(fn.apply(this, args));
              // Add the optional callbacks
              if (callback) {
                promise.then(callback);
              }
              if (errorCallback) {
                promise.catch(errorCallback);
              }
              // Decrement the preload counter only if the promise resolved
              promise.then(function() {
                return _this._decrementPreload();
              });
              // Return the original promise so that neither callback changes the result.
              return promise;
            }
Generate a cubic Bezier representing an arc on the unit circle of total
angle `size` radians, beginning `start` radians above the x-axis. Up to
four of these curves are combined to make a full arc.

See www.joecridge.me/bezier.pdf for an explanation of the method.