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

📄 myrect.java

📁 Android开发精典案例60个
💻 JAVA
字号:
/**
 * 
 */
package com.bh;

import android.graphics.Canvas;
import android.graphics.Paint;

/**
 * @author Himi
 *
 */
public class MyRect {
	//矩形图形的位置、宽高与角度
	private float x, y, w, h, angle;
	//矩形图形的初始化
	public MyRect(float x, float y, float w, float h) {
		this.x = x;
		this.y = y;
		this.w = w;
		this.h = h;
	}
	//矩形图形绘制函数
	public void drawRect(Canvas canvas, Paint paint) {
		canvas.save();
		canvas.rotate(angle, x + w / 2, y + h / 2);
		canvas.drawRect(x, y, x + w, y + h, paint);
		canvas.restore();
	}
	//设置矩形图形的X坐标
	public void setX(float x) {
		this.x = x;
	}
	//设置矩形图形的Y坐标
	public void setY(float y) {
		this.y = y;
	}
	//设置矩形图形的角度
	public void setAngle(float angle) {
		this.angle = angle;
	}
	//获取矩形图形的宽
	public float getWidth() {
		return w;
	}
	//获取矩形图形的高
	public float getHeight() {
		return h;
	}
}

⌨️ 快捷键说明

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