<commit_before>var _ = require('./util');
var Node = require('./node');

var Text = function() {
  Node.apply(this, arguments);
};


Text.prototype = _.extend(Text.prototype, Node.prototype, {
  draw: function(ctx) {
    if (!this.visible) {
      return;
    }

    var x = this.x || 0;
    var y = this.y || 0;

    ctx.font = this.font || (this.fontSize + 'px ' + this.fontFamily) || '10px sans-serif';
    ctx.textAlign = this.textAlign || 'start';
    ctx.textBaseline = this.textBaseline || 'alphabetic';

    if (this.fillStyle) {
      ctx.fillStyle = this.fillStyle;
      ctx.fillText(this.text, x, y);
    }
    if (this.strokeStyle) {
      ctx.strokeStyle = this.strokeStyle;
      ctx.lineWidth = this.lineWidth || 1;
      ctx.lineCap = this.lineCap || 'butt';
      ctx.lineJoin = this.lineJoin || 'miter';
      ctx.strokeText(this.text, x, y);
    }
  },

  pick: function(ctx, x, y, lx, ly) {
    if (!this.visible) {
      return;
    }

    var x = this.x || 0;
    var y = this.y || 0;
    var width = ctx.measureText(this.text);
    // XXX Height
    if (lx >= x && lx < x+width && ly >= y && ly < y+10) {
      return this;
    }
  }
});


module.exports = Text;<commit_msg>Support rotation of text (and apply transition first)<commit_after>var _ = require('./util');
var Node = require('./node');

var Text = function() {
  Node.apply(this, arguments);
};


Text.prototype = _.extend(Text.prototype, Node.prototype, {
  draw: function(ctx) {
    if (!this.visible) {
      return;
    }

    var x = this.x || 0;
    var y = this.y || 0;

    if (this.rotation) {
      ctx.save();
      ctx.translate(x,y);
      x = 0;
      y = 0;
      ctx.rotate(this.rotation);
    }

    ctx.font = this.font || (this.fontSize + 'px ' + this.fontFamily) || '10px sans-serif';
    ctx.textAlign = this.textAlign || 'start';
    ctx.textBaseline = this.textBaseline || 'alphabetic';

    if (this.fillStyle) {
      ctx.fillStyle = this.fillStyle;
      ctx.fillText(this.text, x, y);
    }
    if (this.strokeStyle) {
      ctx.strokeStyle = this.strokeStyle;
      ctx.lineWidth = this.lineWidth || 1;
      ctx.lineCap = this.lineCap || 'butt';
      ctx.lineJoin = this.lineJoin || 'miter';
      ctx.strokeText(this.text, x, y);
    }

    if (this.rotation) {
      ctx.restore();
    }
  },

  pick: function(ctx, x, y, lx, ly) {
    if (!this.visible) {
      return;
    }

    var x = this.x || 0;
    var y = this.y || 0;
    var width = ctx.measureText(this.text);
    // XXX Height
    if (lx >= x && lx < x+width && ly >= y && ly < y+10) {
      return this;
    }
  }
});


module.exports = Text;
{'fraction_non_alphanumeric': 0.17301829268292682, 'fraction_numerical': 0.007621951219512195, 'mean_word_length': 2.2853566958698375, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2164659', 'n_tokens_mistral': 968, 'n_tokens_neox': 923, 'n_words': 212}