<commit_before>﻿using UnityEngine;
using System.Collections;

/**
 * The Universal Coordinate System provides a simple class to convert screen independent co-ordinates from -1.0 to 1.0 into screen space,
 * taking into account aspect ratio.
 * It's a bit raw in it's current state, so improvements are welcome.
 */
public class UCS : MonoBehaviour {
	static float aspectX = 0.0f;
	static float aspectY = 0.0f;
	static float halfX = Screen.width / 2.0f;
	static float halfY = Screen.height / 2.0f;
	static float padX = 0.0f;
	static float padY = 0.0f;


	public static Rect ConvertRect(Rect rect) {
		rect.x = ConvertX (rect.x);
		rect.y = ConvertY (rect.y);
		rect.width = ConvertW (rect.width);
		rect.height = ConvertH (rect.height);
		return rect;
	}

	public static float ConvertX(float x) {
		return ConvertW (x+GetPadX()) + (halfX / GetAspectX ());
	}

	public static float ConvertY(float y) {
		return ConvertH (y+GetPadY()) + (halfY / GetAspectY ());
	}

	/**
	 * Return additional screen space on X axis
	 */
	public static float GetPadX() {
		CheckAspect ();
		return padX;
	}

	public static float GetPadY() {
		CheckAspect ();
		return padY;
	}

	public static float ConvertW(float x) {
		return (x * (halfX / GetAspectX()));
	}
	
	public static float ConvertH(float y) {
		return (y * (halfY / GetAspectY()));
	}

	private static float GetAspectY() {
		CheckAspect ();
		return aspectY;
	}
	private static float GetAspectX() {
		CheckAspect ();
		return aspectX;
	}

	private static void CheckAspect() {
		if (aspectX != 0.0f)
			return;
		aspectX = 1.0f; aspectY = 1.0f;
		if(Screen.width > Screen.height) {
			aspectX = (Screen.width * 1.0f) / (Screen.height * 1.0f);
		} else {
			aspectY = (Screen.height * 1.0f) / (Screen.width * 1.0f);
		}
		padX = aspectX - 1.0f;
		padY = aspectY - 1.0f;
	}

	/**
	 * Returns the full available width of the screen in universal co-ordinates.
	 */
	public static float GetWidth() {
		CheckAspect ();
		return (2.0f + (padX * 2)) / 2;
	}

	/**
	 * Returns the full available width of the screen in universal co-ordinates.
	 */
	public static float GetHeight() {
		CheckAspect ();
		return (2.0f + (padY * 2)) / 2;
	}

	public static int FontSize(int size) {
		return (int)((size * 480.0f) / Screen.height);
	}
}<commit_msg>Fix for font sizing<commit_after>﻿using UnityEngine;
using System.Collections;

/**
 * The Universal Coordinate System provides a simple class to convert screen independent co-ordinates from -1.0 to 1.0 into screen space,
 * taking into account aspect ratio.
 * It's a bit raw in it's current state, so improvements are welcome.
 */
public class UCS : MonoBehaviour {
	static float aspectX = 0.0f;
	static float aspectY = 0.0f;
	static float halfX = Screen.width / 2.0f;
	static float halfY = Screen.height / 2.0f;
	static float padX = 0.0f;
	static float padY = 0.0f;


	public static Rect ConvertRect(Rect rect) {
		rect.x = ConvertX (rect.x);
		rect.y = ConvertY (rect.y);
		rect.width = ConvertW (rect.width);
		rect.height = ConvertH (rect.height);
		return rect;
	}

	public static float ConvertX(float x) {
		return ConvertW (x+GetPadX()) + (halfX / GetAspectX ());
	}

	public static float ConvertY(float y) {
		return ConvertH (y+GetPadY()) + (halfY / GetAspectY ());
	}

	/**
	 * Return additional screen space on X axis
	 */
	public static float GetPadX() {
		CheckAspect ();
		return padX;
	}

	public static float GetPadY() {
		CheckAspect ();
		return padY;
	}

	public static float ConvertW(float x) {
		return (x * (halfX / GetAspectX()));
	}
	
	public static float ConvertH(float y) {
		return (y * (halfY / GetAspectY()));
	}

	private static float GetAspectY() {
		CheckAspect ();
		return aspectY;
	}
	private static float GetAspectX() {
		CheckAspect ();
		return aspectX;
	}

	private static void CheckAspect() {
		if (aspectX != 0.0f)
			return;
		aspectX = 1.0f; aspectY = 1.0f;
		if(Screen.width > Screen.height) {
			aspectX = (Screen.width * 1.0f) / (Screen.height * 1.0f);
		} else {
			aspectY = (Screen.height * 1.0f) / (Screen.width * 1.0f);
		}
		padX = aspectX - 1.0f;
		padY = aspectY - 1.0f;
	}

	/**
	 * Returns the full available width of the screen in universal co-ordinates.
	 */
	public static float GetWidth() {
		CheckAspect ();
		return (2.0f + (padX * 2)) / 2;
	}

	/**
	 * Returns the full available width of the screen in universal co-ordinates.
	 */
	public static float GetHeight() {
		CheckAspect ();
		return (2.0f + (padY * 2)) / 2;
	}

	public static int FontSize(int size) {
		return (int)((size * Screen.height) / 480.0f);
	}
}
{'fraction_non_alphanumeric': 0.13037752414398596, 'fraction_numerical': 0.02019315188762072, 'mean_word_length': 3.1807339449541283, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6209216', 'n_tokens_mistral': 1759, 'n_tokens_neox': 1599, 'n_words': 493}