<commit_before>/**
 * Created by luketwyman on 26/01/2015.
 */
import App = require("./../App");
import Size = Fayde.Utils.Size;
import Grid = require("./../Grid");
import IBlock = require("./../Blocks/IBlock");
import BlocksSketch = require("./../BlocksSketch");

var MAX_FPS: number = 100;
var MAX_MSPF: number = 1000 / MAX_FPS;

class ToolTip {

    private _Ctx: CanvasRenderingContext2D;
    private _Sketch: BlocksSketch;
    public Name: string;
    public Alpha: number;
    public Open: boolean;
    public Position: Point;
    private _AlphaTween: TWEEN.Tween;

    private _Timer: Fayde.ClockTimer;
    private _LastVisualTick: number = new Date(0).getTime();


    constructor(ctx: CanvasRenderingContext2D,sketch: BlocksSketch) {

        this._Ctx = ctx;
        this._Sketch = sketch;
        this.Name = "";
        this.Alpha = 0;
        this.Open = false;
        this.Position = new Point(0,0);

        this._Timer = new Fayde.ClockTimer();
        this._Timer.RegisterTimer(this);

    }

    OnTicked (lastTime: number, nowTime: number) {
        var now = new Date().getTime();
        if (now - this._LastVisualTick < MAX_MSPF) return;
        this._LastVisualTick = now;

        TWEEN.update(nowTime);
    }

    //-------------------------------------------------------------------------------------------
    //  DRAWING
    //-------------------------------------------------------------------------------------------


    Draw() {

        var units = this._Sketch.Unit.width;
        var ctx = this._Ctx;
        var dataType = Math.round(units*10);
        var thisAlpha = this.Alpha/100;

        ctx.font = "400 " + dataType + "px Dosis";
        var thisWidth = ctx.measureText(this.Name.toUpperCase()).width + (40*units);
        var x = this.Position.x + (this._Sketch.ScaledCellWidth.width*0);
        var y = this.Position.y;

        // BG //
        ctx.globalAlpha = thisAlpha*0.9;
        ctx.fillStyle = "#000";

        ctx.beginPath();
        ctx.moveTo(x,y);
        ctx.lineTo(x + thisWidth,y);
        ctx.lineTo(x + thisWidth,y + (20*units));
        ctx.lineTo(x + (20*units),y + (20*units));
        ctx.closePath();
        ctx.fill();

        // NAME //
        ctx.globalAlpha = thisAlpha;
        ctx.fillStyle = App.Palette[8]; // WHITE
        ctx.textAlign = "left";
        ctx.fillText(this.Name.toUpperCase(), x + (30*units), y + (10*units) + (dataType*0.36));
    }

    //-------------------------------------------------------------------------------------------
    //  TWEEN
    //-------------------------------------------------------------------------------------------


    AlphaTo(panel,destination,t) {

        console.log("dest: " + destination);
        if (this._AlphaTween) {
            this._AlphaTween.stop();
        }
        this._AlphaTween = new TWEEN.Tween({x: this.Alpha});
        this._AlphaTween.to({x: destination}, t);
        this._AlphaTween.onUpdate(function () {
            panel.Alpha = this.x;
        });
        this._AlphaTween.onComplete(function () {
            if (!panel.Open) {
                panel.Alpha = 0;
            }

        });
        this._AlphaTween.easing(TWEEN.Easing.Quintic.InOut);
        this._AlphaTween.start(this._LastVisualTick);


    }


}

export = ToolTip;<commit_msg>ToolTip block names added | UI folder added<commit_after>/**
 * Created by luketwyman on 26/01/2015.
 */
import App = require("./../App");
import Size = Fayde.Utils.Size;
import Grid = require("./../Grid");
import IBlock = require("./../Blocks/IBlock");
import BlocksSketch = require("./../BlocksSketch");

var MAX_FPS: number = 100;
var MAX_MSPF: number = 1000 / MAX_FPS;

class ToolTip {

    private _Ctx: CanvasRenderingContext2D;
    private _Sketch: BlocksSketch;
    public Name: string;
    public Alpha: number;
    public Open: boolean;
    public Position: Point;
    private _AlphaTween: TWEEN.Tween;

    private _Timer: Fayde.ClockTimer;
    private _LastVisualTick: number = new Date(0).getTime();


    constructor(ctx: CanvasRenderingContext2D,sketch: BlocksSketch) {

        this._Ctx = ctx;
        this._Sketch = sketch;
        this.Name = "";
        this.Alpha = 0;
        this.Open = false;
        this.Position = new Point(0,0);

        this._Timer = new Fayde.ClockTimer();
        this._Timer.RegisterTimer(this);

    }

    OnTicked (lastTime: number, nowTime: number) {
        var now = new Date().getTime();
        if (now - this._LastVisualTick < MAX_MSPF) return;
        this._LastVisualTick = now;

        TWEEN.update(nowTime);
    }

    //-------------------------------------------------------------------------------------------
    //  DRAWING
    //-------------------------------------------------------------------------------------------


    Draw() {

        var units = this._Sketch.Unit.width;
        var ctx = this._Ctx;
        var dataType = Math.round(units*10);
        var thisAlpha = this.Alpha/100;

        ctx.font = "400 " + dataType + "px Dosis";
        var thisWidth = ctx.measureText(this.Name.toUpperCase()).width + (40*units);
        var x = this.Position.x + (this._Sketch.ScaledCellWidth.width*0);
        var y = this.Position.y;

        // BG //
        ctx.globalAlpha = thisAlpha*0.9;
        ctx.fillStyle = "#000";

        ctx.beginPath();
        ctx.moveTo(x,y);
        ctx.lineTo(x + thisWidth,y);
        ctx.lineTo(x + thisWidth,y + (20*units));
        ctx.lineTo(x + (20*units),y + (20*units));
        ctx.closePath();
        ctx.fill();

        // NAME //
        ctx.globalAlpha = thisAlpha;
        ctx.fillStyle = App.Palette[8]; // WHITE
        ctx.textAlign = "left";
        ctx.fillText(this.Name.toUpperCase(), x + (30*units), y + (10*units) + (dataType*0.36));
    }

    //-------------------------------------------------------------------------------------------
    //  TWEEN
    //-------------------------------------------------------------------------------------------


    AlphaTo(panel,destination,t) {

        if (this._AlphaTween) {
            this._AlphaTween.stop();
        }
        this._AlphaTween = new TWEEN.Tween({x: this.Alpha});
        this._AlphaTween.to({x: destination}, t);
        this._AlphaTween.onUpdate(function () {
            panel.Alpha = this.x;
        });
        this._AlphaTween.easing(TWEEN.Easing.Quintic.InOut);
        this._AlphaTween.start(this._LastVisualTick);
    }


}

export = ToolTip;
{'fraction_non_alphanumeric': 0.24195046439628484, 'fraction_numerical': 0.015944272445820435, 'mean_word_length': 1.5208739758095982, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6492321', 'n_tokens_mistral': 1993, 'n_tokens_neox': 1890, 'n_words': 366}