首次提交

This commit is contained in:
YZ\249929363 2024-10-30 15:19:32 +08:00
commit b7e1bfa778
270 changed files with 79583 additions and 0 deletions

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# 绘图板
使用cocoscreator2.4.3版本开发的画板,包含绘画、撤销、清除、保存(web端)功能。
> 参考https://forum.cocos.org/t/topic/89902.
[在线体验 https://skyxu123.gitee.io/gamelover/games/drawingboard/]('https://skyxu123.gitee.io/gamelover/games/drawingboard/')

12
assets/Prefab.meta Normal file
View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "ac4f1b66-756b-49be-ace6-5c38e06d7b47",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

2703
assets/Prefab/ui.prefab Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
{
"ver": "1.2.7",
"uuid": "3a986c4c-c3e5-426d-ba0e-431ff3fdfacc",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}

12
assets/Scene.meta Normal file
View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

4305
assets/Scene/game.fire Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
{
"ver": "1.2.8",
"uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

12
assets/Script.meta Normal file
View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

View File

@ -0,0 +1,801 @@
/**
*
* 使线
*
* @href https://forum.cocos.org/t/topic/89902
*/
export default class DrawingBoard {
private _witdh: number;
/**画板宽度 */
public get width(): number { return this._witdh; }
private _height: number;
/**画板高度 */
public get height(): number { return this._height; }
/**记录每个像素点的颜色值的数组颜色值用十六进制表示RGBA格式 */
private pointColor: number[][];
/**记录每个像素点能否绘制0表示不能绘制1表示能绘制 */
private maskPoint: number[][];
/**存储像素数据的内存块 */
private buffer: ArrayBuffer;
/**颜色分量一维数组,供渲染使用 */
private pixelColor: Uint8Array;
/**记录各种颜色的像素的数量 */
private colorCount: { [key: number]: number };
/**记录最近一次绘制像素的颜色(十六进制颜色值),调用绘制函数且未指定颜色值时,将使用该值 */
private curColor: number;
/**临时存储的颜色值 */
private tempColor: number;
private tempR: number;
private tempG: number;
private tempB: number;
private tempA: number;
/**
* 使X轴向右为正Y轴向上为正
* @param width
* @param height
* @param data
*/
public constructor(width: number, height: number, data?: ArrayBuffer) {
this.init(width, height, data);
}
//#region 初始化
/**
*
* @param width
* @param height
* @param data
*/
public init(width: number, height: number, data?: ArrayBuffer) {
this.tempColor = this.tempR = this.tempG = this.tempB = this.tempA = 0;
this.curColor = 0;
this._witdh = Math.round(width);
this._height = Math.round(height);
this.initPointColor();
this.initMaskPoint();
this.initPixelColor();
this.initLineData();
if (!!data) {
this.setData(data);
}
}
private initPointColor() {
if (!this.pointColor) {
this.pointColor = [];
}
for (let x = 0; x < this.width; ++x) {
if (!this.pointColor[x]) {
this.pointColor[x] = [];
}
for (let y = 0; y < this.height; ++y) {
this.pointColor[x][y] = 0;
}
}
this.colorCount = {};
this.colorCount[0] = this.width * this.height;
}
private initMaskPoint() {
if (!this.maskPoint) {
this.maskPoint = [];
}
for (let x = 0; x < this.width; ++x) {
if (!this.maskPoint[x]) {
this.maskPoint[x] = [];
}
for (let y = 0; y < this.height; ++y) {
this.maskPoint[x][y] = 1;
}
}
}
private initPixelColor() {
this.buffer = new ArrayBuffer(this.width * this.height * 4);
this.pixelColor = new Uint8Array(this.buffer);
this.pixelColor.fill(0);
}
//#endregion
//#region 重置内容
/**重置画板,画板的宽高不变,但会清空已绘制的所有内容,恢复至透明状态 */
public reset() {
this.resetPointColor();
this.resetMaskPoint();
this.resetPixelColor();
}
private resetPointColor() {
for (let x = this.width - 1; x >= 0; --x) {
for (let y = this.height - 1; y >= 0; --y) {
this.pointColor[x][y] = 0;
}
}
for (let key in this.colorCount) {
this.colorCount[key] = 0;
}
}
private resetMaskPoint() {
for (let x = this.width - 1; x >= 0; --x) {
for (let y = this.height - 1; y >= 0; --y) {
this.maskPoint[x][y] = 1;
}
}
}
private resetPixelColor() {
this.pixelColor.fill(0);
}
//#endregion
/**
* 使 init()
* @param data
*/
public setData(data: ArrayBuffer) {
let pixelData = new Uint8Array(data);
if (pixelData.length != this.width * this.height * 4) {
console.warn("画板设置数据失败,数据长度与画板大小不一致。");
return;
}
this.setPixelColorByRGBA(pixelData);
this.setPointColorByRGBA(pixelData);
}
/**
*
* @param data
*/
private setPixelColorByRGBA(data: Uint8Array) {
this.pixelColor.set(data);
}
/**
*
* @param data
*/
private setPointColorByRGBA(data: Uint8Array) {
this.colorCount = {};
for (let y = 0; y < this.height; ++y) {
let i = y * this.height;
for (let x = 0; x < this.width; ++x) {
let color = this.convertToNumber(data[i++], data[i++], data[i++], data[i++]);
this.pointColor[x][y] = color;
if (!this.colorCount[color]) {
this.colorCount[color] = 1;
} else {
this.colorCount[color] += 1;
}
}
}
}
/**
*
* @param data 01
*/
public setMask(data: number[][]) {
for (let x = this.width - 1; x >= 0; --x) {
if (!!data[x]) {
for (let y = this.height - 1; y >= 0; --y) {
if (undefined != data[x][y]) {
this.maskPoint[x][y] = data[x][y];
}
}
}
}
}
/**
*
*/
public setDisable() {
for (let x = this.width - 1; x >= 0; --x) {
for (let y = this.height - 1; y >= 0; --y) {
this.maskPoint[x][y] = 0;
}
}
}
/**
*
*
* @param data 01
*/
public addEnablePoints(data: number[][]) {
for (let x = this.width - 1; x >= 0; --x) {
if (!!data[x]) {
for (let y = this.height - 1; y >= 0; --y) {
if (!!data[x][y]) {
this.maskPoint[x][y] = data[x][y];
}
}
}
}
}
/**
*
* @param data
* @returns {number[]}
*/
public copyData(data?: number[]): number[] {
if (undefined === data) {
data = [];
}
for (let i = 0, count = this.pixelColor.length; i < count; ++i) {
data[i] = this.pixelColor[i];
}
return data;
}
/**
*
* @returns 使使 copyData
*/
public getData(): Uint8Array {
return this.pixelColor;
}
/**获取画板内部使用的内存块,若仅需要获取像素数据,不进一步处理,使用 getData 即可 */
public getBuffer(): ArrayBuffer {
return this.buffer;
}
public getPointData(): number[][] {
return this.pointColor;
}
/**
*
* @param r r分量
* @param g g分量
* @param b b分量
* @param a 255
*/
public getColorCount(r: number, g: number, b: number, a: number = 255): number {
let c = this.convertToNumber(r, g, b, a);
return this.colorCount[c];
}
/**
* 使使
* @param r RGBA分量的颜色对象r分量
* @param g g分量
* @param b b分量
* @param a 255
*/
public setColor(r: number, g: number, b: number, a: number = 255) {
this.curColor = this.convertToNumber(r, g, b, a);
if (!this.colorCount[this.curColor]) {
this.colorCount[this.curColor] = 0;
}
this.tempColor = this.curColor;
this.tempR = r;
this.tempG = g;
this.tempB = b;
this.tempA = a;
}
/**清空所有已绘制的内容 */
public clear() {
this.reset();
}
//#region 绘制:直线
//直线
/**上一次绘制的直线的终点 */
private previousLineEndPos: Vec2;
private previousLineEndPosT: Vec2;
private previousLineEndPosB: Vec2;
/**上一次绘制的直线的端点样式 */
private previousLineCircleEnd: boolean;
/**上一次绘制的直线的宽度 */
private previousLineWidth: number;
private initLineData() {
this.previousLineEndPos = new Vec2();
this.previousLineEndPosT = new Vec2();
this.previousLineEndPosB = new Vec2();
this.previousLineCircleEnd = true;
this.previousLineWidth = 1;
}
/**
* lineTo 使线
* @param x X
* @param y Y
*/
public moveTo(x: number, y: number) {
x = Math.round(x);
y = Math.round(y);
this.previousLineEndPos.set(x, y);
this.previousLineEndPosT.set(x, y);
this.previousLineEndPosB.set(x, y);
}
/**
* 线
*/
public setLineWidth(w: number) {
this.previousLineWidth = w;
}
/**
* 线
* @param b 线
*/
public setLineCircleEnd(b: boolean) {
this.previousLineCircleEnd = b;
}
/**
* 线使线线
* @param x1 X
* @param y1 Y
* @param x2 X
* @param y2 Y
*/
public line(x1: number, y1: number, x2: number, y2: number) {
x1 = Math.round(x1);
x2 = Math.round(x2);
y1 = Math.round(y1);
y2 = Math.round(y2);
if (x1 == x2 && y1 == y2) return;
let width = this.previousLineWidth;
let circleEnd = this.previousLineCircleEnd;
this.previousLineEndPos.set(x2, y2);
let offsetX = 0;
let offsetY = 0;
let rateK = 1;
if (x1 == x2) {
offsetX = Math.round(width * 0.5);
} else if (y1 == y2) {
offsetY = Math.round(width * 0.5);
} else {
let k = (y2 - y1) / (x2 - x1);
rateK = Math.sqrt(k * k + 1);
offsetY = width * 0.5 / rateK;
offsetX = Math.round(offsetY * k);
offsetY = Math.round(offsetY);
}
this.previousLineEndPosT.set(x2 - offsetX, y2 + offsetY);
this.previousLineEndPosB.set(x2 + offsetX, y2 - offsetY);
let p1 = new Vec2(x1, y1);
let p2 = new Vec2(x2, y2);
if (x1 > x2) {
p1.x = x2;
p1.y = y2;
p2.x = x1;
p2.y = y1;
}
this._drawLine(p1, p2, width, offsetX, offsetY, rateK);
if (circleEnd) {
this._drawCircle(x1, y1, width * 0.5);
this._drawCircle(x2, y2, width * 0.5);
}
}
/**
* 线线使线
* @param x X
* @param y Y
*/
public lineTo(x: number, y: number) {
x = Math.round(x);
y = Math.round(y);
if (this.previousLineEndPos.x == x && this.previousLineEndPos.y == y) return;
let width = this.previousLineWidth;
let circleEnd = this.previousLineCircleEnd;
let x1 = this.previousLineEndPos.x;
let y1 = this.previousLineEndPos.y;
let x2 = x;
let y2 = y;
if (x1 > x2) {
x1 = x2;
y1 = y2;
x2 = this.previousLineEndPos.x;
y2 = this.previousLineEndPos.y;
}
let offsetX = 0;
let offsetY = 0;
let rateK = 1;
if (x1 == x2) {
offsetX = Math.round(width * 0.5);
} else if (y1 == y2) {
offsetY = Math.round(width * 0.5);
} else {
let k = (y2 - y1) / (x2 - x1);
rateK = Math.sqrt(k * k + 1);
offsetY = width * 0.5 / rateK;
offsetX = Math.round(offsetY * k);
offsetY = Math.round(offsetY);
}
if (!circleEnd) {
if (this.previousLineEndPos.x != this.previousLineEndPosT.x
|| this.previousLineEndPos.y != this.previousLineEndPosT.y) {
let p1 = new Vec2(this.previousLineEndPos.x - offsetX, this.previousLineEndPos.y + offsetY);
let p2 = new Vec2(this.previousLineEndPos.x + offsetX, this.previousLineEndPos.y - offsetY);
this._drawTriangle([p1, p2, this.previousLineEndPosT]);
this._drawTriangle([p1, p2, this.previousLineEndPosB]);
}
} else {
this._drawCircle(x1, y1, width * 0.5);
this._drawCircle(x2, y2, width * 0.5);
}
this._drawLine(new Vec2(x1, y1), new Vec2(x2, y2), width, offsetX, offsetY, rateK);
this.previousLineEndPos.set(x, y);
this.previousLineEndPosT.set(x - offsetX, y + offsetY);
this.previousLineEndPosB.set(x + offsetX, y - offsetY);
}
/**
* 线线
* @param p1 线
* @param p2 线
* @param width 线
* @param color 线
*/
private _drawLine(p1: Vec2, p2: Vec2, width: number, offsetX: number, offsetY: number, slopeRate: number) {
if (p1.y == p2.y) {
//水平直线
let x = p1.x < p2.x ? p1.x : p2.x;
this._drawRect(new Vec2(x, Math.round(p1.y - width * 0.5)), Math.abs(p1.x - p2.x), width);
} else if (p1.x == p2.x) {
//垂直直线
let y = p1.y < p2.y ? p1.y : p2.y;
this._drawRect(new Vec2(Math.round(p1.x - width * 0.5), y), width, Math.abs(p1.y - p2.y));
} else {
//倾斜直线
let inverseK = (p1.x - p2.x) / (p1.y - p2.y);
let p1t = new Vec2(p1.x - offsetX, p1.y + offsetY);
let p1b = new Vec2(p1.x + offsetX, p1.y - offsetY);
let p2t = new Vec2(p2.x - offsetX, p2.y + offsetY);
let p2b = new Vec2(p2.x + offsetX, p2.y - offsetY);
let p1c = new Vec2();
let p2c = new Vec2();
let height = Math.round(width * slopeRate);
if (p2.y > p1.y) {
if (p1b.x < p2t.x) {
p1c.x = p1b.x;
p1c.y = p1b.y + height;
p2c.x = p2t.x;
p2c.y = p2t.y - height;
this._drawVerticalTriangle(p1c, p1b, p1t);
this._drawParallelogram(p1b, p2c, height);
this._drawVerticalTriangle(p2t, p2c, p2b);
} else {
p1c.x = p1b.x;
p1c.y = Math.round(p2t.y - (p1c.x - p2t.x) * inverseK);
p2c.x = p2t.x;
p2c.y = Math.round(p1b.y + (p1b.x - p2c.x) * inverseK);
this._drawVerticalTriangle(p2t, p2c, p1t);
this._drawParallelogram(p2c, p1b, p2t.y - p2c.y);
this._drawVerticalTriangle(p1c, p1b, p2b);
}
} else {
if (p1t.x < p2b.x) {
p1c.x = p1t.x;
p1c.y = p1t.y - height;
p2c.x = p2b.x;
p2c.y = p2b.y + height;
this._drawVerticalTriangle(p1t, p1c, p1b);
this._drawParallelogram(p1c, p2b, height);
this._drawVerticalTriangle(p2c, p2b, p2t);
} else {
p1c.x = p1t.x;
p1c.y = Math.round(p2b.y - (p1c.x - p2b.x) * inverseK);
p2c.x = p2b.x;
p2c.y = Math.round(p1t.y + (p1t.x - p2c.x) * inverseK);
this._drawVerticalTriangle(p2c, p2b, p1b);
this._drawParallelogram(p2b, p1c, p1t.y - p1c.y);
this._drawVerticalTriangle(p1t, p1c, p2t);
}
}
}
}
//#endregion
//#region 绘制:矩形
/**
*
* @param x X
* @param y Y
* @param w
* @param h
*/
public rect(x: number, y: number, w: number, h: number) {
x = Math.round(x);
y = Math.round(y);
this._drawRect(new Vec2(x, y), w, h);
}
/**
*
* @param p
* @param w
* @param h
* @param color
*/
private _drawRect(p: Vec2, w: number, h: number) {
let minX = this.clampX(p.x);
let maxX = this.clampX(p.x + w);
let minY = this.clampY(p.y);
let maxY = this.clampY(p.y + h);
// for (let x = minX; x <= maxX; ++x) {
// for (let y = minY; y <= maxY; ++y) {
// this._drawPixel(x, y);
// }
// }
for (let y = minY; y <= maxY; ++y) {
this._drawRowPixel(minX, maxX, y);
}
}
/**
* Y轴平行
* @param p1
* @param p2
* @param height
* @param color
*/
private _drawParallelogram(p1: Vec2, p2: Vec2, height: number) {
if (p1.x == p2.x) return;
let k = (p2.y - p1.y) / (p2.x - p1.x);
let minX = this._minX(p1.x);
let maxX = this._maxX(p2.x);
for (let x = minX; x <= maxX; ++x) {
let minY = p1.y + Math.round((x - p1.x) * k);
let maxY = minY + height;
minY = this._minY(minY);
maxY = this._maxY(maxY);
this._drawColPixel(minY, maxY, x);
// for (let y = minY; y <= maxY; ++y) {
// this._drawPixel(x, y);
// }
}
}
//#endregion
//#region 绘制:三角形
/**
*
* @param x1 1X
* @param y1 1Y
* @param x2 2X
* @param y2 2Y
* @param x3 3X
* @param y3 3Y
*/
public triangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number) {
x1 = Math.round(x1);
y1 = Math.round(y1);
x2 = Math.round(x2);
y2 = Math.round(y2);
x3 = Math.round(x3);
y3 = Math.round(y3);
let pList: Vec2[] = [];
pList.push(new Vec2(x1, y1));
pList.push(new Vec2(x2, y2));
pList.push(new Vec2(x3, y3));
this._drawTriangle(pList);
}
/**
*
* @param p1
* @param p2
* @param p3
* @param color
*/
private _drawTriangle(pList: Vec2[]) {
pList.sort((a, b) => {
return a.x - b.x;
});
let p1 = pList[0];
let p2 = pList[1];
let p3 = pList[2];
if (p1.x == p2.x) {
if (p1.x == p3.x) return;
if (p1.y < p2.y) {
p1 = pList[1];
p2 = pList[0];
}
this._drawVerticalTriangle(p1, p2, p3);
return;
}
let k = (p3.y - p1.y) / (p3.x - p1.x);
let p4 = new Vec2(p2.x, Math.round(p1.y + (p2.x - p1.x) * k));
if (p4.y == p2.y) return;
if (p4.y < p2.y) {
this._drawVerticalTriangle(p2, p4, p1);
this._drawVerticalTriangle(p2, p4, p3);
} else {
this._drawVerticalTriangle(p4, p2, p1);
this._drawVerticalTriangle(p4, p2, p3);
}
}
/**
* Y轴平行的三角形
* @param p1
* @param p2
* @param p3
* @param color
*/
private _drawVerticalTriangle(p1: Vec2, p2: Vec2, p3: Vec2) {
if (p3.x == p1.x) return;
let k1 = (p3.y - p1.y) / (p3.x - p1.x);
let k2 = (p3.y - p2.y) / (p3.x - p2.x);
let maxX = p3.x, minX = p1.x;
if (maxX < minX) {
maxX = p1.x;
minX = p3.x;
}
minX = this._minX(minX);
maxX = this._maxX(maxX);
for (let x = minX; x <= maxX; ++x) {
let maxY = this.clampY(Math.round(p1.y + (x - p1.x) * k1));
let minY = this.clampY(Math.round(p2.y + (x - p2.x) * k2));
this._drawColPixel(minY, maxY, x);
// for (let y = minY; y <= maxY; ++y) {
// this._drawPixel(x, y);
// }
}
}
//#endregion
//#region 绘制:圆
/**
*
* @param x x
* @param y y
* @param radius
*/
public circle(x: number, y: number, radius: number) {
x = Math.round(x);
y = Math.round(y);
this._drawCircle(x, y, radius);
}
private _drawCircle(x: number, y: number, radius: number) {
radius = Math.round(radius);
if (radius == 0) return;
//三角形的斜边的平方
let dis = radius * radius;
// let minX = this._minX(x - radius);
// let maxX = this._maxX(x + radius);
// for (let i = minX; i <= maxX; ++i) {
// let r = x - i;
// r = Math.round(Math.sqrt(dis - r * r));
// let minY = this._minY(y - r);
// let maxY = this._maxY(y + r);
// for (let j = minY; j <= maxY; ++j) {
// this._drawPixel(i, j);
// }
// }
let minY = this.clampY(y - radius);
let maxY = this.clampY(y + radius);
for (let j = minY; j <= maxY; ++j) {
let r = j - y;
r = Math.round(Math.sqrt(dis - r * r));
let minX = this.clampX(x - r);
let maxX = this.clampX(x + r);
this._drawRowPixel(minX, maxX, j);
}
}
//#endregion
//#region 内部绘制方法
private _minX(x: number): number {
return x >= 0 ? x : 0;
}
private _maxX(x: number): number {
return x < this.width ? x : this.width - 1;
}
private _minY(y: number): number {
return y >= 0 ? y : 0;
}
private _maxY(y: number): number {
return y < this.height ? y : this.height - 1;
}
private clampX(x: number): number {
if (x < 0) return 0;
if (x >= this.width) return this.width - 1;
return x;
}
private clampY(y: number): number {
if (y < 0) return 0;
if (y >= this.height) return this.height - 1;
return y;
}
/**绘制一个像素点的颜色 */
private _drawPixel(x: number, y: number) {
x = Math.round(x);
y = Math.round(y);
if (this.maskPoint[x][y] == 0) return;
if (this.pointColor[x][y] == this.tempColor) return;
let index = (y * this.width + x) * 4;
this.pixelColor[index] = this.tempR;
this.pixelColor[index + 1] = this.tempG;
this.pixelColor[index + 2] = this.tempB;
this.pixelColor[index + 3] = this.tempA;
let c = this.pointColor[x][y];
this.colorCount[c]--;
this.colorCount[this.tempColor]++;
this.pointColor[x][y] = this.tempColor;
}
/**
*
* @param startX X坐标
* @param endX X坐标
* @param y Y坐标
*/
private _drawRowPixel(startX: number, endX: number, y: number) {
let index = (y * this.width + startX) * 4;
for (let x = startX; x <= endX; ++x) {
if ((this.maskPoint[x][y] != 0 && this.pointColor[x][y] != this.tempColor) || this.pixelColor[index + 3] != 255) {
this.pixelColor[index] = this.tempR;
this.pixelColor[index + 1] = this.tempG;
this.pixelColor[index + 2] = this.tempB;
this.pixelColor[index + 3] = this.tempA;
cc.tween(this.pixelColor)
.delay(5)
.to(0.5,{[index + 3]:0})
.start();
let c = this.pointColor[x][y];
this.colorCount[c]--;
this.colorCount[this.tempColor]++;
this.pointColor[x][y] = this.tempColor;
}
index += 4;
}
}
/**
*
* @param startY Y坐标
* @param endY Y坐标
* @param x X坐标
*/
private _drawColPixel(startY: number, endY: number, x: number) {
let index = (startY * this.width + x) * 4;
for (let y = startY; y <= endY; ++y) {
if ((this.maskPoint[x][y] != 0 && this.pointColor[x][y] != this.tempColor) || this.pixelColor[index + 3] != 255 ) {
this.pixelColor[index] = this.tempR;
this.pixelColor[index + 1] = this.tempG;
this.pixelColor[index + 2] = this.tempB;
this.pixelColor[index + 3] = this.tempA;
cc.tween(this.pixelColor)
.delay(5)
.to(0.5,{[index + 3]:0})
.start();
let c = this.pointColor[x][y];
this.colorCount[c]--;
this.colorCount[this.tempColor]++;
this.pointColor[x][y] = this.tempColor;
}
index += this.width * 4;
}
}
/**
* RGBA颜色分量转换为一个数值表示的颜色0~255
* @param r
* @param g
* @param b
* @param a
*/
private convertToNumber(r: number, g: number, b: number, a: number = 255): number {
//颜色值将用于数组索引不能为负数故红色分量为奇数时将减1变为偶数
return ((r & 0xfe) << 23) | (g << 16) | (b << 8) | a;
}
/**将十六进制的颜色转换为RGBA分量表示的颜色 */
private convertToRGBA(color: number): { r: number, g: number, b: number, a: number } {
//颜色值将用于数组索引不能为负数故红色分量为奇数时将减1变为偶数
return {
r: (color & 0xef000000) >> 23,
g: (color & 0x00ff0000) >> 16,
b: (color & 0x0000ff00) >> 8,
a: (color & 0x000000ff),
};
}
//#endregion
}
class Vec2 {
public x: number;
public y: number;
constructor(x: number = 0, y: number = 0) {
this.x = x;
this.y = y;
}
public set(p: number | Vec2, y?: number) {
if (typeof p === "number") {
this.x = p;
this.y = y;
} else {
this.x = p.x;
this.y = p.y;
}
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "2e8d29f5-9211-4159-bf28-0966b1ee8f02",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

288
assets/Script/Game.ts Normal file
View File

@ -0,0 +1,288 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import DrawingBoard from "./DrawingBoard";
const { ccclass, property } = cc._decorator;
enum GameState {
drawing = 1,
erasing = 2,
}
@ccclass
export default class Game extends cc.Component {
@property(cc.Node)
drawNode: cc.Node = null;
@property(cc.Camera)
captureCamera: cc.Camera = null;
@property(cc.Camera)
mainCamera: cc.Camera = null;
private targetCamera: cc.Camera;
private db: DrawingBoard = null;
private gameState: GameState = GameState.drawing;
private texture: cc.RenderTexture = null;
private prePos: cc.Vec2 = cc.Vec2.ZERO;
private startPos: cc.Vec2 = cc.Vec2.ZERO;
private lastColor: cc.Color = cc.Color.BLUE;
private errColor: cc.Color = cc.Color.RED;
private lastLineWidth: number = 1;
private history: any[] = [];
private touchId = -1;
private touchScale = false;
start() {
this.initDb();
this.initTexture();
this.initRead();
setTimeout(() => {
this.drawNode.on("touchstart", this.onTouchStart, this);
this.drawNode.on("touchmove", this.onTouchMove, this);
this.drawNode.on("touchend", this.onTouchEnd, this);
this.drawNode.on("touchcancel", this.onTouchEnd, this);
}, 2000);
}
initDb() {
//创建一个画板(需传入画板尺寸,将自动初始化)
this.db = new DrawingBoard(this.drawNode.width, this.drawNode.height);
//设置画板的绘图颜色(每次绘制前都可以重新设置)
this.lastLineWidth = 15;
this.db.setLineWidth(this.lastLineWidth);
// this.db.setColor(this.lastColor.r, this.lastColor.g, this.lastColor.b, this.lastColor.a);
//线条端点以圆角结尾
this.db.setLineCircleEnd(true);
}
initTexture() {
this.texture = new cc.RenderTexture();
this.texture.initWithSize(this.drawNode.width, this.drawNode.height, cc.RenderTexture.DepthStencilFormat.RB_FMT_S8);
let spf: cc.SpriteFrame = new cc.SpriteFrame(this.texture);
this.drawNode.getComponent(cc.Sprite).spriteFrame = spf;
}
initRead(){
this.targetCamera = this.node.getChildByName("tagCamera").getComponent(cc.Camera);
var rander = new cc.RenderTexture();
rander.initWithSize(this.node.width, this.node.height, cc.RenderTexture.DepthStencilFormat.RB_FMT_S8);
this.targetCamera.targetTexture = rander;
this.targetCamera.render();
console.log("完成");
}
onTouchStart(e: cc.Event.EventTouch) {
//将触摸位置作为线条的起点
//画板中使用的坐标系与图片坐标系一样原点在左上角X轴向右为正Y轴向下为正
//所以Y轴坐标应反过来, 这里用getLocationInView而不是getLocation
this.touchId = e.getID();
if(this.touchId == 1){
this.touchScale = true;
return;
}
let pos = e.getLocation();
this.prePos = this.convertToDrawNodePos(pos);
this.startPos = this.convertToDrawNodePos(pos);
this.db.moveTo(this.prePos.x, this.prePos.y);
}
onTouchMove(e: cc.Event.EventTouch) {
let touches = e.getTouches();
var touch1 = touches[0]
var delta1 = touch1.getDelta();
let pos = e.getLocation();
let pos1 = this.convertToDrawNodePos(touch1.getLocation());
let dst = this.startPos.sub(pos1).mag()
// this.label.string = touches.length + "";
if(touches.length == 1 && this.touchId < 1 && !this.touchScale && dst > 7){
// alert("不该进来");
this.prePos = this.convertToDrawNodePos(pos);
var jg = this.pd(e);
this.changeColor(jg)
if (this.gameState == GameState.drawing) {
//从上一次绘制线条后的终点开始向鼠标当前位置绘制线条
this.db.lineTo(this.prePos.x, this.prePos.y);
} else if (this.gameState == GameState.erasing) {
// 橡皮擦
this.db.circle(this.prePos.x, this.prePos.y, 10);
}
//每次画板中的数据有变化后,及时将数据应用到贴图上,在屏幕上显示出来
this.drawToImg();
}
else if(touches.length == 2){
var touch1 = touches[0], touch2 = touches[1];
var delta1 = touch1.getDelta(), delta2 = touch2.getDelta();
var touchPoint1 = this.node.parent.convertToNodeSpaceAR(touch1.getLocation());
var touchPoint2 = this.node.parent.convertToNodeSpaceAR(touch2.getLocation());
var distance = touchPoint1.sub(touchPoint2);
var delta = delta1.sub(delta2);
var scale = 1;
if(Math.abs(distance.x) > Math.abs(distance.y)){
scale = (distance.x + delta.x) / distance.x * this.node.scale;
}
else{
scale = (distance.y + delta.y) / distance.y * this.node.scale;
}
if(scale > 2 ) scale = 2;
this.node.scale = scale <= 0.1 ? 0.1: scale;
}
}
onTouchEnd(e: cc.Event.EventTouch) {
this.touchId = e.getID();
if(this.touchId == 1) this.touchScale = false;
this.addHistory();
}
pd(event){
let cha = 2;
var pos = event.getLocation();
var jg = false;
for(let i=-cha; i<cha;i++){
let postion = cc.v2();
postion.x = pos.x + i;
for(let j =-cha; j<cha; j++){
postion.y = pos.y + j;
// console.log("检测点:",postion.x,postion.y);
let img = this.getGraphisData(postion);
if((img[0] != 255 && img[1]!=255 && img[2]!=255)){
jg = true;
j = 10000; i = 10000;
}
}
}
//
return jg;
}
convertToDrawNodePos(worldPos: cc.Vec2) {
let pos = this.drawNode.convertToNodeSpaceAR(worldPos);
pos.x += this.drawNode.width * this.drawNode.anchorX;
pos.y += this.drawNode.height * this.drawNode.anchorY;
pos.y = this.drawNode.height - pos.y;
return pos;
}
addHistory() {
let copy = this.db.copyData();
let ucopy = new Uint8Array(copy);
this.history.push({ data: ucopy });
// cc.log('历史步骤: ', this.history.length);
}
drawToImg() {
//获取画板中绘制的图案数据
let data: Uint8Array = this.db.getData();
//将数据传递给贴图对象
this.texture.initWithData(data, cc.Texture2D.PixelFormat.RGBA8888, this.db.width, this.db.height);
}
changeColor(red){
if(!red) this.db.setColor(this.errColor.r, this.errColor.g, this.errColor.b, this.errColor.a)
else this.db.setColor(this.lastColor.r, this.lastColor.g, this.lastColor.b, this.lastColor.a);
}
getGraphisData(point){
let Uint8 = new Uint8Array(4);
Uint8 = this.targetCamera.targetTexture.readPixels(Uint8,point.x,point.y,1,1);
return Uint8;
}
onBtnDraw() {
this.db.setLineWidth(this.lastLineWidth);
this.db.setColor(this.lastColor.r, this.lastColor.g, this.lastColor.b, this.lastColor.a);
this.gameState = GameState.drawing;
}
onBtnErase() {
this.db.setLineWidth(this.lastLineWidth * 3);
// 橡皮擦的颜色不能是(0,0,0,0),因为这样会和DrawingBoard里的默认颜色相同导致绘制跳过
this.db.setColor(255, 255, 255, 0);
this.gameState = GameState.erasing;
}
onBtnClear() {
this.db.reset();
this.drawToImg();
this.history.splice(0, this.history.length);
}
onBtnRevoke() {
this.history.pop();
if (this.history.length) {
let data: Uint8Array = this.history[this.history.length - 1].data;
this.db.setData(data.buffer);
this.texture.initWithData(this.db.getData(), cc.Texture2D.PixelFormat.RGBA8888, this.db.width, this.db.height);
} else {
this.onBtnClear();
}
cc.log('历史记录剩余: ', this.history.length);
}
onBtnSave() {
if (cc.sys.isBrowser) {
let width = this.drawNode.width;
let height = this.drawNode.height;
this.captureCamera.enabled = true;
let texture = new cc.RenderTexture();
texture.initWithSize(width, height, cc.RenderTexture.DepthStencilFormat.RB_FMT_S8);
this.captureCamera.targetTexture = texture;
let canvas: HTMLCanvasElement = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
let ctx = canvas.getContext('2d');
this.captureCamera.render();
let data = texture.readPixels();
// write the render data
let rowBytes = width * 4;
for (let row = 0; row < height; row++) {
let srow = height - 1 - row;
let imageData = ctx.createImageData(width, 1);
let start = srow * width * 4;
for (let i = 0; i < rowBytes; i++) {
imageData.data[i] = data[start + i];
}
ctx.putImageData(imageData, 0, row);
}
//
let dataUrl = canvas.toDataURL('image/png');
// cc.log('iamge-base64:', dataUrl);
let saveLink: any = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
saveLink.href = dataUrl;
saveLink.download = String(Date.now()) + '.png';
let event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
saveLink.dispatchEvent(event);
this.scheduleOnce(t => {
this.captureCamera.enabled = false;
}, 0.1);
} else {
cc.warn('暂时只支持web端保存图片');
}
}
update (dt) {
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "1c26d552-a24e-44ee-8d8f-c03dac18125a",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

12
assets/Texture.meta Normal file
View File

@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -0,0 +1,36 @@
{
"ver": "2.3.5",
"uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 195,
"height": 270,
"platformSettings": {},
"subMetas": {
"HelloWorld": {
"ver": "1.0.4",
"uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc",
"rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 195,
"height": 270,
"rawWidth": 195,
"rawHeight": 270,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

BIN
assets/Texture/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

View File

@ -0,0 +1,36 @@
{
"ver": "2.3.5",
"uuid": "1dd1185f-b125-49fb-94e8-ffc97c1baebc",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1200,
"height": 1200,
"platformSettings": {},
"subMetas": {
"icon": {
"ver": "1.0.4",
"uuid": "8146578b-494c-40d1-9ec7-639133cf1645",
"rawTextureUuid": "1dd1185f-b125-49fb-94e8-ffc97c1baebc",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 47,
"trimY": 47,
"width": 1106,
"height": 1106,
"rawWidth": 1200,
"rawHeight": 1200,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

View File

@ -0,0 +1,36 @@
{
"ver": "2.3.5",
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2,
"height": 2,
"platformSettings": {},
"subMetas": {
"singleColor": {
"ver": "1.0.4",
"uuid": "410fb916-8721-4663-bab8-34397391ace7",
"rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 2,
"height": 2,
"rawWidth": 2,
"rawHeight": 2,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,36 @@
{
"ver": "2.3.5",
"uuid": "b1f9556b-9739-432f-8ae5-8076ee980b6d",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 586,
"height": 586,
"platformSettings": {},
"subMetas": {
"tagTexture": {
"ver": "1.0.4",
"uuid": "21260c0a-6436-4941-8a7e-406423a31d04",
"rawTextureUuid": "b1f9556b-9739-432f-8ae5-8076ee980b6d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 586,
"height": 586,
"rawWidth": 586,
"rawHeight": 586,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

BIN
build/Mandala.zip Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
{"paths":{"1":["effects/builtin-2d-gray-sprite",0],"2":["effects/builtin-2d-sprite",0],"3":["materials/builtin-unlit",1],"4":["effects/builtin-3d-trail",0],"5":["effects/builtin-2d-graphics",0],"6":["materials/builtin-2d-gray-sprite",1],"7":["materials/builtin-3d-trail",1],"8":["effects/builtin-unlit",0],"9":["materials/builtin-2d-base",1],"10":["materials/builtin-2d-graphics",1],"11":["effects/builtin-clear-stencil",0],"12":["materials/builtin-clear-stencil",1],"13":["materials/builtin-2d-label",1],"14":["materials/builtin-2d-sprite",1],"15":["effects/builtin-2d-label",0]},"types":["cc.EffectAsset","cc.Material"],"uuids":["02delMVqdBD70a/HSD99FK","14TDKXr2NJ6LjvHPops74o","28dPjdQWxEQIG3VVl1Qm6T","2aKWBXJHxKHLvrBUi2yYZQ","2afAA24LNP4YmYiaVLiivs","30aC+Hnw1PF4pEcoY3kUYb","3ae7efMv1CLq2ilvUY/tQi","46bU+b5fROqIXVPG6aZWWK","6dkeWRTOBGXICfYQ7JUBnG","6fgBCSDDdPMInvyNlggls2","a1U5RdJRFMFL57BdJC9H1X","c0BAyVxX9JzZy8EjFrc9DU","cffgu4qBxEqa150o1DmRAy","e0LYfU5ZlNFoAB4UiRrGUG","ecpdLyjvZBwrvm+cedCcQy","f1h0LXVtJOta5JLZ1xCzfI"],"scenes":{},"redirect":[],"deps":[],"packs":{"079499991":[3,8],"07ce7530a":[1,6],"08018726a":[13,15],"0a5cba09d":[4,7],"0d5255670":[5,10],"0d669730c":[11,12]},"name":"internal","importBase":"import","nativeBase":"native","debug":false,"isZip":false,"encrypted":true,"versions":{"import":[0,"473a4","079499991","b784d","07ce7530a","d804b","08018726a","fa77a","0a5cba09d","ca76f","0d5255670","17633","0d669730c","6f73c",2,"cb6ca",9,"17b20",14,"7f586"],"native":[0,"cea68"]}}

View File

@ -0,0 +1 @@
{"__type__":"cc.Texture2D","content":"0,9729,9729,33071,33071,0,0,1"}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
[{"__type__":"cc.EffectAsset","_name":"builtin-2d-gray-sprite","techniques":[{"passes":[{"blendState":{"targets":[{"blend":true}]},"rasterizerState":{"cullMode":0},"properties":{"texture":{"value":"white","type":29}},"program":"builtin-2d-gray-sprite|vs|fs"}]}],"shaders":[{"hash":4278481454,"glsl3":{"vert":"\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nin vec3 a_position;\nin mediump vec2 a_uv0;\nout mediump vec2 v_uv0;\nin vec4 a_color;\nout vec4 v_color;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n v_uv0 = a_uv0;\n v_color = a_color;\n}","frag":"\nprecision highp float;\nuniform sampler2D texture;\nin mediump vec2 v_uv0;\nin vec4 v_color;\nvoid main () {\n vec4 color = v_color;\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;\n gl_FragColor = vec4(gray, gray, gray, color.a);\n}"},"glsl1":{"vert":"\nprecision highp float;\nuniform mat4 cc_matViewProj;\nattribute vec3 a_position;\nattribute mediump vec2 a_uv0;\nvarying mediump vec2 v_uv0;\nattribute vec4 a_color;\nvarying vec4 v_color;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n v_uv0 = a_uv0;\n v_color = a_color;\n}","frag":"\nprecision highp float;\nuniform sampler2D texture;\nvarying mediump vec2 v_uv0;\nvarying vec4 v_color;\nvoid main () {\n vec4 color = v_color;\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;\n gl_FragColor = vec4(gray, gray, gray, color.a);\n}"},"builtins":{"globals":{"blocks":[{"name":"CCGlobal","defines":[]}],"samplers":[]},"locals":{"blocks":[],"samplers":[]}},"defines":[{"name":"CC_USE_ALPHA_ATLAS_texture","type":"boolean","defines":[]},{"name":"INPUT_IS_GAMMA","type":"boolean","defines":[]}],"blocks":[],"samplers":[{"name":"texture","type":29,"count":1,"defines":[],"binding":30}],"record":null,"name":"builtin-2d-gray-sprite|vs|fs"}]},{"__type__":"cc.Material","_name":"builtin-2d-gray-sprite","_effectAsset":{"__uuid__":"14TDKXr2NJ6LjvHPops74o"},"_techniqueData":{}}]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
[{"__type__":"cc.EffectAsset","_name":"builtin-2d-graphics","techniques":[{"passes":[{"blendState":{"targets":[{"blend":true,"blendSrc":1,"blendDst":771,"blendSrcAlpha":1,"blendDstAlpha":771}]},"rasterizerState":{"cullMode":0},"properties":{"alphaThreshold":{"value":[0.5],"type":13}},"program":"builtin-2d-graphics|vs|fs"}]}],"shaders":[{"hash":550349795,"glsl3":{"vert":"\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\nin float a_dist;\nout float v_dist;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n gl_Position = pos;\n}","frag":"\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\nin float v_dist;\nvoid main () {\n vec4 o = v_color;\n ALPHA_TEST(o);\n #if CC_SUPPORT_standard_derivatives\n float aa = fwidth(v_dist);\n #else\n float aa = 0.05;\n #endif\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n gl_FragColor = o;\n}"},"glsl1":{"vert":"\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\nattribute float a_dist;\nvarying float v_dist;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n gl_Position = pos;\n}","frag":"\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\nvarying float v_dist;\nvoid main () {\n vec4 o = v_color;\n ALPHA_TEST(o);\n #if CC_SUPPORT_standard_derivatives\n float aa = fwidth(v_dist);\n #else\n float aa = 0.05;\n #endif\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n gl_FragColor = o;\n}"},"builtins":{"globals":{"blocks":[{"name":"CCGlobal","defines":[]}],"samplers":[]},"locals":{"blocks":[{"name":"CCLocal","defines":[]}],"samplers":[]}},"defines":[{"name":"CC_SUPPORT_standard_derivatives","type":"boolean","defines":[]},{"name":"USE_ALPHA_TEST","type":"boolean","defines":[]}],"blocks":[{"name":"ALPHA_TEST","members":[{"name":"alphaThreshold","type":13,"count":1}],"defines":["USE_ALPHA_TEST"],"binding":0}],"samplers":[],"record":null,"name":"builtin-2d-graphics|vs|fs"}]},{"__type__":"cc.Material","_name":"builtin-2d-graphics","_effectAsset":{"__uuid__":"30aC+Hnw1PF4pEcoY3kUYb"},"_techniqueData":{"0":{"defines":{}}}}]

View File

@ -0,0 +1 @@
[{"__type__":"cc.EffectAsset","_name":"builtin-clear-stencil","techniques":[{"passes":[{"blendState":{"targets":[{"blend":true}]},"rasterizerState":{"cullMode":0},"program":"builtin-clear-stencil|vs|fs"}]}],"shaders":[{"hash":2075641479,"glsl3":{"vert":"\nprecision highp float;\nin vec3 a_position;\nvoid main () {\n gl_Position = vec4(a_position, 1);\n}","frag":"\nprecision highp float;\nvoid main () {\n gl_FragColor = vec4(1.0);\n}"},"glsl1":{"vert":"\nprecision highp float;\nattribute vec3 a_position;\nvoid main () {\n gl_Position = vec4(a_position, 1);\n}","frag":"\nprecision highp float;\nvoid main () {\n gl_FragColor = vec4(1.0);\n}"},"builtins":{"globals":{"blocks":[],"samplers":[]},"locals":{"blocks":[],"samplers":[]}},"defines":[],"blocks":[],"samplers":[],"record":null,"name":"builtin-clear-stencil|vs|fs"}]},{"__type__":"cc.Material","_name":"builtin-clear-stencil","_effectAsset":{"__uuid__":"c0BAyVxX9JzZy8EjFrc9DU"},"_techniqueData":{}}]

View File

@ -0,0 +1 @@
{"__type__":"cc.EffectAsset","_name":"builtin-2d-sprite","techniques":[{"passes":[{"blendState":{"targets":[{"blend":true}]},"rasterizerState":{"cullMode":0},"properties":{"texture":{"value":"white","type":29},"alphaThreshold":{"value":[0.5],"type":13}},"program":"builtin-2d-sprite|vs|fs"}]}],"shaders":[{"hash":3278106612,"glsl3":{"vert":"\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}","frag":"\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}"},"glsl1":{"vert":"\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}","frag":"\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}"},"builtins":{"globals":{"blocks":[{"name":"CCGlobal","defines":[]}],"samplers":[]},"locals":{"blocks":[{"name":"CCLocal","defines":[]}],"samplers":[]}},"defines":[{"name":"USE_TEXTURE","type":"boolean","defines":[]},{"name":"CC_USE_MODEL","type":"boolean","defines":[]},{"name":"USE_ALPHA_TEST","type":"boolean","defines":[]},{"name":"CC_USE_ALPHA_ATLAS_texture","type":"boolean","defines":["USE_TEXTURE"]},{"name":"INPUT_IS_GAMMA","type":"boolean","defines":["USE_TEXTURE"]}],"blocks":[{"name":"ALPHA_TEST","members":[{"name":"alphaThreshold","type":13,"count":1}],"defines":["USE_ALPHA_TEST"],"binding":0}],"samplers":[{"name":"texture","type":29,"count":1,"defines":["USE_TEXTURE"],"binding":30}],"record":null,"name":"builtin-2d-sprite|vs|fs"}]}

View File

@ -0,0 +1 @@
{"__type__":"cc.Material","_name":"builtin-2d-base","_effectAsset":{"__uuid__":"28dPjdQWxEQIG3VVl1Qm6T"},"_techniqueData":{}}

View File

@ -0,0 +1 @@
{"__type__":"cc.Material","_name":"builtin-2d-sprite","_effectAsset":{"__uuid__":"28dPjdQWxEQIG3VVl1Qm6T"},"_techniqueData":{"0":{"defines":{"USE_TEXTURE":true}}}}

View File

@ -0,0 +1 @@
(function r(e,n,t){function i(u,f){if(!n[u]){if(!e[u]){var _=u.split("/");if(_=_[_.length-1],!e[_]){var p="function"==typeof __require&&__require;if(!f&&p)return p(_,!0);if(o)return o(_,!0);throw new Error("Cannot find module '"+u+"'")}u=_}var a=n[u]={exports:{}};e[u][0].call(a.exports,function(r){return i(e[u][1][r]||r)},a,a.exports,r,e,n,t)}return n[u].exports}for(var o="function"==typeof __require&&__require,u=0;u<t.length;u++)i(t[u]);return i})({},{},[]);

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

View File

@ -0,0 +1 @@
{"paths":{},"types":[],"uuids":["1d0RhfsSVJ+5To/8l8G668","2dL3kvpAxJu6GJ7RdqJG5J","71VhFCTINJM6/Ky3oX9nBT","a8Anh32NZGRZegUtSgEj26","b4P/PCArtIdIH38t6mlw8Y","d8HsitJHxOYqo801xBk8ev","e8Ueib+qJEhL6mXAHdnwbi","02delMVqdBD70a/HSD99FK","29FYIk+N1GYaeWH/q1NxQO","3amGxMw+VCbboOQx/z/frM","41D7kWhyFGY7q4NDlzkazn","81RleLSUxA0Z7HY5EzzxZF","9bvaMerUlDyary99mJa6xp","a2MjXRFdtLlYQ5ouAFv/+R","e97GVMl6JHh5Ml5qEDdSGa","ecpdLyjvZBwrvm+cedCcQy","f0BIwQ8D5Ml7nTNQbh1YlS"],"scenes":{"db://assets/Scene/game.fire":1},"redirect":[7,0,15,0],"deps":["internal"],"packs":{"068b33388":[8,1,9,10,11,12,13,14,16],"0ba7930ae":[0,2,3,4,5,6]},"name":"main","importBase":"import","nativeBase":"native","debug":false,"isZip":false,"encrypted":true,"versions":{"import":["068b33388","1be0c","0ba7930ae","7c178"],"native":[0,"1ea00",2,"c06a9",3,"cea68",4,"83fcc",5,"cdbc9",6,"90cf4"]}}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"type":"cc.Texture2D","data":"0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1|0,9729,9729,33071,33071,0,0,1"}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

90
build/Mandala/index.html Normal file
View File

@ -0,0 +1,90 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Cocos Creator | DrawingBoard</title>
<!--http://www.html5rocks.com/en/mobile/mobifying/-->
<meta name="viewport"
content="width=device-width,user-scalable=no,initial-scale=1, minimum-scale=1,maximum-scale=1"/>
<!--https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html-->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="format-detection" content="telephone=no">
<!-- force webkit on 360 -->
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<!-- force edge on IE -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="msapplication-tap-highlight" content="no">
<!-- force full screen on some browser -->
<meta name="full-screen" content="yes"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<!-- force screen orientation on some browser -->
<meta name="screen-orientation" content=""/>
<meta name="x5-orientation" content="">
<!--fix fireball/issues/3568 -->
<!--<meta name="browsermode" content="application">-->
<meta name="x5-page-mode" content="app">
<!--<link rel="apple-touch-icon" href=".png" />-->
<!--<link rel="apple-touch-icon-precomposed" href=".png" />-->
<link rel="stylesheet" type="text/css" href="style-mobile.6e9cd.css"/>
<link rel="icon" href="favicon.8de18.ico"/>
</head>
<body>
<canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas>
<div id="splash">
<div class="progress-bar stripes">
<span style="width: 0%"></span>
</div>
</div>
<script src="src/settings.985c1.js" charset="utf-8"></script>
<script src="main.554c7.js" charset="utf-8"></script>
<script type="text/javascript">
(function () {
// open web debugger console
if (typeof VConsole !== 'undefined') {
window.vConsole = new VConsole();
}
var debug = window._CCSettings.debug;
var splash = document.getElementById('splash');
splash.style.display = 'block';
function loadScript (moduleName, cb) {
function scriptLoaded () {
document.body.removeChild(domScript);
domScript.removeEventListener('load', scriptLoaded, false);
cb && cb();
};
var domScript = document.createElement('script');
domScript.async = true;
domScript.src = moduleName;
domScript.addEventListener('load', scriptLoaded, false);
document.body.appendChild(domScript);
}
loadScript(debug ? 'cocos2d-js.js' : 'cocos2d-js-min.84c17.js', function () {
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
loadScript(debug ? 'physics.js' : 'physics-min.js', window.boot);
}
else {
window.boot();
}
});
})();
</script>
</body>
</html>

139
build/Mandala/main.554c7.js Normal file
View File

@ -0,0 +1,139 @@
window.boot = function () {
var settings = window._CCSettings;
window._CCSettings = undefined;
var onProgress = null;
let { RESOURCES, INTERNAL, MAIN, START_SCENE } = cc.AssetManager.BuiltinBundleName;
function setLoadingDisplay () {
// Loading splash scene
var splash = document.getElementById('splash');
var progressBar = splash.querySelector('.progress-bar span');
onProgress = function (finish, total) {
var percent = 100 * finish / total;
if (progressBar) {
progressBar.style.width = percent.toFixed(2) + '%';
}
};
splash.style.display = 'block';
progressBar.style.width = '0%';
cc.director.once(cc.Director.EVENT_AFTER_SCENE_LAUNCH, function () {
splash.style.display = 'none';
});
}
var onStart = function () {
cc.view.enableRetina(true);
cc.view.resizeWithBrowserSize(true);
if (cc.sys.isBrowser) {
setLoadingDisplay();
}
if (cc.sys.isMobile) {
if (settings.orientation === 'landscape') {
cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
}
else if (settings.orientation === 'portrait') {
cc.view.setOrientation(cc.macro.ORIENTATION_PORTRAIT);
}
cc.view.enableAutoFullScreen([
cc.sys.BROWSER_TYPE_BAIDU,
cc.sys.BROWSER_TYPE_BAIDU_APP,
cc.sys.BROWSER_TYPE_WECHAT,
cc.sys.BROWSER_TYPE_MOBILE_QQ,
cc.sys.BROWSER_TYPE_MIUI,
].indexOf(cc.sys.browserType) < 0);
}
// Limit downloading max concurrent task to 2,
// more tasks simultaneously may cause performance draw back on some android system / browsers.
// You can adjust the number based on your own test result, you have to set it before any loading process to take effect.
if (cc.sys.isBrowser && cc.sys.os === cc.sys.OS_ANDROID) {
cc.assetManager.downloader.maxConcurrency = 2;
cc.assetManager.downloader.maxRequestsPerFrame = 2;
}
var launchScene = settings.launchScene;
var bundle = cc.assetManager.bundles.find(function (b) {
return b.getSceneInfo(launchScene);
});
bundle.loadScene(launchScene, null, onProgress,
function (err, scene) {
if (!err) {
cc.director.runSceneImmediate(scene);
if (cc.sys.isBrowser) {
// show canvas
var canvas = document.getElementById('GameCanvas');
canvas.style.visibility = '';
var div = document.getElementById('GameDiv');
if (div) {
div.style.backgroundImage = '';
}
console.log('Success to load scene: ' + launchScene);
}
}
}
);
};
var option = {
id: 'GameCanvas',
debugMode: settings.debug ? cc.debug.DebugMode.INFO : cc.debug.DebugMode.ERROR,
showFPS: settings.debug,
frameRate: 60,
groupList: settings.groupList,
collisionMatrix: settings.collisionMatrix,
};
cc.assetManager.init({
bundleVers: settings.bundleVers,
remoteBundles: settings.remoteBundles,
server: settings.server
});
let bundleRoot = [INTERNAL, MAIN];
settings.hasStartSceneBundle && bundleRoot.push(START_SCENE);
settings.hasResourcesBundle && bundleRoot.push(RESOURCES);
var count = 0;
function cb (err) {
if (err) return console.error(err.message, err.stack);
count++;
if (count === bundleRoot.length + 1) {
cc.game.run(option, onStart);
}
}
cc.assetManager.loadScript(settings.jsList.map(function (x) { return 'src/' + x;}), cb);
for (let i = 0; i < bundleRoot.length; i++) {
cc.assetManager.loadBundle(bundleRoot[i], cb);
}
};
if (window.jsb) {
var isRuntime = (typeof loadRuntime === 'function');
if (isRuntime) {
require('src/settings.985c1.js');
require('src/cocos2d-runtime.js');
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
require('src/physics.js');
}
require('jsb-adapter/engine/index.js');
}
else {
require('src/settings.985c1.js');
require('src/cocos2d-jsb.js');
if (CC_PHYSICS_BUILTIN || CC_PHYSICS_CANNON) {
require('src/physics.js');
}
require('jsb-adapter/jsb-engine.js');
}
cc.macro.CLEANUP_IMAGE_CACHE = true;
window.boot();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1 @@
window._CCSettings={platform:"web-mobile",groupList:["default","drawNode","other"],collisionMatrix:[[true],[false,false],[false,false,false]],hasResourcesBundle:false,hasStartSceneBundle:false,remoteBundles:[],subpackages:[],launchScene:"db://assets/Scene/game.fire",orientation:"",jsList:[],bundleVers:{internal:"b25de",main:"311c1"}};

View File

@ -0,0 +1,116 @@
body {
cursor: default;
padding: 0;
border: 0;
margin: 0;
text-align: center;
background-color: white;
font-family: Helvetica, Verdana, Arial, sans-serif;
}
body, canvas, div {
outline: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
/* Remove spin of input type number */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
/* display: none; <- Crashes Chrome on hover */
-webkit-appearance: none;
margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
}
#Cocos2dGameContainer {
position: absolute;
margin: 0;
overflow: hidden;
left: 0px;
top: 0px;
}
canvas {
background-color: rgba(0, 0, 0, 0);
}
a:link, a:visited {
color: #000;
}
a:active, a:hover {
color: #666;
}
p.header {
font-size: small;
}
p.footer {
font-size: x-small;
}
#splash {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #171717 url(./splash.85cfd.png) no-repeat center;
background-size: 350px;
}
.progress-bar {
background-color: #1a1a1a;
position: absolute;
left: 50%;
top: 80%;
height: 5px;
width: 300px;
margin: 0 -150px;
border-radius: 5px;
box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
}
.progress-bar span {
display: block;
height: 100%;
border-radius: 5px;
box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
transition: width .4s ease-in-out;
background-color: #3dc5de;
}
.stripes span {
background-size: 30px 30px;
background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
transparent 75%, transparent);
animation: animate-stripes 1s linear infinite;
}
@keyframes animate-stripes {
0% {background-position: 0 0;} 100% {background-position: 60px 0;}
}
h1 {
color: #444;
text-shadow: 3px 3px 15px;
}
#GameDiv {
width: 800px;
height: 450px;
margin: 0 auto;
background: black;
position: relative;
border: 3px solid black;
border-radius: 6px;
box-shadow: 0 5px 40px #333
}

View File

@ -0,0 +1,124 @@
html {
-ms-touch-action: none;
}
body, canvas, div {
display: block;
outline: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
/* Remove spin of input type number */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
/* display: none; <- Crashes Chrome on hover */
-webkit-appearance: none;
margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
}
body {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding: 0;
border: 0;
margin: 0;
cursor: default;
color: #888;
background-color: #333;
text-align: center;
font-family: Helvetica, Verdana, Arial, sans-serif;
display: flex;
flex-direction: column;
/* fix bug: https://github.com/cocos-creator/2d-tasks/issues/791 */
/* overflow cannot be applied in Cocos2dGameContainer,
otherwise child elements will be hidden when Cocos2dGameContainer rotated 90 deg */
overflow: hidden;
}
#Cocos2dGameContainer {
position: absolute;
margin: 0;
left: 0px;
top: 0px;
display: -webkit-box;
-webkit-box-orient: horizontal;
-webkit-box-align: center;
-webkit-box-pack: center;
}
canvas {
background-color: rgba(0, 0, 0, 0);
}
a:link, a:visited {
color: #666;
}
a:active, a:hover {
color: #666;
}
p.header {
font-size: small;
}
p.footer {
font-size: x-small;
}
#splash {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #171717 url(./splash.85cfd.png) no-repeat center;
background-size: 45%;
}
.progress-bar {
position: absolute;
left: 27.5%;
top: 80%;
height: 3px;
padding: 2px;
width: 45%;
border-radius: 7px;
box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
}
.progress-bar span {
display: block;
height: 100%;
border-radius: 3px;
transition: width .4s ease-in-out;
background-color: #3dc5de;
}
.stripes span {
background-size: 30px 30px;
background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
transparent 75%, transparent);
animation: animate-stripes 1s linear infinite;
}
@keyframes animate-stripes {
0% {background-position: 0 0;} 100% {background-position: 60px 0;}
}

32069
creator.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

13
jsconfig.json Normal file
View File

@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs"
},
"exclude": [
"node_modules",
"library",
"local",
"settings",
"temp"
]
}

View File

@ -0,0 +1,409 @@
[
{
"__type__": "cc.Prefab",
"_name": "slider",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 1,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "slider",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
}
],
"_active": true,
"_components": [
{
"__id__": 9
}
],
"_prefab": {
"__id__": 10
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 300,
"height": 20
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "Background",
"_objFlags": 512,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 300,
"height": 20
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "31d8962d-babb-4ec7-be19-8e9f54a4ea99"
},
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "0004d1cf-a0ad-47d8-ab17-34d3db9d35a3"
},
"fileId": "f43c4gNvOtBE41OTztiOT6T",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "Handle",
"_objFlags": 512,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
},
{
"__id__": 7
}
],
"_prefab": {
"__id__": 8
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 32,
"height": 32
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f"
},
"_type": 1,
"_sizeMode": 2,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.1,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": true,
"_N$transition": 3,
"transition": 3,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$normalSprite": {
"__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f"
},
"_N$pressedSprite": {
"__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f"
},
"pressedSprite": {
"__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f"
},
"_N$hoverSprite": {
"__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f"
},
"hoverSprite": {
"__uuid__": "e7aba14b-f956-4480-b254-8d57832e273f"
},
"_N$disabledSprite": {
"__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
},
"_N$target": {
"__id__": 5
},
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "0004d1cf-a0ad-47d8-ab17-34d3db9d35a3"
},
"fileId": "93f4b6UTvtD0Iy5hi3tLIn2",
"sync": false
},
{
"__type__": "cc.Slider",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"direction": 0,
"slideEvents": [],
"_N$handle": {
"__id__": 7
},
"_N$progress": 0.5,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "0004d1cf-a0ad-47d8-ab17-34d3db9d35a3"
},
"fileId": "8ac42iRpDlK6pemd22ZO6x/",
"sync": false
}
]

