<commit_before>function _snapPixel (p) {
    return Math.floor(p);
}

function _uninterpolate(a, b) {
    b = (b -= a) || 1 / b;
    return function(x) { return (x - a) / b; };
}

function _interpolate(a, b) {
    return function(t) { return a * (1 - t) + b * t; };
}

// pixi config
PIXI.utils._saidHello = true;

window['widgets.pixi-grid'] = Polymer({
    is: 'pixi-grid',

    properties: {
        debugInfo: {
            type: Object,
            value: function () { return {
                xAxisScale: 0,
                xMinLevel: 0,
                xMaxLevel: 0,
                yAxisScale: 0,
                yMinLevel: 0,
                yMaxLevel: 0,
            }; },
        },

        showDebugInfo: {
            type: Boolean,
            value: false,
            reflectToAttribute: true
        },

        showLabelH: {
            type: Boolean,
            value: false,
            reflectToAttribute: true
        },

        showLabelV: {
            type: Boolean,
            value: false,
            reflectToAttribute: true
        },
    },

    created: function () {
        this.canvasWidth = 0;
        this.canvasHeight = 0;
        this.worldPosition = [0, 0];

        this.labels = [];
        this.labelIdx = 0;

        this.hticks = null;
        this.xAxisScale = 1.0;
        this.xAxisOffset = 0.0;
        this.xAnchor = 0.5;

        this.vticks = null;
        this.yAxisScale = 1.0;
        this.yAxisOffset = 0.0;
        this.yAnchor = 0.5;

        // this is generated in setMapping
        this._xAnchorOffset = 0.0;
        this._yAnchorOffset = 0.0;

    },

    ready: function () {
        var rect = this.$.view.getBoundingClientRect();
        this.renderer = new PIXI.WebGLRenderer( rect.width, rect.height, {
            view: this.$.canvas,
            transparent: true,
        });

        this.stage = new PIXI.Container();
        var background = new PIXI.Container();
        this.stage.addChild(background);

        this.graphics = new PIXI.Graphics();
        background.addChild(this.graphics);
    },

    // default 0.5, 0.5
    setAnchor: function ( x, y ) {
        this.xAnchor = Math.clamp( x, -1, 1 );
        this.yAnchor = Math.clamp( y, -1, 1 );
    },

    // recommended: [5,2], 0.001, 1000
    setScaleH: function ( lods, minScale, maxScale, type ) {
        this.hticks = new LinearTicks()
        .initTicks( lods, minScale, maxScale )
        .spacing ( 10, 80 )
        ;
        this.xAxisScale = Math.clamp(this.xAxisScale,<commit_msg>add light dom ready event<commit_after>function _snapPixel (p) {
    return Math.floor(p);
}

function _uninterpolate(a, b) {
    b = (b -= a) || 1 / b;
    return function(x) { return (x - a) / b; };
}

function _interpolate(a, b) {
    return function(t) { return a * (1 - t) + b * t; };
}

// pixi config
PIXI.utils._saidHello = true;

window['widgets.pixi-grid'] = Polymer({
    is: 'pixi-grid',

    properties: {
        debugInfo: {
            type: Object,
            value: function () { return {
                xAxisScale: 0,
                xMinLevel: 0,
                xMaxLevel: 0,
                yAxisScale: 0,
                yMinLevel: 0,
                yMaxLevel: 0,
            }; },
        },

        showDebugInfo: {
            type: Boolean,
            value: false,
            reflectToAttribute: true
        },

        showLabelH: {
            type: Boolean,
            value: false,
            reflectToAttribute: true
        },

        showLabelV: {
            type: Boolean,
            value: false,
            reflectToAttribute: true
        },
    },

    created: function () {
        this.canvasWidth = 0;
        this.canvasHeight = 0;
        this.worldPosition = [0, 0];

        this.labels = [];
        this.labelIdx = 0;

        this.hticks = null;
        this.xAxisScale = 1.0;
        this.xAxisOffset = 0.0;
        this.xAnchor = 0.5;

        this.vticks = null;
        this.yAxisScale = 1.0;
        this.yAxisOffset = 0.0;
        this.yAnchor = 0.5;

        // this is generated in setMapping
        this._xAnchorOffset = 0.0;
        this._yAnchorOffset = 0.0;

    },

    ready: function () {
        var rect = this.$.view.getBoundingClientRect();
        this.renderer = new PIXI.WebGLRenderer( rect.width, rect.height, {
            view: this.$.canvas,
            transparent: true,
        });

        this.stage = new PIXI.Container();
        var background = new PIXI.Container();
        this.stage.addChild(background);

        this.graphics = new PIXI.Graphics();
        background.addChild(this.graphics);
    },

    attached: function () {
        this.async(function() {
            this.lightDomReady();
        });
    },

    lightDomReady: function() {
        this.resize();
        this.repaint();
    },

    // default 0.5, 0.5
    setAnchor: function ( x, y ) {
        this.xAnchor = Math.clamp( x, -1, 1 );
        this.yAnchor = Math.clamp( y, -1, 1 );
    },

    // recommended: [5,2], 0.001, 1000
    setScaleH: function ( lods, minScale, maxScale, type ) {
        this.hticks = new LinearTicks()
        .initTicks( lods, minScale, maxScale )
        .spacing ( 10, 80 )
        ;
        this.xAxisScale = Math.clamp(this.xAxisScale,
{'fraction_non_alphanumeric': 0.1280545557870809, 'fraction_numerical': 0.01932184125781398, 'mean_word_length': 1.5311601150527325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5816083', 'n_tokens_mistral': 1760, 'n_tokens_neox': 1640, 'n_words': 371}