<commit_before>//*************************************************************
//  Filename: object.js
//
//  Author: <NAME> <<EMAIL>>
//*************************************************************

function object(type) {
  console.log("Object Created");

  this.type = type;
}

object.prototype.initialize = function() {
  console.log("Object Initialized");
}

object.prototype.createStrokeObject = function(strokes, min, max, start) {
	this.strokes = strokes;
	this.min = min;
	this.max = max;
	this.start = start;
	console.log("start");
	console.log(this.start);
}

object.prototype.checkAABB = function(x, y) {
	if((x > this.min.x && x < this.max.x) && (y > this.min.y && y < this.max.y)) {
		console.log(this + " is clicked");
		return true;
	}
}

object.prototype.move = function(newPos) {
	var dx = newPos.x - this.start.x;
	var dy = newPos.y - this.start.y;
	this.start = newPos;

	console.log("Offset: " + dx + " - " + dy);

	this.min.x += dx;
	this.min.y += dy;
	this.max.x += dx;
	this.max.y += dy;

	for(var i = 0; i < this.strokes.length; i++) {
		this.strokes[i].start.x += dx;
		this.strokes[i].start.y += dy;
		this.strokes[i].end.x += dx;
		this.strokes[i].end.y += dy;
	}

	CanvasManager.render();
}

object.prototype.render = function() {
	for(var i = 1; i < this.strokes.length - 1; i++) {
		if((this.strokes[i].start.x != -1 && this.strokes[i].start.y != -1 && this.strokes[i].end.x != -1 && this.strokes[i].end.y != -1)) 
		Drawing.draw(this.strokes[i]);
	}

	//CanvasManager.context.rect(this.min.x, this.min.y, this.max.x, this.max.y);
	//CanvasManager.context.stroke();
}<commit_msg>Improved move functionality<commit_after>//*************************************************************
//  Filename: object.js
//
//  Author: <NAME> <<EMAIL>>
//*************************************************************

function object(type) {
  console.log("Object Created");

  this.type = type;
}

object.prototype.initialize = function() {
  console.log("Object Initialized");
}

object.prototype.createStrokeObject = function(strokes, min, max, start) {
	this.strokes = strokes;
	this.min = jQuery.extend(true, {}, min);
	this.max = jQuery.extend(true, {}, max);
	this.start = jQuery.extend(true, {}, start);
}

object.prototype.checkAABB = function(x, y) {
	if((x > this.min.x && x < this.max.x) && (y > this.min.y && y < this.max.y)) {
		return true;
	}
}

object.prototype.move = function(newPos) {
	var dx = newPos.x - ((this.min.x + this.max.x)/2);
	var dy = newPos.y - ((this.min.y + this.max.y)/2);

	//console.log(this);
	//console.log(this.start);
	console.log("Offset: " + dx + " - " + dy);

	this.min.x += dx;
	this.min.y += dy;
	this.max.x += dx;
	this.max.y += dy;

	for(var i = 0; i < this.strokes.length; i++) {
		this.strokes[i].start.x += dx;
		this.strokes[i].start.y += dy;
		this.strokes[i].end.x += dx;
		this.strokes[i].end.y += dy;
	}

	CanvasManager.render();
	this.start = jQuery.extend(true, {}, newPos);
}

object.prototype.render = function() {
	for(var i = 1; i < this.strokes.length - 1; i++) {
		if((this.strokes[i].start.x != -1 && this.strokes[i].start.y != -1 && this.strokes[i].end.x != -1 && this.strokes[i].end.y != -1)) 
		Drawing.draw(this.strokes[i]);
	}

	//CanvasManager.context.rect(this.min.x, this.min.y, this.max.x, this.max.y);
	//CanvasManager.context.stroke();
}
{'fraction_non_alphanumeric': 0.2770108043217287, 'fraction_numerical': 0.004801920768307323, 'mean_word_length': 3.6099585062240664, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, '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': '2326939', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1248, 'n_words': 221}