<commit_before>

var
	// tunables
	max_scale  = 2,
	max_radius = 100,
	easing     = 'linear',

	// Grab the Canvas and Drawing Context
	canvas = document.getElementById('stage'),
	ctx = canvas.getContext('2d'),
	listening = false, img, img2, last_pos = {x: canvas.width / 2, y: canvas.height / 2},
	blob_stack = [],
	file_name;

function reset() {
	img2 = new Image();
	img2.onload = function() {
		img = img2;
		make_stack();
	};
	file_name = $('#staffer').val();
	img2.src = 'img/' + file_name;
}

function toggleFollowMouse() {
	if (listening) {
		canvas.removeEventListener('mousemove', onMouseMove);
	}
	else {
		canvas.addEventListener('mousemove', onMouseMove);
	}

	listening = !listening;
}

function onMouseMove(evt) {
	last_pos = getMousePos(canvas, evt);
	make_stack();
}

function captureSettings() {
	return {
		x:          last_pos.x,
		y:          last_pos.y,
		max_scale:  max_scale,
		max_radius: max_radius,
		easing:     easing
	};
}

// this is where the drawing magic happens
function make_stack(no_stack) {
	if (!img) return;

	// images are center-cropped to the canvas
	var img_ratio = img.width / img.height;
	var canvas_ratio = canvas.width / canvas.height;
	var
		w = canvas.width,
		h = canvas.height,
		offset_x = 0,
		offset_y = 0;

	if (img_ratio > canvas_ratio) {
		// img width is too long
		w = canvas.height * img_ratio;
		offset_x = (canvas.width - w) / 2;
	}
	else if (img_ratio < canvas_ratio) {
		h = canvas.width / img_ratio;
		offset_y = (canvas.height - h) / 2;
	}

	ctx.clearRect(0,0, canvas.width, canvas.height);
	ctx.drawImage(img, offset_x, offset_y, w, h); // scale 1

	if (no_stack) return;

	blob_stack.concat([captureSettings()]).forEach(function(settings) {
		console.log(settings);

		var
			easing_func = $.easing[settings.easing],
			start_scale = 1,
			end_scale   = settings.max_scale,
			max_radius  = settings.max_radius;

		console.log(max_radius);
		for (var radius = max_radius; radius--; ) {
			console.log(radius);
			scale = start_scale + (end_scale - start_scale) * easing_func((max_radius - radius + 1) / max_radius);

			ctx.save();
			ctx.beginPath();
			ctx.arc(settings.x, settings.y, radius, 0, Math.PI * 2);
			ctx.clip();
			ctx.drawImage(img
				, settings.x * (1 - scale) + offset_x * scale
				, settings.y * (1 - scale) + offset_y * scale
				, w * scale
				, h * scale
			);
			ctx.restore();
		}
	});
}

function getMousePos(canvas, evt) {
	var rect = canvas.getBoundingClientRect();
	return {
		x: evt.clientX - rect.left,
		y: evt.clientY - rect.top
	};
}

var staff_sel = $('#staffer').change(reset);<commit_msg>Remove old debug console.log()s<commit_after>

var
	// tunables
	max_scale  = 2,
	max_radius = 100,
	easing     = 'linear',

	// Grab the Canvas and Drawing Context
	canvas = document.getElementById('stage'),
	ctx = canvas.getContext('2d'),
	listening = false, img, img2, last_pos = {x: canvas.width / 2, y: canvas.height / 2},
	blob_stack = [],
	file_name;

function reset() {
	img2 = new Image();
	img2.onload = function() {
		img = img2;
		make_stack();
	};
	file_name = $('#staffer').val();
	img2.src = 'img/' + file_name;
}

function toggleFollowMouse() {
	if (listening) {
		canvas.removeEventListener('mousemove', onMouseMove);
	}
	else {
		canvas.addEventListener('mousemove', onMouseMove);
	}

	listening = !listening;
}

function onMouseMove(evt) {
	last_pos = getMousePos(canvas, evt);
	make_stack();
}

function captureSettings() {
	return {
		x:          last_pos.x,
		y:          last_pos.y,
		max_scale:  max_scale,
		max_radius: max_radius,
		easing:     easing
	};
}

// this is where the drawing magic happens
function make_stack(no_stack) {
	if (!img) return;

	// images are center-cropped to the canvas
	var img_ratio = img.width / img.height;
	var canvas_ratio = canvas.width / canvas.height;
	var
		w = canvas.width,
		h = canvas.height,
		offset_x = 0,
		offset_y = 0;

	if (img_ratio > canvas_ratio) {
		// img width is too long
		w = canvas.height * img_ratio;
		offset_x = (canvas.width - w) / 2;
	}
	else if (img_ratio < canvas_ratio) {
		h = canvas.width / img_ratio;
		offset_y = (canvas.height - h) / 2;
	}

	ctx.clearRect(0,0, canvas.width, canvas.height);
	ctx.drawImage(img, offset_x, offset_y, w, h); // scale 1

	if (no_stack) return;

	blob_stack.concat([captureSettings()]).forEach(function(settings) {

		var
			easing_func = $.easing[settings.easing],
			start_scale = 1,
			end_scale   = settings.max_scale,
			max_radius  = settings.max_radius;

		for (var radius = max_radius; radius--; ) {
			scale = start_scale + (end_scale - start_scale) * easing_func((max_radius - radius + 1) / max_radius);

			ctx.save();
			ctx.beginPath();
			ctx.arc(settings.x, settings.y, radius, 0, Math.PI * 2);
			ctx.clip();
			ctx.drawImage(img
				, settings.x * (1 - scale) + offset_x * scale
				, settings.y * (1 - scale) + offset_y * scale
				, w * scale
				, h * scale
			);
			ctx.restore();
		}
	});
}

function getMousePos(canvas, evt) {
	var rect = canvas.getBoundingClientRect();
	return {
		x: evt.clientX - rect.left,
		y: evt.clientY - rect.top
	};
}

var staff_sel = $('#staffer').change(reset);
{'fraction_non_alphanumeric': 0.14739096573208724, 'fraction_numerical': 0.009735202492211837, 'mean_word_length': 3.2879799666110183, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1614037', 'n_tokens_mistral': 2050, 'n_tokens_neox': 1889, 'n_words': 435}