<commit_before>#include <common.hpp>

int debugCount=0;
pair<float,float> HotspotPos[] = {
	// TOP_LEFT,
	{0.0,0.0},
	// TOP,
	{0.5,0.0},
	// TOP_RIGHT,
	{1.0,0.0},
	// LEFT,
	{0.0,0.5},
	// CENTER,
	{0.5,0.5},
	// RIGHT,
	{1.0,0.5},
	// BOTTOM_LEFT,
	{0.0,1.0},
	// BOTTOM,
	{0.5,1.0},
	// BOTTOM_RIGHT
	{1.0,1.0}
};

SDL_Color MakeColor(int r,int g,int b,int a) {
	SDL_Color color;
	color.r=r;
	color.g=g;
	color.b=b;
	color.a=a;
	return color;
}


bool equals(const float &a,const float &b) {
	return (std::fabs((a-b))<=PRECISION);
}

float closeDist(const float &from,const float &to,const float &change) {
	if (abs(from-to)<change)return to;
	if (from>to)return from - change;
	return from + change;
}

string FloatToStr(float f) {
	char s[15];
	sprintf(s,"%.2f",f);
	return s;
}<commit_msg>Applies Comments Technique to file common.cpp<commit_after>/*
 *  File: common.cpp
 *
 *  Description:  Implements common functions
 */

#include <common.hpp>

// Global variable used as debug counter
int debugCount = 0;

// Hotspot screen positions to be used as shortcuts
// The number on the left is x axis and the right one is y axis
pair<float,float> HotspotPos[] = {
	// TOP_LEFT
	{0.0,0.0},
	// TOP
	{0.5,0.0},
	// TOP_RIGHT
	{1.0,0.0},
	// LEFT
	{0.0,0.5},
	// CENTER
	{0.5,0.5},
	// RIGHT
	{1.0,0.5},
	// BOTTOM_LEFT
	{0.0,1.0},
	// BOTTOM
	{0.5,1.0},
	// BOTTOM_RIGHT
	{1.0,1.0}
};

// Returns a color generated by the params
SDL_Color MakeColor(int r,		// red value, 	range: 0 -> 255
										int g,		// green value, range: 0 -> 255
										int b,		// blue value,	range: 0 -> 255
										int a) {	// alpha value, range: unknown
	SDL_Color color;

	color.r = r;
	color.g = g;
	color.b = b;
	color.a = a;

	return color;
}

// Function that compares two float constants
// Returns true if the difference between them is <= than 0.0001 (PRECISION)
bool equals(const float &a, const float &b) {
	return (std::fabs((a-b)) <= PRECISION);
}

// TODO: refactorate for better understanding
// Function that cannot be comprehended by mere human beings
float closeDist(const float &from, const float &to, const float &change) {
	if (abs(from - to) < change) {
		return to;
	}

	if (from > to) {
		return from - change;
	}

	return from + change;
}

// Converts a float number to a string and returns it
string FloatToStr(float f) {
	char s[15];

	sprintf(s,"%.2f",f);

	return s;
}
{'fraction_non_alphanumeric': 0.17086481947942905, 'fraction_numerical': 0.04072208228379513, 'mean_word_length': 2.9849498327759196, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '6836518', 'n_tokens_mistral': 1066, 'n_tokens_neox': 990, 'n_words': 270}