<commit_before>"use strict";

/**
 * Created by Ed on 20/04/2014.
 */
function TrailEffect(screen)
{
	this.screen = screen;
	this.numSegments = 10;
	this.points = [];
}

TrailEffect.prototype.addPoint =
	function(positionVec)
	{
		if(this.points.length > 0)
		{
			if(this.points[this.points.length-1].equals(positionVec))
				return;
		}

		this.points.push(positionVec.Clone());
		if(this.numSegments > 0 && this.points.length > this.numSegments)
		{
			this.points.shift();
		}
	};

TrailEffect.prototype.draw =
	function(canvas)
	{
		if(this.points.length > 0)
		{
			canvas.save();

			canvas.beginPath();
			canvas.moveTo(this.screen.game.worldToCanvas(this.points[0]));
			for(var pointNum = 1; pointNum < this.points.length; ++pointNum)
			{
				canvas.lineTo(this.screen.game.worldToCanvas(this.points[pointNum]));
			}
			canvas.getCanvas().lineWidth = this.screen.game.worldToCanvas(5);
			canvas.getCanvas().strokeStyle = 'rgb(0, 0, 0)';
			canvas.getCanvas().globalAlpha = 0.2;
			canvas.setLineDash([this.screen.game.worldToCanvas(3),this.screen.game.worldToCanvas(2)]);
			canvas.stroke();

			canvas.restore();<commit_msg>Limited the length of the trail effect to conserve performance<commit_after>"use strict";

/**
 * Created by Ed on 20/04/2014.
 */
function TrailEffect(screen)
{
	this.screen = screen;
	this.numSegments = 10;
	this.points = [];

	this.currentLength = 0;
}

TrailEffect.prototype.addPoint =
	function(positionVec)
	{
		if(this.points.length > 0)
		{
			if(this.points[this.points.length-1].equals(positionVec))
				return;

			this.currentLength += this.screen.game.worldToCanvas(positionVec).DistanceTo(this.screen.game.worldToCanvas(this.points[this.points.length-1]));
		}

		this.points.push(positionVec.Clone());
		if(this.numSegments > 0)
		{
			if(this.points.length > this.numSegments)
			{
				this.points.shift();
			}
		}
	};

TrailEffect.prototype.draw =
	function(canvas)
	{
		if(this.points.length > 0)
		{
			canvas.save();

			canvas.beginPath();
			canvas.moveTo(this.screen.game.worldToCanvas(this.points[this.points.length-1]));
			for(var pointNum = 1; pointNum < Math.min(100, this.points.length); ++pointNum)
			{
				canvas.lineTo(this.screen.game.worldToCanvas(this.points[this.points.length-pointNum]));
			}
			canvas.getCanvas().lineWidth = this.screen.game.worldToCanvas(5);
			canvas.getCanvas().strokeStyle = 'rgb(0, 0, 0)';
			canvas.getCanvas().globalAlpha = 0.2;
			canvas.getCanvas().lineDashOffset = -this.currentLength;
			canvas.setLineDash([this.screen.game.worldToCanvas(3),this.screen.game.worldToCanvas(2)]);
			canvas.stroke();

			canvas.restore();
{'fraction_non_alphanumeric': 0.1643835616438356, 'fraction_numerical': 0.020167427701674276, 'mean_word_length': 4.055769230769231, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2177185', 'n_tokens_mistral': 1064, 'n_tokens_neox': 927, 'n_words': 117}