├── .DS_Store
├── 5.事件机制
├── .DS_Store
└── 执行流程
│ ├── index.html
│ └── main.js
├── 2.显示对象和显示容器
├── .DS_Store
├── README.md
├── 变换操作
│ ├── index.html
│ └── main.js
├── 显示容器
│ ├── index.html
│ └── main.js
├── Shape
│ ├── index.html
│ └── main.js
├── TextField
│ ├── index.html
│ └── main.js
└── 添加与删除显示对象
│ ├── index.html
│ └── main.js
├── 4.碰撞检测
├── README.md
├── index.html
└── main.js
├── 7.时间控制
├── main.js
└── index.html
├── 1.入门安装
├── index.html
└── main.js
├── 3.遮罩
├── index.html
└── main.js
├── 6.网络请求
├── index.html
└── main.js
└── js
├── main.js
└── egret.web.min.js
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/egret/HEAD/.DS_Store
--------------------------------------------------------------------------------
/5.事件机制/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/egret/HEAD/5.事件机制/.DS_Store
--------------------------------------------------------------------------------
/2.显示对象和显示容器/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Wscats/egret/HEAD/2.显示对象和显示容器/.DS_Store
--------------------------------------------------------------------------------
/4.碰撞检测/README.md:
--------------------------------------------------------------------------------
1 | # 碰撞检测
2 | 碰撞检测,判断显示对象是否与一点相交。
3 |
4 | # 矩形碰撞检测
5 | 矩形碰撞检测,是判断显示对象的包围盒是否与一点相交。
--------------------------------------------------------------------------------
/2.显示对象和显示容器/README.md:
--------------------------------------------------------------------------------
1 | # 1.基本概念
2 |
3 | “显示对象”,是可以在舞台上显示的对象。可以显示的对象,既包括可以直接看见的图形、文字、视频、图片等,也包括不能看见但真实存在的显示对象容器。在Egret中,视觉图形都是由显示对象和显示对象容器组成的。
4 |
5 | DisplayObject类是所有显示对象的父类,该类包含显示对象共有的属性与方法。
6 |
7 |
--------------------------------------------------------------------------------
/7.时间控制/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | //创建一个计时器对象
5 | var timer = new egret.Timer(500, 5);
6 | //注册事件侦听器
7 | timer.addEventListener(egret.TimerEvent.TIMER, this.timerFunc, this);
8 | timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.timerComFunc, this);
9 | //开始计时
10 | //三个方法为 start, reset 和 stop。作用分别是开始计时,重新计时和暂停计时
11 | timer.start();
12 | }
13 | timerFunc() {
14 | console.log("计时");
15 | }
16 | timerComFunc() {
17 | console.log("计时结束");
18 | }
19 | }
20 | window['Main'] = Main;
21 | egret.runEgret();
--------------------------------------------------------------------------------
/1.入门安装/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/3.遮罩/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/4.碰撞检测/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/6.网络请求/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/7.时间控制/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/5.事件机制/执行流程/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/2.显示对象和显示容器/变换操作/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/2.显示对象和显示容器/显示容器/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/2.显示对象和显示容器/Shape/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/2.显示对象和显示容器/TextField/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/2.显示对象和显示容器/添加与删除显示对象/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/js/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
5 | }
6 | onAddToStage(event) {
7 | let textfield = new egret.TextField();
8 | this.addChild(textfield);
9 | textfield.textColor = 0xff0000;
10 | textfield.text = 'hello world';
11 |
12 | var shp = new egret.Shape();
13 | shp.graphics.beginFill(0xff0000, 1);
14 | shp.graphics.drawRect(0, 0, 100, 200);
15 | shp.graphics.endFill();
16 | shp.scaleX = 0.5;
17 | shp.scaleY = 0.5;
18 | shp.rotation = 30;
19 | this.addChild(shp);
20 | }
21 | }
22 | window['Main'] = Main;
23 | egret.runEgret();
--------------------------------------------------------------------------------
/1.入门安装/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
5 | }
6 | onAddToStage(event) {
7 | let textfield = new egret.TextField();
8 | this.addChild(textfield);
9 | textfield.textColor = 0xff0000;
10 | textfield.text = 'hello world';
11 |
12 | var shp = new egret.Shape();
13 | shp.graphics.beginFill(0xff0000, 1);
14 | shp.graphics.drawRect(0, 0, 100, 200);
15 | shp.graphics.endFill();
16 | shp.scaleX = 0.5;
17 | shp.scaleY = 0.5;
18 | shp.rotation = 30;
19 | this.addChild(shp);
20 | }
21 | }
22 | window['Main'] = Main;
23 | egret.runEgret();
--------------------------------------------------------------------------------
/6.网络请求/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
5 | }
6 | onAddToStage(event) {
7 | var request = new egret.HttpRequest();
8 | request.responseType = egret.HttpResponseType.TEXT;
9 | request.open("http://httpbin.org/get", egret.HttpMethod.GET);
10 | request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
11 | request.send();
12 | request.addEventListener(egret.Event.COMPLETE, this.onGetComplete, this);
13 | request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onGetIOError, this);
14 | request.addEventListener(egret.ProgressEvent.PROGRESS, this.onGetProgress, this);
15 | }
16 | }
17 | window['Main'] = Main;
18 | egret.runEgret();
--------------------------------------------------------------------------------
/3.遮罩/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
5 | }
6 | onAddToStage(event) {
7 | var shp = new egret.Shape();
8 | shp.graphics.beginFill(0xff0000);
9 | shp.graphics.drawRect(0, 0, 100, 100);
10 | shp.graphics.endFill();
11 | this.addChild(shp);
12 |
13 |
14 | var shp2 = new egret.Shape();
15 | shp2.graphics.beginFill(0x00ff00);
16 | shp2.graphics.drawCircle(0, 0, 20);
17 | shp2.graphics.endFill();
18 | this.addChild(shp2);
19 |
20 | shp2.x = 20;
21 | shp2.y = 20;
22 |
23 | // 将被遮罩显示对象的 mask 属性设置为遮罩对象
24 | shp.mask = shp2;
25 | // 通过将 mask 属性设置为 null 可以删除遮罩:
26 | // shp.mask = null;
27 | }
28 | }
29 | window['Main'] = Main;
30 | egret.runEgret();
--------------------------------------------------------------------------------
/2.显示对象和显示容器/显示容器/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
5 | }
6 | onAddToStage(event) {
7 | // 在文档类中,实例化 GridSprite 即可。
8 | var _myGrid = new GridSprite();
9 | this.addChild(_myGrid);
10 | }
11 | }
12 | // 自定义容器,可编写一个类,继承 DisplayObjectContainer 。如果要同时实现Graphics绘图功能,可继承 Sprite
13 | // 下面是一个自定义容器类的示例,该示例定义了一个GridSprite类。这个类默认绘制一个红蓝相间的格子
14 | class GridSprite extends egret.Sprite {
15 | constructor() {
16 | super();
17 | this.drawGrid();
18 | }
19 | drawGrid() {
20 | this.graphics.beginFill(0x0000ff);
21 | this.graphics.drawRect(0, 0, 50, 50);
22 | this.graphics.endFill();
23 | this.graphics.beginFill(0x0000ff);
24 | this.graphics.drawRect(50, 50, 50, 50);
25 | this.graphics.endFill();
26 | this.graphics.beginFill(0xff0000);
27 | this.graphics.drawRect(50, 0, 50, 50);
28 | this.graphics.endFill();
29 | this.graphics.beginFill(0xff0000);
30 | this.graphics.drawRect(0, 50, 50, 50);
31 | this.graphics.endFill();
32 | }
33 | }
34 | window['Main'] = Main;
35 | egret.runEgret();
--------------------------------------------------------------------------------
/4.碰撞检测/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | infoText; // 私有变量
3 | constructor() {
4 | super();
5 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
6 | }
7 | onAddToStage(event) {
8 | // 碰撞检测
9 | this.drawText();
10 |
11 | // var shp = new egret.Shape();
12 | // shp.graphics.beginFill(0xff0000);
13 | // shp.graphics.drawRect(0, 0, 100, 100);
14 | // shp.graphics.endFill();
15 | // shp.width = 100;
16 | // shp.height = 100;
17 | // this.addChild(shp);
18 |
19 | // 矩形碰撞检测
20 | var shp = new egret.Shape();
21 | shp.graphics.beginFill(0xff0000);
22 | shp.graphics.drawCircle(0, 0, 20);
23 | shp.graphics.endFill();
24 | shp.width = 100;
25 | shp.height = 100;
26 | this.addChild(shp);
27 | // shp 是待检测的显示对象,(x, y)是待检测的点的位置。如果发生碰撞,则方法返回 true,如果没有发生碰撞,则返回 false
28 | // var isHit = shp.hitTestPoint(10, 10); // true
29 | // var isHit = shp.hitTestPoint(101, 101); //false
30 |
31 | var isHit = shp.hitTestPoint(1, 1, true); // 相比于矩形碰撞检测,增加了第三个参数 true ,表示要使用像素碰撞检测
32 | this.infoText.text = "isHit: " + isHit;
33 | }
34 | drawText() {
35 | this.infoText = new egret.TextField();
36 | this.infoText.y = 200;
37 | this.infoText.text = "isHit";
38 | this.infoText.textColor = 0xff0000;
39 | this.addChild(this.infoText);
40 | }
41 | }
42 | window['Main'] = Main;
43 | egret.runEgret();
--------------------------------------------------------------------------------
/2.显示对象和显示容器/添加与删除显示对象/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
5 | }
6 | onAddToStage(event) {
7 | // 显示对象的坐标系是相对坐标系,而非绝对坐标系。
8 | // 当一个显示对象的x,y坐标值均设置为100的时候,该坐标值表示,当前显示对象居于父级原点100,100的位置。通过下面一个实例来说明具体区别。
9 | // 首先建立两个容器,为了能够方便的看清效果,将两个容器的宽高都设置为100*100,同时将两个容器分别设置为红色和绿色。
10 | // 绿色的容器x轴位置设置为120像素。
11 | // 红色的容器y轴位置设置为130像素
12 | // 将两个容器都添加到显示列表中,他们的父级都是文档类。下面是示例代码:
13 | var sprcon1 = new egret.Sprite();
14 | sprcon1.graphics.beginFill(0x00ff00);
15 | sprcon1.graphics.drawRect(0, 0, 100, 100);
16 | sprcon1.graphics.endFill();
17 | this.addChild(sprcon1);
18 | sprcon1.x = 120;
19 | var sprcon2 = new egret.Sprite();
20 | sprcon2.graphics.beginFill(0xff0000);
21 | sprcon2.graphics.drawRect(0, 0, 100, 100);
22 | sprcon2.graphics.endFill();
23 | this.addChild(sprcon2);
24 | sprcon2.y = 130;
25 |
26 |
27 | var spr = new egret.Sprite();
28 | spr.graphics.beginFill(0x0000ff);
29 | spr.graphics.drawRect(0, 0, 50, 50);
30 | spr.graphics.endFill();
31 | spr.x = 10;
32 | spr.y = 10;
33 | // 添加到文档类
34 | // this.addChild(spr);
35 |
36 | // 添加到sprcon1绿色容器中:
37 | // sprcon1.addChild(spr);
38 |
39 | // 添加到sprcon2红色容器中:
40 | sprcon2.addChild(spr);
41 | }
42 | }
43 | window['Main'] = Main;
44 | egret.runEgret();
--------------------------------------------------------------------------------
/2.显示对象和显示容器/TextField/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
5 | }
6 | onAddToStage(event) {
7 | // 1.普通文本
8 | // 普通文本是用于显示标准文本内容的文本类型。
9 | var label = new egret.TextField();
10 | label.text = "This is a text!";
11 | label.textColor = 0x000000;
12 | this.addChild(label);
13 |
14 | // 2.输入文本
15 | // 输入文本是允许用户输入的文本类型。
16 | // 将文本框设置为可输入的代码如下:
17 | var txInput = new egret.TextField();
18 | txInput.type = egret.TextFieldType.INPUT;
19 | txInput.width = 282;
20 | txInput.height = 43;
21 | txInput.x = 134;
22 | txInput.y = 592;
23 | txInput.textColor = 0x000000;
24 | /// 注意_container是事先建立好的一个显示容器,即 egret.Sprite,并且已经添加到显示列表中
25 | this.addChild(txInput);
26 | var _myGrid = new GridSprite();
27 | this.addChild(_myGrid);
28 | }
29 | }
30 | class GridSprite extends egret.Sprite {
31 | constructor() {
32 | super();
33 | this.drawGrid();
34 | }
35 | drawGrid() {
36 | this.graphics.beginFill(0x0000ff);
37 | this.graphics.drawRect(0, 0, 50, 50);
38 | this.graphics.endFill();
39 | this.graphics.beginFill(0x0000ff);
40 | this.graphics.drawRect(50, 50, 50, 50);
41 | this.graphics.endFill();
42 | this.graphics.beginFill(0xff0000);
43 | this.graphics.drawRect(50, 0, 50, 50);
44 | this.graphics.endFill();
45 | this.graphics.beginFill(0xff0000);
46 | this.graphics.drawRect(0, 50, 50, 50);
47 | this.graphics.endFill();
48 | }
49 | }
50 | window['Main'] = Main;
51 | egret.runEgret();
--------------------------------------------------------------------------------
/5.事件机制/执行流程/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
5 | }
6 | onAddToStage(event) {
7 | //创建一个男朋友
8 | var boy = new Boy();
9 | boy.name = "男朋友";
10 | //创建一个女朋友
11 | var girl = new Girl();
12 | girl.name = "女朋友";
13 | //注册侦听器
14 | boy.addEventListener(DateEvent.DATE, girl.getDate, girl);
15 | //男朋友发送要求
16 | boy.order();
17 | //约会邀请完成后,移除侦听器
18 | boy.removeEventListener(DateEvent.DATE, girl.getDate, girl);
19 | }
20 | }
21 | class Boy extends egret.Sprite {
22 | constructor() {
23 | super();
24 | }
25 | order() {
26 | //生成约会事件对象
27 | var daterEvent = new DateEvent(DateEvent.DATE);
28 | //添加对应的约会信息
29 | daterEvent._year = 2014;
30 | daterEvent._month = 8;
31 | daterEvent._date = 2;
32 | daterEvent._where = "肯德基";
33 | daterEvent._todo = "共进晚餐";
34 | //发送要求事件
35 | this.dispatchEvent(daterEvent);
36 | }
37 | }
38 | class Girl extends egret.Sprite {
39 | constructor() {
40 | super();
41 | }
42 | getDate(evt) {
43 | console.log("得到了" + evt.target.name + "的邀请!");
44 | console.log("会在" + evt._year + "年" + evt._month + "月" + evt._date + "日,在" + evt._where + evt._todo);
45 | }
46 | }
47 |
48 | class DateEvent extends egret.Event {
49 | DATE = "约会";
50 | _year = 0;
51 | _month = 0;
52 | _date = 0;
53 | _where = "";
54 | _todo = "";
55 | constructor(type, bubbles = false, cancelable = false) {
56 | super(type, bubbles, cancelable);
57 | }
58 | }
59 | window['Main'] = Main;
60 | egret.runEgret();
--------------------------------------------------------------------------------
/2.显示对象和显示容器/Shape/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
5 | }
6 | onAddToStage(event) {
7 | // 矩形
8 | var shp = new egret.Shape();
9 | shp.x = 200;
10 | shp.y = 20;
11 | shp.graphics.lineStyle(10, 0x00ff00); // 设置线条的样式,通过 lineStyle() 方法实现。该方法的第一个参数是描边的线条宽度,第二个参数是描边的颜色
12 | shp.graphics.beginFill(0xff0000, 0.5); // 调用 beginFill() 方法设置矩形的填充颜色,这里将填充颜色设置为红色(颜色值0xff0000),同时将alpha设置为1,表示完全不透明。
13 | shp.graphics.drawRect(0, 0, 100, 200); // 调用 drawRect() 方法设置矩形的位置和大小,前两个参数分别为矩形左上角的X、Y轴坐标(相对于 shp 的锚点计算),后两个参数分别为矩形的宽和高,这里在 (0, 0) 点绘制了一个 100*200 的矩形
14 | shp.graphics.endFill(); // 调用 endFill() 方法结束当前绘制操作
15 | shp.scaleX = 0.5;
16 | shp.scaleY = 0.5;
17 | shp.rotation = 30;
18 | this.addChild(shp);
19 |
20 | // 圆形
21 | var shp = new egret.Shape();
22 | shp.x = 80;
23 | shp.y = 100;
24 | shp.graphics.lineStyle(10, 0x00ff00);
25 | shp.graphics.beginFill(0xff0000, 1);
26 | shp.graphics.drawCircle(0, 0, 50); // 绘制圆形的方法与绘制矩形类似,只需将 drawRect() 方法改为 drawCircle() 方法x
27 | // 圆心的X轴和Y轴位置是相对于 Shape 对象的锚点计算的
28 | // drawCircle() 方法接受三个参数,第一个参数为圆心的X轴坐标,第二个参数为圆心的Y轴坐标,第三个参数为半径
29 | shp.graphics.endFill();
30 | this.addChild(shp);
31 |
32 | // 直线
33 | // moveTo() 和 lineTo(),它们输入参数是一对坐标值。moveTo() 负责绘制直线的起始点,lineTo() 负责绘制直线的终点
34 | var shp = new egret.Shape();
35 | // 在绘图直线前,需要先制定线条的样式,设置 lineStyle() 方法
36 | shp.graphics.lineStyle(2, 0x00ff00);
37 | // 然后使用 moveTo() 来设定线条的起始点,使用 lineTo() 来设定线条的终点
38 | shp.graphics.moveTo(10, 10);
39 | shp.graphics.lineTo(100, 20);
40 | shp.graphics.endFill();
41 | this.addChild(shp);
42 |
43 | // 多直线组成的折线
44 | var shp = new egret.Shape();
45 | shp.graphics.lineStyle(2, 0x00ff00);
46 | shp.graphics.moveTo(68, 84);
47 | // 绘制折线时,无需多次使用 moveTo() 方法,连续使用 lineTo() 方法即可
48 | shp.graphics.lineTo(167, 76);
49 | shp.graphics.lineTo(221, 118);
50 | shp.graphics.lineTo(290, 162);
51 | shp.graphics.lineTo(297, 228);
52 | shp.graphics.lineTo(412, 250);
53 | shp.graphics.lineTo(443, 174);
54 | shp.graphics.endFill();
55 | this.addChild(shp);
56 |
57 | // 曲线
58 | var shp = new egret.Shape();
59 | shp.graphics.lineStyle( 2, 0x00ff00 );
60 | shp.graphics.moveTo( 50, 50);
61 | shp.graphics.curveTo( 100,100, 200,50);
62 | shp.graphics.endFill();
63 | this.addChild( shp );
64 |
65 | // 圆弧
66 | var shp = new egret.Shape();
67 | shp.graphics.beginFill( 0x1122cc );
68 | // 前两个参数是圆弧路径的圆心位置,radius 是圆弧半径。startAngle 是圆弧起点的角度,从x 轴方向开始计算,以弧度为单位,endAngle 是圆弧终点的角度,anticlockwise 控制绘制方向,如果为 true,逆时针绘制圆弧,反之,顺时针绘制
69 | shp.graphics.drawArc(150,200,20,0,Math.PI,true);
70 | shp.graphics.endFill();
71 | this.addChild( shp );
72 | }
73 | }
74 | window['Main'] = Main;
75 | egret.runEgret();
--------------------------------------------------------------------------------
/2.显示对象和显示容器/变换操作/main.js:
--------------------------------------------------------------------------------
1 | class Main extends egret.DisplayObjectContainer {
2 | constructor() {
3 | super();
4 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
5 | }
6 | onAddToStage(event) {
7 | var shp = new egret.Shape();
8 | shp.graphics.beginFill(0x00ff00);
9 | shp.graphics.drawRect(0, 0, 100, 100);
10 | shp.graphics.endFill();
11 | // 1.位置和平移
12 | // 绘制了一个绿色的正方形,锚点默认在正方形的左上角位置,通过设置 shp 的 x、y属性来改变正方形的位置
13 | shp.x = 100;
14 | shp.y = 100;
15 |
16 | // 2.修改锚点
17 | // 可通过anchorOffsetX和 anchorOffsetY属性访问修改锚点的位置
18 | // 修改上例锚点的位置,让锚点居于正方形左上角x轴 50 像素的位置
19 | shp.anchorOffsetX = 50;
20 | this.addChild(shp);
21 |
22 | // 3.本地坐标和舞台坐标
23 | // this.makeContainer();
24 |
25 |
26 | // 4.平移
27 | this.makeCircle();
28 | this.makeCircle();
29 |
30 | // 5.改变圆的大小
31 | this.changeCircleSize();
32 | }
33 | makeContainer() {
34 | // 创建一个空的 DisplayObjectContainer,把它的 x 和 y 坐标都改为
35 | var container = new egret.DisplayObjectContainer();
36 | container.x = 200;
37 | container.y = 200;
38 | this.addChild(container);
39 | //画一个红色的圆,添加到 container 中
40 | var circle = new egret.Shape();
41 | circle.graphics.beginFill(0xff0000);
42 | circle.graphics.drawCircle(25, 25, 25);
43 | circle.graphics.endFill();
44 | container.addChild(circle);
45 | //给圆增加点击事件
46 | circle.touchEnabled = true;
47 | circle.addEventListener(egret.TouchEvent.TOUCH_TAP, onClick, this);
48 |
49 | function onClick() {
50 | //把舞台左上角的坐标(0,0)转换为 container 内部的坐标
51 | var targetPoint = container.globalToLocal(0, 0);
52 | //重新定位圆,可以看到圆形移到了屏幕的左上角
53 | circle.x = targetPoint.x;
54 | circle.y = targetPoint.y;
55 | }
56 | }
57 | makeCircle() {
58 | //设定2个偏移量
59 | var offsetX;
60 | var offsetY;
61 | //画一个红色的圆
62 | var circle = new egret.Shape();
63 | circle.graphics.beginFill(0xff0000);
64 | circle.graphics.drawCircle(25, 25, 25);
65 | circle.graphics.endFill();
66 | this.addChild(circle);
67 | //手指按到屏幕,触发 startMove 方法
68 | circle.touchEnabled = true;
69 | circle.addEventListener(egret.TouchEvent.TOUCH_BEGIN, startMove, this);
70 | //手指离开屏幕,触发 stopMove 方法
71 | circle.addEventListener(egret.TouchEvent.TOUCH_END, stopMove, this);
72 |
73 | function startMove(e) {
74 | //计算手指和圆形的距离
75 | offsetX = e.stageX - circle.x;
76 | offsetY = e.stageY - circle.y;
77 | //手指在屏幕上移动,会触发 onMove 方法
78 | this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, onMove, this);
79 | }
80 |
81 | function stopMove(e) {
82 | console.log(22);
83 | //手指离开屏幕,移除手指移动的监听
84 | this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, onMove, this);
85 | }
86 |
87 | function onMove(e) {
88 | //通过计算手指在屏幕上的位置,计算当前对象的坐标,达到跟随手指移动的效果
89 | circle.x = e.stageX - offsetX;
90 | circle.y = e.stageY - offsetY;
91 | }
92 | }
93 |
94 | changeCircleSize() {
95 | var circle = new egret.Shape();
96 | circle.graphics.beginFill(0xff6666);
97 | circle.graphics.drawCircle(80, 60, 25);
98 | circle.graphics.endFill();
99 | console.log(circle);
100 | this.addChild(circle);
101 | //手指按到屏幕,触发 startMove 方法
102 | circle.touchEnabled = true;
103 | circle.addEventListener(egret.TouchEvent.TOUCH_TAP, changeSize, this);
104 |
105 | function changeSize() {
106 | circle.scaleX = 2;
107 | circle.scaleY = 2;
108 | }
109 | }
110 | }
111 |
112 | window['Main'] = Main;
113 | egret.runEgret();
--------------------------------------------------------------------------------
/js/egret.web.min.js:
--------------------------------------------------------------------------------
1 | var __reflect=this&&this.__reflect||function(e,t,r){e.__class__=t,r?r.push(t):r=[t],e.__types__=e.__types__?r.concat(e.__types__):r},__extends=this&&this.__extends||function(e,t){function r(){this.constructor=e}for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);r.prototype=t.prototype,e.prototype=new r},egret;!function(e){var t;!function(t){function r(e){if(window.location){var t=location.search;if(""==t)return"";t=t.slice(1);for(var r=t.split("&"),i=r.length,n=0;i>n;n++){var a=r[n],o=a.split("=");if(o[0]==e)return o[1]}}return""}t.getOption=r,e.getOption=r}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(){function e(){}return e.call=function(e,t){},e.addCallback=function(e,t){},e}();t.WebExternalInterface=r,__reflect(r.prototype,"egret.web.WebExternalInterface",["egret.ExternalInterface"]);var i=navigator.userAgent.toLowerCase();i.indexOf("egretnative")<0&&(e.ExternalInterface=r)}(t=e.web||(e.web={}))}(egret||(egret={})),function(e){var t;!function(t){function r(t){var r=JSON.parse(t),n=r.functionName,a=i[n];if(a){var o=r.value;a.call(null,o)}else e.$warn(1050,n)}var i={},n=function(){function e(){}return e.call=function(e,t){var r={};r.functionName=e,r.value=t,egret_native.sendInfoToPlugin(JSON.stringify(r))},e.addCallback=function(e,t){i[e]=t},e}();t.NativeExternalInterface=n,__reflect(n.prototype,"egret.web.NativeExternalInterface",["egret.ExternalInterface"]);var a=navigator.userAgent.toLowerCase();a.indexOf("egretnative")>=0&&(e.ExternalInterface=n,egret_native.receivedPluginInfo=r)}(t=e.web||(e.web={}))}(egret||(egret={})),function(e){var t;!function(t){var r={},i=function(){function t(){}return t.call=function(e,t){__global.ExternalInterface.call(e,t)},t.addCallback=function(e,t){r[e]=t},t.invokeCallback=function(t,i){var n=r[t];n?n.call(null,i):e.$warn(1050,t)},t}();t.WebViewExternalInterface=i,__reflect(i.prototype,"egret.web.WebViewExternalInterface",["egret.ExternalInterface"]);var n=navigator.userAgent.toLowerCase();n.indexOf("egretwebview")>=0&&(e.ExternalInterface=i)}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(){var e=r.call(this)||this;return e.loaded=!1,e}return __extends(i,r),Object.defineProperty(i.prototype,"length",{get:function(){if(this.originAudio)return this.originAudio.duration;throw new Error("sound not loaded!")},enumerable:!0,configurable:!0}),i.prototype.load=function(t){function r(){i.$recycle(this.url,s),a(),c.indexOf("firefox")>=0&&(s.pause(),s.muted=!1),o.loaded=!0,o.dispatchEventWith(e.Event.COMPLETE)}function n(){a(),o.dispatchEventWith(e.IOErrorEvent.IO_ERROR)}function a(){s.removeEventListener("canplaythrough",r),s.removeEventListener("error",n)}var o=this;this.url=t;var s=new Audio(t);s.addEventListener("canplaythrough",r),s.addEventListener("error",n);var c=navigator.userAgent.toLowerCase();c.indexOf("firefox")>=0&&(s.autoplay=!0,s.muted=!0),s.load(),this.originAudio=s,i.clearAudios[this.url]&&delete i.clearAudios[this.url]},i.prototype.play=function(r,n){r=+r||0,n=+n||0;var a=i.$pop(this.url);null==a&&(a=this.originAudio.cloneNode()),a.autoplay=!0;var o=new t.HtmlSoundChannel(a);return o.$url=this.url,o.$loops=n,o.$startTime=r,o.$play(),e.sys.$pushSoundChannel(o),o},i.prototype.close=function(){0==this.loaded&&this.originAudio&&(this.originAudio.src=""),this.originAudio&&(this.originAudio=null),i.$clear(this.url)},i.$clear=function(e){i.clearAudios[e]=!0;var t=i.audios[e];t&&(t.length=0)},i.$pop=function(e){var t=i.audios[e];return t&&t.length>0?t.pop():null},i.$recycle=function(e,t){if(!i.clearAudios[e]){var r=i.audios[e];null==i.audios[e]&&(r=i.audios[e]=[]),r.push(t)}},i.MUSIC="music",i.EFFECT="effect",i.audios={},i.clearAudios={},i}(e.EventDispatcher);t.HtmlSound=r,__reflect(r.prototype,"egret.web.HtmlSound",["egret.Sound"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(t){var i=r.call(this)||this;return i.$startTime=0,i.audio=null,i.isStopped=!1,i.canPlay=function(){i.audio.removeEventListener("canplay",i.canPlay);try{i.audio.currentTime=i.$startTime}catch(e){}finally{i.audio.play()}},i.onPlayEnd=function(){return 1==i.$loops?(i.stop(),void i.dispatchEventWith(e.Event.SOUND_COMPLETE)):(i.$loops>0&&i.$loops--,void i.$play())},i._volume=1,t.addEventListener("ended",i.onPlayEnd),i.audio=t,i}return __extends(i,r),i.prototype.$play=function(){if(this.isStopped)return void e.$error(1036);try{this.audio.volume=this._volume,this.audio.currentTime=this.$startTime}catch(t){return void this.audio.addEventListener("canplay",this.canPlay)}this.audio.play()},i.prototype.stop=function(){if(this.audio){this.isStopped||e.sys.$popSoundChannel(this),this.isStopped=!0;var r=this.audio;r.removeEventListener("ended",this.onPlayEnd),r.removeEventListener("canplay",this.canPlay),r.volume=0,this._volume=0,this.audio=null;var i=this.$url;window.setTimeout(function(){r.pause(),t.HtmlSound.$recycle(i,r)},200)}},Object.defineProperty(i.prototype,"volume",{get:function(){return this._volume},set:function(t){return this.isStopped?void e.$error(1036):(this._volume=t,void(this.audio&&(this.audio.volume=t)))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this.audio?this.audio.currentTime:0},enumerable:!0,configurable:!0}),i}(e.EventDispatcher);t.HtmlSoundChannel=r,__reflect(r.prototype,"egret.web.HtmlSoundChannel",["egret.SoundChannel","egret.IEventDispatcher"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(){function e(){}return e.decodeAudios=function(){if(!(e.decodeArr.length<=0||e.isDecoding)){e.isDecoding=!0;var t=e.decodeArr.shift();e.ctx.decodeAudioData(t.buffer,function(r){t.self.audioBuffer=r,t.success&&t.success(),e.isDecoding=!1,e.decodeAudios()},function(){alert("sound decode error: "+t.url+"锛乗nsee http://edn.egret.com/cn/docs/page/156"),t.fail&&t.fail(),e.isDecoding=!1,e.decodeAudios()})}},e.decodeArr=[],e.isDecoding=!1,e}();t.WebAudioDecode=r,__reflect(r.prototype,"egret.web.WebAudioDecode");var i=function(i){function n(){var e=i.call(this)||this;return e.loaded=!1,e}return __extends(n,i),Object.defineProperty(n.prototype,"length",{get:function(){if(this.audioBuffer)return this.audioBuffer.duration;throw new Error("sound not loaded!")},enumerable:!0,configurable:!0}),n.prototype.load=function(t){function i(){a.loaded=!0,a.dispatchEventWith(e.Event.COMPLETE)}function n(){a.dispatchEventWith(e.IOErrorEvent.IO_ERROR)}var a=this;this.url=t;var o=new XMLHttpRequest;o.open("GET",t,!0),o.responseType="arraybuffer",o.onreadystatechange=function(){if(4==o.readyState){var t=o.status>=400||0==o.status;t?a.dispatchEventWith(e.IOErrorEvent.IO_ERROR):(r.decodeArr.push({buffer:o.response,success:i,fail:n,self:a,url:a.url}),r.decodeAudios())}},o.send()},n.prototype.play=function(r,i){r=+r||0,i=+i||0;var n=new t.WebAudioSoundChannel;return n.$url=this.url,n.$loops=i,n.$audioBuffer=this.audioBuffer,n.$startTime=r,n.$play(),e.sys.$pushSoundChannel(n),n},n.prototype.close=function(){},n.MUSIC="music",n.EFFECT="effect",n}(e.EventDispatcher);t.WebAudioSound=i,__reflect(i.prototype,"egret.web.WebAudioSound",["egret.Sound"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(){var i=r.call(this)||this;return i.$startTime=0,i.bufferSource=null,i.context=t.WebAudioDecode.ctx,i.isStopped=!1,i._currentTime=0,i._volume=1,i.onPlayEnd=function(){return 1==i.$loops?(i.stop(),void i.dispatchEventWith(e.Event.SOUND_COMPLETE)):(i.$loops>0&&i.$loops--,void i.$play())},i._startTime=0,i.context.createGain?i.gain=i.context.createGain():i.gain=i.context.createGainNode(),i}return __extends(i,r),i.prototype.$play=function(){if(this.isStopped)return void e.$error(1036);this.bufferSource&&(this.bufferSource.onended=null,this.bufferSource=null);var t=this.context,r=this.gain,i=t.createBufferSource();this.bufferSource=i,i.buffer=this.$audioBuffer,i.connect(r),r.connect(t.destination),i.onended=this.onPlayEnd,this._startTime=Date.now(),this.gain.gain.value=this._volume,i.start(0,this.$startTime),this._currentTime=0},i.prototype.stop=function(){if(this.bufferSource){var t=this.bufferSource;t.stop?t.stop(0):t.noteOff(0),t.onended=null,t.disconnect(),this.bufferSource=null,this.$audioBuffer=null}this.isStopped||e.sys.$popSoundChannel(this),this.isStopped=!0},Object.defineProperty(i.prototype,"volume",{get:function(){return this._volume},set:function(t){return this.isStopped?void e.$error(1036):(this._volume=t,void(this.gain.gain.value=t))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this.bufferSource?(Date.now()-this._startTime)/1e3+this.$startTime:0},enumerable:!0,configurable:!0}),i}(e.EventDispatcher);t.WebAudioSoundChannel=r,__reflect(r.prototype,"egret.web.WebAudioSoundChannel",["egret.SoundChannel","egret.IEventDispatcher"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(r,i){void 0===i&&(i=!0);var n=t.call(this)||this;return n.loaded=!1,n.closed=!1,n.heightSet=0/0,n.widthSet=0/0,n.waiting=!1,n.userPause=!1,n.userPlay=!1,n.isPlayed=!1,n.screenChanged=function(t){var r=document.fullscreenEnabled||document.webkitIsFullScreen;r||(n.checkFullScreen(!1),e.Capabilities.isMobile||(n._fullscreen=r))},n._fullscreen=!0,n.onVideoLoaded=function(){n.video.removeEventListener("canplay",n.onVideoLoaded);var t=n.video;n.loaded=!0,n.posterData&&(n.posterData.width=n.getPlayWidth(),n.posterData.height=n.getPlayHeight()),t.width=t.videoWidth,t.height=t.videoHeight,window.setTimeout(function(){n.dispatchEventWith(e.Event.COMPLETE)},200)},n.$renderNode=new e.sys.BitmapNode,n.src=r,n.once(e.Event.ADDED_TO_STAGE,n.loadPoster,n),r&&n.load(),n}return __extends(r,t),r.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(1)},r.prototype.load=function(t,r){var i=this;if(void 0===r&&(r=!0),t=t||this.src,this.src=t,!this.video||this.video.src!=t){var n;!this.video||e.Capabilities.isMobile?(n=document.createElement("video"),this.video=n,n.controls=null):n=this.video,n.src=t,n.setAttribute("autoplay","autoplay"),n.setAttribute("webkit-playsinline","true"),n.addEventListener("canplay",this.onVideoLoaded),n.addEventListener("error",function(){return i.onVideoError()}),n.addEventListener("ended",function(){return i.onVideoEnded()});var a=!1;n.addEventListener("canplay",function(){i.waiting=!1,a?i.userPause?i.pause():i.userPlay&&i.play():(a=!0,n.pause())}),n.addEventListener("waiting",function(){i.waiting=!0}),n.load(),this.videoPlay(),n.style.position="absolute",n.style.top="0px",n.style.zIndex="-88888",n.style.left="0px",n.height=1,n.width=1}},r.prototype.play=function(t,r){var i=this;if(void 0===r&&(r=!1),0==this.loaded)return this.load(this.src),void this.once(e.Event.COMPLETE,function(e){return i.play(t,r)},this);this.isPlayed=!0;var n=this.video;void 0!=t&&(n.currentTime=+t||0),n.loop=!!r,e.Capabilities.isMobile?n.style.zIndex="-88888":n.style.zIndex="9999",n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.height=n.videoHeight,n.width=n.videoWidth,"Windows PC"!=e.Capabilities.os&&"Mac OS"!=e.Capabilities.os&&window.setTimeout(function(){n.width=0},1e3),this.checkFullScreen(this._fullscreen)},r.prototype.videoPlay=function(){return this.userPause=!1,this.waiting?void(this.userPlay=!0):(this.userPlay=!1,void this.video.play())},r.prototype.checkFullScreen=function(t){var r=this.video;if(t)null==r.parentElement&&(r.removeAttribute("webkit-playsinline"),document.body.appendChild(r)),e.stopTick(this.markDirty,this),this.goFullscreen();else if(null!=r.parentElement&&r.parentElement.removeChild(r),r.setAttribute("webkit-playsinline","true"),this.setFullScreenMonitor(!1),e.startTick(this.markDirty,this),e.Capabilities.isMobile)return this.video.currentTime=0,void this.onVideoEnded();this.videoPlay()},r.prototype.goFullscreen=function(){var t,r=this.video;return t=e.web.getPrefixStyleName("requestFullscreen",r),r[t]||(t=e.web.getPrefixStyleName("requestFullScreen",r),r[t])?(r.removeAttribute("webkit-playsinline"),r[t](),this.setFullScreenMonitor(!0),!0):!0},r.prototype.setFullScreenMonitor=function(e){var t=this.video;e?(t.addEventListener("mozfullscreenchange",this.screenChanged),t.addEventListener("webkitfullscreenchange",this.screenChanged),t.addEventListener("mozfullscreenerror",this.screenError),t.addEventListener("webkitfullscreenerror",this.screenError)):(t.removeEventListener("mozfullscreenchange",this.screenChanged),t.removeEventListener("webkitfullscreenchange",this.screenChanged),t.removeEventListener("mozfullscreenerror",this.screenError),t.removeEventListener("webkitfullscreenerror",this.screenError))},r.prototype.screenError=function(){e.$error(3014)},r.prototype.exitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.oCancelFullScreen?document.oCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()},r.prototype.onVideoEnded=function(){this.pause(),this.isPlayed=!1,this.dispatchEventWith(e.Event.ENDED)},r.prototype.onVideoError=function(){this.dispatchEventWith(e.IOErrorEvent.IO_ERROR)},r.prototype.close=function(){var e=this;this.closed=!0,this.video.removeEventListener("canplay",this.onVideoLoaded),this.video.removeEventListener("error",function(){return e.onVideoError()}),this.video.removeEventListener("ended",function(){return e.onVideoEnded()}),this.pause(),0==this.loaded&&this.video&&(this.video.src=""),this.video&&this.video.parentElement&&(this.video.parentElement.removeChild(this.video),this.video=null),this.loaded=!1},r.prototype.pause=function(){return this.userPlay=!1,this.waiting?void(this.userPause=!0):(this.userPause=!1,this.video.pause(),void e.stopTick(this.markDirty,this))},Object.defineProperty(r.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(e){this.video&&(this.video.volume=e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"position",{get:function(){return this.video?this.video.currentTime:0},set:function(e){this.video&&(this.video.currentTime=e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fullscreen",{get:function(){return this._fullscreen},set:function(t){e.Capabilities.isMobile||(this._fullscreen=!!t,this.video&&0==this.video.paused&&this.checkFullScreen(this._fullscreen))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bitmapData",{get:function(){return this.video&&this.loaded?(this._bitmapData||(this.video.width=this.video.videoWidth,this.video.height=this.video.videoHeight,this._bitmapData=new e.BitmapData(this.video),this._bitmapData.$deleteSource=!1),this._bitmapData):null},enumerable:!0,configurable:!0}),r.prototype.loadPoster=function(){var t=this,r=this.poster;if(r){var i=new e.ImageLoader;i.once(e.Event.COMPLETE,function(r){i.data;if(t.posterData=i.data,t.$renderDirty=!0,t.posterData.width=t.getPlayWidth(),t.posterData.height=t.getPlayHeight(),e.nativeRender){var n=new e.Texture;n._setBitmapData(t.posterData),t.$nativeDisplayObject.setBitmapData(n)}},this),i.load(r)}},r.prototype.$measureContentBounds=function(e){var t=this.bitmapData,r=this.posterData;t?e.setTo(0,0,this.getPlayWidth(),this.getPlayHeight()):r?e.setTo(0,0,this.getPlayWidth(),this.getPlayHeight()):e.setEmpty()},r.prototype.getPlayWidth=function(){return isNaN(this.widthSet)?this.bitmapData?this.bitmapData.width:this.posterData?this.posterData.width:0/0:this.widthSet},r.prototype.getPlayHeight=function(){return isNaN(this.heightSet)?this.bitmapData?this.bitmapData.height:this.posterData?this.posterData.height:0/0:this.heightSet},r.prototype.$updateRenderNode=function(){var t=this.$renderNode,r=this.bitmapData,i=this.posterData,n=this.getPlayWidth(),a=this.getPlayHeight();this.isPlayed&&!e.Capabilities.isMobile||!i?this.isPlayed&&r&&(t.image=r,t.imageWidth=r.width,t.imageHeight=r.height,e.WebGLUtils.deleteWebGLTexture(r.webGLTexture),r.webGLTexture=null,t.drawImage(0,0,r.width,r.height,0,0,n,a)):(t.image=i,t.imageWidth=n,t.imageHeight=a,t.drawImage(0,0,i.width,i.height,0,0,n,a))},r.prototype.markDirty=function(){return this.$renderDirty=!0,!0},r.prototype.$setHeight=function(e){if(this.heightSet=e,this.paused){var r=this;this.$renderDirty=!0,window.setTimeout(function(){r.$renderDirty=!1},200)}t.prototype.$setHeight.call(this,e)},r.prototype.$setWidth=function(e){if(this.widthSet=e,this.paused){var r=this;this.$renderDirty=!0,window.setTimeout(function(){r.$renderDirty=!1},200)}t.prototype.$setWidth.call(this,e)},Object.defineProperty(r.prototype,"paused",{get:function(){return this.video?this.video.paused:!0},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"length",{get:function(){if(this.video)return this.video.duration;throw new Error("Video not loaded!")},enumerable:!0,configurable:!0}),r}(e.DisplayObject);t.WebVideo=r,__reflect(r.prototype,"egret.web.WebVideo",["egret.Video","egret.DisplayObject"]),e.Video=r}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(){var e=t.call(this)||this;return e._url="",e._method="",e}return __extends(r,t),Object.defineProperty(r.prototype,"response",{get:function(){if(!this._xhr)return null;if(void 0!=this._xhr.response)return this._xhr.response;if("text"==this._responseType)return this._xhr.responseText;if("arraybuffer"==this._responseType&&/msie 9.0/i.test(navigator.userAgent)){var e=window;return e.convertResponseBodyToText(this._xhr.responseBody)}return"document"==this._responseType?this._xhr.responseXML:null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"responseType",{get:function(){return this._responseType},set:function(e){this._responseType=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"withCredentials",{get:function(){return this._withCredentials},set:function(e){this._withCredentials=e},enumerable:!0,configurable:!0}),r.prototype.getXHR=function(){return window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP")},r.prototype.open=function(e,t){void 0===t&&(t="GET"),this._url=e,this._method=t,this._xhr&&(this._xhr.abort(),this._xhr=null),this._xhr=this.getXHR(),this._xhr.onreadystatechange=this.onReadyStateChange.bind(this),this._xhr.onprogress=this.updateProgress.bind(this),this._xhr.open(this._method,this._url,!0)},r.prototype.send=function(e){if(null!=this._responseType&&(this._xhr.responseType=this._responseType),null!=this._withCredentials&&(this._xhr.withCredentials=this._withCredentials),this.headerObj)for(var t in this.headerObj)this._xhr.setRequestHeader(t,this.headerObj[t]);this._xhr.send(e)},r.prototype.abort=function(){this._xhr&&this._xhr.abort()},r.prototype.getAllResponseHeaders=function(){if(!this._xhr)return null;var e=this._xhr.getAllResponseHeaders();return e?e:""},r.prototype.setRequestHeader=function(e,t){this.headerObj||(this.headerObj={}),this.headerObj[e]=t},r.prototype.getResponseHeader=function(e){if(!this._xhr)return null;var t=this._xhr.getResponseHeader(e);return t?t:""},r.prototype.onReadyStateChange=function(){var t=this._xhr;if(4==t.readyState){var r=t.status>=400||0==t.status,i=(this._url,this);window.setTimeout(function(){r?i.dispatchEventWith(e.IOErrorEvent.IO_ERROR):i.dispatchEventWith(e.Event.COMPLETE)},0)}},r.prototype.updateProgress=function(t){t.lengthComputable&&e.ProgressEvent.dispatchProgressEvent(this,e.ProgressEvent.PROGRESS,t.loaded,t.total)},r}(e.EventDispatcher);t.WebHttpRequest=r,__reflect(r.prototype,"egret.web.WebHttpRequest",["egret.HttpRequest"]),e.HttpRequest=r}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=window.URL||window.webkitURL,i=function(i){function n(){var e=null!==i&&i.apply(this,arguments)||this;return e.data=null,e._crossOrigin=null,e._hasCrossOriginSet=!1,e.currentImage=null,e.request=null,e}return __extends(n,i),Object.defineProperty(n.prototype,"crossOrigin",{get:function(){return this._crossOrigin},set:function(e){this._hasCrossOriginSet=!0,this._crossOrigin=e},enumerable:!0,configurable:!0}),n.prototype.load=function(r){if(t.Html5Capatibility._canUseBlob&&0!=r.indexOf("wxLocalResource:")&&0!=r.indexOf("data:")&&0!=r.indexOf("http:")&&0!=r.indexOf("https:")){var i=this.request;i||(i=this.request=new e.web.WebHttpRequest,i.addEventListener(e.Event.COMPLETE,this.onBlobLoaded,this),i.addEventListener(e.IOErrorEvent.IO_ERROR,this.onBlobError,this),i.responseType="blob"),i.open(r),i.send()}else this.loadImage(r)},n.prototype.onBlobLoaded=function(e){var t=this.request.response;this.request=void 0,this.loadImage(r.createObjectURL(t))},n.prototype.onBlobError=function(e){this.dispatchIOError(this.currentURL),this.request=void 0},n.prototype.loadImage=function(e){var t=new Image;this.data=null,this.currentImage=t,this._hasCrossOriginSet?this._crossOrigin&&(t.crossOrigin=this._crossOrigin):n.crossOrigin&&(t.crossOrigin=n.crossOrigin),t.onload=this.onImageComplete.bind(this),t.onerror=this.onLoadError.bind(this),t.src=e},n.prototype.onImageComplete=function(t){var r=this.getImage(t);if(r){this.data=new e.BitmapData(r);var i=this;window.setTimeout(function(){i.dispatchEventWith(e.Event.COMPLETE)},0)}},n.prototype.onLoadError=function(e){var t=this.getImage(e);t&&this.dispatchIOError(t.src)},n.prototype.dispatchIOError=function(t){var r=this;window.setTimeout(function(){r.dispatchEventWith(e.IOErrorEvent.IO_ERROR)},0)},n.prototype.getImage=function(t){var i=t.target,n=i.src;if(0==n.indexOf("blob:"))try{r.revokeObjectURL(i.src)}catch(a){e.$warn(1037)}return i.onerror=null,i.onload=null,this.currentImage!==i?null:(this.currentImage=null,i)},n.crossOrigin=null,n}(e.EventDispatcher);t.WebImageLoader=i,__reflect(i.prototype,"egret.web.WebImageLoader",["egret.ImageLoader"]),e.ImageLoader=i}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(){var e=t.call(this)||this;return e._isNeedShow=!1,e.inputElement=null,e.inputDiv=null,e._gscaleX=0,e._gscaleY=0,e.textValue="",e.colorValue=16777215,e._styleInfoes={},e}return __extends(r,t),r.prototype.$setTextField=function(e){return this.$textfield=e,!0},r.prototype.$addToStage=function(){this.htmlInput=e.web.$getTextAdapter(this.$textfield)},r.prototype._initElement=function(){var t=this.$textfield.localToGlobal(0,0),r=t.x,i=t.y,n=this.htmlInput.$scaleX,a=this.htmlInput.$scaleY;this.inputDiv.style.left=r*n+"px",this.inputDiv.style.top=i*a+"px",this.$textfield.multiline&&this.$textfield.height>this.$textfield.size?(this.inputDiv.style.top=i*a+"px",this.inputElement.style.top=-this.$textfield.lineSpacing/2*a+"px"):(this.inputDiv.style.top=i*a+"px",this.inputElement.style.top="0px");for(var o=this.$textfield,s=1,c=1,l=0;o.parent;)s*=o.scaleX,c*=o.scaleY,l+=o.rotation,o=o.parent;var h=e.web.getPrefixStyleName("transform");this.inputDiv.style[h]="rotate("+l+"deg)",this._gscaleX=n*s,this._gscaleY=a*c},r.prototype.$show=function(){this.htmlInput.isCurrentStageText(this)?this.inputElement.onblur=null:(this.inputElement=this.htmlInput.getInputElement(this),this.$textfield.multiline?this.inputElement.type="text":this.inputElement.type=this.$textfield.inputType,this.inputDiv=this.htmlInput._inputDIV),this.htmlInput._needShow=!0,this._isNeedShow=!0,this._initElement()},r.prototype.onBlurHandler=function(){this.htmlInput.clearInputElement(),window.scrollTo(0,0)},r.prototype.executeShow=function(){this.inputElement.value=this.$getText(),null==this.inputElement.onblur&&(this.inputElement.onblur=this.onBlurHandler.bind(this)),this.$resetStageText(),this.$textfield.maxChars>0?this.inputElement.setAttribute("maxlength",this.$textfield.maxChars):this.inputElement.removeAttribute("maxlength"),this.inputElement.selectionStart=this.inputElement.value.length,this.inputElement.selectionEnd=this.inputElement.value.length,this.inputElement.focus()},r.prototype.$hide=function(){this.htmlInput&&this.htmlInput.disconnectStageText(this)},r.prototype.$getText=function(){return this.textValue||(this.textValue=""),this.textValue},r.prototype.$setText=function(e){return this.textValue=e,this.resetText(),!0},r.prototype.resetText=function(){this.inputElement&&(this.inputElement.value=this.textValue)},r.prototype.$setColor=function(e){return this.colorValue=e,this.resetColor(),!0},r.prototype.resetColor=function(){this.inputElement&&this.setElementStyle("color",e.toColorString(this.colorValue))},r.prototype.$onBlur=function(){},r.prototype._onInput=function(){var t=this;window.setTimeout(function(){t.inputElement&&t.inputElement.selectionStart==t.inputElement.selectionEnd&&(t.textValue=t.inputElement.value,e.Event.dispatchEvent(t,"updateText",!1))},0)},r.prototype.setAreaHeight=function(){var t=this.$textfield;if(t.multiline){var r=e.TextFieldUtils.$getTextHeight(t);if(t.height<=t.size)this.setElementStyle("height",t.size*this._gscaleY+"px"),this.setElementStyle("padding","0px"),this.setElementStyle("lineHeight",t.size*this._gscaleY+"px");else if(t.height=0&&(n=a[o],void 0===i[n]);o--);try{Object.defineProperty(i,"imageSmoothingEnabled",{get:function(){return this[n]},set:function(e){this[n]=e}})}catch(s){i.imageSmoothingEnabled=i[n]}}return r}var r=function(){function e(e,r,i){this.surface=t(e,r),this.context=this.surface.getContext("2d"),this.context&&(this.context.$offsetX=0,this.context.$offsetY=0)}return Object.defineProperty(e.prototype,"width",{get:function(){return this.surface.width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this.surface.height},enumerable:!0,configurable:!0}),e.prototype.resize=function(e,t,r){var i=this.surface;if(r){var n=!1;i.widthi;i++)e.onTouchBegin(t.changedTouches[i]);e.prevent(t)},!1),this.canvas.addEventListener("touchmove",function(t){for(var r=t.changedTouches.length,i=0;r>i;i++)e.onTouchMove(t.changedTouches[i]);e.prevent(t)},!1),this.canvas.addEventListener("touchend",function(t){for(var r=t.changedTouches.length,i=0;r>i;i++)e.onTouchEnd(t.changedTouches[i]);e.prevent(t)},!1),this.canvas.addEventListener("touchcancel",function(t){for(var r=t.changedTouches.length,i=0;r>i;i++)e.onTouchEnd(t.changedTouches[i]);e.prevent(t)},!1)},r.prototype.prevent=function(e){e.stopPropagation(),1==e.isScroll||this.canvas.userTyping||e.preventDefault()},r.prototype.getLocation=function(t){t.identifier=+t.identifier||0;var r=document.documentElement,i=this.canvas.getBoundingClientRect(),n=i.left+window.pageXOffset-r.clientLeft,a=i.top+window.pageYOffset-r.clientTop,o=t.pageX-n,s=o,c=t.pageY-a,l=c;return 90==this.rotation?(s=c,l=i.width-o):-90==this.rotation&&(s=i.height-c,l=o),s/=this.scaleX,l/=this.scaleY,e.$TempPoint.setTo(Math.round(s),Math.round(l))},r.prototype.updateScaleMode=function(e,t,r){this.scaleX=e,this.scaleY=t,this.rotation=r},r.prototype.$updateMaxTouches=function(){this.touch.$initMaxTouches()},r}(e.HashObject);t.WebTouchHandler=r,__reflect(r.prototype,"egret.web.WebTouchHandler")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){e.WebLifeCycleHandler=function(e){var t=function(){document[r]?e.pause():e.resume()};window.addEventListener("focus",e.resume,!1),window.addEventListener("blur",e.pause,!1);var r,i;"undefined"!=typeof document.hidden?(r="hidden",i="visibilitychange"):"undefined"!=typeof document.mozHidden?(r="mozHidden",i="mozvisibilitychange"):"undefined"!=typeof document.msHidden?(r="msHidden",i="msvisibilitychange"):"undefined"!=typeof document.webkitHidden?(r="webkitHidden",i="webkitvisibilitychange"):"undefined"!=typeof document.oHidden&&(r="oHidden",i="ovisibilitychange"),"onpageshow"in window&&"onpagehide"in window&&(window.addEventListener("pageshow",e.resume,!1),window.addEventListener("pagehide",e.pause,!1)),r&&i&&document.addEventListener(i,t,!1);var n=navigator.userAgent,a=/micromessenger/gi.test(n),o=/mqq/gi.test(n),s=/mobile.*qq/gi.test(n);if((s||a)&&(o=!1),o){var c=window.browser||{};c.execWebFn=c.execWebFn||{},c.execWebFn.postX5GamePlayerMessage=function(t){var r=t.type;"app_enter_background"==r?e.pause():"app_enter_foreground"==r&&e.resume()},window.browser=c}}}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){function r(e,t){var r="";if(null!=t)r=i(e,t);else{if(null==o){var n=document.createElement("div").style;o=i("transform",n)}r=o}return""==r?e:r+e.charAt(0).toUpperCase()+e.substring(1,e.length)}function i(e,t){if(e in t)return"";e=e.charAt(0).toUpperCase()+e.substring(1,e.length);for(var r=["webkit","ms","Moz","O"],i=0;i=0?s&&a&&i.setAudioType(n.WEB_AUDIO):(r.indexOf("iphone")>=0||r.indexOf("ipad")>=0||r.indexOf("ipod")>=0)&&i.getIOSVersion()>=7&&(i._canUseBlob=!0,s&&a&&i.setAudioType(n.WEB_AUDIO));var l=window.URL||window.webkitURL;l||(i._canUseBlob=!1),r.indexOf("egretnative")>=0&&(i.setAudioType(n.HTML5_AUDIO),i._canUseBlob=!0),e.Sound=i._AudioClass},i.setAudioType=function(t){switch(i._audioType=t,t){case n.WEB_AUDIO:i._AudioClass=e.web.WebAudioSound;break;case n.HTML5_AUDIO:i._AudioClass=e.web.HtmlSound}},i.getIOSVersion=function(){var e=i.ua.toLowerCase().match(/cpu [^\d]*\d.*like mac os x/);if(!e||0==e.length)return 0;var t=e[0];return parseInt(t.match(/\d+(_\d)*/)[0])||0},i._canUseBlob=!1,i._audioType=0,i.ua="",i}(e.HashObject);t.Html5Capatibility=a,__reflect(a.prototype,"egret.web.Html5Capatibility");var o=null;t.getPrefixStyleName=r,t.getPrefix=i}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){function r(){if(s)for(var e=document.querySelectorAll(".egret-player"),t=e.length,r=0;t>r;r++){var i=e[r],n=i["egret-player"];n.updateScreenSize()}}function i(r){if(!s){s=!0,r||(r={});var i=navigator.userAgent.toLowerCase();if(i.indexOf("egretnative")>=0&&-1==i.indexOf("egretwebview")&&(e.Capabilities.runtimeType=e.RuntimeType.RUNTIME2),i.indexOf("egretnative")>=0&&e.nativeRender)egret_native.addModuleCallback(function(){if(t.Html5Capatibility.$init(),"webgl"==r.renderMode){var i=r.antialias;t.WebGLRenderContext.antialias=!!i}e.sys.CanvasRenderBuffer=t.CanvasRenderBuffer,n(r.renderMode),egret_native.nrSetRenderMode(2);var s;s=r.canvasScaleFactor?r.canvasScaleFactor:r.calculateCanvasScaleFactor?r.calculateCanvasScaleFactor(e.sys.canvasHitTestBuffer.context):window.devicePixelRatio,e.sys.DisplayList.$canvasScaleFactor=s;var l=e.ticker;a(l),r.screenAdapter?e.sys.screenAdapter=r.screenAdapter:e.sys.screenAdapter||(e.sys.screenAdapter=new e.sys.DefaultScreenAdapter);for(var h=document.querySelectorAll(".egret-player"),u=h.length,d=0;u>d;d++){var f=h[d],p=new t.WebPlayer(f,r);f["egret-player"]=p}window.addEventListener("resize",function(){isNaN(c)&&(c=window.setTimeout(o,300))})},null),egret_native.initNativeRender();else{t.Html5Capatibility._audioType=r.audioType,t.Html5Capatibility.$init();var l=r.renderMode;if("webgl"==l){var h=r.antialias;t.WebGLRenderContext.antialias=!!h}e.sys.CanvasRenderBuffer=t.CanvasRenderBuffer,i.indexOf("egretnative")>=0&&"webgl"!=l&&(e.$warn(1051),l="webgl"),n(l);var u=void 0;if(r.canvasScaleFactor)u=r.canvasScaleFactor;else if(r.calculateCanvasScaleFactor)u=r.calculateCanvasScaleFactor(e.sys.canvasHitTestBuffer.context);else{var d=e.sys.canvasHitTestBuffer.context,f=d.backingStorePixelRatio||d.webkitBackingStorePixelRatio||d.mozBackingStorePixelRatio||d.msBackingStorePixelRatio||d.oBackingStorePixelRatio||d.backingStorePixelRatio||1;u=(window.devicePixelRatio||1)/f}e.sys.DisplayList.$canvasScaleFactor=u;var p=e.ticker;a(p),r.screenAdapter?e.sys.screenAdapter=r.screenAdapter:e.sys.screenAdapter||(e.sys.screenAdapter=new e.sys.DefaultScreenAdapter);for(var v=document.querySelectorAll(".egret-player"),g=v.length,y=0;g>y;y++){var x=v[y],m=new t.WebPlayer(x,r);x["egret-player"]=m}window.addEventListener("resize",function(){isNaN(c)&&(c=window.setTimeout(o,300))})}}}function n(r){"webgl"==r&&e.WebGLUtils.checkCanUseWebGL()?(e.sys.RenderBuffer=t.WebGLRenderBuffer,e.sys.systemRenderer=new t.WebGLRenderer,e.sys.canvasRenderer=new e.CanvasRenderer,e.sys.customHitTestBuffer=new t.WebGLRenderBuffer(3,3),e.sys.canvasHitTestBuffer=new t.CanvasRenderBuffer(3,3),e.Capabilities.renderMode="webgl"):(e.sys.RenderBuffer=t.CanvasRenderBuffer,e.sys.systemRenderer=new e.CanvasRenderer,e.sys.canvasRenderer=e.sys.systemRenderer,e.sys.customHitTestBuffer=new t.CanvasRenderBuffer(3,3),e.sys.canvasHitTestBuffer=e.sys.customHitTestBuffer,e.Capabilities.renderMode="canvas")}function a(e){function t(){e.update(),r(t)}var r=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;r||(r=function(e){return window.setTimeout(e,1e3/60)}),r(t)}function o(){c=0/0,e.updateAllScreens()}var s=!1;window.isNaN=function(e){return e=+e,e!==e},e.runEgret=i,e.updateAllScreens=r;var c=0/0}(t=e.web||(e.web={}))}(egret||(egret={}));var language,egret;!function(e){var t;!function(t){var r=function(){function t(){}return t.detect=function(){var r=e.Capabilities,i=navigator.userAgent.toLowerCase();r.isMobile=-1!=i.indexOf("mobile")||-1!=i.indexOf("android"),r.isMobile?i.indexOf("windows")<0&&(-1!=i.indexOf("iphone")||-1!=i.indexOf("ipad")||-1!=i.indexOf("ipod"))?r.os="iOS":-1!=i.indexOf("android")&&-1!=i.indexOf("linux")?r.os="Android":-1!=i.indexOf("windows")&&(r.os="Windows Phone"):-1!=i.indexOf("windows nt")?r.os="Windows PC":-1!=i.indexOf("mac os")&&(r.os="Mac OS");var n=(navigator.language||navigator.browserLanguage).toLowerCase(),a=n.split("-");a.length>1&&(a[1]=a[1].toUpperCase()),r.language=a.join("-"),t.injectUIntFixOnIE9()},t.injectUIntFixOnIE9=function(){if(/msie 9.0/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)){var e="\r\n\r\n\r\n\r\n";document.write(e)}},t}();t.WebCapability=r,__reflect(r.prototype,"egret.web.WebCapability"),r.detect()}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(){function t(t,r,i,n,a){if(this.showPanle=!0,this.fpsHeight=0,this.WIDTH=101,this.HEIGHT=20,this.bgCanvasColor="#18304b",this.fpsFrontColor="#18fefe",this.WIDTH_COST=50,this.cost1Color="#18fefe",this.cost3Color="#ff0000",this.arrFps=[],this.arrCost=[],this.arrLog=[],r||i){"canvas"==e.Capabilities.renderMode?this.renderMode="Canvas":this.renderMode="WebGL",this.panelX=void 0===a.x?0:parseInt(a.x),this.panelY=void 0===a.y?0:parseInt(a.y),this.fontColor=void 0===a.textColor?"#ffffff":a.textColor.replace("0x","#"),this.fontSize=void 0===a.size?12:parseInt(a.size),e.Capabilities.isMobile&&(this.fontSize-=2);var o=document.createElement("div");o.style.position="absolute",o.style.background="rgba(0,0,0,"+a.bgAlpha+")",o.style.left=this.panelX+"px",o.style.top=this.panelY+"px",o.style.pointerEvents="none",document.body.appendChild(o);var s=document.createElement("div");s.style.color=this.fontColor,s.style.fontSize=this.fontSize+"px",s.style.lineHeight=this.fontSize+"px",s.style.margin="4px 4px 4px 4px",this.container=s,o.appendChild(s),r&&this.addFps(),i&&this.addLog()}}return t.prototype.addFps=function(){var e=document.createElement("div");e.style.display="inline-block",this.containerFps=e,this.container.appendChild(e);var t=document.createElement("div");t.style.paddingBottom="2px",this.fps=t,this.containerFps.appendChild(t),t.innerHTML="0 FPS "+this.renderMode+"
min0 max0 avg0";var r=document.createElement("canvas");this.containerFps.appendChild(r),r.width=this.WIDTH,r.height=this.HEIGHT,this.canvasFps=r;var i=r.getContext("2d");this.contextFps=i,i.fillStyle=this.bgCanvasColor,i.fillRect(0,0,this.WIDTH,this.HEIGHT);var n=document.createElement("div");this.divDatas=n,this.containerFps.appendChild(n);var a=document.createElement("div");a.style["float"]="left",a.innerHTML="Draw
Cost",n.appendChild(a);var o=document.createElement("div");o.style.paddingLeft=a.offsetWidth+20+"px",n.appendChild(o);var s=document.createElement("div");this.divDraw=s,s.innerHTML="0
",o.appendChild(s);var c=document.createElement("div");this.divCost=c,c.innerHTML='0 0',o.appendChild(c),r=document.createElement("canvas"),this.canvasCost=r,this.containerFps.appendChild(r),r.width=this.WIDTH,r.height=this.HEIGHT,i=r.getContext("2d"),this.contextCost=i,i.fillStyle=this.bgCanvasColor,i.fillRect(0,0,this.WIDTH,this.HEIGHT),i.fillStyle="#000000",i.fillRect(this.WIDTH_COST,0,1,this.HEIGHT),this.fpsHeight=this.container.offsetHeight},t.prototype.addLog=function(){var e=document.createElement("div");e.style.maxWidth=document.body.clientWidth-8-this.panelX+"px",e.style.wordWrap="break-word",this.log=e,this.container.appendChild(e)},t.prototype.update=function(e,t){void 0===t&&(t=!1);var r,i,n;t?(r=this.arrFps[this.arrFps.length-1],i=this.arrCost[this.arrCost.length-1][0],n=this.arrCost[this.arrCost.length-1][1]):(r=e.fps,i=e.costTicker,n=e.costRender,this.lastNumDraw=e.draw,this.arrFps.push(r),this.arrCost.push([i,n]));var a=0,o=this.arrFps.length;o>101&&(o=101,this.arrFps.shift(),this.arrCost.shift());for(var s=this.arrFps[0],c=this.arrFps[0],l=0;o>l;l++){var h=this.arrFps[l];a+=h,s>h?s=h:h>c&&(c=h)}var u=this.WIDTH,d=this.HEIGHT,f=this.contextFps;f.drawImage(this.canvasFps,1,0,u-1,d,0,0,u-1,d),f.fillStyle=this.bgCanvasColor,f.fillRect(u-1,0,1,d);var p=Math.floor(r/60*20);1>p&&(p=1),f.fillStyle=this.fpsFrontColor,f.fillRect(u-1,20-p,1,p);var v=this.WIDTH_COST;f=this.contextCost,f.drawImage(this.canvasCost,1,0,v-1,d,0,0,v-1,d),f.drawImage(this.canvasCost,v+2,0,v-1,d,v+1,0,v-1,d);var g=Math.floor(i/2);1>g?g=1:g>20&&(g=20);var y=Math.floor(n/2);1>y?y=1:y>20&&(y=20),f.fillStyle=this.bgCanvasColor,f.fillRect(v-1,0,1,d),f.fillRect(2*v,0,1,d),f.fillRect(3*v+1,0,1,d),f.fillStyle=this.cost1Color,f.fillRect(v-1,20-g,1,g),f.fillStyle=this.cost3Color,f.fillRect(2*v,20-y,1,y);var x=Math.floor(a/o),m=r+" FPS "+this.renderMode;this.showPanle&&(m+="
min"+s+" max"+c+" avg"+x,this.divDraw.innerHTML=this.lastNumDraw+"
",this.divCost.innerHTML=''+i+' '+n+""),this.fps.innerHTML=m},t.prototype.updateInfo=function(e){this.arrLog.push(e),this.updateLogLayout()},t.prototype.updateWarn=function(e){this.arrLog.push("[Warning]"+e),this.updateLogLayout()},t.prototype.updateError=function(e){this.arrLog.push("[Error]"+e),this.updateLogLayout()},t.prototype.updateLogLayout=function(){for(this.log.innerHTML=this.arrLog.join("
");document.body.clientHeight")},t}();t.WebFps=r,__reflect(r.prototype,"egret.web.WebFps",["egret.FPSDisplay"]),e.FPSDisplay=r}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r;!function(r){function i(e){return window.localStorage.getItem(e)}function n(t,r){try{return window.localStorage.setItem(t,r),!0}catch(i){return e.$warn(1047,t,r),!1}}function a(e){window.localStorage.removeItem(e)}function o(){window.localStorage.clear()}t.getItem=i,t.setItem=n,t.removeItem=a,t.clear=o}(r=t.web||(t.web={}))}(t=e.localStorage||(e.localStorage={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(e,t){var i=r.call(this)||this;return i.init(e,t),i.initOrientation(),i}return __extends(i,r),i.prototype.init=function(r,i){var n=this.readOption(r,i),a=new e.Stage;a.$screen=this,a.$scaleMode=n.scaleMode,a.$orientation=n.orientation,a.$maxTouches=n.maxTouches,a.frameRate=n.frameRate,a.textureScaleFactor=n.textureScaleFactor;var o=new e.sys.RenderBuffer(void 0,void 0,!0),s=o.surface;this.attachCanvas(r,s);var c=new t.WebTouchHandler(a,s),l=new e.sys.Player(o,a,n.entryClassName);e.lifecycle.stage=a,e.lifecycle.addLifecycleListener(t.WebLifeCycleHandler);var h=new t.HTMLInput;(n.showFPS||n.showLog)&&(e.nativeRender||l.displayFPS(n.showFPS,n.showLog,n.logFilter,n.fpsStyles)),this.playerOption=n,this.container=r,this.canvas=s,this.stage=a,this.player=l,this.webTouchHandler=c,this.webInput=h,e.web.$cacheTextAdapter(h,a,r,s),this.updateScreenSize(),this.updateMaxTouches(),l.start()},i.prototype.initOrientation=function(){var t=this;window.addEventListener("orientationchange",function(){window.setTimeout(function(){e.StageOrientationEvent.dispatchStageOrientationEvent(t.stage,e.StageOrientationEvent.ORIENTATION_CHANGE)},350)})},i.prototype.readOption=function(t,r){var i={};i.entryClassName=t.getAttribute("data-entry-class"),i.scaleMode=t.getAttribute("data-scale-mode")||e.StageScaleMode.NO_SCALE,i.frameRate=+t.getAttribute("data-frame-rate")||30,i.contentWidth=+t.getAttribute("data-content-width")||480,i.contentHeight=+t.getAttribute("data-content-height")||800,i.orientation=t.getAttribute("data-orientation")||e.OrientationMode.AUTO,i.maxTouches=+t.getAttribute("data-multi-fingered")||2,i.textureScaleFactor=+t.getAttribute("texture-scale-factor")||1,i.showFPS="true"==t.getAttribute("data-show-fps");for(var n=t.getAttribute("data-show-fps-style")||"",a=n.split(","),o={},s=0;sa||c==e.OrientationMode.PORTRAIT&&a>o);var l=s?o:a,h=s?a:o;e.Capabilities.boundingClientWidth=l,e.Capabilities.boundingClientHeight=h;var u=e.sys.screenAdapter.calculateStageSize(this.stage.$scaleMode,l,h,r.contentWidth,r.contentHeight),d=u.stageWidth,f=u.stageHeight,p=u.displayWidth,v=u.displayHeight;t.style[e.web.getPrefixStyleName("transformOrigin")]="0% 0% 0px",t.width!=d&&(t.width=d),t.height!=f&&(t.height=f);var g=0;s?c==e.OrientationMode.LANDSCAPE?(g=90,t.style.top=n+(o-p)/2+"px",t.style.left=(a+v)/2+"px"):(g=-90,t.style.top=n+(o+p)/2+"px",t.style.left=(a-v)/2+"px"):(t.style.top=n+(o-v)/2+"px",t.style.left=(a-p)/2+"px");var y=p/d,x=v/f,m=y*e.sys.DisplayList.$canvasScaleFactor,b=x*e.sys.DisplayList.$canvasScaleFactor;"canvas"==e.Capabilities.renderMode&&(m=Math.ceil(m),b=Math.ceil(b));var w=e.Matrix.create();w.identity(),w.scale(y/m,x/b),w.rotate(g*Math.PI/180);var E="matrix("+w.a+","+w.b+","+w.c+","+w.d+","+w.tx+","+w.ty+")";e.Matrix.release(w),t.style[e.web.getPrefixStyleName("transform")]=E,e.sys.DisplayList.$setCanvasScale(m,b),this.webTouchHandler.updateScaleMode(y,x,g),this.webInput.$updateSize(),this.player.updateStageSize(d,f),e.nativeRender&&(t.width=d*m,t.height=f*b)}}},i.prototype.setContentSize=function(e,t){var r=this.playerOption;r.contentWidth=e,r.contentHeight=t,this.updateScreenSize()},i.prototype.updateMaxTouches=function(){this.webTouchHandler.$updateMaxTouches()},i}(e.HashObject);t.WebPlayer=r,__reflect(r.prototype,"egret.web.WebPlayer",["egret.sys.Screen"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){function r(t,r){s||(s=document.createElement("canvas"),c=s.getContext("2d"));var i=t.$getTextureWidth(),n=t.$getTextureHeight();null==r&&(r=e.$TempRectangle,r.x=0,r.y=0,r.width=i,r.height=n),r.x=Math.min(r.x,i-1),r.y=Math.min(r.y,n-1),r.width=Math.min(r.width,i-r.x),r.height=Math.min(r.height,n-r.y);var a=r.width,o=r.height,l=s;if(l.style.width=a+"px",l.style.height=o+"px",s.width=a,s.height=o,"webgl"==e.Capabilities.renderMode){var h=void 0;t.$renderBuffer?h=t:(h=new e.RenderTexture,h.drawToTexture(new e.Bitmap(t)));for(var u=h.$renderBuffer.getPixels(r.x,r.y,a,o),d=new ImageData(a,o),f=0;fn;n++){var a=t.childNodes[n];if(1==a.nodeType)return i(a,null)}return null}function i(e,t){if("parsererror"==e.localName)throw new Error(e.textContent);for(var r=new a(e.localName,t,e.prefix,e.namespaceURI,e.nodeName),n=e.attributes,s=r.attributes,c=n.length,l=0;c>l;l++){var h=n[l],u=h.name;0!=u.indexOf("xmlns:")&&(s[u]=h.value,r["$"+u]=h.value)}var d=e.childNodes;c=d.length;for(var f=r.children,l=0;c>l;l++){var p=d[l],v=p.nodeType,g=null;if(1==v)g=i(p,r);else if(3==v){var y=p.textContent.trim();y&&(g=new o(y,r))}g&&f.push(g)}return r}var n=function(){function e(e,t){this.nodeType=e,this.parent=t}return e}();t.XMLNode=n,__reflect(n.prototype,"egret.web.XMLNode");var a=function(e){function t(t,r,i,n,a){var o=e.call(this,1,r)||this;return o.attributes={},o.children=[],o.localName=t,o.prefix=i,o.namespace=n,o.name=a,o}return __extends(t,e),t}(n);t.XML=a,__reflect(a.prototype,"egret.web.XML");var o=function(e){function t(t,r){var i=e.call(this,3,r)||this;return i.text=t,i}return __extends(t,e),t}(n);t.XMLText=o,__reflect(o.prototype,"egret.web.XMLText");var s=new DOMParser;e.XML={parse:r}}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(){var r=null!==t&&t.apply(this,arguments)||this;return r.onChange=function(t){var i=new e.OrientationEvent(e.Event.CHANGE);i.beta=t.beta,i.gamma=t.gamma,i.alpha=t.alpha,r.dispatchEvent(i)},r}return __extends(r,t),r.prototype.start=function(){window.addEventListener("deviceorientation",this.onChange)},r.prototype.stop=function(){window.removeEventListener("deviceorientation",this.onChange)},r}(e.EventDispatcher);t.WebDeviceOrientation=r,__reflect(r.prototype,"egret.web.WebDeviceOrientation",["egret.DeviceOrientation"])}(t=e.web||(e.web={}))}(egret||(egret={})),egret.DeviceOrientation=egret.web.WebDeviceOrientation;var egret;!function(e){var t;!function(t){var r=function(t){function r(r){var i=t.call(this)||this;return i.onUpdate=function(t){var r=new e.GeolocationEvent(e.Event.CHANGE),n=t.coords;r.altitude=n.altitude,r.heading=n.heading,r.accuracy=n.accuracy,r.latitude=n.latitude,r.longitude=n.longitude,r.speed=n.speed,r.altitudeAccuracy=n.altitudeAccuracy,i.dispatchEvent(r)},i.onError=function(t){var r=e.GeolocationEvent.UNAVAILABLE;t.code==t.PERMISSION_DENIED&&(r=e.GeolocationEvent.PERMISSION_DENIED);var n=new e.GeolocationEvent(e.IOErrorEvent.IO_ERROR);n.errorType=r,n.errorMessage=t.message,i.dispatchEvent(n)},i.geolocation=navigator.geolocation,i}return __extends(r,t),r.prototype.start=function(){var t=this.geolocation;t?this.watchId=t.watchPosition(this.onUpdate,this.onError):this.onError({code:2,message:e.sys.tr(3004),PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2})},r.prototype.stop=function(){var e=this.geolocation;e.clearWatch(this.watchId)},r}(e.EventDispatcher);t.WebGeolocation=r,__reflect(r.prototype,"egret.web.WebGeolocation",["egret.Geolocation"]),e.Geolocation=e.web.WebGeolocation}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(){var r=null!==t&&t.apply(this,arguments)||this;return r.onChange=function(t){var i=new e.MotionEvent(e.Event.CHANGE),n={x:t.acceleration.x,y:t.acceleration.y,z:t.acceleration.z},a={x:t.accelerationIncludingGravity.x,y:t.accelerationIncludingGravity.y,z:t.accelerationIncludingGravity.z},o={alpha:t.rotationRate.alpha,beta:t.rotationRate.beta,gamma:t.rotationRate.gamma};i.acceleration=n,i.accelerationIncludingGravity=a,i.rotationRate=o,r.dispatchEvent(i)},r}return __extends(r,t),r.prototype.start=function(){window.addEventListener("devicemotion",this.onChange)},r.prototype.stop=function(){window.removeEventListener("devicemotion",this.onChange)},r}(e.EventDispatcher);t.WebMotion=r,__reflect(r.prototype,"egret.web.WebMotion",["egret.Motion"]),e.Motion=e.web.WebMotion}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t=function(){function e(){this.drawData=[],this.drawDataLen=0}return e.prototype.pushDrawRect=function(){if(0==this.drawDataLen||1!=this.drawData[this.drawDataLen-1].type){var e=this.drawData[this.drawDataLen]||{};e.type=1,e.count=0,this.drawData[this.drawDataLen]=e,this.drawDataLen++}this.drawData[this.drawDataLen-1].count+=2},e.prototype.pushDrawTexture=function(e,t,r,i,n){if(void 0===t&&(t=2),r){var a=this.drawData[this.drawDataLen]||{};a.type=0,a.texture=e,a.filter=r,a.count=t,a.textureWidth=i,a.textureHeight=n,this.drawData[this.drawDataLen]=a,this.drawDataLen++}else{if(0==this.drawDataLen||0!=this.drawData[this.drawDataLen-1].type||e!=this.drawData[this.drawDataLen-1].texture||this.drawData[this.drawDataLen-1].filter){var a=this.drawData[this.drawDataLen]||{};a.type=0,a.texture=e,a.count=0,this.drawData[this.drawDataLen]=a,this.drawDataLen++}this.drawData[this.drawDataLen-1].count+=t}},e.prototype.pushChangeSmoothing=function(e,t){e.smoothing=t;var r=this.drawData[this.drawDataLen]||{};r.type=10,r.texture=e,r.smoothing=t,this.drawData[this.drawDataLen]=r,this.drawDataLen++},e.prototype.pushPushMask=function(e){void 0===e&&(e=1);var t=this.drawData[this.drawDataLen]||{};t.type=2,t.count=2*e,this.drawData[this.drawDataLen]=t,this.drawDataLen++},e.prototype.pushPopMask=function(e){void 0===e&&(e=1);var t=this.drawData[this.drawDataLen]||{};t.type=3,t.count=2*e,this.drawData[this.drawDataLen]=t,this.drawDataLen++},e.prototype.pushSetBlend=function(e){for(var t=this.drawDataLen,r=!1,i=t-1;i>=0;i--){var n=this.drawData[i];if(n){if((0==n.type||1==n.type)&&(r=!0),!r&&4==n.type){this.drawData.splice(i,1),this.drawDataLen--;continue}if(4==n.type){if(n.value==e)return;break}}}var a=this.drawData[this.drawDataLen]||{};a.type=4,a.value=e,this.drawData[this.drawDataLen]=a,this.drawDataLen++},e.prototype.pushResize=function(e,t,r){var i=this.drawData[this.drawDataLen]||{};i.type=5,i.buffer=e,i.width=t,i.height=r,this.drawData[this.drawDataLen]=i,this.drawDataLen++},e.prototype.pushClearColor=function(){var e=this.drawData[this.drawDataLen]||{};e.type=6,this.drawData[this.drawDataLen]=e,this.drawDataLen++},e.prototype.pushActivateBuffer=function(e){for(var t=this.drawDataLen,r=!1,i=t-1;i>=0;i--){var n=this.drawData[i];!n||(4!=n.type&&7!=n.type&&(r=!0),r||7!=n.type)||(this.drawData.splice(i,1),this.drawDataLen--)}var a=this.drawData[this.drawDataLen]||{};a.type=7,a.buffer=e,a.width=e.rootRenderTarget.width,a.height=e.rootRenderTarget.height,this.drawData[this.drawDataLen]=a,this.drawDataLen++},e.prototype.pushEnableScissor=function(e,t,r,i){var n=this.drawData[this.drawDataLen]||{};n.type=8,n.x=e,n.y=t,n.width=r,n.height=i,this.drawData[this.drawDataLen]=n,this.drawDataLen++},e.prototype.pushDisableScissor=function(){var e=this.drawData[this.drawDataLen]||{};e.type=9,this.drawData[this.drawDataLen]=e,this.drawDataLen++},e.prototype.clear=function(){for(var e=0;er;r+=6,i+=4)this.indices[r+0]=i+0,this.indices[r+1]=i+1,this.indices[r+2]=i+2,this.indices[r+3]=i+0,this.indices[r+4]=i+2,this.indices[r+5]=i+3}return e.prototype.reachMaxSize=function(e,t){return void 0===e&&(e=4),void 0===t&&(t=6),this.vertexIndex>this.vertexMaxSize-e||this.indexIndex>this.indicesMaxSize-t},e.prototype.getVertices=function(){var e=this.vertices.subarray(0,this.vertexIndex*this.vertSize);return e},e.prototype.getIndices=function(){return this.indices},e.prototype.getMeshIndices=function(){return this.indicesForMesh},e.prototype.changeToMeshIndices=function(){if(!this.hasMesh){for(var e=0,t=this.indexIndex;t>e;++e)this.indicesForMesh[e]=this.indices[e];this.hasMesh=!0}},e.prototype.isMesh=function(){return this.hasMesh},e.prototype.cacheArrays=function(e,t,r,i,n,a,o,s,c,l,h,u,d,f,p){var v=e.globalAlpha,g=e.globalMatrix,y=g.a,x=g.b,m=g.c,b=g.d,w=g.tx,E=g.ty,T=e.$offsetX,S=e.$offsetY;if((0!=T||0!=S)&&(w=T*y+S*m+w,E=T*x+S*b+E),!d){(0!=a||0!=o)&&(w=a*y+o*m+w,E=a*x+o*b+E);var _=s/i;1!=_&&(y=_*y,x=_*x);var C=c/n;1!=C&&(m=C*m,b=C*b)}if(d){var R=this.vertices,L=this.vertexIndex*this.vertSize,D=0,$=0,A=0,M=0,I=0,B=0,O=0;for(D=0,A=u.length;A>D;D+=2)$=L+5*D/2,B=d[D],O=d[D+1],M=u[D],I=u[D+1],R[$+0]=y*B+m*O+w,R[$+1]=x*B+b*O+E,p?(R[$+2]=(t+(1-I)*n)/l,R[$+3]=(r+M*i)/h):(R[$+2]=(t+M*i)/l,R[$+3]=(r+I*n)/h),R[$+4]=v;if(this.hasMesh)for(var P=0,W=f.length;W>P;++P)this.indicesForMesh[this.indexIndex+P]=f[P]+this.vertexIndex;this.vertexIndex+=u.length/2,this.indexIndex+=f.length}else{var F=l,G=h,H=i,k=n;t/=F,r/=G;var R=this.vertices,L=this.vertexIndex*this.vertSize;if(p){var N=i;i=n/F,n=N/G,R[L++]=w,R[L++]=E,R[L++]=i+t,R[L++]=r,R[L++]=v,R[L++]=y*H+w,R[L++]=x*H+E,R[L++]=i+t,R[L++]=n+r,R[L++]=v,R[L++]=y*H+m*k+w,R[L++]=b*k+x*H+E,R[L++]=t,R[L++]=n+r,R[L++]=v,R[L++]=m*k+w,R[L++]=b*k+E,R[L++]=t,R[L++]=r,R[L++]=v}else i/=F,n/=G,R[L++]=w,R[L++]=E,R[L++]=t,R[L++]=r,R[L++]=v,R[L++]=y*H+w,R[L++]=x*H+E,R[L++]=i+t,R[L++]=r,R[L++]=v,R[L++]=y*H+m*k+w,R[L++]=b*k+x*H+E,R[L++]=i+t,R[L++]=n+r,R[L++]=v,R[L++]=m*k+w,R[L++]=b*k+E,R[L++]=t,R[L++]=n+r,R[L++]=v;if(this.hasMesh){var U=this.indicesForMesh;U[this.indexIndex+0]=0+this.vertexIndex,U[this.indexIndex+1]=1+this.vertexIndex,U[this.indexIndex+2]=2+this.vertexIndex,U[this.indexIndex+3]=0+this.vertexIndex,U[this.indexIndex+4]=2+this.vertexIndex,U[this.indexIndex+5]=3+this.vertexIndex}this.vertexIndex+=4,this.indexIndex+=6}},e.prototype.clear=function(){this.hasMesh=!1,this.vertexIndex=0,this.indexIndex=0},e}();e.WebGLVertexArrayObject=t,__reflect(t.prototype,"egret.web.WebGLVertexArrayObject")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(e,r,i){var n=t.call(this)||this;return n.clearColor=[0,0,0,0],n.useFrameBuffer=!0,n.gl=e,n.width=r||1,n.height=i||1,n}return __extends(r,t),r.prototype.resize=function(e,t){var r=this.gl;this.width=e,this.height=t,this.frameBuffer&&(r.bindTexture(r.TEXTURE_2D,this.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,e,t,0,r.RGBA,r.UNSIGNED_BYTE,null)),this.stencilBuffer&&(r.deleteRenderbuffer(this.stencilBuffer),this.stencilBuffer=null)},r.prototype.activate=function(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer())},r.prototype.getFrameBuffer=function(){return this.useFrameBuffer?this.frameBuffer:null},r.prototype.initFrameBuffer=function(){if(!this.frameBuffer){var e=this.gl;this.texture=this.createTexture(),this.frameBuffer=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this.frameBuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture,0)}},r.prototype.createTexture=function(){var e=this.gl,t=e.createTexture();return t.glContext=e,e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.width,this.height,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t},r.prototype.clear=function(e){var t=this.gl;e&&this.activate(),t.colorMask(!0,!0,!0,!0),t.clearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),t.clear(t.COLOR_BUFFER_BIT)},r.prototype.enabledStencil=function(){if(this.frameBuffer&&!this.stencilBuffer){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.frameBuffer),this.stencilBuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this.stencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,this.width,this.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,this.stencilBuffer)}},r.prototype.dispose=function(){e.WebGLUtils.deleteWebGLTexture(this.texture)},r}(e.HashObject);t.WebGLRenderTarget=r,__reflect(r.prototype,"egret.web.WebGLRenderTarget")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){function r(e,t){var r=document.createElement("canvas");return isNaN(e)||isNaN(t)||(r.width=e,r.height=t),r}var i=function(){function i(i,n){if(this.glID=null,this.projectionX=0/0,this.projectionY=0/0,this.contextLost=!1,this.$scissorState=!1,this.vertSize=5,this.surface=r(i,n),!e.nativeRender){this.initWebGL(),this.$bufferStack=[];var a=this.context;this.vertexBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),this.drawCmdManager=new t.WebGLDrawCmdManager,this.vao=new t.WebGLVertexArrayObject,this.setGlobalCompositeOperation("source-over")}}return i.getInstance=function(e,t){return this.instance?this.instance:(this.instance=new i(e,t),this.instance)},i.prototype.pushBuffer=function(e){this.$bufferStack.push(e),e!=this.currentBuffer&&(this.currentBuffer,this.drawCmdManager.pushActivateBuffer(e)),this.currentBuffer=e},i.prototype.popBuffer=function(){if(!(this.$bufferStack.length<=1)){var e=this.$bufferStack.pop(),t=this.$bufferStack[this.$bufferStack.length-1];e!=t&&this.drawCmdManager.pushActivateBuffer(t),this.currentBuffer=t}},i.prototype.activateBuffer=function(e,t,r){e.rootRenderTarget.activate(),this.bindIndices||this.uploadIndicesArray(this.vao.getIndices()),e.restoreStencil(),e.restoreScissor(),this.onResize(t,r)},i.prototype.uploadVerticesArray=function(e){var t=this.context;t.bufferData(t.ARRAY_BUFFER,e,t.STREAM_DRAW)},i.prototype.uploadIndicesArray=function(e){var t=this.context;t.bufferData(t.ELEMENT_ARRAY_BUFFER,e,t.STATIC_DRAW),this.bindIndices=!0},i.prototype.destroy=function(){this.surface.width=this.surface.height=0},i.prototype.onResize=function(e,t){e=e||this.surface.width,t=t||this.surface.height,this.projectionX=e/2,this.projectionY=-t/2,this.context&&this.context.viewport(0,0,e,t)},i.prototype.resize=function(e,t,r){var i=this.surface;r?(i.widthr;r++){var i=this.drawCmdManager.drawData[r];t=this.drawData(i,t),7==i.type&&(this.activatedBuffer=i.buffer),(0==i.type||1==i.type||2==i.type||3==i.type)&&this.activatedBuffer&&this.activatedBuffer.$computeDrawCall&&this.activatedBuffer.$drawCalls++}this.vao.isMesh()&&this.uploadIndicesArray(this.vao.getIndices()),this.drawCmdManager.clear(),this.vao.clear()}},i.prototype.drawData=function(e,r){if(e){var i,n=this.context,a=e.filter;switch(e.type){case 0:a?"custom"===a.type?i=t.EgretWebGLProgram.getProgram(n,a.$vertexSrc,a.$fragmentSrc,a.$shaderKey):"colorTransform"===a.type?i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.colorTransform_frag,"colorTransform"):"blurX"===a.type?i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.blur_frag,"blur"):"blurY"===a.type?i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.blur_frag,"blur"):"glow"===a.type&&(i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.glow_frag,"glow")):i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.texture_frag,"texture"),this.activeProgram(n,i),this.syncUniforms(i,a,e.textureWidth,e.textureHeight),r+=this.drawTextureElements(e,r);break;case 1:i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(n,i),this.syncUniforms(i,a,e.textureWidth,e.textureHeight),r+=this.drawRectElements(e,r);break;case 2:i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(n,i),this.syncUniforms(i,a,e.textureWidth,e.textureHeight),r+=this.drawPushMaskElements(e,r);break;case 3:i=t.EgretWebGLProgram.getProgram(n,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(n,i),this.syncUniforms(i,a,e.textureWidth,e.textureHeight),r+=this.drawPopMaskElements(e,r);break;case 4:this.setBlendMode(e.value);break;case 5:e.buffer.rootRenderTarget.resize(e.width,e.height),this.onResize(e.width,e.height);break;case 6:if(this.activatedBuffer){var o=this.activatedBuffer.rootRenderTarget;(0!=o.width||0!=o.height)&&o.clear(!0)}break;case 7:this.activateBuffer(e.buffer,e.width,e.height);break;case 8:var s=this.activatedBuffer;s&&(s.rootRenderTarget&&s.rootRenderTarget.enabledStencil(),s.enableScissor(e.x,e.y,e.width,e.height));break;case 9:s=this.activatedBuffer,s&&s.disableScissor();break;case 10:n.bindTexture(n.TEXTURE_2D,e.texture),e.smoothing?(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR)):(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST))}return r}},i.prototype.activeProgram=function(e,t){if(t!=this.currentProgram){e.useProgram(t.id);var r=t.attributes;for(var i in r)"aVertexPosition"===i?(e.vertexAttribPointer(r.aVertexPosition.location,2,e.FLOAT,!1,20,0),e.enableVertexAttribArray(r.aVertexPosition.location)):"aTextureCoord"===i?(e.vertexAttribPointer(r.aTextureCoord.location,2,e.FLOAT,!1,20,8),e.enableVertexAttribArray(r.aTextureCoord.location)):"aColor"===i&&(e.vertexAttribPointer(r.aColor.location,1,e.FLOAT,!1,20,16),e.enableVertexAttribArray(r.aColor.location));this.currentProgram=t}},i.prototype.syncUniforms=function(e,t,r,i){var n=e.uniforms;t&&"custom"===t.type;for(var a in n)if("projectionVector"===a)n[a].setValue({x:this.projectionX,y:this.projectionY});else if("uTextureSize"===a)n[a].setValue({x:r,y:i});else if("uSampler"===a);else{var o=t.$uniforms[a];void 0!==o&&n[a].setValue(o)}},i.prototype.drawTextureElements=function(e,t){var r=this.context;r.bindTexture(r.TEXTURE_2D,e.texture);var i=3*e.count;return r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),i},i.prototype.drawRectElements=function(e,t){var r=this.context,i=3*e.count;return r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),i},i.prototype.drawPushMaskElements=function(e,t){var r=this.context,i=3*e.count,n=this.activatedBuffer;if(n){n.rootRenderTarget&&n.rootRenderTarget.enabledStencil(),0==n.stencilHandleCount&&(n.enableStencil(),r.clear(r.STENCIL_BUFFER_BIT));var a=n.stencilHandleCount;n.stencilHandleCount++,r.colorMask(!1,!1,!1,!1),r.stencilFunc(r.EQUAL,a,255),r.stencilOp(r.KEEP,r.KEEP,r.INCR),r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),r.stencilFunc(r.EQUAL,a+1,255),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}return i},i.prototype.drawPopMaskElements=function(e,t){var r=this.context,i=3*e.count,n=this.activatedBuffer;if(n)if(n.stencilHandleCount--,0==n.stencilHandleCount)n.disableStencil();else{var a=n.stencilHandleCount;r.colorMask(!1,!1,!1,!1),r.stencilFunc(r.EQUAL,a+1,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR),r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),r.stencilFunc(r.EQUAL,a,255),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}return i},i.prototype.setBlendMode=function(e){var t=this.context,r=i.blendModesForGL[e];r&&t.blendFunc(r[0],r[1])},i.prototype.drawTargetWidthFilters=function(e,r){var i,n=r,a=e.length;if(a>1)for(var o=0;a-1>o;o++){var s=e[o],c=r.rootRenderTarget.width,l=r.rootRenderTarget.height;i=t.WebGLRenderBuffer.create(c,l),i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,this.drawToRenderTarget(s,r,i),r!=n&&t.WebGLRenderBuffer.release(r),r=i}var h=e[a-1];this.drawToRenderTarget(h,r,this.currentBuffer),r!=n&&t.WebGLRenderBuffer.release(r)},i.prototype.drawToRenderTarget=function(e,r,i){if(!this.contextLost){this.vao.reachMaxSize()&&this.$drawWebGL(),this.pushBuffer(i);var n,a=r,o=r.rootRenderTarget.width,s=r.rootRenderTarget.height;if("blur"==e.type){var c=e.blurXFilter,l=e.blurYFilter;0!=c.blurX&&0!=l.blurY?(n=t.WebGLRenderBuffer.create(o,s),n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,this.drawToRenderTarget(e.blurXFilter,r,n),r!=a&&t.WebGLRenderBuffer.release(r),r=n,e=l):e=0===c.blurX?l:c}i.saveTransform(),i.transform(1,0,0,-1,0,s),this.vao.cacheArrays(i,0,0,o,s,0,0,o,s,o,s),i.restoreTransform(),this.drawCmdManager.pushDrawTexture(r.rootRenderTarget.texture,2,e,o,s),r!=a&&t.WebGLRenderBuffer.release(r),this.popBuffer()}},i.initBlendMode=function(){i.blendModesForGL={},i.blendModesForGL["source-over"]=[1,771],i.blendModesForGL.lighter=[1,1],i.blendModesForGL["lighter-in"]=[770,771],i.blendModesForGL["destination-out"]=[0,771],i.blendModesForGL["destination-in"]=[0,770]},i.glContextId=0,i.blendModesForGL=null,i}();t.WebGLRenderContext=i,__reflect(i.prototype,"egret.web.WebGLRenderContext"),i.initBlendMode()}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function n(i,n,a){var o=r.call(this)||this;if(o.globalAlpha=1,o.stencilState=!1,o.$stencilList=[],o.stencilHandleCount=0,o.$scissorState=!1,o.scissorRect=new e.Rectangle,o.$hasScissor=!1,o.$drawCalls=0,o.$computeDrawCall=!1,o.globalMatrix=new e.Matrix,o.savedGlobalMatrix=new e.Matrix,o.$offsetX=0,o.$offsetY=0,o.context=t.WebGLRenderContext.getInstance(i,n),e.nativeRender)return a?o.surface=o.context.surface:o.surface=new egret_native.NativeRenderSurface(o,i,n,a),o.rootRenderTarget=null,o;if(o.rootRenderTarget=new t.WebGLRenderTarget(o.context.context,3,3),i&&n&&o.resize(i,n),o.root=a,o.root)o.context.pushBuffer(o),o.surface=o.context.surface,o.$computeDrawCall=!0;else{var s=o.context.activatedBuffer;s&&s.rootRenderTarget.activate(),o.rootRenderTarget.initFrameBuffer(),o.surface=o.rootRenderTarget}return o}return __extends(n,r),n.prototype.enableStencil=function(){this.stencilState||(this.context.enableStencilTest(),this.stencilState=!0)},n.prototype.disableStencil=function(){this.stencilState&&(this.context.disableStencilTest(),this.stencilState=!1)},n.prototype.restoreStencil=function(){this.stencilState?this.context.enableStencilTest():this.context.disableStencilTest()},n.prototype.enableScissor=function(e,t,r,i){this.$scissorState||(this.$scissorState=!0,this.scissorRect.setTo(e,t,r,i),this.context.enableScissorTest(this.scissorRect))},n.prototype.disableScissor=function(){this.$scissorState&&(this.$scissorState=!1,this.scissorRect.setEmpty(),this.context.disableScissorTest())},n.prototype.restoreScissor=function(){this.$scissorState?this.context.enableScissorTest(this.scissorRect):this.context.disableScissorTest()},Object.defineProperty(n.prototype,"width",{get:function(){return e.nativeRender?this.surface.width:this.rootRenderTarget.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return e.nativeRender?this.surface.height:this.rootRenderTarget.height},enumerable:!0,configurable:!0}),n.prototype.resize=function(t,r,i){return t=t||1,r=r||1,e.nativeRender?void this.surface.resize(t,r):(this.context.pushBuffer(this),(t!=this.rootRenderTarget.width||r!=this.rootRenderTarget.height)&&(this.context.drawCmdManager.pushResize(this,t,r),this.rootRenderTarget.width=t,this.rootRenderTarget.height=r),this.root&&this.context.resize(t,r,i),this.context.clear(),void this.context.popBuffer())},n.prototype.getPixels=function(t,r,i,n){void 0===i&&(i=1),void 0===n&&(n=1);var a=new Uint8Array(4*i*n);if(e.nativeRender)egret_native.activateBuffer(this),egret_native.nrGetPixels(t,r,i,n,a),egret_native.activateBuffer(null);else{var o=this.rootRenderTarget.useFrameBuffer;this.rootRenderTarget.useFrameBuffer=!0,this.rootRenderTarget.activate(),this.context.getPixels(t,r,i,n,a),this.rootRenderTarget.useFrameBuffer=o,this.rootRenderTarget.activate()}for(var s=new Uint8Array(4*i*n),c=0;n>c;c++)for(var l=0;i>l;l++){var h=4*(i*(n-c-1)+l),u=4*(i*c+l),d=a[u+3];s[h]=Math.round(a[u]/d*255),s[h+1]=Math.round(a[u+1]/d*255),s[h+2]=Math.round(a[u+2]/d*255),s[h+3]=a[u+3]}return s},n.prototype.toDataURL=function(e,t){return this.context.surface.toDataURL(e,t)},n.prototype.destroy=function(){this.context.destroy()},n.prototype.onRenderFinish=function(){this.$drawCalls=0},n.prototype.drawFrameBufferToSurface=function(e,t,r,i,n,a,o,s,c){void 0===c&&(c=!1),this.rootRenderTarget.useFrameBuffer=!1,this.rootRenderTarget.activate(),this.context.disableStencilTest(),this.context.disableScissorTest(),this.setTransform(1,0,0,1,0,0),this.globalAlpha=1,this.context.setGlobalCompositeOperation("source-over"),c&&this.context.clear(),this.context.drawImage(this.rootRenderTarget,e,t,r,i,n,a,o,s,r,i,!1),this.context.$drawWebGL(),this.rootRenderTarget.useFrameBuffer=!0,this.rootRenderTarget.activate(),this.restoreStencil(),this.restoreScissor()},n.prototype.drawSurfaceToFrameBuffer=function(e,t,r,i,n,a,o,s,c){void 0===c&&(c=!1),this.rootRenderTarget.useFrameBuffer=!0,this.rootRenderTarget.activate(),this.context.disableStencilTest(),this.context.disableScissorTest(),this.setTransform(1,0,0,1,0,0),this.globalAlpha=1,this.context.setGlobalCompositeOperation("source-over"),c&&this.context.clear(),this.context.drawImage(this.context.surface,e,t,r,i,n,a,o,s,r,i,!1),this.context.$drawWebGL(),this.rootRenderTarget.useFrameBuffer=!1,this.rootRenderTarget.activate(),this.restoreStencil(),this.restoreScissor()},n.prototype.clear=function(){this.context.pushBuffer(this),this.context.clear(),this.context.popBuffer()},n.prototype.setTransform=function(e,t,r,i,n,a){var o=this.globalMatrix;o.a=e,o.b=t,o.c=r,o.d=i,o.tx=n,o.ty=a},n.prototype.transform=function(e,t,r,i,n,a){var o=this.globalMatrix,s=o.a,c=o.b,l=o.c,h=o.d;(1!=e||0!=t||0!=r||1!=i)&&(o.a=e*s+t*l,o.b=e*c+t*h,o.c=r*s+i*l,o.d=r*c+i*h),o.tx=n*s+a*l+o.tx,o.ty=n*c+a*h+o.ty},n.prototype.useOffset=function(){var e=this;(0!=e.$offsetX||0!=e.$offsetY)&&(e.globalMatrix.append(1,0,0,1,e.$offsetX,e.$offsetY),e.$offsetX=e.$offsetY=0)},n.prototype.saveTransform=function(){var e=this.globalMatrix,t=this.savedGlobalMatrix;t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.tx=e.tx,t.ty=e.ty},n.prototype.restoreTransform=function(){var e=this.globalMatrix,t=this.savedGlobalMatrix;e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e.tx=t.tx,e.ty=t.ty},n.create=function(e,t){var r=i.pop();if(r){r.resize(e,t);var a=r.globalMatrix;a.a=1,a.b=0,a.c=0,a.d=1,a.tx=0,a.ty=0,r.globalAlpha=1,r.$offsetX=0,r.$offsetY=0}else r=new n(e,t),r.$computeDrawCall=!1;return r},n.release=function(e){i.push(e)},n.autoClear=!0,n}(e.HashObject);t.WebGLRenderBuffer=r,__reflect(r.prototype,"egret.web.WebGLRenderBuffer",["egret.sys.RenderBuffer"]);var i=[]}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=["source-over","lighter","destination-out"],i="source-over",n=[],a=function(){function a(){this.nestLevel=0}return a.prototype.render=function(t,r,i,a){this.nestLevel++;var o=r,s=o.context;s.pushBuffer(o),o.transform(i.a,i.b,i.c,i.d,0,0),this.drawDisplayObject(t,o,i.tx,i.ty,!0),s.$drawWebGL();var c=o.$drawCalls;o.onRenderFinish(),s.popBuffer();var l=e.Matrix.create();if(i.$invertInto(l),o.transform(l.a,l.b,l.c,l.d,0,0),e.Matrix.release(l),this.nestLevel--,0===this.nestLevel){n.length>6&&(n.length=6);for(var h=n.length,u=0;h>u;u++)n[u].resize(0,0)}return c},a.prototype.drawDisplayObject=function(t,r,i,n,a){var o,s=0,c=t.$displayList;if(c&&!a?((t.$cacheDirty||t.$renderDirty||c.$canvasScaleX!=e.sys.DisplayList.$canvasScaleX||c.$canvasScaleY!=e.sys.DisplayList.$canvasScaleY)&&(s+=c.drawToSurface()),o=c.$renderNode):o=t.$renderDirty?t.$getRenderNode():t.$renderNode,t.$cacheDirty=!1,o){switch(s++,r.$offsetX=i,r.$offsetY=n,o.type){case 1:this.renderBitmap(o,r);break;case 2:this.renderText(o,r);break;case 3:this.renderGraphics(o,r);break;case 4:this.renderGroup(o,r);break;case 5:this.renderMesh(o,r);break;case 6:this.renderNormalBitmap(o,r)}r.$offsetX=0,r.$offsetY=0}if(c&&!a)return s;var l=t.$children;if(l)for(var h=l.length,u=0;h>u;u++){var d=l[u],f=void 0,p=void 0,v=void 0;1!=d.$alpha&&(v=r.globalAlpha,r.globalAlpha*=d.$alpha);var g=void 0;if(d.$useTranslate){var y=d.$getMatrix();f=i+d.$x,p=n+d.$y;var x=r.globalMatrix;g=e.Matrix.create(),g.a=x.a,g.b=x.b,g.c=x.c,g.d=x.d,g.tx=x.tx,g.ty=x.ty,r.transform(y.a,y.b,y.c,y.d,f,p),f=-d.$anchorOffsetX,p=-d.$anchorOffsetY}else f=i+d.$x-d.$anchorOffsetX,p=n+d.$y-d.$anchorOffsetY;switch(d.$renderMode){case 1:break;case 2:s+=this.drawWithFilter(d,r,f,p);break;case 3:s+=this.drawWithClip(d,r,f,p);break;case 4:s+=this.drawWithScrollRect(d,r,f,p);break;default:s+=this.drawDisplayObject(d,r,f,p)}if(v&&(r.globalAlpha=v),g){var y=r.globalMatrix;y.a=g.a,y.b=g.b,y.c=g.c,y.d=g.d,y.tx=g.tx,y.ty=g.ty,e.Matrix.release(g)}}return s},a.prototype.drawWithFilter=function(t,a,o,s){var c=0;if(t.$children&&0==t.$children.length&&(!t.$renderNode||0==t.$renderNode.$getRenderCount()))return c;var l,h=t.$filters,u=0!==t.$blendMode;u&&(l=r[t.$blendMode],l||(l=i));var d=t.$getOriginalBounds(),f=d.x,p=d.y,v=d.width,g=d.height;if(0>=v||0>=g)return c;if(!t.mask&&1==h.length&&("colorTransform"==h[0].type||"custom"===h[0].type&&0===h[0].padding)){var y=this.getRenderCount(t);if(!t.$children||1==y)return u&&a.context.setGlobalCompositeOperation(l),a.context.$filter=h[0],c+=t.$mask?this.drawWithClip(t,a,o,s):t.$scrollRect||t.$maskRect?this.drawWithScrollRect(t,a,o,s):this.drawDisplayObject(t,a,o,s),a.context.$filter=null,u&&a.context.setGlobalCompositeOperation(i),c}var x=this.createRenderBuffer(v,g);if(x.context.pushBuffer(x),c+=t.$mask?this.drawWithClip(t,x,-f,-p):t.$scrollRect||t.$maskRect?this.drawWithScrollRect(t,x,-f,-p):this.drawDisplayObject(t,x,-f,-p),x.context.popBuffer(),c>0){u&&a.context.setGlobalCompositeOperation(l),c++,a.$offsetX=o+f,a.$offsetY=s+p;var m=e.Matrix.create(),b=a.globalMatrix;m.a=b.a,m.b=b.b,m.c=b.c,m.d=b.d,m.tx=b.tx,m.ty=b.ty,a.useOffset(),a.context.drawTargetWidthFilters(h,x),b.a=m.a,b.b=m.b,b.c=m.c,b.d=m.d,b.tx=m.tx,b.ty=m.ty,e.Matrix.release(m),u&&a.context.setGlobalCompositeOperation(i)}return n.push(x),c},a.prototype.getRenderCount=function(e){var t=0,r=e.$getRenderNode();if(r&&(t+=r.$getRenderCount()),e.$children)for(var i=0,n=e.$children;i0)return 2;if(a.$children)t+=this.getRenderCount(a);else{var s=a.$getRenderNode();s&&(t+=s.$getRenderCount())}}return t},a.prototype.drawWithClip=function(t,a,o,s){var c,l=0,h=0!==t.$blendMode;h&&(c=r[t.$blendMode],c||(c=i));var u=t.$scrollRect?t.$scrollRect:t.$maskRect,d=t.$mask;if(d){var f=d.$getMatrix();if(0==f.a&&0==f.b||0==f.c&&0==f.d)return l}if(d||t.$children&&0!=t.$children.length){var p=t.$getOriginalBounds(),v=p.x,g=p.y,y=p.width,x=p.height;if(0>=y||0>=x)return l;var m=this.createRenderBuffer(y,x);if(m.context.pushBuffer(m),l+=this.drawDisplayObject(t,m,-v,-g),d){var b=this.createRenderBuffer(y,x);b.context.pushBuffer(b);var w=e.Matrix.create();w.copyFrom(d.$getConcatenatedMatrix()),d.$getConcatenatedMatrixAt(t,w),w.translate(-v,-g),b.setTransform(w.a,w.b,w.c,w.d,w.tx,w.ty),e.Matrix.release(w),l+=this.drawDisplayObject(d,b,0,0),b.context.popBuffer(),m.context.setGlobalCompositeOperation("destination-in"),m.setTransform(1,0,0,-1,0,b.height);var E=b.rootRenderTarget.width,T=b.rootRenderTarget.height;m.context.drawTexture(b.rootRenderTarget.texture,0,0,E,T,0,0,E,T,E,T),m.setTransform(1,0,0,1,0,0),m.context.setGlobalCompositeOperation("source-over"),b.setTransform(1,0,0,1,0,0),n.push(b)}if(m.context.setGlobalCompositeOperation(i),m.context.popBuffer(),l>0){l++,h&&a.context.setGlobalCompositeOperation(c),u&&a.context.pushMask(u.x+o,u.y+s,u.width,u.height);var S=e.Matrix.create(),_=a.globalMatrix;S.a=_.a,S.b=_.b,S.c=_.c,S.d=_.d,S.tx=_.tx,S.ty=_.ty,_.append(1,0,0,-1,o+v,s+g+m.height);var C=m.rootRenderTarget.width,R=m.rootRenderTarget.height;a.context.drawTexture(m.rootRenderTarget.texture,0,0,C,R,0,0,C,R,C,R),u&&m.context.popMask(),h&&a.context.setGlobalCompositeOperation(i);var L=a.globalMatrix;L.a=S.a,L.b=S.b,L.c=S.c,L.d=S.d,L.tx=S.tx,L.ty=S.ty,e.Matrix.release(S)}return n.push(m),l}return u&&a.context.pushMask(u.x+o,u.y+s,u.width,u.height),h&&a.context.setGlobalCompositeOperation(c),l+=this.drawDisplayObject(t,a,o,s),h&&a.context.setGlobalCompositeOperation(i),u&&a.context.popMask(),l},a.prototype.drawWithScrollRect=function(e,t,r,i){var n=0,a=e.$scrollRect?e.$scrollRect:e.$maskRect;if(a.isEmpty())return n;e.$scrollRect&&(r-=a.x,i-=a.y);var o=t.globalMatrix,s=t.context,c=!1;if(t.$hasScissor||0!=o.b||0!=o.c)t.context.pushMask(a.x+r,a.y+i,a.width,a.height);else{var l=o.a,h=o.d,u=o.tx,d=o.ty,f=a.x+r,p=a.y+i,v=f+a.width,g=p+a.height,y=void 0,x=void 0,m=void 0,b=void 0;if(1==l&&1==h)y=f+u,x=p+d,m=v+u,b=g+d;else{var w=l*f+u,E=h*p+d,T=l*v+u,S=h*p+d,_=l*v+u,C=h*g+d,R=l*f+u,L=h*g+d,D=0;w>T&&(D=w,w=T,T=D),_>R&&(D=_,_=R,R=D),y=_>w?w:_,m=T>R?T:R,E>S&&(D=E,E=S,S=D),C>L&&(D=C,C=L,L=D),x=C>E?E:C,b=S>L?S:L}s.enableScissor(y,-b+t.height,m-y,b-x),c=!0}return n+=this.drawDisplayObject(e,t,r,i),c?s.disableScissor():s.popMask(),n},a.prototype.drawNodeToBuffer=function(e,t,r,i){var n=t;n.context.pushBuffer(n),n.setTransform(r.a,r.b,r.c,r.d,r.tx,r.ty),this.renderNode(e,t,0,0,i),n.context.$drawWebGL(),n.onRenderFinish(),n.context.popBuffer()},a.prototype.drawDisplayToBuffer=function(e,t,r){t.context.pushBuffer(t),r&&t.setTransform(r.a,r.b,r.c,r.d,r.tx,r.ty);
4 | var i;i=e.$renderDirty?e.$getRenderNode():e.$renderNode;var n=0;if(i)switch(n++,i.type){case 1:this.renderBitmap(i,t);break;case 2:this.renderText(i,t);break;case 3:this.renderGraphics(i,t);break;case 4:this.renderGroup(i,t);break;case 5:this.renderMesh(i,t);break;case 6:this.renderNormalBitmap(i,t)}var a=e.$children;if(a)for(var o=a.length,s=0;o>s;s++){var c=a[s];switch(c.$renderMode){case 1:break;case 2:n+=this.drawWithFilter(c,t,0,0);break;case 3:n+=this.drawWithClip(c,t,0,0);break;case 4:n+=this.drawWithScrollRect(c,t,0,0);break;default:n+=this.drawDisplayObject(c,t,0,0)}}return t.context.$drawWebGL(),t.onRenderFinish(),t.context.popBuffer(),n},a.prototype.renderNode=function(e,t,r,i,n){switch(t.$offsetX=r,t.$offsetY=i,e.type){case 1:this.renderBitmap(e,t);break;case 2:this.renderText(e,t);break;case 3:this.renderGraphics(e,t,n);break;case 4:this.renderGroup(e,t);break;case 5:this.renderMesh(e,t);break;case 6:this.renderNormalBitmap(e,t)}},a.prototype.renderNormalBitmap=function(e,t){var r=e.image;r&&t.context.drawImage(r,e.sourceX,e.sourceY,e.sourceW,e.sourceH,e.drawX,e.drawY,e.drawW,e.drawH,e.imageWidth,e.imageHeight,e.rotated,e.smoothing)},a.prototype.renderBitmap=function(t,n){var a=t.image;if(a){var o,s,c,l=t.drawData,h=l.length,u=0,d=t.matrix,f=t.blendMode,p=t.alpha;if(d){o=e.Matrix.create();var v=n.globalMatrix;o.a=v.a,o.b=v.b,o.c=v.c,o.d=v.d,o.tx=v.tx,o.ty=v.ty,s=n.$offsetX,c=n.$offsetY,n.useOffset(),n.transform(d.a,d.b,d.c,d.d,d.tx,d.ty)}f&&n.context.setGlobalCompositeOperation(r[f]);var g;if(p==p&&(g=n.globalAlpha,n.globalAlpha*=p),t.filter){for(n.context.$filter=t.filter;h>u;)n.context.drawImage(a,l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],t.imageWidth,t.imageHeight,t.rotated,t.smoothing);n.context.$filter=null}else for(;h>u;)n.context.drawImage(a,l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],t.imageWidth,t.imageHeight,t.rotated,t.smoothing);if(f&&n.context.setGlobalCompositeOperation(i),p==p&&(n.globalAlpha=g),d){var y=n.globalMatrix;y.a=o.a,y.b=o.b,y.c=o.c,y.d=o.d,y.tx=o.tx,y.ty=o.ty,n.$offsetX=s,n.$offsetY=c,e.Matrix.release(o)}}},a.prototype.renderMesh=function(t,n){var a,o,s,c=t.image,l=t.drawData,h=l.length,u=0,d=t.matrix,f=t.blendMode,p=t.alpha;if(d){a=e.Matrix.create();var v=n.globalMatrix;a.a=v.a,a.b=v.b,a.c=v.c,a.d=v.d,a.tx=v.tx,a.ty=v.ty,o=n.$offsetX,s=n.$offsetY,n.useOffset(),n.transform(d.a,d.b,d.c,d.d,d.tx,d.ty)}f&&n.context.setGlobalCompositeOperation(r[f]);var g;if(p==p&&(g=n.globalAlpha,n.globalAlpha*=p),t.filter){for(n.context.$filter=t.filter;h>u;)n.context.drawMesh(c,l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],t.imageWidth,t.imageHeight,t.uvs,t.vertices,t.indices,t.bounds,t.rotated,t.smoothing);n.context.$filter=null}else for(;h>u;)n.context.drawMesh(c,l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],l[u++],t.imageWidth,t.imageHeight,t.uvs,t.vertices,t.indices,t.bounds,t.rotated,t.smoothing);if(f&&n.context.setGlobalCompositeOperation(i),p==p&&(n.globalAlpha=g),d){var y=n.globalMatrix;y.a=a.a,y.b=a.b,y.c=a.c,y.d=a.d,y.tx=a.tx,y.ty=a.ty,n.$offsetX=o,n.$offsetY=s,e.Matrix.release(a)}},a.prototype.renderText=function(r,i){var n=r.width-r.x,a=r.height-r.y;if(!(0>=n||0>=a)&&n&&a&&0!=r.drawData.length){var o=e.sys.DisplayList.$canvasScaleX,s=e.sys.DisplayList.$canvasScaleY,c=i.context.$maxTextureSize;n*o>c&&(o*=c/(n*o)),a*s>c&&(s*=c/(a*s)),n*=o,a*=s;var l=r.x*o,h=r.y*s;if((r.$canvasScaleX!=o||r.$canvasScaleY!=s)&&(r.$canvasScaleX=o,r.$canvasScaleY=s,r.dirtyRender=!0),this.canvasRenderBuffer&&this.canvasRenderBuffer.context?r.dirtyRender&&this.canvasRenderBuffer.resize(n,a):(this.canvasRenderer=new e.CanvasRenderer,this.canvasRenderBuffer=new t.CanvasRenderBuffer(n,a)),this.canvasRenderBuffer.context){if((1!=o||1!=s)&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),l||h?(r.dirtyRender&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,-l,-h),i.transform(1,0,0,1,l/o,h/s)):(1!=o||1!=s)&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),r.dirtyRender){var u=this.canvasRenderBuffer.surface;this.canvasRenderer.renderText(r,this.canvasRenderBuffer.context);var d=r.$texture;d?i.context.updateTexture(d,u):(d=i.context.createTexture(u),r.$texture=d),r.$textureWidth=u.width,r.$textureHeight=u.height}var f=r.$textureWidth,p=r.$textureHeight;i.context.drawTexture(r.$texture,0,0,f,p,0,0,f/o,p/s,f,p),(l||h)&&(r.dirtyRender&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),i.transform(1,0,0,1,-l/o,-h/s)),r.dirtyRender=!1}}},a.prototype.renderGraphics=function(r,i,n){var a=r.width,o=r.height;if(!(0>=a||0>=o)&&a&&o&&0!=r.drawData.length){var s=e.sys.DisplayList.$canvasScaleX,c=e.sys.DisplayList.$canvasScaleY;(1>a*s||1>o*c)&&(s=c=1),(r.$canvasScaleX!=s||r.$canvasScaleY!=c)&&(r.$canvasScaleX=s,r.$canvasScaleY=c,r.dirtyRender=!0),a*=s,o*=c;var l=Math.ceil(a),h=Math.ceil(o);if(s*=l/a,c*=h/o,a=l,o=h,this.canvasRenderBuffer&&this.canvasRenderBuffer.context?(r.dirtyRender||n)&&this.canvasRenderBuffer.resize(a,o):(this.canvasRenderer=new e.CanvasRenderer,this.canvasRenderBuffer=new t.CanvasRenderBuffer(a,o)),this.canvasRenderBuffer.context){(1!=s||1!=c)&&this.canvasRenderBuffer.context.setTransform(s,0,0,c,0,0),(r.x||r.y)&&((r.dirtyRender||n)&&this.canvasRenderBuffer.context.translate(-r.x,-r.y),i.transform(1,0,0,1,r.x,r.y));var u=this.canvasRenderBuffer.surface;if(n){this.canvasRenderer.renderGraphics(r,this.canvasRenderBuffer.context,!0),e.WebGLUtils.deleteWebGLTexture(u);var d=i.context.getWebGLTexture(u);i.context.drawTexture(d,0,0,a,o,0,0,a,o,u.width,u.height)}else{if(r.dirtyRender){this.canvasRenderer.renderGraphics(r,this.canvasRenderBuffer.context);var d=r.$texture;d?i.context.updateTexture(d,u):(d=i.context.createTexture(u),r.$texture=d),r.$textureWidth=u.width,r.$textureHeight=u.height}var f=r.$textureWidth,p=r.$textureHeight;i.context.drawTexture(r.$texture,0,0,f,p,0,0,f/s,p/c,f,p)}(r.x||r.y)&&((r.dirtyRender||n)&&this.canvasRenderBuffer.context.translate(r.x,r.y),i.transform(1,0,0,1,-r.x,-r.y)),n||(r.dirtyRender=!1)}}},a.prototype.renderGroup=function(t,r){var i,n,a,o=t.matrix;if(o){i=e.Matrix.create();var s=r.globalMatrix;i.a=s.a,i.b=s.b,i.c=s.c,i.d=s.d,i.tx=s.tx,i.ty=s.ty,n=r.$offsetX,a=r.$offsetY,r.useOffset(),r.transform(o.a,o.b,o.c,o.d,o.tx,o.ty)}for(var c=t.drawData,l=c.length,h=0;l>h;h++){var u=c[h];this.renderNode(u,r,r.$offsetX,r.$offsetY)}if(o){var d=r.globalMatrix;d.a=i.a,d.b=i.b,d.c=i.c,d.d=i.d,d.tx=i.tx,d.ty=i.ty,r.$offsetX=n,r.$offsetY=a,e.Matrix.release(i)}},a.prototype.createRenderBuffer=function(e,r){var i=n.pop();return i?i.resize(e,r):(i=new t.WebGLRenderBuffer(e,r),i.$computeDrawCall=!1),i},a}();t.WebGLRenderer=a,__reflect(a.prototype,"egret.web.WebGLRenderer",["egret.sys.SystemRenderer"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t=function(){function e(e,t,r){this.gl=e,this.name=r.name,this.type=r.type,this.size=r.size,this.location=e.getAttribLocation(t,this.name),this.count=0,this.initCount(e),this.format=e.FLOAT,this.initFormat(e)}return e.prototype.initCount=function(e){var t=this.type;switch(t){case 5126:case 5120:case 5121:case 5123:this.count=1;break;case 35664:this.count=2;break;case 35665:this.count=3;break;case 35666:this.count=4}},e.prototype.initFormat=function(e){var t=this.type;switch(t){case 5126:case 35664:case 35665:case 35666:this.format=e.FLOAT;break;case 5121:this.format=e.UNSIGNED_BYTE;break;case 5123:this.format=e.UNSIGNED_SHORT;break;case 5120:this.format=e.BYTE}},e}();e.EgretWebGLAttribute=t,__reflect(t.prototype,"egret.web.EgretWebGLAttribute")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){function t(e,t,r){var i=e.createShader(t);e.shaderSource(i,r),e.compileShader(i);var n=e.getShaderParameter(i,e.COMPILE_STATUS);return n||(console.log("shader not compiled!"),console.log(e.getShaderInfoLog(i))),i}function r(e,t,r){var i=e.createProgram();return e.attachShader(i,t),e.attachShader(i,r),e.linkProgram(i),i}function i(t,r){for(var i={},n=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES),a=0;n>a;a++){var o=t.getActiveAttrib(r,a),s=o.name,c=new e.EgretWebGLAttribute(t,r,o);i[s]=c}return i}function n(t,r){for(var i={},n=t.getProgramParameter(r,t.ACTIVE_UNIFORMS),a=0;n>a;a++){var o=t.getActiveUniform(r,a),s=o.name,c=new e.EgretWebGLUniform(t,r,o);i[s]=c}return i}var a=function(){function e(e,a,o){this.vshaderSource=a,this.fshaderSource=o,this.vertexShader=t(e,e.VERTEX_SHADER,this.vshaderSource),this.fragmentShader=t(e,e.FRAGMENT_SHADER,this.fshaderSource),this.id=r(e,this.vertexShader,this.fragmentShader),this.uniforms=n(e,this.id),this.attributes=i(e,this.id)}return e.getProgram=function(t,r,i,n){return this.programCache[n]||(this.programCache[n]=new e(t,r,i)),this.programCache[n]},e.deleteProgram=function(e,t,r,i){},e.programCache={},e}();e.EgretWebGLProgram=a,__reflect(a.prototype,"egret.web.EgretWebGLProgram")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t=function(){function e(e,t,r){this.gl=e,this.name=r.name,this.type=r.type,this.size=r.size,this.location=e.getUniformLocation(t,this.name),this.setDefaultValue(),this.generateSetValue(),this.generateUpload()}return e.prototype.setDefaultValue=function(){var e=this.type;switch(e){case 5126:case 35678:case 35680:case 35670:case 5124:this.value=0;break;case 35664:case 35671:case 35667:this.value=[0,0];break;case 35665:case 35672:case 35668:this.value=[0,0,0];break;case 35666:case 35673:case 35669:this.value=[0,0,0,0];break;case 35674:this.value=new Float32Array([1,0,0,1]);break;case 35675:this.value=new Float32Array([1,0,0,0,1,0,0,0,1]);break;case 35676:this.value=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}},e.prototype.generateSetValue=function(){var e=this.type;switch(e){case 5126:case 35678:case 35680:case 35670:case 5124:this.setValue=function(e){var t=this.value!==e;this.value=e,t&&this.upload()};break;case 35664:case 35671:case 35667:this.setValue=function(e){var t=this.value[0]!==e.x||this.value[1]!==e.y;this.value[0]=e.x,this.value[1]=e.y,t&&this.upload()};break;case 35665:case 35672:case 35668:this.setValue=function(e){this.value[0]=e.x,this.value[1]=e.y,this.value[2]=e.z,this.upload()};break;case 35666:case 35673:case 35669:this.setValue=function(e){this.value[0]=e.x,this.value[1]=e.y,this.value[2]=e.z,this.value[3]=e.w,this.upload()};break;case 35674:case 35675:case 35676:this.setValue=function(e){this.value.set(e),this.upload()}}},e.prototype.generateUpload=function(){var e=this.gl,t=this.type,r=this.location;switch(t){case 5126:this.upload=function(){var t=this.value;e.uniform1f(r,t)};break;case 35664:this.upload=function(){var t=this.value;e.uniform2f(r,t[0],t[1])};break;case 35665:this.upload=function(){var t=this.value;e.uniform3f(r,t[0],t[1],t[2])};break;case 35666:this.upload=function(){var t=this.value;e.uniform4f(r,t[0],t[1],t[2],t[3])};break;case 35678:case 35680:case 35670:case 5124:this.upload=function(){var t=this.value;e.uniform1i(r,t)};break;case 35671:case 35667:this.upload=function(){var t=this.value;e.uniform2i(r,t[0],t[1])};break;case 35672:case 35668:this.upload=function(){var t=this.value;e.uniform3i(r,t[0],t[1],t[2])};break;case 35673:case 35669:this.upload=function(){var t=this.value;e.uniform4i(r,t[0],t[1],t[2],t[3])};break;case 35674:this.upload=function(){var t=this.value;e.uniformMatrix2fv(r,!1,t)};break;case 35675:this.upload=function(){var t=this.value;e.uniformMatrix3fv(r,!1,t)};break;case 35676:this.upload=function(){var t=this.value;e.uniformMatrix4fv(r,!1,t)}}},e}();e.EgretWebGLUniform=t,__reflect(t.prototype,"egret.web.EgretWebGLUniform")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t=function(){function e(){}return e.blur_frag="precision mediump float;\r\nuniform vec2 blur;\r\nuniform sampler2D uSampler;\r\nvarying vec2 vTextureCoord;\r\nuniform vec2 uTextureSize;\r\nvoid main()\r\n{\r\n const int sampleRadius = 5;\r\n const int samples = sampleRadius * 2 + 1;\r\n vec2 blurUv = blur / uTextureSize;\r\n vec4 color = vec4(0, 0, 0, 0);\r\n vec2 uv = vec2(0.0, 0.0);\r\n blurUv /= float(sampleRadius);\r\n\r\n for (int i = -sampleRadius; i <= sampleRadius; i++) {\r\n uv.x = vTextureCoord.x + float(i) * blurUv.x;\r\n uv.y = vTextureCoord.y + float(i) * blurUv.y;\r\n color += texture2D(uSampler, uv);\r\n }\r\n\r\n color /= float(samples);\r\n gl_FragColor = color;\r\n}",e.colorTransform_frag="precision mediump float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform mat4 matrix;\r\nuniform vec4 colorAdd;\r\nuniform sampler2D uSampler;\r\n\r\nvoid main(void) {\r\n vec4 texColor = texture2D(uSampler, vTextureCoord);\r\n if(texColor.a > 0.) {\r\n // 鎶垫秷棰勪箻鐨刟lpha閫氶亾\r\n texColor = vec4(texColor.rgb / texColor.a, texColor.a);\r\n }\r\n vec4 locColor = clamp(texColor * matrix + colorAdd, 0., 1.);\r\n gl_FragColor = vColor * vec4(locColor.rgb * locColor.a, locColor.a);\r\n}",e.default_vert="attribute vec2 aVertexPosition;\r\nattribute vec2 aTextureCoord;\r\nattribute vec2 aColor;\r\n\r\nuniform vec2 projectionVector;\r\n// uniform vec2 offsetVector;\r\n\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\n\r\nconst vec2 center = vec2(-1.0, 1.0);\r\n\r\nvoid main(void) {\r\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\r\n vTextureCoord = aTextureCoord;\r\n vColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\r\n}",e.glow_frag="precision highp float;\r\nvarying vec2 vTextureCoord;\r\n\r\nuniform sampler2D uSampler;\r\n\r\nuniform float dist;\r\nuniform float angle;\r\nuniform vec4 color;\r\nuniform float alpha;\r\nuniform float blurX;\r\nuniform float blurY;\r\n// uniform vec4 quality;\r\nuniform float strength;\r\nuniform float inner;\r\nuniform float knockout;\r\nuniform float hideObject;\r\n\r\nuniform vec2 uTextureSize;\r\n\r\nfloat random(vec2 scale)\r\n{\r\n return fract(sin(dot(gl_FragCoord.xy, scale)) * 43758.5453);\r\n}\r\n\r\nvoid main(void) {\r\n vec2 px = vec2(1.0 / uTextureSize.x, 1.0 / uTextureSize.y);\r\n // TODO 鑷姩璋冭妭閲囨牱娆℃暟锛焅r\n const float linearSamplingTimes = 7.0;\r\n const float circleSamplingTimes = 12.0;\r\n vec4 ownColor = texture2D(uSampler, vTextureCoord);\r\n vec4 curColor;\r\n float totalAlpha = 0.0;\r\n float maxTotalAlpha = 0.0;\r\n float curDistanceX = 0.0;\r\n float curDistanceY = 0.0;\r\n float offsetX = dist * cos(angle) * px.x;\r\n float offsetY = dist * sin(angle) * px.y;\r\n\r\n const float PI = 3.14159265358979323846264;\r\n float cosAngle;\r\n float sinAngle;\r\n float offset = PI * 2.0 / circleSamplingTimes * random(vec2(12.9898, 78.233));\r\n float stepX = blurX * px.x / linearSamplingTimes;\r\n float stepY = blurY * px.y / linearSamplingTimes;\r\n for (float a = 0.0; a <= PI * 2.0; a += PI * 2.0 / circleSamplingTimes) {\r\n cosAngle = cos(a + offset);\r\n sinAngle = sin(a + offset);\r\n for (float i = 1.0; i <= linearSamplingTimes; i++) {\r\n curDistanceX = i * stepX * cosAngle;\r\n curDistanceY = i * stepY * sinAngle;\r\n if (vTextureCoord.x + curDistanceX - offsetX >= 0.0 && vTextureCoord.y + curDistanceY + offsetY <= 1.0){\r\n curColor = texture2D(uSampler, vec2(vTextureCoord.x + curDistanceX - offsetX, vTextureCoord.y + curDistanceY + offsetY));\r\n totalAlpha += (linearSamplingTimes - i) * curColor.a;\r\n }\r\n maxTotalAlpha += (linearSamplingTimes - i);\r\n }\r\n }\r\n\r\n ownColor.a = max(ownColor.a, 0.0001);\r\n ownColor.rgb = ownColor.rgb / ownColor.a;\r\n\r\n float outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1. - inner) * max(min(hideObject, knockout), 1. - ownColor.a);\r\n float innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * ownColor.a;\r\n\r\n ownColor.a = max(ownColor.a * knockout * (1. - hideObject), 0.0001);\r\n vec3 mix1 = mix(ownColor.rgb, color.rgb, innerGlowAlpha / (innerGlowAlpha + ownColor.a));\r\n vec3 mix2 = mix(mix1, color.rgb, outerGlowAlpha / (innerGlowAlpha + ownColor.a + outerGlowAlpha));\r\n float resultAlpha = min(ownColor.a + outerGlowAlpha + innerGlowAlpha, 1.);\r\n gl_FragColor = vec4(mix2 * resultAlpha, resultAlpha);\r\n}",e.primitive_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\n\r\nvoid main(void) {\r\n gl_FragColor = vColor;\r\n}",e.texture_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform sampler2D uSampler;\r\n\r\nvoid main(void) {\r\n gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;\r\n}",e}();e.EgretShaderLib=t,__reflect(t.prototype,"egret.web.EgretShaderLib")}(t=e.web||(e.web={}))}(egret||(egret={}));
--------------------------------------------------------------------------------