【Laya】Graphics 使用说明
·
Laya.Graphics 使用说明文档
LayaAir 3.3.6 - Graphics 矢量绘图 API 参考
一、Graphics 基础概念
Graphics 类是 LayaAir 中用于绘制矢量图形的核心类。每个 Sprite 对象都有 graphics 属性,通过它可以进行各种矢量图形的绘制。
获取 Graphics 实例
import Sprite = Laya.Sprite;
const sprite = new Sprite();
const graphics = sprite.graphics; // 获取 Graphics 实例
二、基本绘制方法
1. drawRect() - 绘制矩形
绘制填充矩形,可选择添加边框。
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 纯填充矩形
sprite.graphics.drawRect(0, 0, 100, 100, "#ff0000");
// 带边框矩形
sprite.graphics.drawRect(100, 0, 100, 100, "#00ff00", "#000000", 2);
// 半透明填充 (RGBA)
sprite.graphics.drawRect(200, 0, 100, 100, "rgba(0, 0, 255, 0.5)");
// 带透明度的十六进制
sprite.graphics.drawRect(300, 0, 100, 100, "#ff00ff88");
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
| x | number | 矩形左上角 X 坐标 |
| y | number | 矩形左上角 Y 坐标 |
| width | number | 矩形宽度 |
| height | number | 矩形高度 |
| fillColor | string | 填充颜色 |
| lineColor | string | 边框颜色(可选) |
| lineWidth | number | 边框宽度(可选) |
2. drawCircle() - 绘制圆形
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 纯填充圆形
sprite.graphics.drawCircle(50, 50, 40, "#ff0000");
// 带边框圆形
sprite.graphics.drawCircle(150, 50, 40, "#00ff00", "#000000", 2);
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
| x | number | 圆心 X 坐标 |
| y | number | 圸心 Y 坐标 |
| radius | number | 半径 |
| fillColor | string | 填充颜色 |
| lineColor | string | 边框颜色(可选) |
| lineWidth | number | 边框宽度(可选) |
3. drawPie() - 绘制扇形
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 绘制 90 度扇形 (0 到 90)
sprite.graphics.drawPie(50, 50, 40, 0, 90, "#ff0000");
// 绘制半圆
sprite.graphics.drawPie(150, 50, 40, 0, 180, "#00ff00");
// 绘制 270 度扇形
sprite.graphics.drawPie(250, 50, 40, 0, 270, "#0000ff");
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
| x | number | 圆心 X 坐标 |
| y | number | 圸心 Y 坐标 |
| radius | number | 半径 |
| startAngle | number | 起始角度(弧度) |
| endAngle | number | 结束角度(弧度) |
| fillColor | string | 填充颜色 |
| lineColor | string | 边框颜色(可选) |
| lineWidth | number | 边框宽度(可选) |
4. drawLine() - 绘制直线
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 绘制直线
sprite.graphics.drawLine(0, 0, 100, 100, "#ff0000", 2);
// 绘制水平线
sprite.graphics.drawLine(0, 50, 200, 50, "#00ff00", 1);
// 绘制垂直线
sprite.graphics.drawLine(100, 0, 100, 100, "#0000ff", 3);
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
| x1 | number | 起点 X 坐标 |
| y1 | number | 起点 Y 坐标 |
| x2 | number | 终点 X 坐标 |
| y2 | number | 终点 Y 坐标 |
| lineColor | string | 线条颜色 |
| lineWidth | number | 线条宽度(可选) |
5. drawLines() - 绘制多条连续线段
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 绘制折线 - 坐标数组格式 [x1, y1, x2, y2, x3, y3, ...]
const points = [50, 50, 100, 100, 150, 50, 200, 100];
sprite.graphics.drawLines(0, 0, points, "#ff0000", 2);
// 绘制波浪线
const wavePoints = [0, 50, 50, 0, 100, 50, 150, 100, 200, 50];
sprite.graphics.drawLines(0, 50, wavePoints, "#00ff00", 2);
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
| x | number | 起点 X 偏移坐标 |
| y | number | 起点 Y 偏移坐标 |
| points | number[] | 坐标数组 [x1, y1, x2, y2, …] |
| lineColor | string | 线条颜色 |
| lineWidth | number | 线条宽度(可选) |
6. drawCurves() - 绘制贝塞尔曲线
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 绘制平滑曲线
const points = [50, 100, 100, 0, 150, 100, 200, 0];
sprite.graphics.drawCurves(0, 0, points, "#ff0000", 2);
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
| x | number | 起点 X 偏移坐标 |
| y | number | 起点 Y 偏移坐标 |
| points | number[] | 控制点坐标数组 |
| lineColor | string | 线条颜色 |
| lineWidth | number | 线条宽度(可选) |
7. drawPath() - 绘制路径
使用路径命令绘制复杂图形。
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 绘制矩形路径
const rectPath = [
["moveTo", 50, 50], // 移动到起点
["lineTo", 150, 50], // 画线到
["lineTo", 150, 150],
["lineTo", 50, 150],
["closePath"] // 闭合路径
];
sprite.graphics.drawPath(0, 0, rectPath, {fillStyle:"#FF0000"});
// 绘制三角形路径
const trianglePath = [
["moveTo", 100, 0],
["lineTo", 200, 100],
["lineTo", 0, 100],
["lineTo", 100, 0],
["closePath"]
];
sprite.graphics.drawPath(0, 100, trianglePath, {fillStyle:"#00ff04"});
路径命令类型:
| 命令 | 参数 | 说明 |
|---|---|---|
| moveTo | x, y | 移动到指定点(不绘制) |
| lineTo | x, y | 画直线到指定点 |
| arcTo | x, y, radius | 画弧线到指定点 |
| closePath | 无 | 闭合路径 |
8. drawPoly() - 绘制多边形
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 绘制三角形 - 顶点坐标数组 [x1, y1, x2, y2, x3, y3]
sprite.graphics.drawPoly(0, 0, [50, 0, 100, 100, 0, 100], "#ff0000");
// 绘制六边形
const hexPoints: number[] = [];
for (let i = 0; i < 6; i++) {
const angle = (i * 60) * Math.PI / 180;
hexPoints.push(50 + 40 * Math.cos(angle), 50 + 40 * Math.sin(angle));
}
sprite.graphics.drawPoly(100, 0, hexPoints, "#00ff00", "#000000", 2);
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
| x | number | 起点 X 偏移坐标 |
| y | number | 起点 Y 偏移坐标 |
| points | number[] | 顶点坐标数组 |
| fillColor | string | 填充颜色 |
| lineColor | string | 边框颜色(可选) |
| lineWidth | number | 边框宽度(可选) |
三、高级绘制方法
9. drawTexture() - 绘制纹理
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 方式一:先加载后绘制
Laya.loader.load("atlas/comp/image.png", Laya.Loader.IMAGE).then((texture: Laya.Texture) => {
sprite.graphics.drawTexture(texture, 0, 0);
// 方式二:使用已缓存的纹理
const cachedTexture = Laya.Loader.getRes("atlas/comp/image.png");
if (cachedTexture) {
sprite.graphics.drawTexture(cachedTexture, 520, 100, 100, 100);
}
});
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
| texture | Texture | 纹理对象 |
| x | number | X 坐标(默认 0) |
| y | number | Y 坐标(默认 0) |
| width | number | 宽度(可选,缩放纹理) |
| height | number | 高度(可选,缩放纹理) |
10. fillTexture() - 纹理平铺填充
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 用纹理平铺填充矩形区域
Laya.loader.load("atlas/comp/image.png", Laya.Loader.IMAGE).then((texture: Laya.Texture) => {
sprite.graphics.fillTexture(texture, 0, 0, 1000, 1000);
});
四、图形控制方法
11. clear() - 清除绘制内容
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 绘制一些图形
sprite.graphics.drawRect(0, 0, 100, 100, "#ff0000");
// 清除所有绘制内容
sprite.graphics.clear();
12. save() / restore() - 保存/恢复状态
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 保存当前绘图状态
sprite.graphics.save();
// 修改状态进行绘制
sprite.graphics.translate(50, 50); // 平移
sprite.graphics.scale(2, 2); // 缩放
sprite.graphics.rotate(Math.PI / 4); // 旋转
sprite.graphics.drawRect(0, 0, 50, 50, "#ff0000");
// 恢复之前保存的状态
sprite.graphics.restore();
// 后续绘制不受之前变换影响
sprite.graphics.drawRect(0, 0, 50, 50, "#00ff00");
13. transform() - 应用变换矩阵
import Sprite = Laya.Sprite;
import Matrix = Laya.Matrix;
const sprite = new Sprite();
const matrix = new Matrix();
// 组合变换:先缩放、再旋转、最后平移
matrix.scale(2, 2);
matrix.rotate(Math.PI / 4);
matrix.translate(100, 100);
sprite.graphics.transform(matrix);
sprite.graphics.drawRect(0, 0, 50, 50, "#ff0000");
五、颜色格式说明
Laya.Graphics 支持以下颜色格式:
| 格式 | 示例 | 说明 |
|---|---|---|
| 十六进制(不透明) | "#ff0000" |
红色 |
| 十六进制(带透明度) | "#ff000088" |
半透明红色 |
| RGB 函数 | "rgb(255, 0, 0)" |
红色 |
| RGBA 函数 | "rgba(255, 0, 0, 0.5)" |
半透明红色(alpha 0-1) |
六、实际应用示例
示例1:绘制网格背景
import Sprite = Laya.Sprite;
function drawGridBackground(container: Sprite, width: number, height: number, gridSize: number = 40): void {
const grid = new Sprite();
// 绘制垂直线
for (let x = 0; x <= width; x += gridSize) {
grid.graphics.drawLine(x, 0, x, height, "#2a2a4e", 1);
}
// 绘制水平线
for (let y = 0; y <= height; y += gridSize) {
grid.graphics.drawLine(0, y, width, y, "#2a2a4e", 1);
}
container.addChild(grid);
}
示例2:绘制圆角矩形
import Sprite = Laya.Sprite;
function drawRoundRect(
sprite: Sprite,
x: number,
y: number,
width: number,
height: number,
radius: number,
fillColor: string
): void {
const paths: any[] = [];
const r = Math.min(radius, Math.min(width, height) / 2);
// 从左上角开始,顺时针绘制
paths.push(["moveTo", x + r, y]);
paths.push(["lineTo", x + width - r, y]);
paths.push(["arcTo", x + width, y, x + width, y + r, r]);
paths.push(["lineTo", x + width, y + height - r]);
paths.push(["arcTo", x + width, y + height, x + width - r, y + height, r]);
paths.push(["lineTo", x + r, y + height]);
paths.push(["arcTo", x, y + height, x, y + height - r, r]);
paths.push(["lineTo", x, y + r]);
paths.push(["arcTo", x, y, x + r, y, r]);
paths.push(["closePath"]);
sprite.graphics.drawPath(0, 0, paths, {fillStyle: fillColor});
}
// 使用示例
const sprite = new Sprite();
drawRoundRect(sprite, 50, 50, 200, 100, 20, "#ffffff");
示例3:进度条组件
import Sprite = Laya.Sprite;
class ProgressBar extends Sprite {
private bg: Sprite;
private fill: Sprite;
private _value: number = 0;
private _maxValue: number = 100;
constructor(width: number = 200, height: number = 20) {
super();
this.size(width, height);
// 背景
this.bg = new Sprite();
this.bg.graphics.drawRect(0, 0, width, height, "#1a1a2e", "#3a3a4e", 1);
this.addChild(this.bg);
// 填充条
this.fill = new Sprite();
this.fill.graphics.drawRect(0, 0, 1, 1, "#00ff88", null, null, true);
this.fill.width = width;
this.fill.height = height;
this.addChild(this.fill);
}
public set value(v: number) {
this._value = Math.max(0, Math.min(v, this._maxValue));
const progress = this._value / this._maxValue;
this.fill.width = this.width * progress;
}
public get value(): number {
return this._value;
}
public setMaxValue(max: number): void {
this._maxValue = max;
}
}
// 使用示例
const progressBar = new ProgressBar(300, 30);
progressBar.pos(100, 100);
progressBar.value = 75;
Laya.stage.addChild(progressBar);
示例4:代码雨效果
import Sprite = Laya.Sprite;
import Text = Laya.Text;
import Event = Laya.Event;
/**
* 黑客帝国代码雨效果
* 使用 LayaAir 3.3.6 API 实现
*/
export class MatrixRain extends Sprite {
/** 雨滴列数组 */
private drops: RainColumn[] = [];
/** 列数 */
private columnCount: number = 0;
/** 每列宽度 */
private columnWidth: number = 20;
/** 是否运行中 */
private isRunning: boolean = false;
/** 使用的字符集 */
private charset: string = "";
/** 背景透明度层 */
private fadeLayer: Sprite;
constructor(width: number = Laya.stage.width, height: number = Laya.stage.height) {
super();
this.size(width, height);
this.charset = this.generateCharset();
this.init();
}
/**
* 初始化代码雨
*/
private init(): void {
// 创建背景淡化层(用于产生拖尾效果)
this.fadeLayer = new Sprite();
this.fadeLayer.size(this.width, this.height);
this.addChild(this.fadeLayer);
// 计算列数
this.columnCount = Math.floor(this.width / this.columnWidth);
// 初始化每列的雨滴
for (let i = 0; i < this.columnCount; i++) {
const drop = new RainColumn(
i * this.columnWidth,
Math.random() * this.height,
this.columnWidth,
this.charset
);
this.drops.push(drop);
this.addChild(drop);
}
// 设置事件监听
this.on(Event.ADDED, this, this.onAdded);
this.on(Event.REMOVED, this, this.onRemoved);
}
/**
* 生成字符集(片假名+数字+符号)
*/
private generateCharset(): string {
const katakana = "アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン";
const numbers = "0123456789";
const symbols = "@#$%&*+-=?<>[]{}";
return katakana + numbers + symbols;
}
/**
* 添加到舞台时启动
*/
private onAdded(): void {
this.start();
}
/**
* 从舞台移除时停止
*/
private onRemoved(): void {
this.stop();
}
/**
* 开始动画
*/
public start(): void {
if (this.isRunning) return;
this.isRunning = true;
// 使用帧循环进行更新
Laya.timer.frameLoop(1, this, this.update);
}
/**
* 停止动画
*/
public stop(): void {
this.isRunning = false;
Laya.timer.clear(this, this.update);
}
/**
* 更新动画帧
*/
private update(): void {
// 绘制半透明黑色背景(产生拖尾效果)
this.fadeLayer.graphics.clear();
this.fadeLayer.graphics.drawRect(0, 0, this.width, this.height, "#000000cc");
// 更新每列雨滴
for (const drop of this.drops) {
drop.update();
}
}
/**
* 设置列宽
*/
public setColumnWidth(width: number): void {
this.columnWidth = width;
this.columnCount = Math.floor(this.width / this.columnWidth);
}
/**
* 设置颜色
*/
public setColor(color: string): void {
for (const drop of this.drops) {
drop.setColor(color);
}
}
/**
* 销毁
*/
public destroy(): void {
this.stop();
this.off(Event.ADDED, this, this.onAdded);
this.off(Event.REMOVED, this, this.onRemoved);
super.destroy();
}
}
/**
* 单列雨滴类
*/
class RainColumn extends Sprite {
/** 字符数组 */
private chars: CharText[] = [];
/** 下落速度 */
private speed: number = 0;
/** 当前头部位置 */
private headY: number = 0;
/** 列宽度 */
private colWidth: number = 20;
/** 字符集 */
private charset: string = "";
/** 主颜色 */
private mainColor: string = "#00ff00";
/** 颜色变化 */
private colorVariant: number = 0;
constructor(x: number, y: number, colWidth: number, charset: string) {
super();
this.pos(x, y);
this.colWidth = colWidth;
this.charset = charset;
this.headY = y;
this.speed = 3 + Math.random() * 5; // 随机速度
this.colorVariant = Math.random() > 0.8 ? 1 : 0; // 20%的概率有颜色变化
}
/**
* 更新雨滴状态
*/
public update(): void {
// 移动头部
this.headY += this.speed;
// 如果头部超出屏幕,重置到顶部
if (this.headY > Laya.stage.height + 100) {
this.reset();
return;
}
// 添加新字符到头部
this.addCharAtHead();
// 移除尾部字符(产生拖尾效果)
if (this.chars.length > 20 + Math.random() * 10) {
const oldChar = this.chars.shift();
if (oldChar) {
oldChar.removeSelf();
oldChar.destroy();
}
}
// 更新所有字符的亮度状态
this.updateCharColors();
}
/**
* 在头部添加新字符
*/
private addCharAtHead(): void {
// 使用当前时间作为随机种子,增加随机性
const charIndex = Math.floor(Math.random() * this.charset.length);
const char = this.charset[charIndex];
const text = new CharText(char, this.colWidth);
text.pos(0, this.headY);
this.addChild(text);
this.chars.push(text);
}
/**
* 更新字符颜色(头部最亮,尾部渐暗)
*/
private updateCharColors(): void {
const length = this.chars.length;
for (let i = 0; i < length; i++) {
const char = this.chars[i];
const progress = i / length; // 0 = 尾部, 1 = 头部
if (i === length - 1) {
// 头部最亮(白色)
char.setColor("#ffffff");
char.alpha = 1;
} else {
// 其他字符绿色渐变
const brightness = Math.floor(progress * 200);
if (this.colorVariant === 1) {
// 偶尔出现蓝色系
char.setColor(`rgb(0, ${brightness}, ${Math.floor(brightness * 0.5)})`);
} else {
char.setColor(`rgb(0, ${brightness}, 0)`);
}
char.alpha = 0.3 + progress * 0.7;
}
}
}
/**
* 重置雨滴到顶部
*/
private reset(): void {
// 清除所有字符
for (const char of this.chars) {
char.removeSelf();
char.destroy();
}
this.chars = [];
// 重置位置和速度
this.headY = -50 - Math.random() * 200;
this.speed = 3 + Math.random() * 5;
this.colorVariant = Math.random() > 0.8 ? 1 : 0;
}
/**
* 设置颜色
*/
public setColor(color: string): void {
this.mainColor = color;
}
}
/**
* 单个字符文本类
*/
class CharText extends Text {
constructor(char: string, width: number) {
super();
this.text = char;
this.fontSize = 14 + Math.random() * 4; // 随机字体大小
this.color = "#00ff00";
this.bold = true;
this.width = width;
this.height = this.fontSize;
this.align = "center";
this.valign = "middle";
}
/**
* 设置颜色
*/
public setColor(color: string): void {
this.color = color;
}
}
// 使用示例
const matrixRain = new MatrixRain(Laya.stage.width, Laya.stage.height);
Laya.stage.addChild(matrixRain);
示例5:绘制雷达图
import Sprite = Laya.Sprite;
function drawRadarChart(
container: Sprite,
data: number[],
labels: string[],
size: number = 200
): void {
const centerX = size / 2;
const centerY = size / 2;
const radius = size / 2 - 40;
const sides = data.length;
const chart = new Sprite();
chart.size(size, size);
// 绘制背景网格(5层)
for (let i = 1; i <= 5; i++) {
const points: number[] = [];
const currentRadius = (radius / 5) * i;
for (let j = 0; j < sides; j++) {
const angle = (j * 2 * Math.PI / sides) - Math.PI / 2;
points.push(
centerX + currentRadius * Math.cos(angle),
centerY + currentRadius * Math.sin(angle)
);
}
chart.graphics.drawPoly(0, 0, points, "", "#444444", 1);
}
// 绘制数据区域
const maxValue = Math.max(...data);
const dataPoints: number[] = [];
for (let i = 0; i < sides; i++) {
const angle = (i * 2 * Math.PI / sides) - Math.PI / 2;
const value = (data[i] / maxValue) * radius;
dataPoints.push(
centerX + value * Math.cos(angle),
centerY + value * Math.sin(angle)
);
}
chart.graphics.drawPoly(0, 0, dataPoints, "rgba(0, 255, 136, 0.3)", "#00ff88", 2);
// 绘制数据点
for (let i = 0; i < dataPoints.length; i += 2) {
chart.graphics.drawCircle(dataPoints[i], dataPoints[i + 1], 5, "#00ff88", "#ffffff", 2);
}
container.addChild(chart);
}
// 使用示例
const container = new Sprite();
drawRadarChart(container, [80, 65, 90, 75, 85], ["速度", "力量", "敏捷", "智力", "耐力"]);
Laya.stage.addChild(container);
示例6:加载动画(旋转圆环)
import Sprite = Laya.Sprite;
class LoadingSpinner extends Sprite {
private angle: number = 0;
private dotCount: number = 12;
private radius: number = 30;
private dotSize: number = 4;
constructor() {
super();
this.size(80, 80);
}
public start(): void {
Laya.timer.frameLoop(2, this, this.update);
}
public stop(): void {
Laya.timer.clear(this, this.update);
}
private update(): void {
this.graphics.clear();
this.angle = (this.angle + 15) % 360;
for (let i = 0; i < this.dotCount; i++) {
const currentAngle = (this.angle + i * (360 / this.dotCount)) * Math.PI / 180;
const x = 40 + this.radius * Math.cos(currentAngle);
const y = 40 + this.radius * Math.sin(currentAngle);
const alpha = (i + 1) / this.dotCount;
this.graphics.drawCircle(x, y, this.dotSize, `rgba(0, 255, 136, ${alpha})`);
}
}
public destroy(): void {
this.stop();
super.destroy();
}
}
// 使用示例
const spinner = new LoadingSpinner();
spinner.pos(500, 500);
spinner.start();
Laya.stage.addChild(spinner);
// 3秒后停止
Laya.timer.once(3000, this, () => {
spinner.destroy();
});
七、性能优化建议
1. 使用 cacheAs 缓存静态图形
import Sprite = Laya.Sprite;
const sprite = new Sprite();
// 绘制复杂图形
sprite.graphics.drawPath(0, 0, complexPath, {fillStyle:"#FF0000"});
// 设置缓存,避免每帧重新绘制
sprite.cacheAs = "normal"; // 静态缓存
// sprite.cacheAs = "bitmap"; // 位图缓存(更高效但占用更多内存)
2. 避免频繁调用 clear()
对于动态更新的图形,尽量增量更新而非每次清空重绘。
// ❌ 不推荐 - 每帧都清空重绘
private badUpdate(): void {
this.graphics.clear();
this.graphics.drawRect(x, y, 100, 100, "#ff0000");
}
// ✅ 推荐 - 移动已有对象
private goodUpdate(): void {
this.x = x;
this.y = y;
}
3. 合理控制绘制对象数量
过多 Sprite 会影响性能,尽量将静态图形合并到一个 Sprite 中绘制。
八、API 速查表
| 方法 | 说明 |
|---|---|
drawRect(x, y, w, h, fill, line, lineWidth) |
绘制矩形 |
drawCircle(x, y, r, fill, line, lineWidth) |
绘制圆形 |
drawPie(x, y, r, startAngle, endAngle, fill, line, lineWidth) |
绘制扇形 |
drawLine(x1, y1, x2, y2, color, lineWidth) |
绘制直线 |
drawLines(x, y, points, color, lineWidth) |
绘制折线 |
drawCurves(x, y, points, color, lineWidth) |
绘制曲线 |
drawPath(x, y, paths, fill, line, lineWidth) |
绘制路径 |
drawPoly(x, y, points, fill, line, lineWidth) |
绘制多边形 |
drawTexture(texture, x, y, width, height) |
绘制纹理 |
fillTexture(texture, x, y, width, height) |
纹理平铺 |
clear() |
清除所有绘制 |
save() |
保存状态 |
restore() |
恢复状态 |
translate(x, y) |
平移 |
scale(scaleX, scaleY) |
缩放 |
rotate(angle) |
旋转 |
transform(matrix) |
应用变换矩阵 |
clip() |
设置裁剪区域 |
文档版本:LayaAir 3.3.6
更多推荐

所有评论(0)