<commit_before>var scale, gridX, gridY, offset, player;
var offsetX = 5;
var offsetY = 5;
var allPaths = new Array();

gridApi.setScale = function (newScale) {
    scale = newScale;
    gridX = new Point(scale, 0);
    gridY = new Point(0, scale);
    offset = new Point(offsetX * scale, offsetY * scale);
}

function onMouseDrag(event) {
    offset += event.delta;
	for (var i = 0; i < allPaths.length; i++) {
		allPaths[i].position += event.delta;
	};
}

// dummy onFrame function ensures that canvas is redrawn immediately, not just when the mouse moves
function onFrame(event) {
}

gridApi.drawGrid = function (minX, minY, maxX, maxY) {
    function gridLine(start, end) {
        var path = new Path();
        path.strokeColor = "#D0D0D0";
        path.add(start, end);
        allPaths.push(path);
    }

    // draw the vertical lines
    for (var x = minX; x <= maxX; x++) {
        var start = gridPoint(x, minY)
        var end = gridPoint(x, maxY);
        gridLine(start, end);
    };

    // draw the horizontal lines
    for (var y = minY; y <= maxY; y++) {
        var start = gridPoint(minX, y)
        var end = gridPoint(maxX, y);
        gridLine(start, end);
    };
}

function gridPoint(x, y) {
	return (gridX * x) + (gridY * y) + offset;
}

gridApi.drawBox = function(x, y, width, height, border, borderWidth, fill) {
	var path = new Path();
	path.strokeColor = border;
	path.strokeWidth = borderWidth;
	path.fillColor = fill;
	path.add(gridPoint(x, y));
	path.add(gridPoint(x + width, y));
	path.add(gridPoint(x + width, y + height));
	path.add(gridPoint(x, y + height));
	path.closed = true;
	allPaths.push(path);
}

gridApi.drawPlayer = function (x, y, radius, border, borderWidth, fill) {
    if (!player) {
        player = new Path.Circle(gridPoint(x, y), radius);
        player.strokeColor = border;
        player.strokeWidth = borderWidth;
        player.fillColor = fill;
        player.fillColor = fill;
        allPaths.push(player);
    }
    else {
        player.position = gridPoint(x, y);
        // move player to the end of the activeLayer so it gets drawn on top
        project.activeLayer.addChild(player);
    }
}

gridApi.onLoad();<commit_msg>Animate moving player<commit_after>var scale, gridX, gridY, offset, player
var playerVector, playerDestination;
var offsetX = 5;
var offsetY = 5;
var allPaths = new Array();

gridApi.setScale = function (newScale) {
    scale = newScale;
    gridX = new Point(scale, 0);
    gridY = new Point(0, scale);
    offset = new Point(offsetX * scale, offsetY * scale);
}

function onMouseDrag(event) {
    offset += event.delta;
	for (var i = 0; i < allPaths.length; i++) {
		allPaths[i].position += event.delta;
	}
    if (playerDestination) {
        playerDestination += event.delta;
    }
}

function onFrame(event) {
    if (playerVector) {
        var distance = player.position - playerDestination;
        if (distance.length > playerVector.length) {
            player.position += playerVector;
        }
        else {
            player.position = playerDestination;
            playerVector = null;
            playerDestination = null;
        }
    }
}

gridApi.drawGrid = function (minX, minY, maxX, maxY) {
    function gridLine(start, end) {
        var path = new Path();
        path.strokeColor = "#D0D0D0";
        path.add(start, end);
        allPaths.push(path);
    }

    // draw the vertical lines
    for (var x = minX; x <= maxX; x++) {
        var start = gridPoint(x, minY)
        var end = gridPoint(x, maxY);
        gridLine(start, end);
    };

    // draw the horizontal lines
    for (var y = minY; y <= maxY; y++) {
        var start = gridPoint(minX, y)
        var end = gridPoint(maxX, y);
        gridLine(start, end);
    };
}

function gridPoint(x, y) {
	return (gridX * x) + (gridY * y) + offset;
}

gridApi.drawBox = function(x, y, width, height, border, borderWidth, fill) {
	var path = new Path();
	path.strokeColor = border;
	path.strokeWidth = borderWidth;
	path.fillColor = fill;
	path.add(gridPoint(x, y));
	path.add(gridPoint(x + width, y));
	path.add(gridPoint(x + width, y + height));
	path.add(gridPoint(x, y + height));
	path.closed = true;
	allPaths.push(path);
}

gridApi.drawPlayer = function (x, y, radius, border, borderWidth, fill) {
    if (!player) {
        player = new Path.Circle(gridPoint(x, y), radius);
        player.strokeColor = border;
        player.strokeWidth = borderWidth;
        player.fillColor = fill;
        player.fillColor = fill;
        allPaths.push(player);
    }
    else {
        playerDestination = gridPoint(x, y);
        playerVector = (playerDestination - player.position) / 10;
        // move player to the end of the activeLayer so it gets drawn on top
        project.activeLayer.addChild(player);
    }
}

gridApi.onLoad();
{'fraction_non_alphanumeric': 0.12813314618006819, 'fraction_numerical': 0.00360938439943854, 'mean_word_length': 2.386286490156144, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 4, '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': '6166310', 'n_tokens_mistral': 1613, 'n_tokens_neox': 1599, 'n_words': 437}