rect.java

来自「Position.java :辅助类 SerpentGameCanvas.jav」· Java 代码 · 共 37 行

JAVA
37
字号
public class Rect extends Object
{
	public int left;
	public int top;
	public int width;
	public int height;
	
	public Rect(Position pos)
	{
		left=pos.x *6;
		top=pos.y *6;
		width=6;
		height=6;
	}
	
	public Rect(Position pos, int ratio)
	{
		left=pos.x * ratio;
		top=pos.y * ratio;
		width=ratio;
		height=ratio;
	}
	
	public void merge(Rect rt)
	{
		int l, t, r, b;
		l=Math.min(left, rt.left);
		t=Math.min(top, rt.top);
		r=Math.max(left+width, rt.left+rt.width);
		b=Math.max(top+height, rt.top+rt.height);
		left=l;
		top=t;
		width=r-l;
		height=b-t;
	}
	
}

⌨️ 快捷键说明

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