<commit_before><!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title><NAME></title>
	<link rel="stylesheet" href="../css/style.css">
	<script type="text/javascript" src="../../dist/paper.js"></script>
	<script type="text/paperscript" canvas="canvas">
	// kynd.info 2014

	var Ball = function(r, p, v) {
		this.radius = r;
		this.point = p;
		this.vector = v;
		this.maxVec = 15;
		this.numSegment = Math.floor(r / 3 + 2);
		this.boundOffset = [];
		this.boundOffsetBuff = [];
		this.path = new Path({
			fillColor: {
				hue: Math.random() * 360,
				saturation: 1,
				brightness: 1
			},
			blendMode: 'screen'
		});

		for (var i = 0; i < this.numSegment; i ++) {
			this.boundOffset.push(this.radius);
			this.boundOffsetBuff.push(this.radius);
			this.path.add(new Point());
		}
	}


	Ball.prototype.iterate = function() {
		this.checkWallCollision();
		if (this.vector.length > this.maxVec) {
			this.vector.length = this.maxVec;
		}
		this.point += this.vector;
		this.updateShape();
	}

	Ball.prototype.checkWallCollision = function() {
		if (this.point.x < -this.radius) { this.point.x = view.size.width + this.radius;}
		if (this.point.x > view.size.width + this.radius) { this.point.x = -this.radius;}
		if (this.point.y < -this.radius) { this.point.y = view.size.height + this.radius;}
		if (this.point.y > view.size.height + this.radius) { this.point.y = -this.radius;}
	}

	Ball.prototype.updateShape = function() {
		var segments = this.path.segments;
		for (var i = 0; i < this.numSegment; i ++) {
			segments[i].point = this.point + {
				angle: 360 / this.numSegment * i,
				length: this.boundOffset[i]
			};
		}

		this.path.smooth();
		for (var i = 0; i < this.numSegment; i ++) {
			if (this.boundOffset[i] < this.radius / 4) {
				this.boundOffset[i] = this.radius / 4;
			};
	        var next = (i + 1) % this.numSegment;
	        var prev = (i > 0) ? i - 1 : this.numSegment - 1;
	        this.boundOffsetBuff[i] = this.boundOffset[i] += (this.radius - this.boundOffset[i]) / 15;
	        this.boundOffsetBuff[i] = this.boundOffset[i] += ((this.boundOffset[next] + this.boundOffset[prev]) / 2 - this.boundOffset[i]) / 3;
	    }
	}

	Ball.prototype.react = function(b) {
	    var dist = this.point.getDistance(b.point);
	    if (dist < this.radius + b.radius && dist != 0) {
			var overlap = this.radius + b.radius - dist;
	    	var direc = (this.point - b.point).normalize(overlap * 0.015);
	        this.vector += direc;
	        b.vector -= direc;

	        this.calcBounds(b);
	        b.calcBounds(this);
	        this.updateBounds();
	        b.updateBounds();
	    }
	}

	Ball.prototype.getboundOffset = function(b) {
		var diff = this.point - b;
		var angle = (diff.angle + 180) % 360;
		return this.boundOffset[Math.floor(angle / 360 * this.boundOffset.length)];
	}

	Ball.prototype.calcBounds = function(b) {
		for (var i = 0; i < this.numSegment; i ++) {
			var tp = this.getSidePoint(i);
			var bLen = b.getboundOffset(tp);
			var td = tp.getDistance(b.point);
			if (td < bLen ) {
				this.boundOffsetBuff[i] -= (bLen  - td) / 2;
			}
		}
	}

	Ball.prototype.getSidePoint = function(index) {
		return this.point + {
			angle: 360 / this.numSegment * index,
			length: this.boundOffset[index]
		};<commit_msg>Precalculate side points again for better performance.<commit_after><!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Wine Gums</title>
	<link rel="stylesheet" href="../css/style.css">
	<script type="text/javascript" src="../../dist/paper.js"></script>
	<script type="text/paperscript" canvas="canvas">
	// kynd.info 2014

	var Ball = function(r, p, v) {
		this.radius = r;
		this.point = p;
		this.vector = v;
		this.maxVec = 15;
		this.numSegment = Math.floor(r / 3 + 2);
		this.boundOffset = [];
		this.boundOffsetBuff = [];
		this.sidePoints = [];
		this.path = new Path({
			fillColor: {
				hue: Math.random() * 360,
				saturation: 1,
				brightness: 1
			},
			blendMode: 'screen'
		});

		for (var i = 0; i < this.numSegment; i ++) {
			this.boundOffset.push(this.radius);
			this.boundOffsetBuff.push(this.radius);
			this.path.add(new Point());
			this.sidePoints.push(new Point({
				angle: 360 / this.numSegment * i,
				length: 1
			}));
		}
	}


	Ball.prototype.iterate = function() {
		this.checkWallCollision();
		if (this.vector.length > this.maxVec) {
			this.vector.length = this.maxVec;
		}
		this.point += this.vector;
		this.updateShape();
	}

	Ball.prototype.checkWallCollision = function() {
		if (this.point.x < -this.radius) { this.point.x = view.size.width + this.radius;}
		if (this.point.x > view.size.width + this.radius) { this.point.x = -this.radius;}
		if (this.point.y < -this.radius) { this.point.y = view.size.height + this.radius;}
		if (this.point.y > view.size.height + this.radius) { this.point.y = -this.radius;}
	}

	Ball.prototype.updateShape = function() {
		var segments = this.path.segments;
		for (var i = 0; i < this.numSegment; i ++) {
			segments[i].point = this.point + {
				angle: 360 / this.numSegment * i,
				length: this.boundOffset[i]
			};
		}

		this.path.smooth();
		for (var i = 0; i < this.numSegment; i ++) {
			if (this.boundOffset[i] < this.radius / 4) {
				this.boundOffset[i] = this.radius / 4;
			};
	        var next = (i + 1) % this.numSegment;
	        var prev = (i > 0) ? i - 1 : this.numSegment - 1;
	        this.boundOffsetBuff[i] = this.boundOffset[i] += (this.radius - this.boundOffset[i]) / 15;
	        this.boundOffsetBuff[i] = this.boundOffset[i] += ((this.boundOffset[next] + this.boundOffset[prev]) / 2 - this.boundOffset[i]) / 3;
	    }
	}

	Ball.prototype.react = function(b) {
	    var dist = this.point.getDistance(b.point);
	    if (dist < this.radius + b.radius && dist != 0) {
			var overlap = this.radius + b.radius - dist;
	    	var direc = (this.point - b.point).normalize(overlap * 0.015);
	        this.vector += direc;
	        b.vector -= direc;

	        this.calcBounds(b);
	        b.calcBounds(this);
	        this.updateBounds();
	        b.updateBounds();
	    }
	}

	Ball.prototype.getboundOffset = function(b) {
		var diff = this.point - b;
		var angle = (diff.angle + 180) % 360;
		return this.boundOffset[Math.floor(angle / 360 * this.boundOffset.length)];
	}

	Ball.prototype.calcBounds = function(b) {
		for (var i = 0; i < this.numSegment; i ++) {
			var tp = this.getSidePoint(i);
			var bLen = b.getboundOffset(tp);
			var td = tp.getDistance(b.point);
			if (td < bLen ) {
				this.boundOffsetBuff[i] -= (bLen  - td) / 2;
			}
		}
	}

	Ball.prototype.getSidePoint = function(index) {
		return this.point + this.sidePoints[index] * this.boundOffset[index];
{'fraction_non_alphanumeric': 0.17342172668374264, 'fraction_numerical': 0.014916377881573, 'mean_word_length': 2.788812785388128, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 32, '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': '3844045', 'n_tokens_mistral': 2754, 'n_tokens_neox': 2390, 'n_words': 486}