View File

@ -0,0 +1,4 @@
{
"__type__": "cc.Texture2D",
"content": "0,9729,9729,33071,33071,0,0,1"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

View File

@ -0,0 +1,4 @@
{
"__type__": "cc.Texture2D",
"content": "0,9729,9729,33071,33071,0,0,1"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,90 @@
[
{
"__type__": "cc.Mesh",
"_name": "",
"_objFlags": 0,
"_native": ".bin",
"_vertexBundles": [
{
"__id__": 1
}
],
"_primitives": [
{
"__id__": 6
}
],
"_minPos": {
"__type__": "cc.Vec3",
"x": -0.5,
"y": -0.5,
"z": -0.5
},
"_maxPos": {
"__type__": "cc.Vec3",
"x": 0.5,
"y": 0.5,
"z": 0.5
}
},
{
"__type__": "cc.mesh.VertexBundle",
"data": {
"__id__": 2
},
"formats": [
{
"__id__": 3
},
{
"__id__": 4
},
{
"__id__": 5
}
],
"verticesCount": 24
},
{
"__type__": "cc.BufferRange",
"offset": 0,
"length": 768
},
{
"__type__": "cc.mesh.VertexFormat",
"name": "a_normal",
"type": 5126,
"num": 3,
"normalize": false
},
{
"__type__": "cc.mesh.VertexFormat",
"name": "a_position",
"type": 5126,
"num": 3,
"normalize": false
},
{
"__type__": "cc.mesh.VertexFormat",
"name": "a_uv0",
"type": 5126,
"num": 2,
"normalize": false
},
{
"__type__": "cc.mesh.Primitive",
"vertexBundleIndices": [
0
],
"data": {
"__id__": 7
},
"indexUnit": 5123,
"topology": 4
},
{
"__type__": "cc.BufferRange",
"offset": 768,
"length": 72
}
]

View File

@ -0,0 +1,117 @@
[
{
"__type__": "cc.Prefab",
"_name": "point",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "light",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": true,
"groupIndex": 0,
"_id": "",
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
0,
1,
1,
1
]
}
},
{
"__type__": "cc.Light",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_type": 1,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_intensity": 1,
"_range": 1000,
"_spotAngle": 60,
"_spotExp": 1,
"_shadowType": 0,
"_shadowResolution": 1024,
"_shadowDarkness": 0.5,
"_shadowMinDepth": 1,
"_shadowMaxDepth": 1000,
"_shadowDepthScale": 250,
"_shadowFrustumSize": 50,
"_shadowBias": 0.0005,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "0cf30284-9073-46bc-9eba-e62b69dbbff3"
},
"fileId": "33zOkteexCqamZ4PXuwJaW",
"sync": false
}
]

