⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scaler.cs

📁 game implemented java
💻 CS
字号:
using System;
using System.Drawing;

namespace WindowsApplication2
{
	/// <summary>
	/// Summary description for Scaler.
	/// </summary>
	[Serializable]
	public class Scaler
	{
		private int max_x, max_y, min_x, min_y, height, width;
		private float ratio;
		private double unitsPerMile;

		public Scaler()
		{
			max_x = -1;
			max_y = -1;
			min_x = -1;
			min_y = -1;
			height= -1;
			width = -1;
			unitsPerMile = 5280.0;
		}
		public PointF translate (Point old)
		{
			PointF toReturn = new PointF();
			toReturn.X = (old.X-min_x)*ratio;
			toReturn.Y = (old.Y-min_y)*ratio;
			return toReturn;
		}
		public Point revert (PointF old)
		{
			Point toReturn = new Point();
			toReturn.X = (int)((old.X/ratio)+min_x);
			toReturn.Y = (int)((old.Y/ratio)+min_y);
			return toReturn;
		}
		public PointF translate (int X, int Y)
		{
			return translate (new Point(X,Y));
		}
		public bool calculate()
		{
			try 
			{
				float x_ratio = width/(float)(max_x-min_x);
				float y_ratio = height/(float)(max_y-min_y);
				ratio = Math.Min(x_ratio,y_ratio);
				return true;
			}
			catch {return false;}
		}
		public void setRange(int Max_X, int Max_Y, int Min_X, int Min_Y)
		{
			max_x = Max_X;
			max_y = Max_Y;
			min_x = Min_X;
			min_y = Min_Y;
		}
		public int Height
		{
			get {return height;}
			set {height = value;}
		}
		public double UnitsPerMile
		{
			get {return unitsPerMile;}
			set {unitsPerMile = value;}
		}
		public int Width
		{
			get {return width;}
			set {width = value;}
		}
		public float Ratio
		{
			get {return ratio;}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -