window.__require = function e(t, n, r) {
  function s(o, u) {
    if (!n[o]) {
      if (!t[o]) {
        var b = o.split("/");
        b = b[b.length - 1];
        if (!t[b]) {
          var a = "function" == typeof __require && __require;
          if (!u && a) return a(b, !0);
          if (i) return i(b, !0);
          throw new Error("Cannot find module '" + o + "'");
        }
      }
      var f = n[o] = {
        exports: {}
      };
      t[o][0].call(f.exports, function(e) {
        var n = t[o][1][e];
        return s(n || e);
      }, f, f.exports, e, t, n, r);
    }
    return n[o].exports;
  }
  var i = "function" == typeof __require && __require;
  for (var o = 0; o < r.length; o++) s(r[o]);
  return s;
}({
  Capture: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "b7224LFrbBJBL32y6sIfQrZ", "Capture");
    "use strict";
    cc.Class({
      extends: cc.Component,
      properties: {
        nodeImage: cc.Node,
        btnCapture: cc.Node
      },
      onLoad: function onLoad() {
        this.finalTexture;
      },
      capture1: function capture1() {
        cc.log("capture1()");
        var data = this.nodeToArray1(this.nodeImage);
      },
      capture2: function capture2() {
        cc.log("capture2()");
        var that = this;
        var image = new Image();
        image.onload = function() {
          cc.log("image.onload()");
          var data = that.imgToArray(image);
          that.checkData(data);
          image = null;
        };
        image.onerror = function() {
          cc.log("image.onerror() \uff01\uff01\uff01");
        };
        image.src = "https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0F/09/ChMkJlauze2IPKICABzBh_ueXY0AAH9JAMQ2qUAHMGf334.jpg";
        cc.log("image.src =", image.src);
      },
      nodeToArray1: function nodeToArray1(node) {
        cc.log("nodeToArray1()");
        node.x = -cc.winSize.height;
        node.y = -cc.winSize.height;
        node.name = "GET_TEXTURE_ARR_NODE";
        node.parent = cc.director.getScene();
        var camera = node.getComponent(cc.Camera);
        if (null == camera) {
          camera = node.addComponent(cc.Camera);
          camera.cullingMask = 4294967295;
          var texture = new cc.RenderTexture();
          var gl = cc.game._renderContext;
          texture.initWithSize(node.width, node.height, gl.STENCIL_INDEX8);
          camera.targetTexture = texture;
        }
        camera.render();
        this.finalTexture = camera.targetTexture;
        setTimeout(function() {
          var data = this.textureToArray(this.finalTexture);
          this.checkData(data);
        }.bind(this), 1e3);
      },
      textureToArray: function textureToArray(texture) {
        console.log("textureToArray()");
        var data = texture.readPixels();
        var newData = new Uint8Array(data.length);
        for (var i = 0; i < texture.height; i++) for (var j = 0; j < 4 * texture.width; j++) newData[i * texture.width * 4 + j] = data[(texture.height - i - 1) * texture.width * 4 + j];
        return newData;
      },
      imgToArray: function imgToArray(image) {
        cc.log("imgToArray()");
        try {
          var canvas = document.createElement("canvas");
          canvas.width = image.width;
          canvas.height = image.height;
          cc.log("  canvas.size =", canvas.width, canvas.height);
          var context = canvas.getContext("2d");
          context.drawImage(image, 0, 0, image.width, image.height);
          context.drawImage(image, 100, 100, image.width - 200, image.height - 200);
          var imageData = context.getImageData(0, 0, canvas.width, canvas.height).data;
          cc.log("  imageData.length =", imageData.length);
          var aryData = new Uint8Array(imageData.length);
          for (var i = 0; i < imageData.length; i++) aryData[i] = imageData[i];
          canvas = null;
          return aryData;
        } catch (e) {
          cc.log(e);
          return null;
        }
      },
      checkData: function checkData(data) {
        var nSumRGB = 0;
        var nSumA = 0;
        for (var i = 0; i < data.length; i += 4) {
          nSumRGB += data[i] + data[i + 1] + data[i + 2];
          nSumA += data[i + 3];
          i < 500 && cc.log(" ", data[i], data[i + 1], data[i + 2], data[i + 3]);
        }
        cc.log("Avg RGB =", nSumRGB / data.length * 4 / 3);
        cc.log("Avg A =", nSumA / data.length * 4);
      }
    });
    cc._RF.pop();
  }, {} ]
}, {}, [ "Capture" ]);