View File

@ -0,0 +1,384 @@
[
{
"__type__": "cc.Prefab",
"_name": "toggle",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 1,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "toggle",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
}
],
"_active": true,
"_components": [
{
"__id__": 8
}
],
"_prefab": {
"__id__": 9
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 28,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "Background",
"_objFlags": 512,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 28,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "6827ca32-0107-4552-bab2-dfb31799bb44"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "0d784963-d024-4ea6-a7db-03be0ad63010"
},
"fileId": "238bacn/jZGGYuFN7ndSzkO",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "checkmark",
"_objFlags": 512,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 28,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "90004ad6-2f6d-40e1-93ef-b714375c6f06"
},
"_type": 0,
"_sizeMode": 2,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "0d784963-d024-4ea6-a7db-03be0ad63010"
},
"fileId": "0d447hRg/9AuLVwR7+lDw/1",
"sync": false
},
{
"__type__": "cc.Toggle",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 3,
"transition": 3,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 214,
"g": 214,
"b": 214,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 2
},
"_N$isChecked": true,
"toggleGroup": null,
"checkMark": {
"__id__": 6
},
"checkEvents": [],
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "0d784963-d024-4ea6-a7db-03be0ad63010"
},
"fileId": "3d81aISgHdGFblE/PZD2Cp3",
"sync": false
}
]

