      1 (function() {
      2
      3   /**
      4    * Removes value from an array.
      5    * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`
      6    * @static
      7    * @memberOf fabric.util
      8    * @method removeFromArray
      9    * @param {Array} array
     10    * @param {Any} value
     11    * @return {Array} original array
     12    */
     13   function removeFromArray(array, value) {
     14     var idx = array.indexOf(value);
     15     if (idx !== -1) {
     16       array.splice(idx, 1);
     17     }
     18     return array;
     19   };
     20
     21   /**
     22    * Returns random number between 2 specified ones.
     23    * @static
     24    * @method getRandomInt
     25    * @memberOf fabric.util
     26    * @param {Number} min lower limit
     27    * @param {Number} max upper limit
     28    * @return {Number} random value (between min and max)
     29    */
     30   function getRandomInt(min, max) {
     31     return Math.floor(Math.random() * (max - min + 1)) + min;
     32   }
     33
     34   var PiBy180 = Math.PI / 180;
     35
     36   /**
     37    * Transforms degrees to radians.
     38    * @static
     39    * @method degreesToRadians
     40    * @memberOf fabric.util
     41    * @param {Number} degrees value in degrees
     42    * @return {Number} value in radians
     43    */
     44   function degreesToRadians(degrees) {
     45     return degrees * PiBy180;
     46   }
     47
     48   /**
     49    * A wrapper around Number#toFixed, which contrary to native method returns number, not string.
     50    * @static
     51    * @method toFixed
     52    * @memberOf fabric.util
     53    * @param {Number | String} number number to operate on
     54    * @param {Number} fractionDigits number of fraction digits to "leave"
     55    * @return {Number}
     56    */
     57    function toFixed(number, fractionDigits) {
     58      return parseFloat(Number(number).toFixed(fractionDigits));
     59    }
     60
     61    /**
     62     * Function which always returns `false`.
     63     * @static
     64     * @method falseFunction
     65     * @memberOf fabric.util
     66     * @return {Boolean}
     67     */
     68    function falseFunction() {
     69      return false;
     70    }
     71
     72    fabric.util.removeFromArray = removeFromArray;
     73    fabric.util.degreesToRadians = degreesToRadians;
     74    fabric.util.toFixed = toFixed;
     75    fabric.util.getRandomInt = getRandomInt;
     76    fabric.util.falseFunction = falseFunction;
     77 })();