%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/shaban/laviva/wp-content/themes/levelup/assets/js/
Upload File :
Create Path :
Current File : /var/www/html/shaban/laviva/wp-content/themes/levelup/assets/js/graphic.js

/**
 * Renderer to render the chart on a canvas object
 * @param {DOMElement} el      DOM element to host the canvas (root of the plugin)
 * @param {object}     options options object of the plugin
 */
var CanvasRenderer = function(el, options) {
    var cachedBackground;
    var canvas = document.createElement('canvas');

    el.appendChild(canvas);

    if (typeof(G_vmlCanvasManager) !== 'undefined') {
        G_vmlCanvasManager.initElement(canvas);
    }

    var ctx = canvas.getContext('2d');

    canvas.width = canvas.height = options.size;

    // canvas on retina devices
    var scaleBy = 1;
    if (window.devicePixelRatio > 1) {
        scaleBy = window.devicePixelRatio;
        canvas.style.width = canvas.style.height = [options.size, 'px'].join('');
        canvas.width = canvas.height = options.size * scaleBy;
        ctx.scale(scaleBy, scaleBy);
    }

    // move 0,0 coordinates to the center
    ctx.translate(options.size / 2, options.size / 2);

    // rotate canvas -90deg
    ctx.rotate((-1 / 2 + options.rotate / 180) * Math.PI);

    var radius = (options.size - options.lineWidth) / 2;
    if (options.scaleColor && options.scaleLength) {
        radius -= options.scaleLength + 2; // 2 is the distance between scale and bar
    }

    // IE polyfill for Date
    Date.now = Date.now || function() {
        return +(new Date());
    };

    /**
     * Draw a circle around the center of the canvas
     * @param {strong} color     Valid CSS color string
     * @param {number} lineWidth Width of the line in px
     * @param {number} percent   Percentage to draw (float between -1 and 1)
     */
    var drawCircle = function(color, lineWidth, percent) {
        percent = Math.min(Math.max(-1, percent || 0), 1);
        var isNegative = percent <= 0 ? true : false;

        ctx.beginPath();
        ctx.arc(0, 0, radius, 0, Math.PI * 2 * percent, isNegative);

        ctx.strokeStyle = color;
        ctx.lineWidth = lineWidth;

        ctx.stroke();
    };

    /**
     * Draw the scale of the chart
     */
    var drawScale = function() {
        var offset;
        var length;

        ctx.lineWidth = 1;
        ctx.fillStyle = options.scaleColor;

        ctx.save();
        for (var i = 24; i > 0; --i) {
            if (i % 6 === 0) {
                length = options.scaleLength;
                offset = 0;
            } else {
                length = options.scaleLength * 0.6;
                offset = options.scaleLength - length;
            }
            ctx.fillRect(-options.size/2 + offset, 0, length, 1);
            ctx.rotate(Math.PI / 12);
        }
        ctx.restore();
    };

    /**
     * Request animation frame wrapper with polyfill
     * @return {function} Request animation frame method or timeout fallback
     */
    var reqAnimationFrame = (function() {
        return  window.requestAnimationFrame ||
            window.webkitRequestAnimationFrame ||
            window.mozRequestAnimationFrame ||
            function(callback) {
                window.setTimeout(callback, 1000 / 60);
            };
    }());

    /**
     * Draw the background of the plugin including the scale and the track
     */
    var drawBackground = function() {
        if(options.scaleColor) drawScale();
        if(options.trackColor) drawCircle(options.trackColor, options.lineWidth, 1);
    };

    /**
     * Canvas accessor
     */
    this.getCanvas = function() {
        return canvas;
    };

    /**
     * Canvas 2D context 'ctx' accessor
     */
    this.getCtx = function() {
        return ctx;
    };

    /**
     * Clear the complete canvas
     */
    this.clear = function() {
        ctx.clearRect(options.size / -2, options.size / -2, options.size, options.size);
    };

    /**
     * Draw the complete chart
     * @param {number} percent Percent shown by the chart between -100 and 100
     */
    this.draw = function(percent) {
        // do we need to render a background
        if (!!options.scaleColor || !!options.trackColor) {
            // getImageData and putImageData are supported
            if (ctx.getImageData && ctx.putImageData) {
                if (!cachedBackground) {
                    drawBackground();
                    cachedBackground = ctx.getImageData(0, 0, options.size * scaleBy, options.size * scaleBy);
                } else {
                    ctx.putImageData(cachedBackground, 0, 0);
                }
            } else {
                this.clear();
                drawBackground();
            }
        } else {
            this.clear();
        }

        ctx.lineCap = options.lineCap;

        // if barcolor is a function execute it and pass the percent as a value
        var color;
        if (typeof(options.barColor) === 'function') {
            color = options.barColor(percent);
        } else {
            color = options.barColor;
        }

        // draw bar
        drawCircle(color, options.lineWidth, percent / 100);
    }.bind(this);

    /**
     * Animate from some percent to some other percentage
     * @param {number} from Starting percentage
     * @param {number} to   Final percentage
     */
    this.animate = function(from, to) {
        var startTime = Date.now();
        options.onStart(from, to);
        var animation = function() {
            var process = Math.min(Date.now() - startTime, options.animate.duration);
            var currentValue = options.easing(this, process, from, to - from, options.animate.duration);
            this.draw(currentValue);
            options.onStep(from, to, currentValue);
            if (process >= options.animate.duration) {
                options.onStop(from, to);
            } else {
                reqAnimationFrame(animation);
            }
        }.bind(this);

        reqAnimationFrame(animation);
    }.bind(this);
};