View File

@ -0,0 +1,101 @@
[
{
"__type__": "cc.Prefab",
"_name": "tiledtile",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "New TiledTile",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_skewX": 0,
"_skewY": 0,
"_localZOrder": 45,
"groupIndex": 0,
"_id": "",
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
0,
1,
1,
1
]
}
},
{
"__type__": "cc.TiledTile",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_x": 0,
"_y": 0,
"_gid": 6,
"_layer": null,
"_id": "39h1tJvWtC8oLyzYKulleV"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "0e42ba95-1fa1-46aa-b2cf-143cd1bcee2c"
},
"fileId": "fb1JS09SVFapQy1+PoRN4F",
"sync": false
}
]

View File

@ -0,0 +1,125 @@
{
"__type__": "cc.EffectAsset",
"_name": "builtin-2d-spine",
"_objFlags": 0,
"_native": "",
"properties": null,
"techniques": [
{
"passes": [
{
"blendState": {
"targets": [
{
"blend": true
}
]
},
"rasterizerState": {
"cullMode": 0
},
"properties": {
"texture": {
"value": "white",
"type": 29
},
"alphaThreshold": {
"value": [
0.5
],
"type": 13
}
},
"program": "builtin-2d-spine|vs|fs"
}
]
}
],
"shaders": [
{
"hash": 3550530479,
"glsl3": {
"vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\n#if USE_TINT\n in vec4 a_color0;\n#endif\nin vec2 a_uv0;\nout vec2 v_uv0;\nout vec4 v_light;\n#if USE_TINT\n out vec4 v_dark;\n#endif\nvoid main () {\n mat4 mvp;\n #if CC_USE_MODEL\n mvp = cc_matViewProj * cc_matWorld;\n #else\n mvp = cc_matViewProj;\n #endif\n v_uv0 = a_uv0;\n v_light = a_color;\n #if USE_TINT\n v_dark = a_color0;\n #endif\n gl_Position = mvp * vec4(a_position, 1);\n}",
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nin vec2 v_uv0;\nin vec4 v_light;\n#if USE_TINT\n in vec4 v_dark;\n#endif\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvoid main () {\n vec4 texColor = vec4(1.0);\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n texColor.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n texColor.a *= texture_tmp.a;\n #else\n texColor *= texture_tmp;\n #endif\n vec4 finalColor;\n #if USE_TINT\n finalColor.a = v_light.a * texColor.a;\n finalColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n #else\n finalColor = texColor * v_light;\n #endif\n ALPHA_TEST(finalColor);\n gl_FragColor = finalColor;\n}"
},
"glsl1": {
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\n#if USE_TINT\n attribute vec4 a_color0;\n#endif\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\nvarying vec4 v_light;\n#if USE_TINT\n varying vec4 v_dark;\n#endif\nvoid main () {\n mat4 mvp;\n #if CC_USE_MODEL\n mvp = cc_matViewProj * cc_matWorld;\n #else\n mvp = cc_matViewProj;\n #endif\n v_uv0 = a_uv0;\n v_light = a_color;\n #if USE_TINT\n v_dark = a_color0;\n #endif\n gl_Position = mvp * vec4(a_position, 1);\n}",
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nvarying vec2 v_uv0;\nvarying vec4 v_light;\n#if USE_TINT\n varying vec4 v_dark;\n#endif\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvoid main () {\n vec4 texColor = vec4(1.0);\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n texColor.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n texColor.a *= texture_tmp.a;\n #else\n texColor *= texture_tmp;\n #endif\n vec4 finalColor;\n #if USE_TINT\n finalColor.a = v_light.a * texColor.a;\n finalColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n #else\n finalColor = texColor * v_light;\n #endif\n ALPHA_TEST(finalColor);\n gl_FragColor = finalColor;\n}"
},
"builtins": {
"globals": {
"blocks": [
{
"name": "CCGlobal",
"defines": []
}
],
"samplers": []
},
"locals": {
"blocks": [
{
"name": "CCLocal",
"defines": []
}
],
"samplers": []
}
},
"defines": [
{
"name": "USE_TINT",
"type": "boolean",
"defines": []
},
{
"name": "CC_USE_MODEL",
"type": "boolean",
"defines": []
},
{
"name": "USE_ALPHA_TEST",
"type": "boolean",
"defines": []
},
{
"name": "CC_USE_ALPHA_ATLAS_texture",
"type": "boolean",
"defines": []
},
{
"name": "INPUT_IS_GAMMA",
"type": "boolean",
"defines": []
}
],
"blocks": [
{
"name": "ALPHA_TEST",
"members": [
{
"name": "alphaThreshold",
"type": 13,
"count": 1
}
],
"defines": [
"USE_ALPHA_TEST"
],
"binding": 0
}
],
"samplers": [
{
"name": "texture",
"type": 29,
"count": 1,
"defines": [],
"binding": 30
}
],
"record": null,
"name": "builtin-2d-spine|vs|fs"
}
]
}

View File

@ -0,0 +1,106 @@
{
"__type__": "cc.EffectAsset",
"_name": "__builtin-editor-gizmo",
"_objFlags": 0,
"_native": "",
"properties": null,
"techniques": [
{
"passes": [
{
"stage": "transparent",
"blendState": {
"targets": [
{
"blend": true,
"blendEq": 32774,
"blendAlphaEq": 32774,
"blendSrcAlpha": 1,
"blendDstAlpha": 771
}
]
},
"rasterizerState": {
"cullMode": 0
},
"depthStencilState": {
"depthTest": false,
"depthWrite": false
},
"properties": {
"diffuseColor": {
"value": [
1,
1,
1,
1
],
"editor": {
"type": "color"
},
"type": 16
}
},
"program": "__builtin-editor-gizmo|vs|fs"
}
]
}
],
"shaders": [
{
"hash": 2992916359,
"glsl3": {
"vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nvarying vec3 v_worldNormal;\nvarying vec3 v_worldPosition;\nvarying vec3 v_localPosition;\nvarying vec3 v_right;\nvarying vec3 v_up;\nvarying vec3 v_forward;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n v_localPosition = a_position;\n v_worldPosition = (cc_matWorld * pos).xyz;\n v_worldNormal = (cc_matWorldIT * vec4(a_normal, 0)).xyz;\n v_right = vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]);\n v_up = vec3(cc_matView[0][1], cc_matView[1][1], cc_matView[2][1]);\n v_forward = vec3(cc_matView[0][2], cc_matView[1][2], cc_matView[2][2]);\n gl_Position = cc_matViewProj * cc_matWorld * pos;\n}",
"frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nmat3 transpose(mat3 v) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\nvoid ClipQuadToHorizon(inout vec3 L[5], out int n) {\n int config = 0;\n if (L[0].z > 0.0) config += 1;\n if (L[1].z > 0.0) config += 2;\n if (L[2].z > 0.0) config += 4;\n if (L[3].z > 0.0) config += 8;\n config = 15;\n n = 0;\n if (config == 0)\n {\n }\n else if (config == 1)\n {\n n = 3;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 2)\n {\n n = 3;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 3)\n {\n n = 4;\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n L[3] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 4)\n {\n n = 3;\n L[0] = -L[3].z * L[2] + L[2].z * L[3];\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n }\n else if (config == 5)\n {\n n = 0;\n }\n else if (config == 6)\n {\n n = 4;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 7)\n {\n n = 5;\n L[4] = -L[3].z * L[0] + L[0].z * L[3];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 8)\n {\n n = 3;\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n L[1] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = L[3];\n }\n else if (config == 9)\n {\n n = 4;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[2].z * L[3] + L[3].z * L[2];\n }\n else if (config == 10)\n {\n n = 0;\n }\n else if (config == 11)\n {\n n = 5;\n L[4] = L[3];\n L[3] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 12)\n {\n n = 4;\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n }\n else if (config == 13)\n {\n n = 5;\n L[4] = L[3];\n L[3] = L[2];\n L[2] = -L[1].z * L[2] + L[2].z * L[1];\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n }\n else if (config == 14)\n {\n n = 5;\n L[4] = -L[0].z * L[3] + L[3].z * L[0];\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n }\n else if (config == 15)\n {\n n = 4;\n }\n if (n == 3)\n L[3] = L[0];\n if (n == 4)\n L[4] = L[0];\n}\nfloat IntegrateEdge(vec3 v1, vec3 v2) {\n float cosTheta = dot(v1, v2);\n float theta = acos(cosTheta);\n return cross(v1, v2).z * ((theta > 0.001) ? theta/sin(theta) : 4.0);\n}\nvec3 LTC_Evaluate(vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4]) {\n vec3 T1, T2;\n T1 = normalize(V - N*dot(V, N));\n T2 = cross(N, T1);\n Minv = Minv * transpose(mat3(T1, T2, N));\n vec3 L[5];\n L[0] = Minv * (points[0] - P);\n L[1] = Minv * (points[1] - P);\n L[2] = Minv * (points[2] - P);\n L[3] = Minv * (points[3] - P);\n int n;\n ClipQuadToHorizon(L, n);\n if (n == 0)\n return vec3(0, 0, 0);\n L[0] = normalize(L[0]);\n L[1] = normalize(L[1]);\n L[2] = normalize(L[2]);\n L[3] = normalize(L[3]);\n L[4] = normalize(L[4]);\n float sum = 0.0;\n sum += IntegrateEdge(L[0], L[1]);\n sum += IntegrateEdge(L[1], L[2]);\n sum += IntegrateEdge(L[2], L[3]);\n if (n >= 4)\n sum += IntegrateEdge(L[3], L[4]);\n if (n == 5)\n sum += IntegrateEdge(L[4], L[0]);\n sum = max(0.0, sum);\n vec3 Lo_i = vec3(sum, sum, sum);\n return Lo_i;\n}\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform DIFFUSE_COLOR {\n vec4 diffuseColor;\n};\nvarying vec3 v_worldNormal;\nvarying vec3 v_worldPosition;\nvarying vec3 v_localPosition;\nvarying vec3 v_right;\nvarying vec3 v_up;\nvarying vec3 v_forward;\nvoid main () {\n vec3 N = normalize(v_worldNormal);\n vec3 V = normalize(cc_cameraPos.xyz - v_worldPosition);\n vec3 points[4];\n vec3 up = vec3(0, 1, 0);\n points[0] = (v_forward * 3.0 + v_right + up) * 40.0;\n points[1] = (v_forward * 3.0 - v_right + up) * 40.0;\n points[2] = (v_forward * 3.0 - v_right - up) * 40.0;\n points[3] = (v_forward * 3.0 + v_right - up) * 40.0;\n vec3 diffuse = diffuseColor.rgb * (0.2 + LTC_Evaluate(N, V, v_localPosition, mat3(1), points) * 0.8);\n gl_FragColor = CCFragOutput(vec4(diffuse, diffuseColor.a));\n}"
},
"glsl1": {
"vert": "\nprecision highp float;\nuniform mat4 cc_matView;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nuniform mat4 cc_matWorldIT;\nvarying vec3 v_worldNormal;\nvarying vec3 v_worldPosition;\nvarying vec3 v_localPosition;\nvarying vec3 v_right;\nvarying vec3 v_up;\nvarying vec3 v_forward;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n v_localPosition = a_position;\n v_worldPosition = (cc_matWorld * pos).xyz;\n v_worldNormal = (cc_matWorldIT * vec4(a_normal, 0)).xyz;\n v_right = vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]);\n v_up = vec3(cc_matView[0][1], cc_matView[1][1], cc_matView[2][1]);\n v_forward = vec3(cc_matView[0][2], cc_matView[1][2], cc_matView[2][2]);\n gl_Position = cc_matViewProj * cc_matWorld * pos;\n}",
"frag": "\nprecision highp float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nmat3 transpose(mat3 v) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\nvoid ClipQuadToHorizon(inout vec3 L[5], out int n) {\n int config = 0;\n if (L[0].z > 0.0) config += 1;\n if (L[1].z > 0.0) config += 2;\n if (L[2].z > 0.0) config += 4;\n if (L[3].z > 0.0) config += 8;\n config = 15;\n n = 0;\n if (config == 0)\n {\n }\n else if (config == 1)\n {\n n = 3;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 2)\n {\n n = 3;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 3)\n {\n n = 4;\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n L[3] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 4)\n {\n n = 3;\n L[0] = -L[3].z * L[2] + L[2].z * L[3];\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n }\n else if (config == 5)\n {\n n = 0;\n }\n else if (config == 6)\n {\n n = 4;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 7)\n {\n n = 5;\n L[4] = -L[3].z * L[0] + L[0].z * L[3];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 8)\n {\n n = 3;\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n L[1] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = L[3];\n }\n else if (config == 9)\n {\n n = 4;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[2].z * L[3] + L[3].z * L[2];\n }\n else if (config == 10)\n {\n n = 0;\n }\n else if (config == 11)\n {\n n = 5;\n L[4] = L[3];\n L[3] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 12)\n {\n n = 4;\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n }\n else if (config == 13)\n {\n n = 5;\n L[4] = L[3];\n L[3] = L[2];\n L[2] = -L[1].z * L[2] + L[2].z * L[1];\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n }\n else if (config == 14)\n {\n n = 5;\n L[4] = -L[0].z * L[3] + L[3].z * L[0];\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n }\n else if (config == 15)\n {\n n = 4;\n }\n if (n == 3)\n L[3] = L[0];\n if (n == 4)\n L[4] = L[0];\n}\nfloat IntegrateEdge(vec3 v1, vec3 v2) {\n float cosTheta = dot(v1, v2);\n float theta = acos(cosTheta);\n return cross(v1, v2).z * ((theta > 0.001) ? theta/sin(theta) : 4.0);\n}\nvec3 LTC_Evaluate(vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4]) {\n vec3 T1, T2;\n T1 = normalize(V - N*dot(V, N));\n T2 = cross(N, T1);\n Minv = Minv * transpose(mat3(T1, T2, N));\n vec3 L[5];\n L[0] = Minv * (points[0] - P);\n L[1] = Minv * (points[1] - P);\n L[2] = Minv * (points[2] - P);\n L[3] = Minv * (points[3] - P);\n int n;\n ClipQuadToHorizon(L, n);\n if (n == 0)\n return vec3(0, 0, 0);\n L[0] = normalize(L[0]);\n L[1] = normalize(L[1]);\n L[2] = normalize(L[2]);\n L[3] = normalize(L[3]);\n L[4] = normalize(L[4]);\n float sum = 0.0;\n sum += IntegrateEdge(L[0], L[1]);\n sum += IntegrateEdge(L[1], L[2]);\n sum += IntegrateEdge(L[2], L[3]);\n if (n >= 4)\n sum += IntegrateEdge(L[3], L[4]);\n if (n == 5)\n sum += IntegrateEdge(L[4], L[0]);\n sum = max(0.0, sum);\n vec3 Lo_i = vec3(sum, sum, sum);\n return Lo_i;\n}\nuniform vec4 cc_cameraPos;\nuniform vec4 diffuseColor;\nvarying vec3 v_worldNormal;\nvarying vec3 v_worldPosition;\nvarying vec3 v_localPosition;\nvarying vec3 v_right;\nvarying vec3 v_up;\nvarying vec3 v_forward;\nvoid main () {\n vec3 N = normalize(v_worldNormal);\n vec3 V = normalize(cc_cameraPos.xyz - v_worldPosition);\n vec3 points[4];\n vec3 up = vec3(0, 1, 0);\n points[0] = (v_forward * 3.0 + v_right + up) * 40.0;\n points[1] = (v_forward * 3.0 - v_right + up) * 40.0;\n points[2] = (v_forward * 3.0 - v_right - up) * 40.0;\n points[3] = (v_forward * 3.0 + v_right - up) * 40.0;\n vec3 diffuse = diffuseColor.rgb * (0.2 + LTC_Evaluate(N, V, v_localPosition, mat3(1), points) * 0.8);\n gl_FragColor = CCFragOutput(vec4(diffuse, diffuseColor.a));\n}"
},
"builtins": {
"globals": {
"blocks": [
{
"name": "CCGlobal",
"defines": []
}
],
"samplers": []
},
"locals": {
"blocks": [
{
"name": "CCLocal",
"defines": []
}
],
"samplers": []
}
},
"defines": [
{
"name": "OUTPUT_TO_GAMMA",
"type": "boolean",
"defines": []
}
],
"blocks": [
{
"name": "DIFFUSE_COLOR",
"members": [
{
"name": "diffuseColor",
"type": 16,
"count": 1
}
],
"defines": [],
"binding": 0
}
],
"samplers": [],
"record": null,
"name": "__builtin-editor-gizmo|vs|fs"
}
]
}

