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

📄 axis.java

📁 日本人写的QRcode的编码和解码的java程序
💻 JAVA
字号:
package jp.sourceforge.qrcode.codec.geom;

import jp.sourceforge.qrcode.codec.reader.QRCodeImageReader;

public class Axis {
	int sin, cos;
	int modulePitch;
	Point origin;
	
	public Axis(int sin, int cos, int modulePitch) {
		this.sin = sin;
		this.cos = cos;
		this.modulePitch = modulePitch;
		this.origin = new Point();
	}
	
	public void setOrigin(Point origin) {
		this.origin = origin;
	}
	
	public void setModulePitch(int modulePitch) {
		this.modulePitch = modulePitch;
	}
	
	public Point translate(Point offset) {
		int moveX = offset.getX();
		int moveY = offset.getY();
		return this.translate(moveX, moveY);
	}
	
	public Point translate(int moveX, int moveY) {
		long dp = QRCodeImageReader.DECIMAL_POINT;
		Point point = new Point();
		int yf = 0; //, xf = 0 ?
		if (moveX >= 0 & moveY >= 0) yf = 1;
		else if (moveX < 0 & moveY >= 0) yf = -1;
		else if (moveX >= 0 & moveY < 0) yf = -1;
		else if (moveX < 0 & moveY < 0) yf = 1;
		//System.out.println((modulePitch * moveX) >> dp);
		int dx = (moveX == 0) ? 0 : (modulePitch * moveX) >> dp;
		int dy = (moveY == 0) ? 0 : (modulePitch * moveY) >> dp;
		if (dx != 0 && dy != 0)
			point.translate((dx * cos - dy * sin) >> dp, yf * (dx * cos + dy * sin) >> dp);
		else if (dy == 0) { 
			if (dx < 0) yf = -yf;
			point.translate((dx * cos) >> dp, yf * (dx * sin) >> dp);
		}
		else if (dx == 0) {
			if (dy < 0) yf = -yf;
			point.translate(-yf * (dy * sin) >> dp, (dy * cos) >> dp);	
		}
		point.translate(origin.getX(), origin.getY());

		return point;
	}
}

⌨️ 快捷键说明

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