/**
 * @author alteredq / http://alteredqualia.com/
 * @author mr.doob / http://mrdoob.com/
 */

var Detector = {

    canvas: !! window.CanvasRenderingContext2D,
    webgl: ( function () {

        try {

            var canvas = document.createElement( 'canvas' ); return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );

        } catch ( e ) {

            return false;

        }

    } )(),
    workers: !! window.Worker,
    fileapi: window.File && window.FileReader && window.FileList && window.Blob

};

// browserify support
if ( typeof module === 'object' ) {

    module.exports = Detector;

}


window.PIXI = window.PIXI || {};
PIXI.RandomDataGenerator = function (seeds) {

    if (typeof seeds === "undefined") { seeds = []; }

    /**
     * @property {number} c - Internal var.
     * @private
     */
    this.c = 1;

    /**
     * @property {number} s0 - Internal var.
     * @private
     */
    this.s0 = 0;

    /**
     * @property {number} s1 - Internal var.
     * @private
     */
    this.s1 = 0;

    /**
     * @property {number} s2 - Internal var.
     * @private
     */
    this.s2 = 0;

    this.sow(seeds);

};

PIXI.RandomDataGenerator.prototype = {

    /**
     * Private random helper.
     *
     * @method Phaser.RandomDataGenerator#rnd
     * @private
     * @return {number}
     */
    rnd: function () {

        var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32

        this.c = t | 0;
        this.s0 = this.s1;
        this.s1 = this.s2;
        this.s2 = t - this.c;

        return this.s2;
    },

    /**
     * Reset the seed of the random data generator.
     *
     * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present.
     *
     * @method Phaser.RandomDataGenerator#sow
     * @param {any[]} seeds - The array of seeds: the `toString()` of each value is used.
     */
    sow: function (seeds) {

        // Always reset to default seed
        this.s0 = this.hash(' ');
        this.s1 = this.hash(this.s0);
        this.s2 = this.hash(this.s1);
        this.c = 1;

        if (!seeds)
        {
            return;
        }

        // Apply any seeds
        for (var i = 0; i < seeds.length && (seeds[i] != null); i++)
        {
            var seed = seeds[i];

            this.s0 -= this.hash(seed);
            this.s0 += ~~(this.s0 < 0);
            this.s1 -= this.hash(seed);
            this.s1 += ~~(this.s1 < 0);
            this.s2 -= this.hash(seed);
            this.s2 += ~~(this.s2 < 0);
        }

    },

    /**
     * Internal method that creates a seed hash.
     *
     * @method Phaser.RandomDataGenerator#hash
     * @private
     * @param {any} data
     * @return {number} hashed value.
     */
    hash: function (data) {

        var h, i, n;
        n = 0xefc8249d;
        data = data.toString();

        for (i = 0; i < data.length; i++) {
            n += data.charCodeAt(i);
            h = 0.02519603282416938 * n;
            n = h >>> 0;
            h -= n;
            h *= n;
            n = h >>> 0;
            h -= n;
            n += h * 0x100000000;// 2^32
        }

        return (n >>> 0) * 2.3283064365386963e-10;// 2^-32

    },

    /**
     * Returns a random integer between 0 and 2^32.
     *
     * @method Phaser.RandomDataGenerator#integer
     * @return {number} A random integer between 0 and 2^32.
     */
    integer: function() {

        return this.rnd.apply(this) * 0x100000000;// 2^32

    },

    /**
     * Returns a random real number between 0 and 1.
     *
     * @method Phaser.RandomDataGenerator#frac
     * @return {number} A random real number between 0 and 1.
     */
    frac: function() {

        return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16;   // 2^-53

    },

    /**
     * Returns a random real number between 0 and 2^32.
     *
     * @method Phaser.RandomDataGenerator#real
     * @return {number} A random real number between 0 and 2^32.
     */
    real: function() {

        return this.integer() + this.frac();

    },

    /**
     * Returns a random integer between and including min and max.
     *
     * @method Phaser.RandomDataGenerator#integerInRange
     * @param {number} min - The minimum value in the range.
     * @param {number} max - The maximum value in the range.
     * @return {number} A random number between min and max.
     */
    integerInRange: function (min, max) {

        return Math.floor(this.realInRange(0, max - min + 1) + min);

    },

    /**
     * Returns a random integer between and including min and max.
     * This method is an alias for RandomDataGenerator.integerInRange.
     *
     * @method Phaser.RandomDataGenerator#between
     * @param {number} min - The minimum value in the range.
     * @param {number} max - The maximum value in the range.
     * @return {number} A random number between min and max.
     */
    between: function (min, max) {

        return this.integerInRange(min, max);

    },

    /**
     * Returns a random real number between min and max.
     *
     * @method Phaser.RandomDataGenerator#realInRange
     * @param {number} min - The minimum value in the range.
     * @param {number} max - The maximum value in the range.
     * @return {number} A random number between min and max.
     */
    realInRange: function (min, max) {

        return this.frac() * (max - min) + min;

    },

    /**
     * Returns a random real number between -1 and 1.
     *
     * @method Phaser.RandomDataGenerator#normal
     * @return {number} A random real number between -1 and 1.
     */
    normal: function () {

        return 1 - 2 * this.frac();

    },

    /**
     * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368
     *
     * @method Phaser.RandomDataGenerator#uuid
     * @return {string} A valid RFC4122 version4 ID hex string
     */
    uuid: function () {

        var a = '';
        var b = '';

        for (b = a = ''; a++ < 36; b +=~a % 5 | a * 3&4 ? (a^15 ? 8^this.frac() * (a^20 ? 16 : 4) : 4).toString(16) : '-')
        {
        }

        return b;

    },

    /**
     * Returns a random member of `array`.
     *
     * @method Phaser.RandomDataGenerator#pick
     * @param {Array} ary - An Array to pick a random member of.
     * @return {any} A random member of the array.
     */
    pick: function (ary) {

        return ary[this.integerInRange(0, ary.length - 1)];

    },

    /**
     * Returns a random member of `array`, favoring the earlier entries.
     *
     * @method Phaser.RandomDataGenerator#weightedPick
     * @param {Array} ary - An Array to pick a random member of.
     * @return {any} A random member of the array.
     */
    weightedPick: function (ary) {

        return ary[~~(Math.pow(this.frac(), 2) * (ary.length - 1))];

    },

    /**
     * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified.
     *
     * @method Phaser.RandomDataGenerator#timestamp
     * @param {number} min - The minimum value in the range.
     * @param {number} max - The maximum value in the range.
     * @return {number} A random timestamp between min and max.
     */
    timestamp: function (min, max) {

        return this.realInRange(min || 946684800000, max || 1577862000000);

    },

    /**
     * Returns a random angle between -180 and 180.
     *
     * @method Phaser.RandomDataGenerator#angle
     * @return {number} A random number between -180 and 180.
     */
    angle: function() {

        return this.integerInRange(-180, 180);

    }

};

PIXI.RandomDataGenerator.prototype.constructor = PIXI.RandomDataGenerator;

Zerion Mini Shell 1.0