View File

@ -0,0 +1,84 @@
{
"__type__": "cc.EffectAsset",
"_name": "builtin-2d-gray-sprite",
"_objFlags": 0,
"_native": "",
"properties": null,
"techniques": [
{
"passes": [
{
"blendState": {
"targets": [
{
"blend": true
}
]
},
"rasterizerState": {
"cullMode": 0
},
"properties": {
"texture": {
"value": "white",
"type": 29
}
},
"program": "builtin-2d-gray-sprite|vs|fs"
}
]
}
],
"shaders": [
{
"hash": 4278481454,
"glsl3": {
"vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nin vec3 a_position;\nin mediump vec2 a_uv0;\nout mediump vec2 v_uv0;\nin vec4 a_color;\nout vec4 v_color;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n v_uv0 = a_uv0;\n v_color = a_color;\n}",
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nin mediump vec2 v_uv0;\nin vec4 v_color;\nvoid main () {\n vec4 color = v_color;\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;\n gl_FragColor = vec4(gray, gray, gray, color.a);\n}"
},
"glsl1": {
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nattribute vec3 a_position;\nattribute mediump vec2 a_uv0;\nvarying mediump vec2 v_uv0;\nattribute vec4 a_color;\nvarying vec4 v_color;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n v_uv0 = a_uv0;\n v_color = a_color;\n}",
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nvarying mediump vec2 v_uv0;\nvarying vec4 v_color;\nvoid main () {\n vec4 color = v_color;\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n color.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n color.a *= texture_tmp.a;\n #else\n color *= texture_tmp;\n #endif\n float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;\n gl_FragColor = vec4(gray, gray, gray, color.a);\n}"
},
"builtins": {
"globals": {
"blocks": [
{
"name": "CCGlobal",
"defines": []
}
],
"samplers": []
},
"locals": {
"blocks": [],
"samplers": []
}
},
"defines": [
{
"name": "CC_USE_ALPHA_ATLAS_texture",
"type": "boolean",
"defines": []
},
{
"name": "INPUT_IS_GAMMA",
"type": "boolean",
"defines": []
}
],
"blocks": [],
"samplers": [
{
"name": "texture",
"type": 29,
"count": 1,
"defines": [],
"binding": 30
}
],
"record": null,
"name": "builtin-2d-gray-sprite|vs|fs"
}
]
}

View File

@ -0,0 +1,90 @@
[
{
"__type__": "cc.Mesh",
"_name": "",
"_objFlags": 0,
"_native": ".bin",
"_vertexBundles": [
{
"__id__": 1
}
],
"_primitives": [
{
"__id__": 6
}
],
"_minPos": {
"__type__": "cc.Vec3",
"x": -0.5,
"y": -0.0999999940395355,
"z": -0.5
},
"_maxPos": {
"__type__": "cc.Vec3",
"x": 0.5,
"y": 0.0999999940395355,
"z": 0.5
}
},
{
"__type__": "cc.mesh.VertexBundle",
"data": {
"__id__": 2
},
"formats": [
{
"__id__": 3
},
{
"__id__": 4
},
{
"__id__": 5
}
],
"verticesCount": 1089
},
{
"__type__": "cc.BufferRange",
"offset": 0,
"length": 34848
},
{
"__type__": "cc.mesh.VertexFormat",
"name": "a_normal",
"type": 5126,
"num": 3,
"normalize": false
},
{
"__type__": "cc.mesh.VertexFormat",
"name": "a_position",
"type": 5126,
"num": 3,
"normalize": false
},
{
"__type__": "cc.mesh.VertexFormat",
"name": "a_uv0",
"type": 5126,
"num": 2,
"normalize": false
},
{
"__type__": "cc.mesh.Primitive",
"vertexBundleIndices": [
0
],
"data": {
"__id__": 7
},
"indexUnit": 5123,
"topology": 4
},
{
"__type__": "cc.BufferRange",
"offset": 34848,
"length": 12288
}
]

View File

@ -0,0 +1,28 @@
{
"__type__": "cc.SpriteFrame",
"content": {
"name": "default_radio_button_on",
"texture": "9d60001f-b5f4-4726-a629-2659e3ded0b8",
"atlas": "",
"rect": [
1,
1,
30,
30
],
"offset": [
0,
0
],
"originalSize": [
32,
32
],
"capInsets": [
0,
0,
0,
0
]
}
}

View File

@ -0,0 +1,298 @@
"use strict";
cc._RF.push(module, '1c26dVSok5E7o2PwD2sGBJa', 'Game');
// Script/Game.ts
"use strict";
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var DrawingBoard_1 = require("./DrawingBoard");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var GameState;
(function (GameState) {
GameState[GameState["drawing"] = 1] = "drawing";
GameState[GameState["erasing"] = 2] = "erasing";
})(GameState || (GameState = {}));
var Game = /** @class */ (function (_super) {
__extends(Game, _super);
function Game() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.drawNode = null;
_this.captureCamera = null;
_this.mainCamera = null;
_this.db = null;
_this.gameState = GameState.drawing;
_this.texture = null;
_this.prePos = cc.Vec2.ZERO;
_this.startPos = cc.Vec2.ZERO;
_this.lastColor = cc.Color.BLUE;
_this.errColor = cc.Color.RED;
_this.lastLineWidth = 1;
_this.history = [];
_this.touchId = -1;
_this.touchScale = false;
return _this;
}
Game.prototype.start = function () {
var _this = this;
this.initDb();
this.initTexture();
this.initRead();
setTimeout(function () {
_this.drawNode.on("touchstart", _this.onTouchStart, _this);
_this.drawNode.on("touchmove", _this.onTouchMove, _this);
_this.drawNode.on("touchend", _this.onTouchEnd, _this);
_this.drawNode.on("touchcancel", _this.onTouchEnd, _this);
}, 2000);
};
Game.prototype.initDb = function () {
//创建一个画板(需传入画板尺寸,将自动初始化)
this.db = new DrawingBoard_1.default(this.drawNode.width, this.drawNode.height);
//设置画板的绘图颜色(每次绘制前都可以重新设置)
this.lastLineWidth = 15;
this.db.setLineWidth(this.lastLineWidth);
// this.db.setColor(this.lastColor.r, this.lastColor.g, this.lastColor.b, this.lastColor.a);
//线条端点以圆角结尾
this.db.setLineCircleEnd(true);
};
Game.prototype.initTexture = function () {
this.texture = new cc.RenderTexture();
this.texture.initWithSize(this.drawNode.width, this.drawNode.height, cc.RenderTexture.DepthStencilFormat.RB_FMT_S8);
var spf = new cc.SpriteFrame(this.texture);
this.drawNode.getComponent(cc.Sprite).spriteFrame = spf;
};
Game.prototype.initRead = function () {
this.targetCamera = this.node.getChildByName("tagCamera").getComponent(cc.Camera);
var rander = new cc.RenderTexture();
rander.initWithSize(this.node.width, this.node.height, cc.RenderTexture.DepthStencilFormat.RB_FMT_S8);
this.targetCamera.targetTexture = rander;
this.targetCamera.render();
console.log("完成");
};
Game.prototype.onTouchStart = function (e) {
//将触摸位置作为线条的起点
//画板中使用的坐标系与图片坐标系一样原点在左上角X轴向右为正Y轴向下为正
//所以Y轴坐标应反过来, 这里用getLocationInView而不是getLocation
this.touchId = e.getID();
if (this.touchId == 1) {
this.touchScale = true;
return;
}
var pos = e.getLocation();
this.prePos = this.convertToDrawNodePos(pos);
this.startPos = this.convertToDrawNodePos(pos);
this.db.moveTo(this.prePos.x, this.prePos.y);
};
Game.prototype.onTouchMove = function (e) {
var touches = e.getTouches();
var touch1 = touches[0];
var delta1 = touch1.getDelta();
var pos = e.getLocation();
var pos1 = this.convertToDrawNodePos(touch1.getLocation());
var dst = this.startPos.sub(pos1).mag();
// this.label.string = touches.length + "";
if (touches.length == 1 && this.touchId < 1 && !this.touchScale && dst > 7) {
// alert("不该进来");
this.prePos = this.convertToDrawNodePos(pos);
var jg = this.pd(e);
this.changeColor(jg);
if (this.gameState == GameState.drawing) {
//从上一次绘制线条后的终点开始向鼠标当前位置绘制线条
this.db.lineTo(this.prePos.x, this.prePos.y);
}
else if (this.gameState == GameState.erasing) {
// 橡皮擦
this.db.circle(this.prePos.x, this.prePos.y, 10);
}
//每次画板中的数据有变化后,及时将数据应用到贴图上,在屏幕上显示出来
this.drawToImg();
}
else if (touches.length == 2) {
var touch1 = touches[0], touch2 = touches[1];
var delta1 = touch1.getDelta(), delta2 = touch2.getDelta();
var touchPoint1 = this.node.parent.convertToNodeSpaceAR(touch1.getLocation());
var touchPoint2 = this.node.parent.convertToNodeSpaceAR(touch2.getLocation());
var distance = touchPoint1.sub(touchPoint2);
var delta = delta1.sub(delta2);
var scale = 1;
if (Math.abs(distance.x) > Math.abs(distance.y)) {
scale = (distance.x + delta.x) / distance.x * this.node.scale;
}
else {
scale = (distance.y + delta.y) / distance.y * this.node.scale;
}
if (scale > 2)
scale = 2;
this.node.scale = scale <= 0.1 ? 0.1 : scale;
}
};
Game.prototype.onTouchEnd = function (e) {
this.touchId = e.getID();
if (this.touchId == 1)
this.touchScale = false;
this.addHistory();
};
Game.prototype.pd = function (event) {
var cha = 2;
var pos = event.getLocation();
var jg = false;
for (var i = -cha; i < cha; i++) {
var postion = cc.v2();
postion.x = pos.x + i;
for (var j = -cha; j < cha; j++) {
postion.y = pos.y + j;
// console.log("检测点:",postion.x,postion.y);
var img = this.getGraphisData(postion);
if ((img[0] != 255 && img[1] != 255 && img[2] != 255)) {
jg = true;
j = 10000;
i = 10000;
}
}
}
//
return jg;
};
Game.prototype.convertToDrawNodePos = function (worldPos) {
var pos = this.drawNode.convertToNodeSpaceAR(worldPos);
pos.x += this.drawNode.width * this.drawNode.anchorX;
pos.y += this.drawNode.height * this.drawNode.anchorY;
pos.y = this.drawNode.height - pos.y;
return pos;
};
Game.prototype.addHistory = function () {
var copy = this.db.copyData();
var ucopy = new Uint8Array(copy);
this.history.push({ data: ucopy });
// cc.log('历史步骤: ', this.history.length);
};
Game.prototype.drawToImg = function () {
//获取画板中绘制的图案数据
var data = this.db.getData();
//将数据传递给贴图对象
this.texture.initWithData(data, cc.Texture2D.PixelFormat.RGBA8888, this.db.width, this.db.height);
};
Game.prototype.changeColor = function (red) {
if (!red)
this.db.setColor(this.errColor.r, this.errColor.g, this.errColor.b, this.errColor.a);
else
this.db.setColor(this.lastColor.r, this.lastColor.g, this.lastColor.b, this.lastColor.a);
};
Game.prototype.getGraphisData = function (point) {
var Uint8 = new Uint8Array(4);
Uint8 = this.targetCamera.targetTexture.readPixels(Uint8, point.x, point.y, 1, 1);
return Uint8;
};
Game.prototype.onBtnDraw = function () {
this.db.setLineWidth(this.lastLineWidth);
this.db.setColor(this.lastColor.r, this.lastColor.g, this.lastColor.b, this.lastColor.a);
this.gameState = GameState.drawing;
};
Game.prototype.onBtnErase = function () {
this.db.setLineWidth(this.lastLineWidth * 3);
// 橡皮擦的颜色不能是(0,0,0,0),因为这样会和DrawingBoard里的默认颜色相同导致绘制跳过
this.db.setColor(255, 255, 255, 0);
this.gameState = GameState.erasing;
};
Game.prototype.onBtnClear = function () {
this.db.reset();
this.drawToImg();
this.history.splice(0, this.history.length);
};
Game.prototype.onBtnRevoke = function () {
this.history.pop();
if (this.history.length) {
var data = this.history[this.history.length - 1].data;
this.db.setData(data.buffer);
this.texture.initWithData(this.db.getData(), cc.Texture2D.PixelFormat.RGBA8888, this.db.width, this.db.height);
}
else {
this.onBtnClear();
}
cc.log('历史记录剩余: ', this.history.length);
};
Game.prototype.onBtnSave = function () {
var _this = this;
if (cc.sys.isBrowser) {
var width = this.drawNode.width;
var height = this.drawNode.height;
this.captureCamera.enabled = true;
var texture = new cc.RenderTexture();
texture.initWithSize(width, height, cc.RenderTexture.DepthStencilFormat.RB_FMT_S8);
this.captureCamera.targetTexture = texture;
var canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext('2d');
this.captureCamera.render();
var data = texture.readPixels();
// write the render data
var rowBytes = width * 4;
for (var row = 0; row < height; row++) {
var srow = height - 1 - row;
var imageData = ctx.createImageData(width, 1);
var start = srow * width * 4;
for (var i = 0; i < rowBytes; i++) {
imageData.data[i] = data[start + i];
}
ctx.putImageData(imageData, 0, row);
}
//
var dataUrl = canvas.toDataURL('image/png');
// cc.log('iamge-base64:', dataUrl);
var saveLink = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
saveLink.href = dataUrl;
saveLink.download = String(Date.now()) + '.png';
var event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
saveLink.dispatchEvent(event);
this.scheduleOnce(function (t) {
_this.captureCamera.enabled = false;
}, 0.1);
}
else {
cc.warn('暂时只支持web端保存图片');
}
};
Game.prototype.update = function (dt) {
};
__decorate([
property(cc.Node)
], Game.prototype, "drawNode", void 0);
__decorate([
property(cc.Camera)
], Game.prototype, "captureCamera", void 0);
__decorate([
property(cc.Camera)
], Game.prototype, "mainCamera", void 0);
Game = __decorate([
ccclass
], Game);
return Game;
}(cc.Component));
exports.default = Game;
cc._RF.pop();

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,109 @@
[
{
"__type__": "cc.Prefab",
"_name": "cylinder",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "cylinder",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": true,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.MeshRenderer",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f"
}
],
"_mesh": {
"__uuid__": "b430cea3-6ab3-4106-b073-26c698918edd"
},
"_receiveShadows": false,
"_shadowCastingMode": 0,
"_enableAutoBatch": false,
"textures": [],
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "1c5e4038-953a-44c2-b620-0bbfc6170477"
},
"fileId": "3dlUtIqQhGCrx5Sishojtq",
"sync": false
}
]

View File

@ -0,0 +1,4 @@
{
"__type__": "cc.Texture2D",
"content": "0,9729,9729,33071,33071,0,0,1"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

View File

@ -0,0 +1,112 @@
[
{
"__type__": "cc.Prefab",
"_name": "sprite_splash",
"_objFlags": 0,
"data": {
"__id__": 1
},
"optimizationPolicy": 1,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "New Sprite (Splash)",
"_objFlags": 0,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_cascadeOpacityEnabled": true,
"_parent": null,
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 100,
"height": 100
},
"_children": [],
"_skewX": 0,
"_skewY": 0,
"_localZOrder": 0,
"_globalZOrder": 0,
"_tag": -1,
"_opacityModifyRGB": false,
"_reorderChildDirty": false,
"_id": "",
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
0,
1,
1,
1
]
}
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_spriteFrame": {
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_atlas": null
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": null,
"fileId": "1a0f4zwu2VOapqEJkWXIF0R"
}
]

View File

@ -0,0 +1,28 @@
{
"__type__": "cc.SpriteFrame",
"content": {
"name": "tagTexture",
"texture": "b1f9556b-9739-432f-8ae5-8076ee980b6d",
"atlas": "",
"rect": [
0,
0,
586,
586
],
"offset": [
0,
0
],
"originalSize": [
586,
586
],
"capInsets": [
0,
0,
0,
0
]
}
}

View File

@ -0,0 +1,108 @@
[
{
"__type__": "cc.Prefab",
"_name": "videoplayer",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 1,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "videoplayer",
"_objFlags": 0,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_cascadeOpacityEnabled": true,
"_parent": null,
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 428,
"height": 240
},
"_children": [],
"_skewX": 0,
"_skewY": 0,
"_localZOrder": 0,
"_globalZOrder": 0,
"_tag": -1,
"_opacityModifyRGB": false,
"_reorderChildDirty": false,
"_id": "",
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"groupIndex": 0,
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
0,
1,
1,
1
]
}
},
{
"__type__": "cc.VideoPlayer",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_resourceType": 1,
"_remoteURL": "",
"_clip": {
"__uuid__": "2be36297-9abb-4fee-8049-9ed5e271da8a"
},
"_time": 0,
"videoPlayerEvent": [],
"_N$keepAspectRatio": true,
"_N$isFullscreen": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "232d2782-c4bd-4bb4-9e01-909f03d6d3b9"
},
"fileId": "f0e6ehf9IVMI51Egy+e0ZTA"
}
]

View File

@ -0,0 +1,105 @@
[
{
"__type__": "cc.Prefab",
"_name": "label",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 1,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "Label",
"_objFlags": 0,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_cascadeOpacityEnabled": true,
"_parent": null,
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 128,
"height": 50
},
"_children": [],
"_skewX": 0,
"_skewY": 0,
"_localZOrder": 0,
"_globalZOrder": 0,
"_ignoreAnchorPointForPosition": false,
"_tag": -1,
"_opacityModifyRGB": false,
"_id": "",
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
0,
1,
1,
1
]
}
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_useOriginalSize": false,
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_isSystemFontUsed": true,
"_N$string": "Label",
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$overflow": 0
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": null,
"fileId": "d1cddH/doRNQ4Aodz8556bh"
}
]

View File

@ -0,0 +1,131 @@
{
"__type__": "cc.EffectAsset",
"_name": "builtin-2d-sprite",
"_objFlags": 0,
"_native": "",
"properties": null,
"techniques": [
{
"passes": [
{
"blendState": {
"targets": [
{
"blend": true
}
]
},
"rasterizerState": {
"cullMode": 0
},
"properties": {
"texture": {
"value": "white",
"type": 29
},
"alphaThreshold": {
"value": [
0.5
],
"type": 13
}
},
"program": "builtin-2d-sprite|vs|fs"
}
]
}
],
"shaders": [
{
"hash": 3278106612,
"glsl3": {
"vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}",
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}"
},
"glsl1": {
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}",
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}"
},
"builtins": {
"globals": {
"blocks": [
{
"name": "CCGlobal",
"defines": []
}
],
"samplers": []
},
"locals": {
"blocks": [
{
"name": "CCLocal",
"defines": []
}
],
"samplers": []
}
},
"defines": [
{
"name": "USE_TEXTURE",
"type": "boolean",
"defines": []
},
{
"name": "CC_USE_MODEL",
"type": "boolean",
"defines": []
},
{
"name": "USE_ALPHA_TEST",
"type": "boolean",
"defines": []
},
{
"name": "CC_USE_ALPHA_ATLAS_texture",
"type": "boolean",
"defines": [
"USE_TEXTURE"
]
},
{
"name": "INPUT_IS_GAMMA",
"type": "boolean",
"defines": [
"USE_TEXTURE"
]
}
],
"blocks": [
{
"name": "ALPHA_TEST",
"members": [
{
"name": "alphaThreshold",
"type": 13,
"count": 1
}
],
"defines": [
"USE_ALPHA_TEST"
],
"binding": 0
}
],
"samplers": [
{
"name": "texture",
"type": 29,
"count": 1,
"defines": [
"USE_TEXTURE"
],
"binding": 30
}
],
"record": null,
"name": "builtin-2d-sprite|vs|fs"
}
]
}

View File

@ -0,0 +1,28 @@
{
"__type__": "cc.SpriteFrame",
"content": {
"name": "default_btn_disabled",
"texture": "71561142-4c83-4933-afca-cb7a17f67053",
"atlas": "",
"rect": [
0,
0,
40,
40
],
"offset": [
0,
0
],
"originalSize": [
40,
40
],
"capInsets": [
12,
12,
12,
12
]
}
}

View File

@ -0,0 +1,21 @@
{
"__type__": "cc.Material",
"_name": "builtin-unlit",
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "6d91e591-4ce0-465c-809f-610ec95019c6"
},
"_techniqueData": {
"0": {
"props": {
"diffuseTexture": {
"__uuid__": "0275e94c-56a7-410f-bd1a-fc7483f7d14a"
}
},
"defines": {
"USE_DIFFUSE_TEXTURE": true
}
}
}
}

View File

@ -0,0 +1,653 @@
{
"__type__": "cc.EffectAsset",
"_name": "builtin-3d-trail",
"_objFlags": 0,
"_native": "",
"properties": null,
"techniques": [
{
"name": "add",
"passes": [
{
"rasterizerState": {
"cullMode": 0
},
"blendState": {
"targets": [
{
"blend": true,
"blendSrc": 770,
"blendDst": 1,
"blendSrcAlpha": 770,
"blendDstAlpha": 1
}
]
},
"depthStencilState": {
"depthTest": true,
"depthWrite": false
},
"properties": {
"mainTexture": {
"value": "grey",
"type": 29
},
"mainTiling_Offset": {
"value": [
1,
1,
0,
0
],
"type": 16
},
"frameTile_velLenScale": {
"value": [
1,
1,
0,
0
],
"type": 16
},
"tintColor": {
"value": [
0.5,
0.5,
0.5,
0.5
],
"inspector": {
"type": "color"
},
"type": 16
}
},
"program": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:add"
}
]
},
{
"name": "alpha-blend",
"passes": [
{
"rasterizerState": {
"cullMode": 0
},
"blendState": {
"targets": [
{
"blend": true,
"blendSrc": 1,
"blendDst": 771,
"blendSrcAlpha": 1,
"blendDstAlpha": 771
}
]
},
"depthStencilState": {
"depthTest": true,
"depthWrite": false
},
"properties": {
"mainTexture": {
"value": "grey",
"type": 29
},
"mainTiling_Offset": {
"value": [
1,
1,
0,
0
],
"type": 16
},
"frameTile_velLenScale": {
"value": [
1,
1,
0,
0
],
"type": 16
},
"tintColor": {
"value": [
0.5,
0.5,
0.5,
0.5
],
"inspector": {
"type": "color"
},
"type": 16
}
},
"program": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:add"
}
]
},
{
"name": "add-multiply",
"passes": [
{
"rasterizerState": {
"cullMode": 0
},
"blendState": {
"targets": [
{
"blend": true,
"blendSrc": 1,
"blendDst": 771,
"blendSrcAlpha": 1,
"blendDstAlpha": 771
}
]
},
"depthStencilState": {
"depthTest": true,
"depthWrite": false
},
"properties": {
"mainTexture": {
"value": "grey",
"type": 29
},
"mainTiling_Offset": {
"value": [
1,
1,
0,
0
],
"type": 16
},
"frameTile_velLenScale": {
"value": [
1,
1,
0,
0
],
"type": 16
},
"tintColor": {
"value": [
0.5,
0.5,
0.5,
0.5
],
"inspector": {
"type": "color"
},
"type": 16
}
},
"program": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:multiply"
}
]
},
{
"name": "add-smooth",
"passes": [
{
"rasterizerState": {
"cullMode": 0
},
"blendState": {
"targets": [
{
"blend": true,
"blendSrc": 1,
"blendDst": 771,
"blendSrcAlpha": 1,
"blendDstAlpha": 771
}
]
},
"depthStencilState": {
"depthTest": true,
"depthWrite": false
},
"properties": {
"mainTexture": {
"value": "grey",
"type": 29
},
"mainTiling_Offset": {
"value": [
1,
1,
0,
0
],
"type": 16
},
"frameTile_velLenScale": {
"value": [
1,
1,
0,
0
],
"type": 16
}
},
"program": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:addSmooth"
}
]
},
{
"name": "premultiply-blend",
"passes": [
{
"rasterizerState": {
"cullMode": 0
},
"blendState": {
"targets": [
{
"blend": true,
"blendSrc": 1,
"blendDst": 771,
"blendSrcAlpha": 1,
"blendDstAlpha": 771
}
]
},
"depthStencilState": {
"depthTest": true,
"depthWrite": false
},
"properties": {
"mainTexture": {
"value": "grey",
"type": 29
},
"mainTiling_Offset": {
"value": [
1,
1,
0,
0
],
"type": 16
},
"frameTile_velLenScale": {
"value": [
1,
1,
0,
0
],
"type": 16
}
},
"program": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:premultiplied"
}
]
}
],
"shaders": [
{
"hash": 2929688198,
"glsl3": {
"vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",
"frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\n#if CC_DRAW_WIRE_FRAME\n in vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., 1.);\n }\n #endif\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"
},
"glsl1": {
"vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",
"frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., 1.);\n }\n #endif\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }"
},
"builtins": {
"globals": {
"blocks": [
{
"name": "CCGlobal",
"defines": []
}
],
"samplers": []
},
"locals": {
"blocks": [
{
"name": "CCLocal",
"defines": []
}
],
"samplers": []
}
},
"defines": [
{
"name": "CC_DRAW_WIRE_FRAME",
"type": "boolean",
"defines": []
},
{
"name": "CC_USE_WORLD_SPACE",
"type": "boolean",
"defines": []
},
{
"name": "OUTPUT_TO_GAMMA",
"type": "boolean",
"defines": []
}
],
"blocks": [
{
"name": "Constants",
"members": [
{
"name": "mainTiling_Offset",
"type": 16,
"count": 1
},
{
"name": "frameTile_velLenScale",
"type": 16,
"count": 1
},
{
"name": "scale",
"type": 16,
"count": 1
}
],
"defines": [],
"binding": 0
},
{
"name": "FragConstants",
"members": [
{
"name": "tintColor",
"type": 16,
"count": 1
}
],
"defines": [],
"binding": 1
}
],
"samplers": [
{
"name": "mainTexture",
"type": 29,
"count": 1,
"defines": [],
"binding": 30
}
],
"record": null,
"name": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:add"
},
{
"hash": 4224037318,
"glsl3": {
"vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",
"frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\n#if CC_DRAW_WIRE_FRAME\n in vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform FragConstants {\n vec4 tintColor;\n};\nvec4 multiply () {\n vec4 col;\n vec4 texColor = texture(mainTexture, uv);\n col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);\n col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., col.a);\n }\n #endif\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = multiply(); }"
},
"glsl1": {
"vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",
"frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 multiply () {\n vec4 col;\n vec4 texColor = texture2D(mainTexture, uv);\n col.rgb = tintColor.rgb * texColor.rgb * color.rgb * vec3(2.0);\n col.a = (1.0 - texColor.a) * (tintColor.a * color.a * 2.0);\n #if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., col.a);\n }\n #endif\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = multiply(); }"
},
"builtins": {
"globals": {
"blocks": [
{
"name": "CCGlobal",
"defines": []
}
],
"samplers": []
},
"locals": {
"blocks": [
{
"name": "CCLocal",
"defines": []
}
],
"samplers": []
}
},
"defines": [
{
"name": "CC_DRAW_WIRE_FRAME",
"type": "boolean",
"defines": []
},
{
"name": "CC_USE_WORLD_SPACE",
"type": "boolean",
"defines": []
},
{
"name": "OUTPUT_TO_GAMMA",
"type": "boolean",
"defines": []
}
],
"blocks": [
{
"name": "Constants",
"members": [
{
"name": "mainTiling_Offset",
"type": 16,
"count": 1
},
{
"name": "frameTile_velLenScale",
"type": 16,
"count": 1
},
{
"name": "scale",
"type": 16,
"count": 1
}
],
"defines": [],
"binding": 0
},
{
"name": "FragConstants",
"members": [
{
"name": "tintColor",
"type": 16,
"count": 1
}
],
"defines": [],
"binding": 1
}
],
"samplers": [
{
"name": "mainTexture",
"type": 29,
"count": 1,
"defines": [],
"binding": 30
}
],
"record": null,
"name": "builtin-3d-trail|particle-trail:vs_main|tinted-fs:multiply"
},
{
"hash": 1704877102,
"glsl3": {
"vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",
"frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nvec4 addSmooth () {\n vec4 col = color * texture(mainTexture, uv);\n col.rgb *= col.a;\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = addSmooth(); }"
},
"glsl1": {
"vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",
"frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nvec4 addSmooth () {\n vec4 col = color * texture2D(mainTexture, uv);\n col.rgb *= col.a;\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = addSmooth(); }"
},
"builtins": {
"globals": {
"blocks": [
{
"name": "CCGlobal",
"defines": []
}
],
"samplers": []
},
"locals": {
"blocks": [
{
"name": "CCLocal",
"defines": []
}
],
"samplers": []
}
},
"defines": [
{
"name": "CC_DRAW_WIRE_FRAME",
"type": "boolean",
"defines": []
},
{
"name": "CC_USE_WORLD_SPACE",
"type": "boolean",
"defines": []
},
{
"name": "OUTPUT_TO_GAMMA",
"type": "boolean",
"defines": []
}
],
"blocks": [
{
"name": "Constants",
"members": [
{
"name": "mainTiling_Offset",
"type": 16,
"count": 1
},
{
"name": "frameTile_velLenScale",
"type": 16,
"count": 1
},
{
"name": "scale",
"type": 16,
"count": 1
}
],
"defines": [],
"binding": 0
}
],
"samplers": [
{
"name": "mainTexture",
"type": 29,
"count": 1,
"defines": [],
"binding": 30
}
],
"record": null,
"name": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:addSmooth"
},
{
"hash": 2717357054,
"glsl3": {
"vert": "\nprecision mediump float;\nuniform Constants{\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nout vec2 uv;\nout vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",
"frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nvec4 premultiplied () {\n vec4 col = color * texture(mainTexture, uv) * color.a;\n return CCFragOutput(col);\n}\nout vec4 cc_FragColor;\nvoid main() { cc_FragColor = premultiplied(); }"
},
"glsl1": {
"vert": "\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform mat4 cc_matViewProj;\nuniform vec4 cc_cameraPos;\nuniform mat4 cc_matWorld;\nvarying vec2 uv;\nvarying vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n#endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n#if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n#endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",
"frag": "\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\n #if OUTPUT_TO_GAMMA\n color.rgb = sqrt(color.rgb);\n #endif\n\treturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nvec4 premultiplied () {\n vec4 col = color * texture2D(mainTexture, uv) * color.a;\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = premultiplied(); }"
},
"builtins": {
"globals": {
"blocks": [
{
"name": "CCGlobal",
"defines": []
}
],
"samplers": []
},
"locals": {
"blocks": [
{
"name": "CCLocal",
"defines": []
}
],
"samplers": []
}
},
"defines": [
{
"name": "CC_DRAW_WIRE_FRAME",
"type": "boolean",
"defines": []
},
{
"name": "CC_USE_WORLD_SPACE",
"type": "boolean",
"defines": []
},
{
"name": "OUTPUT_TO_GAMMA",
"type": "boolean",
"defines": []
}
],
"blocks": [
{
"name": "Constants",
"members": [
{
"name": "mainTiling_Offset",
"type": 16,
"count": 1
},
{
"name": "frameTile_velLenScale",
"type": 16,
"count": 1
},
{
"name": "scale",
"type": 16,
"count": 1
}
],
"defines": [],
"binding": 0
}
],
"samplers": [
{
"name": "mainTexture",
"type": 29,
"count": 1,
"defines": [],
"binding": 30
}
],
"record": null,
"name": "builtin-3d-trail|particle-trail:vs_main|no-tint-fs:premultiplied"
}
]
}

View File

@ -0,0 +1,6 @@
{
"__type__": "cc.Asset",
"_name": "default_video",
"_objFlags": 0,
"_native": ".mp4"
}

View File

@ -0,0 +1,249 @@
[
{
"__type__": "cc.Prefab",
"_name": "canvas",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 1,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "Canvas",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [
{
"__id__": 5
},
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 960,
"height": 640
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
480,
320,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "Main Camera",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
365.46272039703314,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_cullingMask": 4294967295,
"_clearFlags": 7,
"_backgroundColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_depth": -1,
"_zoomRatio": 1,
"_targetTexture": null,
"_fov": 60,
"_orthoSize": 10,
"_nearClip": 1,
"_farClip": 4096,
"_ortho": true,
"_rect": {
"__type__": "cc.Rect",
"x": 0,
"y": 0,
"width": 1,
"height": 1
},
"_renderStages": 1,
"_alignWithScreen": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "2c937608-2562-40ea-b264-7395df6f0cea"
},
"fileId": "d2xIc1y/ZF6Kn7K3yqwDJm",
"sync": false
},
{
"__type__": "cc.Canvas",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_designResolution": {
"__type__": "cc.Size",
"width": 960,
"height": 640
},
"_fitWidth": false,
"_fitHeight": true,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "2c937608-2562-40ea-b264-7395df6f0cea"
},
"fileId": "a6aa1W/pshGFZkMhhqxkZYP",
"sync": false
}
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,109 @@
[
{
"__type__": "cc.Prefab",
"_name": "sphere",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "sphere",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": true,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.MeshRenderer",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f"
}
],
"_mesh": {
"__uuid__": "3bbdb0f6-c5f6-45de-9f33-8b5cbafb4d6d"
},
"_receiveShadows": false,
"_shadowCastingMode": 0,
"_enableAutoBatch": false,
"textures": [],
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "2d9a4b85-b0ab-4c46-84c5-18f393ab2058"
},
"fileId": "e0chObmn1N5q+1kVoqVegu",
"sync": false
}
]

View File

@ -0,0 +1,801 @@
"use strict";
cc._RF.push(module, '2e8d2n1khFBWb8oCWax7o8C', 'DrawingBoard');
// Script/DrawingBoard.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* 画板
* 可使用任意颜色绘制矩形三角形直线并统计每种颜色的像素个数
* 擦除图案时设置画板的颜色为透明色再进行绘制即可
* @href https://forum.cocos.org/t/topic/89902
*/
var DrawingBoard = /** @class */ (function () {
/**
* 可对每个像素点绘制的画板画板使用的坐标系原点为左下角X轴向右为正Y轴向上为正
* @param width 画板宽度
* @param height 画板高度
* @param data 指定画板初始内容参数为记录颜色分量的一维数组不传入参数时画板中全部像素为透明
*/
function DrawingBoard(width, height, data) {
this.init(width, height, data);
}
Object.defineProperty(DrawingBoard.prototype, "width", {
/**画板宽度 */
get: function () { return this._witdh; },
enumerable: false,
configurable: true
});
Object.defineProperty(DrawingBoard.prototype, "height", {
/**画板高度 */
get: function () { return this._height; },
enumerable: false,
configurable: true
});
//#region 初始化
/**
* 对画板进行初始化会清空已绘制的所有内容
* @param width 画板宽度
* @param height 画板高度
* @param data 指定画板初始内容参数为记录颜色分量的一维数组不传入参数时画板内容为全部透明的矩形
*/
DrawingBoard.prototype.init = function (width, height, data) {
this.tempColor = this.tempR = this.tempG = this.tempB = this.tempA = 0;
this.curColor = 0;
this._witdh = Math.round(width);
this._height = Math.round(height);
this.initPointColor();
this.initMaskPoint();
this.initPixelColor();
this.initLineData();
if (!!data) {
this.setData(data);
}
};
DrawingBoard.prototype.initPointColor = function () {
if (!this.pointColor) {
this.pointColor = [];
}
for (var x = 0; x < this.width; ++x) {
if (!this.pointColor[x]) {
this.pointColor[x] = [];
}
for (var y = 0; y < this.height; ++y) {
this.pointColor[x][y] = 0;
}
}
this.colorCount = {};
this.colorCount[0] = this.width * this.height;
};
DrawingBoard.prototype.initMaskPoint = function () {
if (!this.maskPoint) {
this.maskPoint = [];
}
for (var x = 0; x < this.width; ++x) {
if (!this.maskPoint[x]) {
this.maskPoint[x] = [];
}
for (var y = 0; y < this.height; ++y) {
this.maskPoint[x][y] = 1;
}
}
};
DrawingBoard.prototype.initPixelColor = function () {
this.buffer = new ArrayBuffer(this.width * this.height * 4);
this.pixelColor = new Uint8Array(this.buffer);
this.pixelColor.fill(0);
};
//#endregion
//#region 重置内容
/**重置画板,画板的宽高不变,但会清空已绘制的所有内容,恢复至透明状态 */
DrawingBoard.prototype.reset = function () {
this.resetPointColor();
this.resetMaskPoint();
this.resetPixelColor();
};
DrawingBoard.prototype.resetPointColor = function () {
for (var x = this.width - 1; x >= 0; --x) {
for (var y = this.height - 1; y >= 0; --y) {
this.pointColor[x][y] = 0;
}
}
for (var key in this.colorCount) {
this.colorCount[key] = 0;
}
};
DrawingBoard.prototype.resetMaskPoint = function () {
for (var x = this.width - 1; x >= 0; --x) {
for (var y = this.height - 1; y >= 0; --y) {
this.maskPoint[x][y] = 1;
}
}
};
DrawingBoard.prototype.resetPixelColor = function () {
this.pixelColor.fill(0);
};
//#endregion
/**
* 传入图像的像素数据直接设置画板的内容图像尺寸必须与画板一致若需要重新设置画板大小请使用 init() 函数
* @param data 记录各像素颜色分量的一维数组
*/
DrawingBoard.prototype.setData = function (data) {
var pixelData = new Uint8Array(data);
if (pixelData.length != this.width * this.height * 4) {
console.warn("画板设置数据失败,数据长度与画板大小不一致。");
return;
}
this.setPixelColorByRGBA(pixelData);
this.setPointColorByRGBA(pixelData);
};
/**
* 记录各像素颜色分量
* @param data 颜色分量一维数组
*/
DrawingBoard.prototype.setPixelColorByRGBA = function (data) {
this.pixelColor.set(data);
};
/**
* 按像素点的坐标记录像素点的颜色值
* @param data 颜色分量一维数组
*/
DrawingBoard.prototype.setPointColorByRGBA = function (data) {
this.colorCount = {};
for (var y = 0; y < this.height; ++y) {
var i = y * this.height;
for (var x = 0; x < this.width; ++x) {
var color = this.convertToNumber(data[i++], data[i++], data[i++], data[i++]);
this.pointColor[x][y] = color;
if (!this.colorCount[color]) {
this.colorCount[color] = 1;
}
else {
this.colorCount[color] += 1;
}
}
}
};
/**
* 设置不能绘制图案的像素区域
* @param data 像素坐标为索引0表示不能绘制1表示能绘制
*/
DrawingBoard.prototype.setMask = function (data) {
for (var x = this.width - 1; x >= 0; --x) {
if (!!data[x]) {
for (var y = this.height - 1; y >= 0; --y) {
if (undefined != data[x][y]) {
this.maskPoint[x][y] = data[x][y];
}
}
}
}
};
/**
* 设置画板为全部区域都不能绘制
*/
DrawingBoard.prototype.setDisable = function () {
for (var x = this.width - 1; x >= 0; --x) {
for (var y = this.height - 1; y >= 0; --y) {
this.maskPoint[x][y] = 0;
}
}
};
/**
* 在现有可绘制区域的基础上添加可以绘制的像素点区域
* 此方法不会禁用画板当前可绘制的像素点区域只会添加新的可绘制区域
* @param data 像素坐标为索引0表示不能绘制1表示能绘制
*/
DrawingBoard.prototype.addEnablePoints = function (data) {
for (var x = this.width - 1; x >= 0; --x) {
if (!!data[x]) {
for (var y = this.height - 1; y >= 0; --y) {
if (!!data[x][y]) {
this.maskPoint[x][y] = data[x][y];
}
}
}
}
};
/**
* 获取画板中的数据
* @param data 用于接收数据的数组
* @returns {number[]} 返回存储各像素点颜色分量的一维数组
*/
DrawingBoard.prototype.copyData = function (data) {
if (undefined === data) {
data = [];
}
for (var i = 0, count = this.pixelColor.length; i < count; ++i) {
data[i] = this.pixelColor[i];
}
return data;
};
/**
* 获取画板中记录每个像素的颜色分量的数据
* @returns 将直接返回画板内部的数组若使用者需要对该数据进行修改请使用 copyData 方法获取以免影响画板的像素个数计数功能
*/
DrawingBoard.prototype.getData = function () {
return this.pixelColor;
};
/**获取画板内部使用的内存块,若仅需要获取像素数据,不进一步处理,使用 getData 即可 */
DrawingBoard.prototype.getBuffer = function () {
return this.buffer;
};
DrawingBoard.prototype.getPointData = function () {
return this.pointColor;
};
/**
* 获取指定颜色的像素的个数
* @param r 颜色的r分量
* @param g 颜色的g分量
* @param b 颜色的b分量
* @param a 颜色透明度默认为255
*/
DrawingBoard.prototype.getColorCount = function (r, g, b, a) {
if (a === void 0) { a = 255; }
var c = this.convertToNumber(r, g, b, a);
return this.colorCount[c];
};
/**
* 设置画板绘制图案使使用的颜色
* @param r 包含RGBA分量的颜色对象或者颜色的r分量
* @param g 颜色的g分量
* @param b 颜色的b分量
* @param a 颜色透明度默认为255
*/
DrawingBoard.prototype.setColor = function (r, g, b, a) {
if (a === void 0) { a = 255; }
this.curColor = this.convertToNumber(r, g, b, a);
if (!this.colorCount[this.curColor]) {
this.colorCount[this.curColor] = 0;
}
this.tempColor = this.curColor;
this.tempR = r;
this.tempG = g;
this.tempB = b;
this.tempA = a;
};
/**清空所有已绘制的内容 */
DrawingBoard.prototype.clear = function () {
this.reset();
};
DrawingBoard.prototype.initLineData = function () {
this.previousLineEndPos = new Vec2();
this.previousLineEndPosT = new Vec2();
this.previousLineEndPosB = new Vec2();
this.previousLineCircleEnd = true;
this.previousLineWidth = 1;
};
/**
* 移动画笔到指定的位置调用 lineTo 函数时将使用该点作为直线的起点
* @param x 坐标X
* @param y 坐标Y
*/
DrawingBoard.prototype.moveTo = function (x, y) {
x = Math.round(x);
y = Math.round(y);
this.previousLineEndPos.set(x, y);
this.previousLineEndPosT.set(x, y);
this.previousLineEndPosB.set(x, y);
};
/**
* 设置线宽
*/
DrawingBoard.prototype.setLineWidth = function (w) {
this.previousLineWidth = w;
};
/**
* 设置线段端点样式
* @param b 线段端点是否为圆形
*/
DrawingBoard.prototype.setLineCircleEnd = function (b) {
this.previousLineCircleEnd = b;
};
/**
* 绘制直线使用默认的颜色线宽和线段端点样式
* @param x1 起点坐标X
* @param y1 起点坐标Y
* @param x2 终点坐标X
* @param y2 终点坐标Y
*/
DrawingBoard.prototype.line = function (x1, y1, x2, y2) {
x1 = Math.round(x1);
x2 = Math.round(x2);
y1 = Math.round(y1);
y2 = Math.round(y2);
if (x1 == x2 && y1 == y2)
return;
var width = this.previousLineWidth;
var circleEnd = this.previousLineCircleEnd;
this.previousLineEndPos.set(x2, y2);
var offsetX = 0;
var offsetY = 0;
var rateK = 1;
if (x1 == x2) {
offsetX = Math.round(width * 0.5);
}
else if (y1 == y2) {
offsetY = Math.round(width * 0.5);
}
else {
var k = (y2 - y1) / (x2 - x1);
rateK = Math.sqrt(k * k + 1);
offsetY = width * 0.5 / rateK;
offsetX = Math.round(offsetY * k);
offsetY = Math.round(offsetY);
}
this.previousLineEndPosT.set(x2 - offsetX, y2 + offsetY);
this.previousLineEndPosB.set(x2 + offsetX, y2 - offsetY);
var p1 = new Vec2(x1, y1);
var p2 = new Vec2(x2, y2);
if (x1 > x2) {
p1.x = x2;
p1.y = y2;
p2.x = x1;
p2.y = y1;
}
this._drawLine(p1, p2, width, offsetX, offsetY, rateK);
if (circleEnd) {
this._drawCircle(x1, y1, width * 0.5);
this._drawCircle(x2, y2, width * 0.5);
}
};
/**
* 绘制到指定坐标的直线起点为上一次绘制的直线的终点使用默认的颜色宽度和线段端点样式
* @param x 终点坐标X
* @param y 终点坐标Y
*/
DrawingBoard.prototype.lineTo = function (x, y) {
x = Math.round(x);
y = Math.round(y);
if (this.previousLineEndPos.x == x && this.previousLineEndPos.y == y)
return;
var width = this.previousLineWidth;
var circleEnd = this.previousLineCircleEnd;
var x1 = this.previousLineEndPos.x;
var y1 = this.previousLineEndPos.y;
var x2 = x;
var y2 = y;
if (x1 > x2) {
x1 = x2;
y1 = y2;
x2 = this.previousLineEndPos.x;
y2 = this.previousLineEndPos.y;
}
var offsetX = 0;
var offsetY = 0;
var rateK = 1;
if (x1 == x2) {
offsetX = Math.round(width * 0.5);
}
else if (y1 == y2) {
offsetY = Math.round(width * 0.5);
}
else {
var k = (y2 - y1) / (x2 - x1);
rateK = Math.sqrt(k * k + 1);
offsetY = width * 0.5 / rateK;
offsetX = Math.round(offsetY * k);
offsetY = Math.round(offsetY);
}
if (!circleEnd) {
if (this.previousLineEndPos.x != this.previousLineEndPosT.x
|| this.previousLineEndPos.y != this.previousLineEndPosT.y) {
var p1 = new Vec2(this.previousLineEndPos.x - offsetX, this.previousLineEndPos.y + offsetY);
var p2 = new Vec2(this.previousLineEndPos.x + offsetX, this.previousLineEndPos.y - offsetY);
this._drawTriangle([p1, p2, this.previousLineEndPosT]);
this._drawTriangle([p1, p2, this.previousLineEndPosB]);
}
}
else {
this._drawCircle(x1, y1, width * 0.5);
this._drawCircle(x2, y2, width * 0.5);
}
this._drawLine(new Vec2(x1, y1), new Vec2(x2, y2), width, offsetX, offsetY, rateK);
this.previousLineEndPos.set(x, y);
this.previousLineEndPosT.set(x - offsetX, y + offsetY);
this.previousLineEndPosB.set(x + offsetX, y - offsetY);
};
/**
* 绘制直线不包含线段端点样式
* @param p1 线段起点坐标
* @param p2 线段终点坐标
* @param width 线段宽度
* @param color 线段颜色
*/
DrawingBoard.prototype._drawLine = function (p1, p2, width, offsetX, offsetY, slopeRate) {
if (p1.y == p2.y) {
//水平直线
var x = p1.x < p2.x ? p1.x : p2.x;
this._drawRect(new Vec2(x, Math.round(p1.y - width * 0.5)), Math.abs(p1.x - p2.x), width);
}
else if (p1.x == p2.x) {
//垂直直线
var y = p1.y < p2.y ? p1.y : p2.y;
this._drawRect(new Vec2(Math.round(p1.x - width * 0.5), y), width, Math.abs(p1.y - p2.y));
}
else {
//倾斜直线
var inverseK = (p1.x - p2.x) / (p1.y - p2.y);
var p1t = new Vec2(p1.x - offsetX, p1.y + offsetY);
var p1b = new Vec2(p1.x + offsetX, p1.y - offsetY);
var p2t = new Vec2(p2.x - offsetX, p2.y + offsetY);
var p2b = new Vec2(p2.x + offsetX, p2.y - offsetY);
var p1c = new Vec2();
var p2c = new Vec2();
var height = Math.round(width * slopeRate);
if (p2.y > p1.y) {
if (p1b.x < p2t.x) {
p1c.x = p1b.x;
p1c.y = p1b.y + height;
p2c.x = p2t.x;
p2c.y = p2t.y - height;
this._drawVerticalTriangle(p1c, p1b, p1t);
this._drawParallelogram(p1b, p2c, height);
this._drawVerticalTriangle(p2t, p2c, p2b);
}
else {
p1c.x = p1b.x;
p1c.y = Math.round(p2t.y - (p1c.x - p2t.x) * inverseK);
p2c.x = p2t.x;
p2c.y = Math.round(p1b.y + (p1b.x - p2c.x) * inverseK);
this._drawVerticalTriangle(p2t, p2c, p1t);
this._drawParallelogram(p2c, p1b, p2t.y - p2c.y);
this._drawVerticalTriangle(p1c, p1b, p2b);
}
}
else {
if (p1t.x < p2b.x) {
p1c.x = p1t.x;
p1c.y = p1t.y - height;
p2c.x = p2b.x;
p2c.y = p2b.y + height;
this._drawVerticalTriangle(p1t, p1c, p1b);
this._drawParallelogram(p1c, p2b, height);
this._drawVerticalTriangle(p2c, p2b, p2t);
}
else {
p1c.x = p1t.x;
p1c.y = Math.round(p2b.y - (p1c.x - p2b.x) * inverseK);
p2c.x = p2b.x;
p2c.y = Math.round(p1t.y + (p1t.x - p2c.x) * inverseK);
this._drawVerticalTriangle(p2c, p2b, p1b);
this._drawParallelogram(p2b, p1c, p1t.y - p1c.y);
this._drawVerticalTriangle(p1t, p1c, p2t);
}
}
}
};
//#endregion
//#region 绘制:矩形
/**
* 绘制矩形
* @param x 矩形左下角的坐标X
* @param y 矩形左下角的坐标Y
* @param w 矩形宽度
* @param h 矩形高度
*/
DrawingBoard.prototype.rect = function (x, y, w, h) {
x = Math.round(x);
y = Math.round(y);
this._drawRect(new Vec2(x, y), w, h);
};
/**
* 绘制矩形
* @param p 矩形左下顶点的坐标
* @param w 矩形宽度
* @param h 矩形高度
* @param color 矩形填充的颜色
*/
DrawingBoard.prototype._drawRect = function (p, w, h) {
var minX = this.clampX(p.x);
var maxX = this.clampX(p.x + w);
var minY = this.clampY(p.y);
var maxY = this.clampY(p.y + h);
// for (let x = minX; x <= maxX; ++x) {
// for (let y = minY; y <= maxY; ++y) {
// this._drawPixel(x, y);
// }
// }
for (var y = minY; y <= maxY; ++y) {
this._drawRowPixel(minX, maxX, y);
}
};
/**
* 绘制平行四边形平行四边形的左右两边与Y轴平行
* @param p1 左下顶点坐标
* @param p2 右下顶点坐标
* @param height 垂直边高度
* @param color 颜色
*/
DrawingBoard.prototype._drawParallelogram = function (p1, p2, height) {
if (p1.x == p2.x)
return;
var k = (p2.y - p1.y) / (p2.x - p1.x);
var minX = this._minX(p1.x);
var maxX = this._maxX(p2.x);
for (var x = minX; x <= maxX; ++x) {
var minY = p1.y + Math.round((x - p1.x) * k);
var maxY = minY + height;
minY = this._minY(minY);
maxY = this._maxY(maxY);
this._drawColPixel(minY, maxY, x);
// for (let y = minY; y <= maxY; ++y) {
// this._drawPixel(x, y);
// }
}
};
//#endregion
//#region 绘制:三角形
/**
* 绘制三角形
* @param x1 顶点1坐标X
* @param y1 顶点1坐标Y
* @param x2 顶点2坐标X
* @param y2 顶点2坐标Y
* @param x3 顶点3坐标X
* @param y3 顶点3坐标Y
*/
DrawingBoard.prototype.triangle = function (x1, y1, x2, y2, x3, y3) {
x1 = Math.round(x1);
y1 = Math.round(y1);
x2 = Math.round(x2);
y2 = Math.round(y2);
x3 = Math.round(x3);
y3 = Math.round(y3);
var pList = [];
pList.push(new Vec2(x1, y1));
pList.push(new Vec2(x2, y2));
pList.push(new Vec2(x3, y3));
this._drawTriangle(pList);
};
/**
* 绘制任意三角形
* @param p1 顶点坐标
* @param p2
* @param p3
* @param color 填充颜色
*/
DrawingBoard.prototype._drawTriangle = function (pList) {
pList.sort(function (a, b) {
return a.x - b.x;
});
var p1 = pList[0];
var p2 = pList[1];
var p3 = pList[2];
if (p1.x == p2.x) {
if (p1.x == p3.x)
return;
if (p1.y < p2.y) {
p1 = pList[1];
p2 = pList[0];
}
this._drawVerticalTriangle(p1, p2, p3);
return;
}
var k = (p3.y - p1.y) / (p3.x - p1.x);
var p4 = new Vec2(p2.x, Math.round(p1.y + (p2.x - p1.x) * k));
if (p4.y == p2.y)
return;
if (p4.y < p2.y) {
this._drawVerticalTriangle(p2, p4, p1);
this._drawVerticalTriangle(p2, p4, p3);
}
else {
this._drawVerticalTriangle(p4, p2, p1);
this._drawVerticalTriangle(p4, p2, p3);
}
};
/**
* 绘制一条边与Y轴平行的三角形
* @param p1 三角形垂直边的 顶点坐标
* @param p2 三角形垂直边的 顶点坐标
* @param p3 三角形 左侧或右侧 顶点坐标
* @param color 要绘制的颜色
*/
DrawingBoard.prototype._drawVerticalTriangle = function (p1, p2, p3) {
if (p3.x == p1.x)
return;
var k1 = (p3.y - p1.y) / (p3.x - p1.x);
var k2 = (p3.y - p2.y) / (p3.x - p2.x);
var maxX = p3.x, minX = p1.x;
if (maxX < minX) {
maxX = p1.x;
minX = p3.x;
}
minX = this._minX(minX);
maxX = this._maxX(maxX);
for (var x = minX; x <= maxX; ++x) {
var maxY = this.clampY(Math.round(p1.y + (x - p1.x) * k1));
var minY = this.clampY(Math.round(p2.y + (x - p2.x) * k2));
this._drawColPixel(minY, maxY, x);
// for (let y = minY; y <= maxY; ++y) {
// this._drawPixel(x, y);
// }
}
};
//#endregion
//#region 绘制:圆
/**
* 绘制一个圆
* @param x 圆心坐标x
* @param y 圆心坐标y
* @param radius 圆的半径
*/
DrawingBoard.prototype.circle = function (x, y, radius) {
x = Math.round(x);
y = Math.round(y);
this._drawCircle(x, y, radius);
};
DrawingBoard.prototype._drawCircle = function (x, y, radius) {
radius = Math.round(radius);
if (radius == 0)
return;
//三角形的斜边的平方
var dis = radius * radius;
// let minX = this._minX(x - radius);
// let maxX = this._maxX(x + radius);
// for (let i = minX; i <= maxX; ++i) {
// let r = x - i;
// r = Math.round(Math.sqrt(dis - r * r));
// let minY = this._minY(y - r);
// let maxY = this._maxY(y + r);
// for (let j = minY; j <= maxY; ++j) {
// this._drawPixel(i, j);
// }
// }
var minY = this.clampY(y - radius);
var maxY = this.clampY(y + radius);
for (var j = minY; j <= maxY; ++j) {
var r = j - y;
r = Math.round(Math.sqrt(dis - r * r));
var minX = this.clampX(x - r);
var maxX = this.clampX(x + r);
this._drawRowPixel(minX, maxX, j);
}
};
//#endregion
//#region 内部绘制方法
DrawingBoard.prototype._minX = function (x) {
return x >= 0 ? x : 0;
};
DrawingBoard.prototype._maxX = function (x) {
return x < this.width ? x : this.width - 1;
};
DrawingBoard.prototype._minY = function (y) {
return y >= 0 ? y : 0;
};
DrawingBoard.prototype._maxY = function (y) {
return y < this.height ? y : this.height - 1;
};
DrawingBoard.prototype.clampX = function (x) {
if (x < 0)
return 0;
if (x >= this.width)
return this.width - 1;
return x;
};
DrawingBoard.prototype.clampY = function (y) {
if (y < 0)
return 0;
if (y >= this.height)
return this.height - 1;
return y;
};
/**绘制一个像素点的颜色 */
DrawingBoard.prototype._drawPixel = function (x, y) {
x = Math.round(x);
y = Math.round(y);
if (this.maskPoint[x][y] == 0)
return;
if (this.pointColor[x][y] == this.tempColor)
return;
var index = (y * this.width + x) * 4;
this.pixelColor[index] = this.tempR;
this.pixelColor[index + 1] = this.tempG;
this.pixelColor[index + 2] = this.tempB;
this.pixelColor[index + 3] = this.tempA;
var c = this.pointColor[x][y];
this.colorCount[c]--;
this.colorCount[this.tempColor]++;
this.pointColor[x][y] = this.tempColor;
};
/**
* 连续绘制一行中的像素点
* @param startX 起点X坐标
* @param endX 终点X坐标
* @param y Y坐标
*/
DrawingBoard.prototype._drawRowPixel = function (startX, endX, y) {
var _a;
var index = (y * this.width + startX) * 4;
for (var x = startX; x <= endX; ++x) {
if ((this.maskPoint[x][y] != 0 && this.pointColor[x][y] != this.tempColor) || this.pixelColor[index + 3] != 255) {
this.pixelColor[index] = this.tempR;
this.pixelColor[index + 1] = this.tempG;
this.pixelColor[index + 2] = this.tempB;
this.pixelColor[index + 3] = this.tempA;
cc.tween(this.pixelColor)
.delay(5)
.to(0.5, (_a = {}, _a[index + 3] = 0, _a))
.start();
var c = this.pointColor[x][y];
this.colorCount[c]--;
this.colorCount[this.tempColor]++;
this.pointColor[x][y] = this.tempColor;
}
index += 4;
}
};
/**
* 连续绘制一列中的像素点
* @param startY 起点Y坐标
* @param endY 终点Y坐标
* @param x X坐标
*/
DrawingBoard.prototype._drawColPixel = function (startY, endY, x) {
var _a;
var index = (startY * this.width + x) * 4;
for (var y = startY; y <= endY; ++y) {
if ((this.maskPoint[x][y] != 0 && this.pointColor[x][y] != this.tempColor) || this.pixelColor[index + 3] != 255) {
this.pixelColor[index] = this.tempR;
this.pixelColor[index + 1] = this.tempG;
this.pixelColor[index + 2] = this.tempB;
this.pixelColor[index + 3] = this.tempA;
cc.tween(this.pixelColor)
.delay(5)
.to(0.5, (_a = {}, _a[index + 3] = 0, _a))
.start();
var c = this.pointColor[x][y];
this.colorCount[c]--;
this.colorCount[this.tempColor]++;
this.pointColor[x][y] = this.tempColor;
}
index += this.width * 4;
}
};
/**
* 将RGBA颜色分量转换为一个数值表示的颜色颜色分量为0~255之间的值
* @param r
* @param g
* @param b
* @param a
*/
DrawingBoard.prototype.convertToNumber = function (r, g, b, a) {
if (a === void 0) { a = 255; }
//颜色值将用于数组索引不能为负数故红色分量为奇数时将减1变为偶数
return ((r & 0xfe) << 23) | (g << 16) | (b << 8) | a;
};
/**将十六进制的颜色转换为RGBA分量表示的颜色 */
DrawingBoard.prototype.convertToRGBA = function (color) {
//颜色值将用于数组索引不能为负数故红色分量为奇数时将减1变为偶数
return {
r: (color & 0xef000000) >> 23,
g: (color & 0x00ff0000) >> 16,
b: (color & 0x0000ff00) >> 8,
a: (color & 0x000000ff),
};
};
return DrawingBoard;
}());
exports.default = DrawingBoard;
var Vec2 = /** @class */ (function () {
function Vec2(x, y) {
if (x === void 0) { x = 0; }
if (y === void 0) { y = 0; }
this.x = x;
this.y = y;
}
Vec2.prototype.set = function (p, y) {
if (typeof p === "number") {
this.x = p;
this.y = y;
}
else {
this.x = p.x;
this.y = p.y;
}
};
return Vec2;
}());
cc._RF.pop();

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,102 @@
{
"__type__": "cc.EffectAsset",
"_name": "builtin-2d-graphics",
"_objFlags": 0,
"_native": "",
"properties": null,
"techniques": [
{
"passes": [
{
"blendState": {
"targets": [
{
"blend": true,
"blendSrc": 1,
"blendDst": 771,
"blendSrcAlpha": 1,
"blendDstAlpha": 771
}
]
},
"rasterizerState": {
"cullMode": 0
},
"properties": {
"alphaThreshold": {
"value": [
0.5
],
"type": 13
}
},
"program": "builtin-2d-graphics|vs|fs"
}
]
}
],
"shaders": [
{
"hash": 550349795,
"glsl3": {
"vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\nin float a_dist;\nout float v_dist;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n gl_Position = pos;\n}",
"frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\nin float v_dist;\nvoid main () {\n vec4 o = v_color;\n ALPHA_TEST(o);\n #if CC_SUPPORT_standard_derivatives\n float aa = fwidth(v_dist);\n #else\n float aa = 0.05;\n #endif\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n gl_FragColor = o;\n}"
},
"glsl1": {
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\nattribute float a_dist;\nvarying float v_dist;\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n gl_Position = pos;\n}",
"frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\nvarying float v_dist;\nvoid main () {\n vec4 o = v_color;\n ALPHA_TEST(o);\n #if CC_SUPPORT_standard_derivatives\n float aa = fwidth(v_dist);\n #else\n float aa = 0.05;\n #endif\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n gl_FragColor = o;\n}"
},
"builtins": {
"globals": {
"blocks": [
{
"name": "CCGlobal",
"defines": []
}
],
"samplers": []
},
"locals": {
"blocks": [
{
"name": "CCLocal",
"defines": []
}
],
"samplers": []
}
},
"defines": [
{
"name": "CC_SUPPORT_standard_derivatives",
"type": "boolean",
"defines": []
},
{
"name": "USE_ALPHA_TEST",
"type": "boolean",
"defines": []
}
],
"blocks": [
{
"name": "ALPHA_TEST",
"members": [
{
"name": "alphaThreshold",
"type": 13,
"count": 1
}
],
"defines": [
"USE_ALPHA_TEST"
],
"binding": 0
}
],
"samplers": [],
"record": null,
"name": "builtin-2d-graphics|vs|fs"
}
]
}

View File

@ -0,0 +1,28 @@
{
"__type__": "cc.SpriteFrame",
"content": {
"name": "HelloWorld",
"texture": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
"atlas": "",
"rect": [
0,
0,
195,
270
],
"offset": [
0,
0
],
"originalSize": [
195,
270
],
"capInsets": [
0,
0,
0,
0
]
}
}

View File

@ -0,0 +1,28 @@
{
"__type__": "cc.SpriteFrame",
"content": {
"name": "default_scrollbar",
"texture": "0291c134-b3da-4098-b7b5-e397edbe947f",
"atlas": "",
"rect": [
0,
0,
30,
15
],
"offset": [
0,
0
],
"originalSize": [
30,
15
],
"capInsets": [
10,
4,
10,
4
]
}
}

View File

@ -0,0 +1,710 @@
[
{
"__type__": "cc.Prefab",
"_name": "scrollview",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 1,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "scrollview",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 9
}
],
"_active": true,
"_components": [
{
"__id__": 19
},
{
"__id__": 7
}
],
"_prefab": {
"__id__": 20
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 240,
"height": 250
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "scrollBar",
"_objFlags": 512,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
}
],
"_active": true,
"_components": [
{
"__id__": 6
},
{
"__id__": 16
},
{
"__id__": 17
}
],
"_prefab": {
"__id__": 18
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 12,
"height": 250
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 1,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
120,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "bar",
"_objFlags": 512,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
}
],
"_prefab": {
"__id__": 5
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 10,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 1,
"y": 0
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-1,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "5c3bb932-6c3c-468f-88a9-c8c61d458641"
},
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb"
},
"fileId": "b1f27kt1ClHyJvwBLxrEfQY",
"sync": false
},
{
"__type__": "cc.Scrollbar",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_scrollView": {
"__id__": 7
},
"_touching": false,
"_opacity": 255,
"enableAutoHide": true,
"autoHideTime": 1,
"_N$handle": {
"__id__": 4
},
"_N$direction": 1,
"_id": ""
},
{
"__type__": "cc.ScrollView",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"horizontal": false,
"vertical": true,
"inertia": true,
"brake": 0.75,
"elastic": true,
"bounceDuration": 0.23,
"scrollEvents": [],
"cancelInnerEvents": true,
"_N$content": {
"__id__": 8
},
"content": {
"__id__": 8
},
"_N$horizontalScrollBar": null,
"_N$verticalScrollBar": {
"__id__": 6
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "content",
"_objFlags": 512,
"_parent": {
"__id__": 9
},
"_children": [
{
"__id__": 12
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 15
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 220,
"height": 400
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 1
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
115.30999755859375,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "view",
"_objFlags": 512,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 8
}
],
"_active": true,
"_components": [
{
"__id__": 10
}
],
"_prefab": {
"__id__": 11
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 240,
"height": 250
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Mask",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_spriteFrame": null,
"_type": 0,
"_segments": 64,
"_N$alphaThreshold": 0,
"_N$inverted": false,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb"
},
"fileId": "c1dc9Kk/CRJqaNnBOP4YGDS",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "item",
"_objFlags": 512,
"_parent": {
"__id__": 8
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 13
}
],
"_prefab": {
"__id__": 14
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 131.33,
"height": 65.2
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 1
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-102.19999694824219,
-10.149999618530273,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_useOriginalSize": false,
"_string": "ScrollView content\n\n",
"_N$string": "ScrollView content\n\n",
"_fontSize": 16,
"_lineHeight": 20,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 0,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb"
},
"fileId": "5280bTjVfhISb/ztQTswOuX",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb"
},
"fileId": "036a4WKD5hBcbQJmMrbqoW8",
"sync": false
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 0,
"_target": null,
"_alignFlags": 37,
"_left": 350.07654921020657,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 237,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "5fe5dcaa-b513-4dc5-a166-573627b3a159"
},
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb"
},
"fileId": "f8b835eFHxKj4uMGeoBGz+U",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69"
},
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "32044bd2-481f-4cf1-a656-e2b2fb1594eb"
},
"fileId": "2bb72ntvphNH4HtVfnSNUVp",
"sync": false
}
]

View File

@ -0,0 +1,10 @@
{
"__type__": "cc.Material",
"_name": "builtin-2d-gray-sprite",
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "144c3297-af63-49e8-b8ef-1cfa29b3be28"
},
"_techniqueData": {}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,90 @@
[
{
"__type__": "cc.Mesh",
"_name": "",
"_objFlags": 0,
"_native": ".bin",
"_vertexBundles": [
{
"__id__": 1
}
],
"_primitives": [
{
"__id__": 6
}
],
"_minPos": {
"__type__": "cc.Vec3",
"x": -0.5,
"y": -0.5,
"z": -0.5
},
"_maxPos": {
"__type__": "cc.Vec3",
"x": 0.5,
"y": 0.5,
"z": 0.5
}
},
{
"__type__": "cc.mesh.VertexBundle",
"data": {
"__id__": 2
},
"formats": [
{
"__id__": 3
},
{
"__id__": 4
},
{
"__id__": 5
}
],
"verticesCount": 1089
},
{
"__type__": "cc.BufferRange",
"offset": 0,
"length": 34848
},
{
"__type__": "cc.mesh.VertexFormat",
"name": "a_normal",
"type": 5126,
"num": 3,
"normalize": false
},
{
"__type__": "cc.mesh.VertexFormat",
"name": "a_position",
"type": 5126,
"num": 3,
"normalize": false
},
{
"__type__": "cc.mesh.VertexFormat",
"name": "a_uv0",
"type": 5126,
"num": 2,
"normalize": false
},
{
"__type__": "cc.mesh.Primitive",
"vertexBundleIndices": [
0
],
"data": {
"__id__": 7
},
"indexUnit": 5123,
"topology": 4
},
{
"__type__": "cc.BufferRange",
"offset": 34848,
"length": 12288
}
]

View File

@ -0,0 +1,109 @@
[
{
"__type__": "cc.Prefab",
"_name": "plane",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "plane",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
}
],
"_prefab": {
"__id__": 3
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": true,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.MeshRenderer",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "a5849239-3ad3-41d1-8ab4-ae9fea11f97f"
}
],
"_mesh": {
"__uuid__": "a1ef2fc9-9c57-418a-8f69-6bed9a7a0e7f"
},
"_receiveShadows": false,
"_shadowCastingMode": 0,
"_enableAutoBatch": false,
"textures": [],
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "3f376125-a699-40ca-ad05-04d662eaa1f2"
},
"fileId": "9fhEbTXI1IApxjLqbjx+1L",
"sync": false
}
]

Some files were not shown because too many files have changed in this diff Show More