ART & GALLERY
ART & GALLERY
「デヴィッド・リンチ_精神的辺境の帝国」展は、6月23日(日)までGYRE GALLERYにて開催されています。 こちらの記事もあわせて、ぜひお楽しみください。
展示されている作品は、 どのように選ばれたのですか?
「今回の個展は、デヴィッド・リンチ自身が、これまで手放そうとしなかった作品がメインになっています。事前にその作品リストを見せてもらい、僕からも意見を伝えて、協議しながら選定を進めていきました。最終的には、ペインティング7点、ドローイング3点、水彩画12点、写真14点に、ショートフィルム1本という内容です。トリプティック(3枚組み)のペインティングなど、個人のコレクターの方にお借りした作品もあります」
会場に、屋根の焼け落ちた “黒い小屋”があるのはなぜですか?
「『ロスト・ハイウェイ』にしても『ツイン・ピークス』にしても、リンチが監督した映画には、さまざまな“小屋”が登場します。しかもそうした映画のなかで、怪しげな、目に見えないパワーが潜む場所として描かれています。僕は今回の展示を通じて、彼のインスピレーションの源泉を、あらためてクローズアップしたいと考えていました。そのために、彼の映像世界を象徴するような“小屋”を設置してみたかった。それを実現しようと準備を進めていたところに、リンチのほうから『Fire』というショートフィルムを上映してもいいという提案があって。僕たちが用意しようとしていたのは、まさしく火事で真っ黒に焼けて、屋根が落ちてしまったような小屋だったので、とても驚きました。『Fire』を上映するのに、ふさわしい場所ができたと思います」
展覧会の「精神的辺境の帝国」というタイトルには、 どういう意味が込められていますか?
「これはリンチの長編映画『インランド・エンパイア』というタイトルを、独自に解釈し直したものです。そこに込められた心理的な状況にもっと迫ってみたい、という意図がありました。リンチの手がけた映画や絵画では、アンダーグラウンドなものが、オーバーグラウンドにあふれ出てくるところが、さまざまに描写されています。とくに映画においては、まずは美しい日常がフレームとしてきちんと描かれる。しかし、じつはそこに潜んでいる不気味なものや凶暴性が、やがて顔を覗かせるようになって、ゆくゆくは日常というフレームそのものまで壊していく。オーバーグラウンドだったものが、次第に、強い力をもったアンダーグラウンドなものに覆されてしまうという展開を見せます。そうした物語や世界観によって、誰もが自分のなかに潜在的に秘めているものを暴露してくれている、ということもできると思います。あるいは、「内面的なもの」と「外面的なもの」との、心理的な境界線が崩壊していくところも、リンチ作品の面白さです。内であって外である。外であって内である。といった状況を、さまざまな現象として描き続けているのです。そうした彼ならではの、表現における本性のようなところを表すタイトルを模索しました。英語では“From the Fringes of the Mind”というタイトルをつけています」
デヴィッド・リンチが絵を描き続けるのは、 どういった理由からでしょうか?
「リンチは映画監督として世界的に知られていますが、もともと美術学校に通っていたりして、若い頃から画家を目指していました。かつて僕が、絵を描くことについて訊いてみたところ、映画をつくることも、絵を描くことも、自分にとっては同じなのだと話してくれたことがあります。またずいぶん昔には、映画をつくりたいと思ったのはどうしてか?と尋ねたこともあるのですが、絵に描いたイメージを動かしてみたかったから、といった答えが返ってきました。僕が知る限りでは、映画を撮っている間も、毎日のように絵を描いていたようです。絵を描くことはそれくらい、彼のクリエイティビティの支えになっているのだと思います。むしろ、彼にとっては絵を描くことこそ根源的な欲求であって、映画はそこから派生した表現方法なのかもしれませんね」
デヴィッド・リンチのアート作品は、 どのような評価を受けているのですか?
「たとえば、ヘンリー・ムーアやヨゼフ・ボイス、ゲルハルト・リヒター、シンディ・シャーマン、ジェニー・ホルツァーといった錚々たるアーティストたちが受賞してきた『Goslar Kaiserring Award(ゴスラー・カイザーリング賞)』を2010年に受賞しました。世界に数ある国際的な美術賞のなかでも、とくに栄誉ある賞です。その受賞理由は、デヴィッド・リンチほど映画と造形芸術の境界線を打破したクリエイターは存在しない、といったものでした。映画監督にして、美術界においてこれほどの賞をもらうという快挙は、ほかに例がないと思います。そうした経緯もあり、近年では、さまざまな作品がオークションにも出品されるなど、かなりの高額で取引されているようですね。とくにペインティングは、この約10年のあいだに価値がとても上がっています」
「今回出展された一連の写真作品は、『イレイザーヘッド』のロケ地となったフィラデルフィアの工業地帯を想起させる、リンチにとっての心象風景のようなものです。彼は映画監督としてデビューする前に、フィラデルフィアにあったモルグ(死体安置所)の隣のアパートメントに住んでいました。その間に、廃線になった線路にずっと耳をあてている男など、リンチが“ストレンジ・ピープル”と呼ぶ人たちの姿を、目に焼き付けることになったのです。そうして蓄積されたインスピレーションをもとに生まれたのが、はじめての長編映画『イレイザーヘッド』でした。リンチの作品は、日常的な風景のなかに、突出した違和感や異物を見つけることで成り立っている。かつてフィラデルフィアで得たインスピレーションを追い求めるかのように、これらの写真のなかにも、そうしたイメージが写し出されています。ただし、実際に撮影された場所はフィラデルフィアではなく、イギリスやドイツなどの工業地帯です」
“カルトの帝王”などと呼ばれたりしますが、 本人としては、どんな人たちに向けて映画やアートをつくっていると思いますか?
「リンチ本人はそんなカテゴライズなど意に介さず、できるだけ、たくさんのいろんな人に見てもらいたいのだと思いますよ。コアな人にだけ届く、閉ざされたものをつくっているつもりなど、まったくない。アバンギャルドな作品をつくっているとさえ思っていないところも、彼ならではの特徴でしょうね。たしかに、その作品にはユーモアが感じられるし、全体を俯瞰して、客観的に見る目も効いているのです。たとえば『ワイルド・アット・ハート』も『ロスト・ハイウェイ』も、ある部分においてはコミカルというか。『イレイザーヘッド』でさえも、そういう気配があると思います」
「最初に会ったのは1990年のことになりますが、その人柄は当時からまるで変わらないですね。いつでも温かく迎え入れてくれるし、投げかけた質問には誠実に答えてくれる。決してごまかしたりせず、丁寧に話してくれます。『ロスト・ハイウェイ』の撮影が終わった際、打ち上げのパーティーに呼ばれたことがあったのですが、スタッフみんなが和気あいあいとして、実際の撮影の現場も楽しかったようです。ただ、映画そのものは「サイコジェニック・フーガ(心因性記憶喪失)」をテーマとして、人間の心理的な闇をフィーチャーしたものだったのですが。どんな内容の映画であっても、その制作過程においては、チームワークを大切にしているのでしょう。いずれにしても、彼が偉そうにしているところは見たことがありません。それからこれは余談になりますが、彼のいちばん好きな食べ物は、ハンバーガーなんじゃないかな(笑)。これまで食事をともにした経験から、個人的にはそう思っています」
飯田さんがとくに影響を受けた デヴィッド・リンチ監督の映画は?
「やっぱり『イレイザーヘッド』ですね。最初、大学生の頃に渋谷パンテオン(2003年に閉館)という映画館で見たときは、あまりに気持ち悪くて、悪夢かと思ったほどなのですが、なぜかそのあとVHSのビデオ版を買ってしまって。たしか1万5000円くらいと高かったので、買った以上は見ないと損だなと、あらためて見はじめたら止まらなくなっちゃったんですよ。見続けることで、癒やされるというか…。それで結局、1週間かけて全編を見終えるという習慣を、3年間にわたって欠かさず続けることになりました(笑)。最後のほうは意地のようになっていましたが、あの映画を見ないと一日が終わらなかったんです。その当時はヘンリーが歩く工業地帯の音が耳から離れなくなって、いまでもすべてのシーンが、すぐに自分の脳内スクリーンに映し出されます。映画を通じて、忘れがたい記憶やある種のトラウマを共有できたからこそ、そこまで受け入れられたのだろうと思いますね」
飯田さんが、デヴィッド・リンチの映画やアートに 惹かれ続ける理由とは?
「本物の芸術家というのは、どこか自分を救うために作品をつくり続けている人たちであって、はじめから自分以外の誰かのためにつくっているわけではないんですよね。逃れられない不条理なことがあったり、そのために感情をコントロールできなくなったり。そうした状況をなんらかのかたちで作品化することで、多少なりとも救われているところがある。リンチにとっては、幼い頃から絵を描かざるを得なかった、ということなのではないでしょうか。本人の抱えた心理的な風景を、孤独な作業によって、いちばんダイレクトに表現できるのがペインティングなのだと思います」
デヴィッド・リンチにインタビューをする飯田高誉。2007年、ウエスト・ハリウッドのスタジオにて
飯田高誉 (Takayo Iida)
1956年、東京都生まれ。1980年からフジテレビギャラリーに在籍し、草間彌生の展示などを担当。1990年に独立し、インディペンデント・キュレーターとして活動をスタート。2003年より、東京大学総合研究博物館小石川分館にて現代美術シリーズを企画。フランス・パリのカルティエ現代美術財団にて杉本博司展(2004年)、横尾忠則展(2006年)をキュレーション。2007年に京都造形芸術大学国際藝術研究センター所長に就任し、「戦争と芸術」展シリーズを企画。〈コム デ ギャルソン〉によるアートスペース「Six」(大阪・心斎橋)のキュレーションや、GYREのギャラリースペース「EYE OF GYRE」のディレクションを手がける。青森県立美術館美術統括監、森美術館理事などを務めたのち、現在はスクールデレック芸術社会学研究所所長、「GYRE GALLERY」ディレクター。国際美術評論家連盟会員。
デヴィッド・リンチ (David Lynch)
1946年、アメリカ・モンタナ州生まれ。映画監督、画家。ボストンの美術学校などで学んだのち、フィラデルフィアに移り住み、ペンシルベニア美術アカデミーに入学。その後、ロサンゼルスに移り、長編映画『イレイザーヘッド』を1977年に公開。長編映画としてはほかに『エレファント・マン』(1980年)、『ブルーベルベット』(1986年)、 『ワイルド・アット・ハート』(1990年)、『マルホランド・ドライブ』(2001年)、『インランド・エンパイア』(2006年)など。テレビドラマ版(1990〜91年)をはじめとした『ツイン・ピークス』シリーズも代表作。2007年には、フランス・パリのカルティエ現代美術財団で回顧展「The Air is on Fire」を開催した。
ペインティングと映画にあてはまる、従うべきルールがある。このルールは、とても親密なもので抽象的なものである。なおかつ、無限の可能性を秘めている。ときにこれらのルールは存在しないとさえも思わせるほどだ。しかし、たしかに、ルールは存在する。それらのルールは本には書かれていないが、我々の精神と心の中に内在する。行動と決断の直前、あるいは直後に、それらは直感を通してその存在を現す。これらのルールは、すべての表現媒体に適応する。それらに従えば、幸福がもたらされる。
-デヴィッド・リンチ
アトリウムでは、断裁前の膨大な数のフライヤーをワイヤーで連ねたインスタレーションが展示されています。「デヴィッド・リンチ_精神的辺境の帝国」展の展示コンセプトからインスピレーションを得て、グラフィックデザイナーの長嶋りかこがアートディレクションを手がけたものです。
会期: 2019年4月14日(日) - 6月 23日(日) / 11:00 - 20:00 / 無休アートディレクション: 長嶋りかこ(village®)
主催: GYRE
協力: HiRAO INC
CONTACT: GYRE (03-3498-6990)
会場: アトリウム(吹き抜けスペース) - GYRE B1F – 5F
var GYRE = GYRE || {}; GYRE.ARTDETAIL = {}; GYRE.ARTDETAIL.INIT = []; GYRE.ARTDETAIL.DESTROY = [];
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 228);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(2);
var core = __webpack_require__(24);
var hide = __webpack_require__(16);
var redefine = __webpack_require__(17);
var ctx = __webpack_require__(25);
var PROTOTYPE = 'prototype';
var $export = function (type, name, source) {
var IS_FORCED = type & $export.F;
var IS_GLOBAL = type & $export.G;
var IS_STATIC = type & $export.S;
var IS_PROTO = type & $export.P;
var IS_BIND = type & $export.B;
var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
var key, own, out, exp;
if (IS_GLOBAL) source = name;
for (key in source) {
// contains in native
own = !IS_FORCED && target && target[key] !== undefined;
// export native or passed
out = (own ? target : source)[key];
// bind timers to global for call from export context
exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
// extend global
if (target) redefine(target, key, out, type & $export.U);
// export
if (exports[key] != out) hide(exports, key, exp);
if (IS_PROTO && expProto[key] != out) expProto[key] = out;
}
};
global.core = core;
// type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
module.exports = $export;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(6);
module.exports = function (it) {
if (!isObject(it)) throw TypeError(it + ' is not an object!');
return it;
};
/***/ }),
/* 2 */
/***/ (function(module, exports) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self
// eslint-disable-next-line no-new-func
: Function('return this')();
if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
/**
* String of the current PIXI version.
*
* @static
* @constant
* @memberof PIXI
* @name VERSION
* @type {string}
*/
var VERSION = exports.VERSION = '4.8.7';
/**
* Two Pi.
*
* @static
* @constant
* @memberof PIXI
* @type {number}
*/
var PI_2 = exports.PI_2 = Math.PI * 2;
/**
* Conversion factor for converting radians to degrees.
*
* @static
* @constant
* @memberof PIXI
* @type {number}
*/
var RAD_TO_DEG = exports.RAD_TO_DEG = 180 / Math.PI;
/**
* Conversion factor for converting degrees to radians.
*
* @static
* @constant
* @memberof PIXI
* @type {number}
*/
var DEG_TO_RAD = exports.DEG_TO_RAD = Math.PI / 180;
/**
* Constant to identify the Renderer Type.
*
* @static
* @constant
* @memberof PIXI
* @name RENDERER_TYPE
* @type {object}
* @property {number} UNKNOWN - Unknown render type.
* @property {number} WEBGL - WebGL render type.
* @property {number} CANVAS - Canvas render type.
*/
var RENDERER_TYPE = exports.RENDERER_TYPE = {
UNKNOWN: 0,
WEBGL: 1,
CANVAS: 2
};
/**
* Various blend modes supported by PIXI.
*
* IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.
* Anything else will silently act like NORMAL.
*
* @static
* @constant
* @memberof PIXI
* @name BLEND_MODES
* @type {object}
* @property {number} NORMAL
* @property {number} ADD
* @property {number} MULTIPLY
* @property {number} SCREEN
* @property {number} OVERLAY
* @property {number} DARKEN
* @property {number} LIGHTEN
* @property {number} COLOR_DODGE
* @property {number} COLOR_BURN
* @property {number} HARD_LIGHT
* @property {number} SOFT_LIGHT
* @property {number} DIFFERENCE
* @property {number} EXCLUSION
* @property {number} HUE
* @property {number} SATURATION
* @property {number} COLOR
* @property {number} LUMINOSITY
*/
var BLEND_MODES = exports.BLEND_MODES = {
NORMAL: 0,
ADD: 1,
MULTIPLY: 2,
SCREEN: 3,
OVERLAY: 4,
DARKEN: 5,
LIGHTEN: 6,
COLOR_DODGE: 7,
COLOR_BURN: 8,
HARD_LIGHT: 9,
SOFT_LIGHT: 10,
DIFFERENCE: 11,
EXCLUSION: 12,
HUE: 13,
SATURATION: 14,
COLOR: 15,
LUMINOSITY: 16,
NORMAL_NPM: 17,
ADD_NPM: 18,
SCREEN_NPM: 19
};
/**
* Various webgl draw modes. These can be used to specify which GL drawMode to use
* under certain situations and renderers.
*
* @static
* @constant
* @memberof PIXI
* @name DRAW_MODES
* @type {object}
* @property {number} POINTS
* @property {number} LINES
* @property {number} LINE_LOOP
* @property {number} LINE_STRIP
* @property {number} TRIANGLES
* @property {number} TRIANGLE_STRIP
* @property {number} TRIANGLE_FAN
*/
var DRAW_MODES = exports.DRAW_MODES = {
POINTS: 0,
LINES: 1,
LINE_LOOP: 2,
LINE_STRIP: 3,
TRIANGLES: 4,
TRIANGLE_STRIP: 5,
TRIANGLE_FAN: 6
};
/**
* The scale modes that are supported by pixi.
*
* The {@link PIXI.settings.SCALE_MODE} scale mode affects the default scaling mode of future operations.
* It can be re-assigned to either LINEAR or NEAREST, depending upon suitability.
*
* @static
* @constant
* @memberof PIXI
* @name SCALE_MODES
* @type {object}
* @property {number} LINEAR Smooth scaling
* @property {number} NEAREST Pixelating scaling
*/
var SCALE_MODES = exports.SCALE_MODES = {
LINEAR: 0,
NEAREST: 1
};
/**
* The wrap modes that are supported by pixi.
*
* The {@link PIXI.settings.WRAP_MODE} wrap mode affects the default wrapping mode of future operations.
* It can be re-assigned to either CLAMP or REPEAT, depending upon suitability.
* If the texture is non power of two then clamp will be used regardless as webGL can
* only use REPEAT if the texture is po2.
*
* This property only affects WebGL.
*
* @static
* @constant
* @name WRAP_MODES
* @memberof PIXI
* @type {object}
* @property {number} CLAMP - The textures uvs are clamped
* @property {number} REPEAT - The texture uvs tile and repeat
* @property {number} MIRRORED_REPEAT - The texture uvs tile and repeat with mirroring
*/
var WRAP_MODES = exports.WRAP_MODES = {
CLAMP: 0,
REPEAT: 1,
MIRRORED_REPEAT: 2
};
/**
* The gc modes that are supported by pixi.
*
* The {@link PIXI.settings.GC_MODE} Garbage Collection mode for PixiJS textures is AUTO
* If set to GC_MODE, the renderer will occasionally check textures usage. If they are not
* used for a specified period of time they will be removed from the GPU. They will of course
* be uploaded again when they are required. This is a silent behind the scenes process that
* should ensure that the GPU does not get filled up.
*
* Handy for mobile devices!
* This property only affects WebGL.
*
* @static
* @constant
* @name GC_MODES
* @memberof PIXI
* @type {object}
* @property {number} AUTO - Garbage collection will happen periodically automatically
* @property {number} MANUAL - Garbage collection will need to be called manually
*/
var GC_MODES = exports.GC_MODES = {
AUTO: 0,
MANUAL: 1
};
/**
* Regexp for image type by extension.
*
* @static
* @constant
* @memberof PIXI
* @type {RegExp|string}
* @example `image.png`
*/
var URL_FILE_EXTENSION = exports.URL_FILE_EXTENSION = /\.(\w{3,4})(?:$|\?|#)/i;
/**
* Regexp for data URI.
* Based on: {@link https://github.com/ragingwind/data-uri-regex}
*
* @static
* @constant
* @name DATA_URI
* @memberof PIXI
* @type {RegExp|string}
* @example data:image/png;base64
*/
var DATA_URI = exports.DATA_URI = /^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;
/**
* Regexp for SVG size.
*
* @static
* @constant
* @name SVG_SIZE
* @memberof PIXI
* @type {RegExp|string}
* @example <svg width="100" height="100"></svg>
*/
var SVG_SIZE = exports.SVG_SIZE = /<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i; // eslint-disable-line max-len
/**
* Constants that identify shapes, mainly to prevent `instanceof` calls.
*
* @static
* @constant
* @name SHAPES
* @memberof PIXI
* @type {object}
* @property {number} POLY Polygon
* @property {number} RECT Rectangle
* @property {number} CIRC Circle
* @property {number} ELIP Ellipse
* @property {number} RREC Rounded Rectangle
*/
var SHAPES = exports.SHAPES = {
POLY: 0,
RECT: 1,
CIRC: 2,
ELIP: 3,
RREC: 4
};
/**
* Constants that specify float precision in shaders.
*
* @static
* @constant
* @name PRECISION
* @memberof PIXI
* @type {object}
* @property {string} LOW='lowp'
* @property {string} MEDIUM='mediump'
* @property {string} HIGH='highp'
*/
var PRECISION = exports.PRECISION = {
LOW: 'lowp',
MEDIUM: 'mediump',
HIGH: 'highp'
};
/**
* Constants that specify the transform type.
*
* @static
* @constant
* @name TRANSFORM_MODE
* @memberof PIXI
* @type {object}
* @property {number} STATIC
* @property {number} DYNAMIC
*/
var TRANSFORM_MODE = exports.TRANSFORM_MODE = {
STATIC: 0,
DYNAMIC: 1
};
/**
* Constants that define the type of gradient on text.
*
* @static
* @constant
* @name TEXT_GRADIENT
* @memberof PIXI
* @type {object}
* @property {number} LINEAR_VERTICAL Vertical gradient
* @property {number} LINEAR_HORIZONTAL Linear gradient
*/
var TEXT_GRADIENT = exports.TEXT_GRADIENT = {
LINEAR_VERTICAL: 0,
LINEAR_HORIZONTAL: 1
};
/**
* Represents the update priorities used by internal PIXI classes when registered with
* the {@link PIXI.ticker.Ticker} object. Higher priority items are updated first and lower
* priority items, such as render, should go later.
*
* @static
* @constant
* @name UPDATE_PRIORITY
* @memberof PIXI
* @type {object}
* @property {number} INTERACTION=50 Highest priority, used for {@link PIXI.interaction.InteractionManager}
* @property {number} HIGH=25 High priority updating, {@link PIXI.VideoBaseTexture} and {@link PIXI.extras.AnimatedSprite}
* @property {number} NORMAL=0 Default priority for ticker events, see {@link PIXI.ticker.Ticker#add}.
* @property {number} LOW=-25 Low priority used for {@link PIXI.Application} rendering.
* @property {number} UTILITY=-50 Lowest priority used for {@link PIXI.prepare.BasePrepare} utility.
*/
var UPDATE_PRIORITY = exports.UPDATE_PRIORITY = {
INTERACTION: 50,
HIGH: 25,
NORMAL: 0,
LOW: -25,
UTILITY: -50
};
//# sourceMappingURL=const.js.map
/***/ }),
/* 4 */
/***/ (function(module, exports) {
module.exports = function (exec) {
try {
return !!exec();
} catch (e) {
return true;
}
};
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.autoDetectRenderer = exports.Application = exports.Filter = exports.SpriteMaskFilter = exports.Quad = exports.RenderTarget = exports.ObjectRenderer = exports.WebGLManager = exports.Shader = exports.CanvasRenderTarget = exports.TextureUvs = exports.VideoBaseTexture = exports.BaseRenderTexture = exports.RenderTexture = exports.BaseTexture = exports.TextureMatrix = exports.Texture = exports.Spritesheet = exports.CanvasGraphicsRenderer = exports.GraphicsRenderer = exports.GraphicsData = exports.Graphics = exports.TextMetrics = exports.TextStyle = exports.Text = exports.SpriteRenderer = exports.CanvasTinter = exports.CanvasSpriteRenderer = exports.Sprite = exports.TransformBase = exports.TransformStatic = exports.Transform = exports.Container = exports.DisplayObject = exports.Bounds = exports.glCore = exports.WebGLRenderer = exports.CanvasRenderer = exports.ticker = exports.utils = exports.settings = undefined;
var _const = __webpack_require__(3);
Object.keys(_const).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _const[key];
}
});
});
var _math = __webpack_require__(14);
Object.keys(_math).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _math[key];
}
});
});
var _pixiGlCore = __webpack_require__(23);
Object.defineProperty(exports, 'glCore', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_pixiGlCore).default;
}
});
var _Bounds = __webpack_require__(121);
Object.defineProperty(exports, 'Bounds', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Bounds).default;
}
});
var _DisplayObject = __webpack_require__(181);
Object.defineProperty(exports, 'DisplayObject', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_DisplayObject).default;
}
});
var _Container = __webpack_require__(64);
Object.defineProperty(exports, 'Container', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Container).default;
}
});
var _Transform = __webpack_require__(183);
Object.defineProperty(exports, 'Transform', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Transform).default;
}
});
var _TransformStatic = __webpack_require__(182);
Object.defineProperty(exports, 'TransformStatic', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_TransformStatic).default;
}
});
var _TransformBase = __webpack_require__(123);
Object.defineProperty(exports, 'TransformBase', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_TransformBase).default;
}
});
var _Sprite = __webpack_require__(125);
Object.defineProperty(exports, 'Sprite', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Sprite).default;
}
});
var _CanvasSpriteRenderer = __webpack_require__(465);
Object.defineProperty(exports, 'CanvasSpriteRenderer', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_CanvasSpriteRenderer).default;
}
});
var _CanvasTinter = __webpack_require__(84);
Object.defineProperty(exports, 'CanvasTinter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_CanvasTinter).default;
}
});
var _SpriteRenderer = __webpack_require__(468);
Object.defineProperty(exports, 'SpriteRenderer', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_SpriteRenderer).default;
}
});
var _Text = __webpack_require__(484);
Object.defineProperty(exports, 'Text', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Text).default;
}
});
var _TextStyle = __webpack_require__(196);
Object.defineProperty(exports, 'TextStyle', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_TextStyle).default;
}
});
var _TextMetrics = __webpack_require__(197);
Object.defineProperty(exports, 'TextMetrics', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_TextMetrics).default;
}
});
var _Graphics = __webpack_require__(486);
Object.defineProperty(exports, 'Graphics', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Graphics).default;
}
});
var _GraphicsData = __webpack_require__(198);
Object.defineProperty(exports, 'GraphicsData', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_GraphicsData).default;
}
});
var _GraphicsRenderer = __webpack_require__(488);
Object.defineProperty(exports, 'GraphicsRenderer', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_GraphicsRenderer).default;
}
});
var _CanvasGraphicsRenderer = __webpack_require__(495);
Object.defineProperty(exports, 'CanvasGraphicsRenderer', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_CanvasGraphicsRenderer).default;
}
});
var _Spritesheet = __webpack_require__(496);
Object.defineProperty(exports, 'Spritesheet', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Spritesheet).default;
}
});
var _Texture = __webpack_require__(40);
Object.defineProperty(exports, 'Texture', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Texture).default;
}
});
var _TextureMatrix = __webpack_require__(194);
Object.defineProperty(exports, 'TextureMatrix', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_TextureMatrix).default;
}
});
var _BaseTexture = __webpack_require__(58);
Object.defineProperty(exports, 'BaseTexture', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_BaseTexture).default;
}
});
var _RenderTexture = __webpack_require__(128);
Object.defineProperty(exports, 'RenderTexture', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_RenderTexture).default;
}
});
var _BaseRenderTexture = __webpack_require__(189);
Object.defineProperty(exports, 'BaseRenderTexture', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_BaseRenderTexture).default;
}
});
var _VideoBaseTexture = __webpack_require__(186);
Object.defineProperty(exports, 'VideoBaseTexture', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_VideoBaseTexture).default;
}
});
var _TextureUvs = __webpack_require__(187);
Object.defineProperty(exports, 'TextureUvs', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_TextureUvs).default;
}
});
var _CanvasRenderTarget = __webpack_require__(190);
Object.defineProperty(exports, 'CanvasRenderTarget', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_CanvasRenderTarget).default;
}
});
var _Shader = __webpack_require__(67);
Object.defineProperty(exports, 'Shader', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Shader).default;
}
});
var _WebGLManager = __webpack_require__(66);
Object.defineProperty(exports, 'WebGLManager', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_WebGLManager).default;
}
});
var _ObjectRenderer = __webpack_require__(85);
Object.defineProperty(exports, 'ObjectRenderer', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_ObjectRenderer).default;
}
});
var _RenderTarget = __webpack_require__(87);
Object.defineProperty(exports, 'RenderTarget', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_RenderTarget).default;
}
});
var _Quad = __webpack_require__(195);
Object.defineProperty(exports, 'Quad', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Quad).default;
}
});
var _SpriteMaskFilter = __webpack_require__(192);
Object.defineProperty(exports, 'SpriteMaskFilter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_SpriteMaskFilter).default;
}
});
var _Filter = __webpack_require__(193);
Object.defineProperty(exports, 'Filter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Filter).default;
}
});
var _Application = __webpack_require__(199);
Object.defineProperty(exports, 'Application', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Application).default;
}
});
var _autoDetectRenderer = __webpack_require__(200);
Object.defineProperty(exports, 'autoDetectRenderer', {
enumerable: true,
get: function get() {
return _autoDetectRenderer.autoDetectRenderer;
}
});
var _utils = __webpack_require__(7);
var utils = _interopRequireWildcard(_utils);
var _ticker = __webpack_require__(127);
var ticker = _interopRequireWildcard(_ticker);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
var _CanvasRenderer = __webpack_require__(65);
var _CanvasRenderer2 = _interopRequireDefault(_CanvasRenderer);
var _WebGLRenderer = __webpack_require__(86);
var _WebGLRenderer2 = _interopRequireDefault(_WebGLRenderer);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.settings = _settings2.default;
exports.utils = utils;
exports.ticker = ticker;
exports.CanvasRenderer = _CanvasRenderer2.default;
exports.WebGLRenderer = _WebGLRenderer2.default; /**
* @namespace PIXI
*/
//# sourceMappingURL=index.js.map
/***/ }),
/* 6 */
/***/ (function(module, exports) {
module.exports = function (it) {
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.premultiplyBlendMode = exports.BaseTextureCache = exports.TextureCache = exports.earcut = exports.mixins = exports.pluginTarget = exports.EventEmitter = exports.removeItems = exports.isMobile = undefined;
exports.uid = uid;
exports.hex2rgb = hex2rgb;
exports.hex2string = hex2string;
exports.rgb2hex = rgb2hex;
exports.getResolutionOfUrl = getResolutionOfUrl;
exports.decomposeDataUri = decomposeDataUri;
exports.getUrlFileExtension = getUrlFileExtension;
exports.getSvgSize = getSvgSize;
exports.skipHello = skipHello;
exports.sayHello = sayHello;
exports.isWebGLSupported = isWebGLSupported;
exports.sign = sign;
exports.destroyTextureCache = destroyTextureCache;
exports.clearTextureCache = clearTextureCache;
exports.correctBlendMode = correctBlendMode;
exports.premultiplyTint = premultiplyTint;
exports.premultiplyRgba = premultiplyRgba;
exports.premultiplyTintToRgba = premultiplyTintToRgba;
var _const = __webpack_require__(3);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
var _eventemitter = __webpack_require__(52);
var _eventemitter2 = _interopRequireDefault(_eventemitter);
var _pluginTarget = __webpack_require__(453);
var _pluginTarget2 = _interopRequireDefault(_pluginTarget);
var _mixin = __webpack_require__(454);
var mixins = _interopRequireWildcard(_mixin);
var _ismobilejs = __webpack_require__(122);
var isMobile = _interopRequireWildcard(_ismobilejs);
var _removeArrayItems = __webpack_require__(455);
var _removeArrayItems2 = _interopRequireDefault(_removeArrayItems);
var _mapPremultipliedBlendModes = __webpack_require__(456);
var _mapPremultipliedBlendModes2 = _interopRequireDefault(_mapPremultipliedBlendModes);
var _earcut = __webpack_require__(124);
var _earcut2 = _interopRequireDefault(_earcut);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var nextUid = 0;
var saidHello = false;
/**
* Generalized convenience utilities for PIXI.
* @example
* // Extend PIXI's internal Event Emitter.
* class MyEmitter extends PIXI.utils.EventEmitter {
* constructor() {
* super();
* console.log("Emitter created!");
* }
* }
*
* // Get info on current device
* console.log(PIXI.utils.isMobile);
*
* // Convert hex color to string
* console.log(PIXI.utils.hex2string(0xff00ff)); // returns: "#ff00ff"
* @namespace PIXI.utils
*/
exports.isMobile = isMobile;
exports.removeItems = _removeArrayItems2.default;
exports.EventEmitter = _eventemitter2.default;
exports.pluginTarget = _pluginTarget2.default;
exports.mixins = mixins;
exports.earcut = _earcut2.default;
/**
* Gets the next unique identifier
*
* @memberof PIXI.utils
* @function uid
* @return {number} The next unique identifier to use.
*/
function uid() {
return ++nextUid;
}
/**
* Converts a hex color number to an [R, G, B] array
*
* @memberof PIXI.utils
* @function hex2rgb
* @param {number} hex - The number to convert
* @param {number[]} [out=[]] If supplied, this array will be used rather than returning a new one
* @return {number[]} An array representing the [R, G, B] of the color.
*/
function hex2rgb(hex, out) {
out = out || [];
out[0] = (hex >> 16 & 0xFF) / 255;
out[1] = (hex >> 8 & 0xFF) / 255;
out[2] = (hex & 0xFF) / 255;
return out;
}
/**
* Converts a hex color number to a string.
*
* @memberof PIXI.utils
* @function hex2string
* @param {number} hex - Number in hex
* @return {string} The string color.
*/
function hex2string(hex) {
hex = hex.toString(16);
hex = '000000'.substr(0, 6 - hex.length) + hex;
return '#' + hex;
}
/**
* Converts a color as an [R, G, B] array to a hex number
*
* @memberof PIXI.utils
* @function rgb2hex
* @param {number[]} rgb - rgb array
* @return {number} The color number
*/
function rgb2hex(rgb) {
return (rgb[0] * 255 << 16) + (rgb[1] * 255 << 8) + (rgb[2] * 255 | 0);
}
/**
* get the resolution / device pixel ratio of an asset by looking for the prefix
* used by spritesheets and image urls
*
* @memberof PIXI.utils
* @function getResolutionOfUrl
* @param {string} url - the image path
* @param {number} [defaultValue=1] - the defaultValue if no filename prefix is set.
* @return {number} resolution / device pixel ratio of an asset
*/
function getResolutionOfUrl(url, defaultValue) {
var resolution = _settings2.default.RETINA_PREFIX.exec(url);
if (resolution) {
return parseFloat(resolution[1]);
}
return defaultValue !== undefined ? defaultValue : 1;
}
/**
* Typedef for decomposeDataUri return object.
*
* @typedef {object} PIXI.utils~DecomposedDataUri
* @property {mediaType} Media type, eg. `image`
* @property {subType} Sub type, eg. `png`
* @property {encoding} Data encoding, eg. `base64`
* @property {data} The actual data
*/
/**
* Split a data URI into components. Returns undefined if
* parameter `dataUri` is not a valid data URI.
*
* @memberof PIXI.utils
* @function decomposeDataUri
* @param {string} dataUri - the data URI to check
* @return {PIXI.utils~DecomposedDataUri|undefined} The decomposed data uri or undefined
*/
function decomposeDataUri(dataUri) {
var dataUriMatch = _const.DATA_URI.exec(dataUri);
if (dataUriMatch) {
return {
mediaType: dataUriMatch[1] ? dataUriMatch[1].toLowerCase() : undefined,
subType: dataUriMatch[2] ? dataUriMatch[2].toLowerCase() : undefined,
charset: dataUriMatch[3] ? dataUriMatch[3].toLowerCase() : undefined,
encoding: dataUriMatch[4] ? dataUriMatch[4].toLowerCase() : undefined,
data: dataUriMatch[5]
};
}
return undefined;
}
/**
* Get type of the image by regexp for extension. Returns undefined for unknown extensions.
*
* @memberof PIXI.utils
* @function getUrlFileExtension
* @param {string} url - the image path
* @return {string|undefined} image extension
*/
function getUrlFileExtension(url) {
var extension = _const.URL_FILE_EXTENSION.exec(url);
if (extension) {
return extension[1].toLowerCase();
}
return undefined;
}
/**
* Typedef for Size object.
*
* @typedef {object} PIXI.utils~Size
* @property {width} Width component
* @property {height} Height component
*/
/**
* Get size from an svg string using regexp.
*
* @memberof PIXI.utils
* @function getSvgSize
* @param {string} svgString - a serialized svg element
* @return {PIXI.utils~Size|undefined} image extension
*/
function getSvgSize(svgString) {
var sizeMatch = _const.SVG_SIZE.exec(svgString);
var size = {};
if (sizeMatch) {
size[sizeMatch[1]] = Math.round(parseFloat(sizeMatch[3]));
size[sizeMatch[5]] = Math.round(parseFloat(sizeMatch[7]));
}
return size;
}
/**
* Skips the hello message of renderers that are created after this is run.
*
* @function skipHello
* @memberof PIXI.utils
*/
function skipHello() {
saidHello = true;
}
/**
* Logs out the version and renderer information for this running instance of PIXI.
* If you don't want to see this message you can run `PIXI.utils.skipHello()` before
* creating your renderer. Keep in mind that doing that will forever makes you a jerk face.
*
* @static
* @function sayHello
* @memberof PIXI.utils
* @param {string} type - The string renderer type to log.
*/
function sayHello(type) {
if (saidHello) {
return;
}
if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
var args = ['\n %c %c %c PixiJS ' + _const.VERSION + ' - \u2730 ' + type + ' \u2730 %c %c http://www.pixijs.com/ %c %c \u2665%c\u2665%c\u2665 \n\n', 'background: #ff66a5; padding:5px 0;', 'background: #ff66a5; padding:5px 0;', 'color: #ff66a5; background: #030307; padding:5px 0;', 'background: #ff66a5; padding:5px 0;', 'background: #ffc3dc; padding:5px 0;', 'background: #ff66a5; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;', 'color: #ff2424; background: #fff; padding:5px 0;'];
window.console.log.apply(console, args);
} else if (window.console) {
window.console.log('PixiJS ' + _const.VERSION + ' - ' + type + ' - http://www.pixijs.com/');
}
saidHello = true;
}
/**
* Helper for checking for webgl support
*
* @memberof PIXI.utils
* @function isWebGLSupported
* @return {boolean} is webgl supported
*/
function isWebGLSupported() {
var contextOptions = { stencil: true, failIfMajorPerformanceCaveat: true };
try {
if (!window.WebGLRenderingContext) {
return false;
}
var canvas = document.createElement('canvas');
var gl = canvas.getContext('webgl', contextOptions) || canvas.getContext('experimental-webgl', contextOptions);
var success = !!(gl && gl.getContextAttributes().stencil);
if (gl) {
var loseContext = gl.getExtension('WEBGL_lose_context');
if (loseContext) {
loseContext.loseContext();
}
}
gl = null;
return success;
} catch (e) {
return false;
}
}
/**
* Returns sign of number
*
* @memberof PIXI.utils
* @function sign
* @param {number} n - the number to check the sign of
* @returns {number} 0 if `n` is 0, -1 if `n` is negative, 1 if `n` is positive
*/
function sign(n) {
if (n === 0) return 0;
return n < 0 ? -1 : 1;
}
/**
* @todo Describe property usage
*
* @memberof PIXI.utils
* @private
*/
var TextureCache = exports.TextureCache = Object.create(null);
/**
* @todo Describe property usage
*
* @memberof PIXI.utils
* @private
*/
var BaseTextureCache = exports.BaseTextureCache = Object.create(null);
/**
* Destroys all texture in the cache
*
* @memberof PIXI.utils
* @function destroyTextureCache
*/
function destroyTextureCache() {
var key = void 0;
for (key in TextureCache) {
TextureCache[key].destroy();
}
for (key in BaseTextureCache) {
BaseTextureCache[key].destroy();
}
}
/**
* Removes all textures from cache, but does not destroy them
*
* @memberof PIXI.utils
* @function clearTextureCache
*/
function clearTextureCache() {
var key = void 0;
for (key in TextureCache) {
delete TextureCache[key];
}
for (key in BaseTextureCache) {
delete BaseTextureCache[key];
}
}
/**
* maps premultiply flag and blendMode to adjusted blendMode
* @memberof PIXI.utils
* @const premultiplyBlendMode
* @type {Array<number[]>}
*/
var premultiplyBlendMode = exports.premultiplyBlendMode = (0, _mapPremultipliedBlendModes2.default)();
/**
* changes blendMode according to texture format
*
* @memberof PIXI.utils
* @function correctBlendMode
* @param {number} blendMode supposed blend mode
* @param {boolean} premultiplied whether source is premultiplied
* @returns {number} true blend mode for this texture
*/
function correctBlendMode(blendMode, premultiplied) {
return premultiplyBlendMode[premultiplied ? 1 : 0][blendMode];
}
/**
* premultiplies tint
*
* @memberof PIXI.utils
* @param {number} tint integet RGB
* @param {number} alpha floating point alpha (0.0-1.0)
* @returns {number} tint multiplied by alpha
*/
function premultiplyTint(tint, alpha) {
if (alpha === 1.0) {
return (alpha * 255 << 24) + tint;
}
if (alpha === 0.0) {
return 0;
}
var R = tint >> 16 & 0xFF;
var G = tint >> 8 & 0xFF;
var B = tint & 0xFF;
R = R * alpha + 0.5 | 0;
G = G * alpha + 0.5 | 0;
B = B * alpha + 0.5 | 0;
return (alpha * 255 << 24) + (R << 16) + (G << 8) + B;
}
/**
* combines rgb and alpha to out array
*
* @memberof PIXI.utils
* @param {Float32Array|number[]} rgb input rgb
* @param {number} alpha alpha param
* @param {Float32Array} [out] output
* @param {boolean} [premultiply=true] do premultiply it
* @returns {Float32Array} vec4 rgba
*/
function premultiplyRgba(rgb, alpha, out, premultiply) {
out = out || new Float32Array(4);
if (premultiply || premultiply === undefined) {
out[0] = rgb[0] * alpha;
out[1] = rgb[1] * alpha;
out[2] = rgb[2] * alpha;
} else {
out[0] = rgb[0];
out[1] = rgb[1];
out[2] = rgb[2];
}
out[3] = alpha;
return out;
}
/**
* converts integer tint and float alpha to vec4 form, premultiplies by default
*
* @memberof PIXI.utils
* @param {number} tint input tint
* @param {number} alpha alpha param
* @param {Float32Array} [out] output
* @param {boolean} [premultiply=true] do premultiply it
* @returns {Float32Array} vec4 rgba
*/
function premultiplyTintToRgba(tint, alpha, out, premultiply) {
out = out || new Float32Array(4);
out[0] = (tint >> 16 & 0xFF) / 255.0;
out[1] = (tint >> 8 & 0xFF) / 255.0;
out[2] = (tint & 0xFF) / 255.0;
if (premultiply || premultiply === undefined) {
out[0] *= alpha;
out[1] *= alpha;
out[2] *= alpha;
}
out[3] = alpha;
return out;
}
//# sourceMappingURL=index.js.map
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
var store = __webpack_require__(59)('wks');
var uid = __webpack_require__(42);
var Symbol = __webpack_require__(2).Symbol;
var USE_SYMBOL = typeof Symbol == 'function';
var $exports = module.exports = function (name) {
return store[name] || (store[name] =
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
};
$exports.store = store;
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
// 7.1.15 ToLength
var toInteger = __webpack_require__(27);
var min = Math.min;
module.exports = function (it) {
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
};
/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {
// Thank's IE8 for his funny defineProperty
module.exports = !__webpack_require__(4)(function () {
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
});
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
var anObject = __webpack_require__(1);
var IE8_DOM_DEFINE = __webpack_require__(133);
var toPrimitive = __webpack_require__(30);
var dP = Object.defineProperty;
exports.f = __webpack_require__(10) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
anObject(O);
P = toPrimitive(P, true);
anObject(Attributes);
if (IE8_DOM_DEFINE) try {
return dP(O, P, Attributes);
} catch (e) { /* empty */ }
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
// 7.1.13 ToObject(argument)
var defined = __webpack_require__(31);
module.exports = function (it) {
return Object(defined(it));
};
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _maxRecommendedTextures = __webpack_require__(451);
var _maxRecommendedTextures2 = _interopRequireDefault(_maxRecommendedTextures);
var _canUploadSameBuffer = __webpack_require__(452);
var _canUploadSameBuffer2 = _interopRequireDefault(_canUploadSameBuffer);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* User's customizable globals for overriding the default PIXI settings, such
* as a renderer's default resolution, framerate, float percision, etc.
* @example
* // Use the native window resolution as the default resolution
* // will support high-density displays when rendering
* PIXI.settings.RESOLUTION = window.devicePixelRatio.
*
* // Disable interpolation when scaling, will make texture be pixelated
* PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;
* @namespace PIXI.settings
*/
exports.default = {
/**
* Target frames per millisecond.
*
* @static
* @memberof PIXI.settings
* @type {number}
* @default 0.06
*/
TARGET_FPMS: 0.06,
/**
* If set to true WebGL will attempt make textures mimpaped by default.
* Mipmapping will only succeed if the base texture uploaded has power of two dimensions.
*
* @static
* @memberof PIXI.settings
* @type {boolean}
* @default true
*/
MIPMAP_TEXTURES: true,
/**
* Default resolution / device pixel ratio of the renderer.
*
* @static
* @memberof PIXI.settings
* @type {number}
* @default 1
*/
RESOLUTION: 1,
/**
* Default filter resolution.
*
* @static
* @memberof PIXI.settings
* @type {number}
* @default 1
*/
FILTER_RESOLUTION: 1,
/**
* The maximum textures that this device supports.
*
* @static
* @memberof PIXI.settings
* @type {number}
* @default 32
*/
SPRITE_MAX_TEXTURES: (0, _maxRecommendedTextures2.default)(32),
// TODO: maybe change to SPRITE.BATCH_SIZE: 2000
// TODO: maybe add PARTICLE.BATCH_SIZE: 15000
/**
* The default sprite batch size.
*
* The default aims to balance desktop and mobile devices.
*
* @static
* @memberof PIXI.settings
* @type {number}
* @default 4096
*/
SPRITE_BATCH_SIZE: 4096,
/**
* The prefix that denotes a URL is for a retina asset.
*
* @static
* @memberof PIXI.settings
* @type {RegExp}
* @example `@2x`
* @default /@([0-9\.]+)x/
*/
RETINA_PREFIX: /@([0-9\.]+)x/,
/**
* The default render options if none are supplied to {@link PIXI.WebGLRenderer}
* or {@link PIXI.CanvasRenderer}.
*
* @static
* @constant
* @memberof PIXI.settings
* @type {object}
* @property {HTMLCanvasElement} view=null
* @property {number} resolution=1
* @property {boolean} antialias=false
* @property {boolean} forceFXAA=false
* @property {boolean} autoResize=false
* @property {boolean} transparent=false
* @property {number} backgroundColor=0x000000
* @property {boolean} clearBeforeRender=true
* @property {boolean} preserveDrawingBuffer=false
* @property {boolean} roundPixels=false
* @property {number} width=800
* @property {number} height=600
* @property {boolean} legacy=false
*/
RENDER_OPTIONS: {
view: null,
antialias: false,
forceFXAA: false,
autoResize: false,
transparent: false,
backgroundColor: 0x000000,
clearBeforeRender: true,
preserveDrawingBuffer: false,
roundPixels: false,
width: 800,
height: 600,
legacy: false
},
/**
* Default transform type.
*
* @static
* @memberof PIXI.settings
* @type {PIXI.TRANSFORM_MODE}
* @default PIXI.TRANSFORM_MODE.STATIC
*/
TRANSFORM_MODE: 0,
/**
* Default Garbage Collection mode.
*
* @static
* @memberof PIXI.settings
* @type {PIXI.GC_MODES}
* @default PIXI.GC_MODES.AUTO
*/
GC_MODE: 0,
/**
* Default Garbage Collection max idle.
*
* @static
* @memberof PIXI.settings
* @type {number}
* @default 3600
*/
GC_MAX_IDLE: 60 * 60,
/**
* Default Garbage Collection maximum check count.
*
* @static
* @memberof PIXI.settings
* @type {number}
* @default 600
*/
GC_MAX_CHECK_COUNT: 60 * 10,
/**
* Default wrap modes that are supported by pixi.
*
* @static
* @memberof PIXI.settings
* @type {PIXI.WRAP_MODES}
* @default PIXI.WRAP_MODES.CLAMP
*/
WRAP_MODE: 0,
/**
* The scale modes that are supported by pixi.
*
* @static
* @memberof PIXI.settings
* @type {PIXI.SCALE_MODES}
* @default PIXI.SCALE_MODES.LINEAR
*/
SCALE_MODE: 0,
/**
* Default specify float precision in vertex shader.
*
* @static
* @memberof PIXI.settings
* @type {PIXI.PRECISION}
* @default PIXI.PRECISION.HIGH
*/
PRECISION_VERTEX: 'highp',
/**
* Default specify float precision in fragment shader.
*
* @static
* @memberof PIXI.settings
* @type {PIXI.PRECISION}
* @default PIXI.PRECISION.MEDIUM
*/
PRECISION_FRAGMENT: 'mediump',
/**
* Can we upload the same buffer in a single frame?
*
* @static
* @constant
* @memberof PIXI.settings
* @type {boolean}
*/
CAN_UPLOAD_SAME_BUFFER: (0, _canUploadSameBuffer2.default)(),
/**
* Default Mesh `canvasPadding`.
*
* @see PIXI.mesh.Mesh#canvasPadding
* @static
* @constant
* @memberof PIXI.settings
* @type {number}
*/
MESH_CANVAS_PADDING: 0
};
//# sourceMappingURL=settings.js.map
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Point = __webpack_require__(117);
Object.defineProperty(exports, 'Point', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Point).default;
}
});
var _ObservablePoint = __webpack_require__(170);
Object.defineProperty(exports, 'ObservablePoint', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_ObservablePoint).default;
}
});
var _Matrix = __webpack_require__(118);
Object.defineProperty(exports, 'Matrix', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Matrix).default;
}
});
var _GroupD = __webpack_require__(171);
Object.defineProperty(exports, 'GroupD8', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_GroupD).default;
}
});
var _Circle = __webpack_require__(441);
Object.defineProperty(exports, 'Circle', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Circle).default;
}
});
var _Ellipse = __webpack_require__(442);
Object.defineProperty(exports, 'Ellipse', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Ellipse).default;
}
});
var _Polygon = __webpack_require__(443);
Object.defineProperty(exports, 'Polygon', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Polygon).default;
}
});
var _Rectangle = __webpack_require__(119);
Object.defineProperty(exports, 'Rectangle', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Rectangle).default;
}
});
var _RoundedRectangle = __webpack_require__(444);
Object.defineProperty(exports, 'RoundedRectangle', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_RoundedRectangle).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map
/***/ }),
/* 15 */
/***/ (function(module, exports) {
module.exports = function (it) {
if (typeof it != 'function') throw TypeError(it + ' is not a function!');
return it;
};
/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {
var dP = __webpack_require__(11);
var createDesc = __webpack_require__(41);
module.exports = __webpack_require__(10) ? function (object, key, value) {
return dP.f(object, key, createDesc(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(2);
var hide = __webpack_require__(16);
var has = __webpack_require__(19);
var SRC = __webpack_require__(42)('src');
var $toString = __webpack_require__(232);
var TO_STRING = 'toString';
var TPL = ('' + $toString).split(TO_STRING);
__webpack_require__(24).inspectSource = function (it) {
return $toString.call(it);
};
(module.exports = function (O, key, val, safe) {
var isFunction = typeof val == 'function';
if (isFunction) has(val, 'name') || hide(val, 'name', key);
if (O[key] === val) return;
if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
if (O === global) {
O[key] = val;
} else if (!safe) {
delete O[key];
hide(O, key, val);
} else if (O[key]) {
O[key] = val;
} else {
hide(O, key, val);
}
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
})(Function.prototype, TO_STRING, function toString() {
return typeof this == 'function' && this[SRC] || $toString.call(this);
});
/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
var fails = __webpack_require__(4);
var defined = __webpack_require__(31);
var quot = /"/g;
// B.2.3.2.1 CreateHTML(string, tag, attribute, value)
var createHTML = function (string, tag, attribute, value) {
var S = String(defined(string));
var p1 = '<' + tag;
if (attribute !== '') p1 += ' ' + attribute + '="' + String(value).replace(quot, '"') + '"';
return p1 + '>' + S + '</' + tag + '>';
};
module.exports = function (NAME, exec) {
var O = {};
O[NAME] = exec(createHTML);
$export($export.P + $export.F * fails(function () {
var test = ''[NAME]('"');
return test !== test.toLowerCase() || test.split('"').length > 3;
}), 'String', O);
};
/***/ }),
/* 19 */
/***/ (function(module, exports) {
var hasOwnProperty = {}.hasOwnProperty;
module.exports = function (it, key) {
return hasOwnProperty.call(it, key);
};
/***/ }),
/* 20 */
/***/ (function(module, exports, __webpack_require__) {
// to indexed object, toObject with fallback for non-array-like ES3 strings
var IObject = __webpack_require__(60);
var defined = __webpack_require__(31);
module.exports = function (it) {
return IObject(defined(it));
};
/***/ }),
/* 21 */
/***/ (function(module, exports, __webpack_require__) {
var pIE = __webpack_require__(61);
var createDesc = __webpack_require__(41);
var toIObject = __webpack_require__(20);
var toPrimitive = __webpack_require__(30);
var has = __webpack_require__(19);
var IE8_DOM_DEFINE = __webpack_require__(133);
var gOPD = Object.getOwnPropertyDescriptor;
exports.f = __webpack_require__(10) ? gOPD : function getOwnPropertyDescriptor(O, P) {
O = toIObject(O);
P = toPrimitive(P, true);
if (IE8_DOM_DEFINE) try {
return gOPD(O, P);
} catch (e) { /* empty */ }
if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
};
/***/ }),
/* 22 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
var has = __webpack_require__(19);
var toObject = __webpack_require__(12);
var IE_PROTO = __webpack_require__(91)('IE_PROTO');
var ObjectProto = Object.prototype;
module.exports = Object.getPrototypeOf || function (O) {
O = toObject(O);
if (has(O, IE_PROTO)) return O[IE_PROTO];
if (typeof O.constructor == 'function' && O instanceof O.constructor) {
return O.constructor.prototype;
} return O instanceof Object ? ObjectProto : null;
};
/***/ }),
/* 23 */
/***/ (function(module, exports, __webpack_require__) {
var gl = {
createContext: __webpack_require__(445),
setVertexAttribArrays: __webpack_require__(172),
GLBuffer: __webpack_require__(446),
GLFramebuffer: __webpack_require__(447),
GLShader: __webpack_require__(448),
GLTexture: __webpack_require__(173),
VertexArrayObject: __webpack_require__(449),
shader: __webpack_require__(450)
};
// Export for Node-compatible environments
if (typeof module !== 'undefined' && module.exports)
{
// Export the module
module.exports = gl;
}
// Add to the browser window pixi.gl
if (typeof window !== 'undefined')
{
// add the window object
window.PIXI = window.PIXI || {};
window.PIXI.glCore = gl;
}
/***/ }),
/* 24 */
/***/ (function(module, exports) {
var core = module.exports = { version: '2.6.5' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
/***/ }),
/* 25 */
/***/ (function(module, exports, __webpack_require__) {
// optional / simple context binding
var aFunction = __webpack_require__(15);
module.exports = function (fn, that, length) {
aFunction(fn);
if (that === undefined) return fn;
switch (length) {
case 1: return function (a) {
return fn.call(that, a);
};
case 2: return function (a, b) {
return fn.call(that, a, b);
};
case 3: return function (a, b, c) {
return fn.call(that, a, b, c);
};
}
return function (/* ...args */) {
return fn.apply(that, arguments);
};
};
/***/ }),
/* 26 */
/***/ (function(module, exports) {
var toString = {}.toString;
module.exports = function (it) {
return toString.call(it).slice(8, -1);
};
/***/ }),
/* 27 */
/***/ (function(module, exports) {
// 7.1.4 ToInteger
var ceil = Math.ceil;
var floor = Math.floor;
module.exports = function (it) {
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
/***/ }),
/* 28 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var fails = __webpack_require__(4);
module.exports = function (method, arg) {
return !!method && fails(function () {
// eslint-disable-next-line no-useless-call
arg ? method.call(null, function () { /* empty */ }, 1) : method.call(null);
});
};
/***/ }),
/* 29 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(module, global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return _gsScope; });
/* unused harmony export TweenLite */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return globals; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return TweenLite; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return SimpleTimeline; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Animation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Ease; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Linear; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return Power0; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return Power1; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return Power2; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return Power3; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return Power4; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return TweenPlugin; });
/* unused harmony export EventDispatcher */
/*!
* VERSION: 2.1.2
* DATE: 2019-03-01
* UPDATES AND DOCS AT: http://greensock.com
*
* @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
* This work is subject to the terms at http://greensock.com/standard-license or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
/* eslint-disable */
/* ES6 changes:
- declare and export _gsScope at top.
- set var TweenLite = the result of the main function
- export default TweenLite at the bottom
- return TweenLite at the bottom of the main function
- pass in _gsScope as the first parameter of the main function (which is actually at the bottom)
- remove the "export to multiple environments" in Definition().
*/
var _gsScope = (typeof(window) !== "undefined") ? window : (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || {};
var TweenLite = (function(window) {
"use strict";
var _exports = {},
_doc = window.document,
_globals = window.GreenSockGlobals = window.GreenSockGlobals || window;
if (_globals.TweenLite) {
return _globals.TweenLite; //in case the core set of classes is already loaded, don't instantiate twice.
}
var _namespace = function(ns) {
var a = ns.split("."),
p = _globals, i;
for (i = 0; i < a.length; i++) {
p[a[i]] = p = p[a[i]] || {};
}
return p;
},
gs = _namespace("com.greensock"),
_tinyNum = 0.00000001,
_slice = function(a) { //don't use Array.prototype.slice.call(target, 0) because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll()
var b = [],
l = a.length,
i;
for (i = 0; i !== l; b.push(a[i++])) {}
return b;
},
_emptyFunc = function() {},
_isArray = (function() { //works around issues in iframe environments where the Array global isn't shared, thus if the object originates in a different window/iframe, "(obj instanceof Array)" will evaluate false. We added some speed optimizations to avoid Object.prototype.toString.call() unless it's absolutely necessary because it's VERY slow (like 20x slower)
var toString = Object.prototype.toString,
array = toString.call([]);
return function(obj) {
return obj != null && (obj instanceof Array || (typeof(obj) === "object" && !!obj.push && toString.call(obj) === array));
};
}()),
a, i, p, _ticker, _tickerActive,
_defLookup = {},
/**
* @constructor
* Defines a GreenSock class, optionally with an array of dependencies that must be instantiated first and passed into the definition.
* This allows users to load GreenSock JS files in any order even if they have interdependencies (like CSSPlugin extends TweenPlugin which is
* inside TweenLite.js, but if CSSPlugin is loaded first, it should wait to run its code until TweenLite.js loads and instantiates TweenPlugin
* and then pass TweenPlugin to CSSPlugin's definition). This is all done automatically and internally.
*
* Every definition will be added to a "com.greensock" global object (typically window, but if a window.GreenSockGlobals object is found,
* it will go there as of v1.7). For example, TweenLite will be found at window.com.greensock.TweenLite and since it's a global class that should be available anywhere,
* it is ALSO referenced at window.TweenLite. However some classes aren't considered global, like the base com.greensock.core.Animation class, so
* those will only be at the package like window.com.greensock.core.Animation. Again, if you define a GreenSockGlobals object on the window, everything
* gets tucked neatly inside there instead of on the window directly. This allows you to do advanced things like load multiple versions of GreenSock
* files and put them into distinct objects (imagine a banner ad uses a newer version but the main site uses an older one). In that case, you could
* sandbox the banner one like:
*
* <script>
* var gs = window.GreenSockGlobals = {}; //the newer version we're about to load could now be referenced in a "gs" object, like gs.TweenLite.to(...). Use whatever alias you want as long as it's unique, "gs" or "banner" or whatever.
* </script>
* <script src="js/greensock/v1.7/TweenMax.js"></script>
* <script>
* window.GreenSockGlobals = window._gsQueue = window._gsDefine = null; //reset it back to null (along with the special _gsQueue variable) so that the next load of TweenMax affects the window and we can reference things directly like TweenLite.to(...)
* </script>
* <script src="js/greensock/v1.6/TweenMax.js"></script>
* <script>
* gs.TweenLite.to(...); //would use v1.7
* TweenLite.to(...); //would use v1.6
* </script>
*
* @param {!string} ns The namespace of the class definition, leaving off "com.greensock." as that's assumed. For example, "TweenLite" or "plugins.CSSPlugin" or "easing.Back".
* @param {!Array.<string>} dependencies An array of dependencies (described as their namespaces minus "com.greensock." prefix). For example ["TweenLite","plugins.TweenPlugin","core.Animation"]
* @param {!function():Object} func The function that should be called and passed the resolved dependencies which will return the actual class for this definition.
* @param {boolean=} global If true, the class will be added to the global scope (typically window unless you define a window.GreenSockGlobals object)
*/
Definition = function(ns, dependencies, func, global) {
this.sc = (_defLookup[ns]) ? _defLookup[ns].sc : []; //subclasses
_defLookup[ns] = this;
this.gsClass = null;
this.func = func;
var _classes = [];
this.check = function(init) {
var i = dependencies.length,
missing = i,
cur, a, n, cl;
while (--i > -1) {
if ((cur = _defLookup[dependencies[i]] || new Definition(dependencies[i], [])).gsClass) {
_classes[i] = cur.gsClass;
missing--;
} else if (init) {
cur.sc.push(this);
}
}
if (missing === 0 && func) {
a = ("com.greensock." + ns).split(".");
n = a.pop();
cl = _namespace(a.join("."))[n] = this.gsClass = func.apply(func, _classes);
//exports to multiple environments
if (global) {
_globals[n] = _exports[n] = cl; //provides a way to avoid global namespace pollution. By default, the main classes like TweenLite, Power1, Strong, etc. are added to window unless a GreenSockGlobals is defined. So if you want to have things added to a custom object instead, just do something like window.GreenSockGlobals = {} before loading any GreenSock files. You can even set up an alias like window.GreenSockGlobals = windows.gs = {} so that you can access everything like gs.TweenLite. Also remember that ALL classes are added to the window.com.greensock object (in their respective packages, like com.greensock.easing.Power1, com.greensock.TweenLite, etc.)
/*
if (typeof(module) !== "undefined" && module.exports) { //node
if (ns === moduleName) {
module.exports = _exports[moduleName] = cl;
for (i in _exports) {
cl[i] = _exports[i];
}
} else if (_exports[moduleName]) {
_exports[moduleName][n] = cl;
}
} else if (typeof(define) === "function" && define.amd){ //AMD
define((window.GreenSockAMDPath ? window.GreenSockAMDPath + "/" : "") + ns.split(".").pop(), [], function() { return cl; });
}
*/
}
for (i = 0; i < this.sc.length; i++) {
this.sc[i].check();
}
}
};
this.check(true);
},
//used to create Definition instances (which basically registers a class that has dependencies).
_gsDefine = window._gsDefine = function(ns, dependencies, func, global) {
return new Definition(ns, dependencies, func, global);
},
//a quick way to create a class that doesn't have any dependencies. Returns the class, but first registers it in the GreenSock namespace so that other classes can grab it (other classes might be dependent on the class).
_class = gs._class = function(ns, func, global) {
func = func || function() {};
_gsDefine(ns, [], function(){ return func; }, global);
return func;
};
_gsDefine.globals = _globals;
/*
* ----------------------------------------------------------------
* Ease
* ----------------------------------------------------------------
*/
var _baseParams = [0, 0, 1, 1],
Ease = _class("easing.Ease", function(func, extraParams, type, power) {
this._func = func;
this._type = type || 0;
this._power = power || 0;
this._params = extraParams ? _baseParams.concat(extraParams) : _baseParams;
}, true),
_easeMap = Ease.map = {},
_easeReg = Ease.register = function(ease, names, types, create) {
var na = names.split(","),
i = na.length,
ta = (types || "easeIn,easeOut,easeInOut").split(","),
e, name, j, type;
while (--i > -1) {
name = na[i];
e = create ? _class("easing."+name, null, true) : gs.easing[name] || {};
j = ta.length;
while (--j > -1) {
type = ta[j];
_easeMap[name + "." + type] = _easeMap[type + name] = e[type] = ease.getRatio ? ease : ease[type] || new ease();
}
}
};
p = Ease.prototype;
p._calcEnd = false;
p.getRatio = function(p) {
if (this._func) {
this._params[0] = p;
return this._func.apply(null, this._params);
}
var t = this._type,
pw = this._power,
r = (t === 1) ? 1 - p : (t === 2) ? p : (p < 0.5) ? p * 2 : (1 - p) * 2;
if (pw === 1) {
r *= r;
} else if (pw === 2) {
r *= r * r;
} else if (pw === 3) {
r *= r * r * r;
} else if (pw === 4) {
r *= r * r * r * r;
}
return (t === 1) ? 1 - r : (t === 2) ? r : (p < 0.5) ? r / 2 : 1 - (r / 2);
};
//create all the standard eases like Linear, Quad, Cubic, Quart, Quint, Strong, Power0, Power1, Power2, Power3, and Power4 (each with easeIn, easeOut, and easeInOut)
a = ["Linear","Quad","Cubic","Quart","Quint,Strong"];
i = a.length;
while (--i > -1) {
p = a[i]+",Power"+i;
_easeReg(new Ease(null,null,1,i), p, "easeOut", true);
_easeReg(new Ease(null,null,2,i), p, "easeIn" + ((i === 0) ? ",easeNone" : ""));
_easeReg(new Ease(null,null,3,i), p, "easeInOut");
}
_easeMap.linear = gs.easing.Linear.easeIn;
_easeMap.swing = gs.easing.Quad.easeInOut; //for jQuery folks
/*
* ----------------------------------------------------------------
* EventDispatcher
* ----------------------------------------------------------------
*/
var EventDispatcher = _class("events.EventDispatcher", function(target) {
this._listeners = {};
this._eventTarget = target || this;
});
p = EventDispatcher.prototype;
p.addEventListener = function(type, callback, scope, useParam, priority) {
priority = priority || 0;
var list = this._listeners[type],
index = 0,
listener, i;
if (this === _ticker && !_tickerActive) {
_ticker.wake();
}
if (list == null) {
this._listeners[type] = list = [];
}
i = list.length;
while (--i > -1) {
listener = list[i];
if (listener.c === callback && listener.s === scope) {
list.splice(i, 1);
} else if (index === 0 && listener.pr < priority) {
index = i + 1;
}
}
list.splice(index, 0, {c:callback, s:scope, up:useParam, pr:priority});
};
p.removeEventListener = function(type, callback) {
var list = this._listeners[type], i;
if (list) {
i = list.length;
while (--i > -1) {
if (list[i].c === callback) {
list.splice(i, 1);
return;
}
}
}
};
p.dispatchEvent = function(type) {
var list = this._listeners[type],
i, t, listener;
if (list) {
i = list.length;
if (i > 1) {
list = list.slice(0); //in case addEventListener() is called from within a listener/callback (otherwise the index could change, resulting in a skip)
}
t = this._eventTarget;
while (--i > -1) {
listener = list[i];
if (listener) {
if (listener.up) {
listener.c.call(listener.s || t, {type:type, target:t});
} else {
listener.c.call(listener.s || t);
}
}
}
}
};
/*
* ----------------------------------------------------------------
* Ticker
* ----------------------------------------------------------------
*/
var _reqAnimFrame = window.requestAnimationFrame,
_cancelAnimFrame = window.cancelAnimationFrame,
_getTime = Date.now || function() {return new Date().getTime();},
_lastUpdate = _getTime();
//now try to determine the requestAnimationFrame and cancelAnimationFrame functions and if none are found, we'll use a setTimeout()/clearTimeout() polyfill.
a = ["ms","moz","webkit","o"];
i = a.length;
while (--i > -1 && !_reqAnimFrame) {
_reqAnimFrame = window[a[i] + "RequestAnimationFrame"];
_cancelAnimFrame = window[a[i] + "CancelAnimationFrame"] || window[a[i] + "CancelRequestAnimationFrame"];
}
_class("Ticker", function(fps, useRAF) {
var _self = this,
_startTime = _getTime(),
_useRAF = (useRAF !== false && _reqAnimFrame) ? "auto" : false,
_lagThreshold = 500,
_adjustedLag = 33,
_tickWord = "tick", //helps reduce gc burden
_fps, _req, _id, _gap, _nextTime,
_tick = function(manual) {
var elapsed = _getTime() - _lastUpdate,
overlap, dispatch;
if (elapsed > _lagThreshold) {
_startTime += elapsed - _adjustedLag;
}
_lastUpdate += elapsed;
_self.time = (_lastUpdate - _startTime) / 1000;
overlap = _self.time - _nextTime;
if (!_fps || overlap > 0 || manual === true) {
_self.frame++;
_nextTime += overlap + (overlap >= _gap ? 0.004 : _gap - overlap);
dispatch = true;
}
if (manual !== true) { //make sure the request is made before we dispatch the "tick" event so that timing is maintained. Otherwise, if processing the "tick" requires a bunch of time (like 15ms) and we're using a setTimeout() that's based on 16.7ms, it'd technically take 31.7ms between frames otherwise.
_id = _req(_tick);
}
if (dispatch) {
_self.dispatchEvent(_tickWord);
}
};
EventDispatcher.call(_self);
_self.time = _self.frame = 0;
_self.tick = function() {
_tick(true);
};
_self.lagSmoothing = function(threshold, adjustedLag) {
if (!arguments.length) { //if lagSmoothing() is called with no arguments, treat it like a getter that returns a boolean indicating if it's enabled or not. This is purposely undocumented and is for internal use.
return (_lagThreshold < 1 / _tinyNum);
}
_lagThreshold = threshold || (1 / _tinyNum); //zero should be interpreted as basically unlimited
_adjustedLag = Math.min(adjustedLag, _lagThreshold, 0);
};
_self.sleep = function() {
if (_id == null) {
return;
}
if (!_useRAF || !_cancelAnimFrame) {
clearTimeout(_id);
} else {
_cancelAnimFrame(_id);
}
_req = _emptyFunc;
_id = null;
if (_self === _ticker) {
_tickerActive = false;
}
};
_self.wake = function(seamless) {
if (_id !== null) {
_self.sleep();
} else if (seamless) {
_startTime += -_lastUpdate + (_lastUpdate = _getTime());
} else if (_self.frame > 10) { //don't trigger lagSmoothing if we're just waking up, and make sure that at least 10 frames have elapsed because of the iOS bug that we work around below with the 1.5-second setTimout().
_lastUpdate = _getTime() - _lagThreshold + 5;
}
_req = (_fps === 0) ? _emptyFunc : (!_useRAF || !_reqAnimFrame) ? function(f) { return setTimeout(f, ((_nextTime - _self.time) * 1000 + 1) | 0); } : _reqAnimFrame;
if (_self === _ticker) {
_tickerActive = true;
}
_tick(2);
};
_self.fps = function(value) {
if (!arguments.length) {
return _fps;
}
_fps = value;
_gap = 1 / (_fps || 60);
_nextTime = this.time + _gap;
_self.wake();
};
_self.useRAF = function(value) {
if (!arguments.length) {
return _useRAF;
}
_self.sleep();
_useRAF = value;
_self.fps(_fps);
};
_self.fps(fps);
//a bug in iOS 6 Safari occasionally prevents the requestAnimationFrame from working initially, so we use a 1.5-second timeout that automatically falls back to setTimeout() if it senses this condition.
setTimeout(function() {
if (_useRAF === "auto" && _self.frame < 5 && (_doc || {}).visibilityState !== "hidden") {
_self.useRAF(false);
}
}, 1500);
});
p = gs.Ticker.prototype = new gs.events.EventDispatcher();
p.constructor = gs.Ticker;
/*
* ----------------------------------------------------------------
* Animation
* ----------------------------------------------------------------
*/
var Animation = _class("core.Animation", function(duration, vars) {
this.vars = vars = vars || {};
this._duration = this._totalDuration = duration || 0;
this._delay = Number(vars.delay) || 0;
this._timeScale = 1;
this._active = !!vars.immediateRender;
this.data = vars.data;
this._reversed = !!vars.reversed;
if (!_rootTimeline) {
return;
}
if (!_tickerActive) { //some browsers (like iOS 6 Safari) shut down JavaScript execution when the tab is disabled and they [occasionally] neglect to start up requestAnimationFrame again when returning - this code ensures that the engine starts up again properly.
_ticker.wake();
}
var tl = this.vars.useFrames ? _rootFramesTimeline : _rootTimeline;
tl.add(this, tl._time);
if (this.vars.paused) {
this.paused(true);
}
});
_ticker = Animation.ticker = new gs.Ticker();
p = Animation.prototype;
p._dirty = p._gc = p._initted = p._paused = false;
p._totalTime = p._time = 0;
p._rawPrevTime = -1;
p._next = p._last = p._onUpdate = p._timeline = p.timeline = null;
p._paused = false;
//some browsers (like iOS) occasionally drop the requestAnimationFrame event when the user switches to a different tab and then comes back again, so we use a 2-second setTimeout() to sense if/when that condition occurs and then wake() the ticker.
var _checkTimeout = function() {
if (_tickerActive && _getTime() - _lastUpdate > 2000 && ((_doc || {}).visibilityState !== "hidden" || !_ticker.lagSmoothing())) { //note: if the tab is hidden, we should still wake if lagSmoothing has been disabled.
_ticker.wake();
}
var t = setTimeout(_checkTimeout, 2000);
if (t.unref) {
// allows a node process to exit even if the timeout’s callback hasn't been invoked. Without it, the node process could hang as this function is called every two seconds.
t.unref();
}
};
_checkTimeout();
p.play = function(from, suppressEvents) {
if (from != null) {
this.seek(from, suppressEvents);
}
return this.reversed(false).paused(false);
};
p.pause = function(atTime, suppressEvents) {
if (atTime != null) {
this.seek(atTime, suppressEvents);
}
return this.paused(true);
};
p.resume = function(from, suppressEvents) {
if (from != null) {
this.seek(from, suppressEvents);
}
return this.paused(false);
};
p.seek = function(time, suppressEvents) {
return this.totalTime(Number(time), suppressEvents !== false);
};
p.restart = function(includeDelay, suppressEvents) {
return this.reversed(false).paused(false).totalTime(includeDelay ? -this._delay : 0, (suppressEvents !== false), true);
};
p.reverse = function(from, suppressEvents) {
if (from != null) {
this.seek((from || this.totalDuration()), suppressEvents);
}
return this.reversed(true).paused(false);
};
p.render = function(time, suppressEvents, force) {
//stub - we override this method in subclasses.
};
p.invalidate = function() {
this._time = this._totalTime = 0;
this._initted = this._gc = false;
this._rawPrevTime = -1;
if (this._gc || !this.timeline) {
this._enabled(true);
}
return this;
};
p.isActive = function() {
var tl = this._timeline, //the 2 root timelines won't have a _timeline; they're always active.
startTime = this._startTime,
rawTime;
return (!tl || (!this._gc && !this._paused && tl.isActive() && (rawTime = tl.rawTime(true)) >= startTime && rawTime < startTime + this.totalDuration() / this._timeScale - _tinyNum));
};
p._enabled = function (enabled, ignoreTimeline) {
if (!_tickerActive) {
_ticker.wake();
}
this._gc = !enabled;
this._active = this.isActive();
if (ignoreTimeline !== true) {
if (enabled && !this.timeline) {
this._timeline.add(this, this._startTime - this._delay);
} else if (!enabled && this.timeline) {
this._timeline._remove(this, true);
}
}
return false;
};
p._kill = function(vars, target) {
return this._enabled(false, false);
};
p.kill = function(vars, target) {
this._kill(vars, target);
return this;
};
p._uncache = function(includeSelf) {
var tween = includeSelf ? this : this.timeline;
while (tween) {
tween._dirty = true;
tween = tween.timeline;
}
return this;
};
p._swapSelfInParams = function(params) {
var i = params.length,
copy = params.concat();
while (--i > -1) {
if (params[i] === "{self}") {
copy[i] = this;
}
}
return copy;
};
p._callback = function(type) {
var v = this.vars,
callback = v[type],
params = v[type + "Params"],
scope = v[type + "Scope"] || v.callbackScope || this,
l = params ? params.length : 0;
switch (l) { //speed optimization; call() is faster than apply() so use it when there are only a few parameters (which is by far most common). Previously we simply did var v = this.vars; v[type].apply(v[type + "Scope"] || v.callbackScope || this, v[type + "Params"] || _blankArray);
case 0: callback.call(scope); break;
case 1: callback.call(scope, params[0]); break;
case 2: callback.call(scope, params[0], params[1]); break;
default: callback.apply(scope, params);
}
};
//----Animation getters/setters --------------------------------------------------------
p.eventCallback = function(type, callback, params, scope) {
if ((type || "").substr(0,2) === "on") {
var v = this.vars;
if (arguments.length === 1) {
return v[type];
}
if (callback == null) {
delete v[type];
} else {
v[type] = callback;
v[type + "Params"] = (_isArray(params) && params.join("").indexOf("{self}") !== -1) ? this._swapSelfInParams(params) : params;
v[type + "Scope"] = scope;
}
if (type === "onUpdate") {
this._onUpdate = callback;
}
}
return this;
};
p.delay = function(value) {
if (!arguments.length) {
return this._delay;
}
if (this._timeline.smoothChildTiming) {
this.startTime( this._startTime + value - this._delay );
}
this._delay = value;
return this;
};
p.duration = function(value) {
if (!arguments.length) {
this._dirty = false;
return this._duration;
}
this._duration = this._totalDuration = value;
this._uncache(true); //true in case it's a TweenMax or TimelineMax that has a repeat - we'll need to refresh the totalDuration.
if (this._timeline.smoothChildTiming) if (this._time > 0) if (this._time < this._duration) if (value !== 0) {
this.totalTime(this._totalTime * (value / this._duration), true);
}
return this;
};
p.totalDuration = function(value) {
this._dirty = false;
return (!arguments.length) ? this._totalDuration : this.duration(value);
};
p.time = function(value, suppressEvents) {
if (!arguments.length) {
return this._time;
}
if (this._dirty) {
this.totalDuration();
}
return this.totalTime((value > this._duration) ? this._duration : value, suppressEvents);
};
p.totalTime = function(time, suppressEvents, uncapped) {
if (!_tickerActive) {
_ticker.wake();
}
if (!arguments.length) {
return this._totalTime;
}
if (this._timeline) {
if (time < 0 && !uncapped) {
time += this.totalDuration();
}
if (this._timeline.smoothChildTiming) {
if (this._dirty) {
this.totalDuration();
}
var totalDuration = this._totalDuration,
tl = this._timeline;
if (time > totalDuration && !uncapped) {
time = totalDuration;
}
this._startTime = (this._paused ? this._pauseTime : tl._time) - ((!this._reversed ? time : totalDuration - time) / this._timeScale);
if (!tl._dirty) { //for performance improvement. If the parent's cache is already dirty, it already took care of marking the ancestors as dirty too, so skip the function call here.
this._uncache(false);
}
//in case any of the ancestor timelines had completed but should now be enabled, we should reset their totalTime() which will also ensure that they're lined up properly and enabled. Skip for animations that are on the root (wasteful). Example: a TimelineLite.exportRoot() is performed when there's a paused tween on the root, the export will not complete until that tween is unpaused, but imagine a child gets restarted later, after all [unpaused] tweens have completed. The startTime of that child would get pushed out, but one of the ancestors may have completed.
if (tl._timeline) {
while (tl._timeline) {
if (tl._timeline._time !== (tl._startTime + tl._totalTime) / tl._timeScale) {
tl.totalTime(tl._totalTime, true);
}
tl = tl._timeline;
}
}
}
if (this._gc) {
this._enabled(true, false);
}
if (this._totalTime !== time || this._duration === 0) {
if (_lazyTweens.length) {
_lazyRender();
}
this.render(time, suppressEvents, false);
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when someone calls seek() or time() or progress(), they expect an immediate render.
_lazyRender();
}
}
}
return this;
};
p.progress = p.totalProgress = function(value, suppressEvents) {
var duration = this.duration();
return (!arguments.length) ? (duration ? this._time / duration : this.ratio) : this.totalTime(duration * value, suppressEvents);
};
p.startTime = function(value) {
if (!arguments.length) {
return this._startTime;
}
if (value !== this._startTime) {
this._startTime = value;
if (this.timeline) if (this.timeline._sortChildren) {
this.timeline.add(this, value - this._delay); //ensures that any necessary re-sequencing of Animations in the timeline occurs to make sure the rendering order is correct.
}
}
return this;
};
p.endTime = function(includeRepeats) {
return this._startTime + ((includeRepeats != false) ? this.totalDuration() : this.duration()) / this._timeScale;
};
p.timeScale = function(value) {
if (!arguments.length) {
return this._timeScale;
}
var pauseTime, t;
value = value || _tinyNum; //can't allow zero because it'll throw the math off
if (this._timeline && this._timeline.smoothChildTiming) {
pauseTime = this._pauseTime;
t = (pauseTime || pauseTime === 0) ? pauseTime : this._timeline.totalTime();
this._startTime = t - ((t - this._startTime) * this._timeScale / value);
}
this._timeScale = value;
t = this.timeline;
while (t && t.timeline) { //must update the duration/totalDuration of all ancestor timelines immediately in case in the middle of a render loop, one tween alters another tween's timeScale which shoves its startTime before 0, forcing the parent timeline to shift around and shiftChildren() which could affect that next tween's render (startTime). Doesn't matter for the root timeline though.
t._dirty = true;
t.totalDuration();
t = t.timeline;
}
return this;
};
p.reversed = function(value) {
if (!arguments.length) {
return this._reversed;
}
if (value != this._reversed) {
this._reversed = value;
this.totalTime(((this._timeline && !this._timeline.smoothChildTiming) ? this.totalDuration() - this._totalTime : this._totalTime), true);
}
return this;
};
p.paused = function(value) {
if (!arguments.length) {
return this._paused;
}
var tl = this._timeline,
raw, elapsed;
if (value != this._paused) if (tl) {
if (!_tickerActive && !value) {
_ticker.wake();
}
raw = tl.rawTime();
elapsed = raw - this._pauseTime;
if (!value && tl.smoothChildTiming) {
this._startTime += elapsed;
this._uncache(false);
}
this._pauseTime = value ? raw : null;
this._paused = value;
this._active = this.isActive();
if (!value && elapsed !== 0 && this._initted && this.duration()) {
raw = tl.smoothChildTiming ? this._totalTime : (raw - this._startTime) / this._timeScale;
this.render(raw, (raw === this._totalTime), true); //in case the target's properties changed via some other tween or manual update by the user, we should force a render.
}
}
if (this._gc && !value) {
this._enabled(true, false);
}
return this;
};
/*
* ----------------------------------------------------------------
* SimpleTimeline
* ----------------------------------------------------------------
*/
var SimpleTimeline = _class("core.SimpleTimeline", function(vars) {
Animation.call(this, 0, vars);
this.autoRemoveChildren = this.smoothChildTiming = true;
});
p = SimpleTimeline.prototype = new Animation();
p.constructor = SimpleTimeline;
p.kill()._gc = false;
p._first = p._last = p._recent = null;
p._sortChildren = false;
p.add = p.insert = function(child, position, align, stagger) {
var prevTween, st;
child._startTime = Number(position || 0) + child._delay;
if (child._paused) if (this !== child._timeline) { //we only adjust the _pauseTime if it wasn't in this timeline already. Remember, sometimes a tween will be inserted again into the same timeline when its startTime is changed so that the tweens in the TimelineLite/Max are re-ordered properly in the linked list (so everything renders in the proper order).
child._pauseTime = this.rawTime() - (child._timeline.rawTime() - child._pauseTime);
}
if (child.timeline) {
child.timeline._remove(child, true); //removes from existing timeline so that it can be properly added to this one.
}
child.timeline = child._timeline = this;
if (child._gc) {
child._enabled(true, true);
}
prevTween = this._last;
if (this._sortChildren) {
st = child._startTime;
while (prevTween && prevTween._startTime > st) {
prevTween = prevTween._prev;
}
}
if (prevTween) {
child._next = prevTween._next;
prevTween._next = child;
} else {
child._next = this._first;
this._first = child;
}
if (child._next) {
child._next._prev = child;
} else {
this._last = child;
}
child._prev = prevTween;
this._recent = child;
if (this._timeline) {
this._uncache(true);
}
return this;
};
p._remove = function(tween, skipDisable) {
if (tween.timeline === this) {
if (!skipDisable) {
tween._enabled(false, true);
}
if (tween._prev) {
tween._prev._next = tween._next;
} else if (this._first === tween) {
this._first = tween._next;
}
if (tween._next) {
tween._next._prev = tween._prev;
} else if (this._last === tween) {
this._last = tween._prev;
}
tween._next = tween._prev = tween.timeline = null;
if (tween === this._recent) {
this._recent = this._last;
}
if (this._timeline) {
this._uncache(true);
}
}
return this;
};
p.render = function(time, suppressEvents, force) {
var tween = this._first,
next;
this._totalTime = this._time = this._rawPrevTime = time;
while (tween) {
next = tween._next; //record it here because the value could change after rendering...
if (tween._active || (time >= tween._startTime && !tween._paused && !tween._gc)) {
if (!tween._reversed) {
tween.render((time - tween._startTime) * tween._timeScale, suppressEvents, force);
} else {
tween.render(((!tween._dirty) ? tween._totalDuration : tween.totalDuration()) - ((time - tween._startTime) * tween._timeScale), suppressEvents, force);
}
}
tween = next;
}
};
p.rawTime = function() {
if (!_tickerActive) {
_ticker.wake();
}
return this._totalTime;
};
/*
* ----------------------------------------------------------------
* TweenLite
* ----------------------------------------------------------------
*/
var TweenLite = _class("TweenLite", function(target, duration, vars) {
Animation.call(this, duration, vars);
this.render = TweenLite.prototype.render; //speed optimization (avoid prototype lookup on this "hot" method)
if (target == null) {
throw "Cannot tween a null target.";
}
this.target = target = (typeof(target) !== "string") ? target : TweenLite.selector(target) || target;
var isSelector = (target.jquery || (target.length && target !== window && target[0] && (target[0] === window || (target[0].nodeType && target[0].style && !target.nodeType)))),
overwrite = this.vars.overwrite,
i, targ, targets;
this._overwrite = overwrite = (overwrite == null) ? _overwriteLookup[TweenLite.defaultOverwrite] : (typeof(overwrite) === "number") ? overwrite >> 0 : _overwriteLookup[overwrite];
if ((isSelector || target instanceof Array || (target.push && _isArray(target))) && typeof(target[0]) !== "number") {
this._targets = targets = _slice(target); //don't use Array.prototype.slice.call(target, 0) because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll()
this._propLookup = [];
this._siblings = [];
for (i = 0; i < targets.length; i++) {
targ = targets[i];
if (!targ) {
targets.splice(i--, 1);
continue;
} else if (typeof(targ) === "string") {
targ = targets[i--] = TweenLite.selector(targ); //in case it's an array of strings
if (typeof(targ) === "string") {
targets.splice(i+1, 1); //to avoid an endless loop (can't imagine why the selector would return a string, but just in case)
}
continue;
} else if (targ.length && targ !== window && targ[0] && (targ[0] === window || (targ[0].nodeType && targ[0].style && !targ.nodeType))) { //in case the user is passing in an array of selector objects (like jQuery objects), we need to check one more level and pull things out if necessary. Also note that <select> elements pass all the criteria regarding length and the first child having style, so we must also check to ensure the target isn't an HTML node itself.
targets.splice(i--, 1);
this._targets = targets = targets.concat(_slice(targ));
continue;
}
this._siblings[i] = _register(targ, this, false);
if (overwrite === 1) if (this._siblings[i].length > 1) {
_applyOverwrite(targ, this, null, 1, this._siblings[i]);
}
}
} else {
this._propLookup = {};
this._siblings = _register(target, this, false);
if (overwrite === 1) if (this._siblings.length > 1) {
_applyOverwrite(target, this, null, 1, this._siblings);
}
}
if (this.vars.immediateRender || (duration === 0 && this._delay === 0 && this.vars.immediateRender !== false)) {
this._time = -_tinyNum; //forces a render without having to set the render() "force" parameter to true because we want to allow lazying by default (using the "force" parameter always forces an immediate full render)
this.render(Math.min(0, -this._delay)); //in case delay is negative
}
}, true),
_isSelector = function(v) {
return (v && v.length && v !== window && v[0] && (v[0] === window || (v[0].nodeType && v[0].style && !v.nodeType))); //we cannot check "nodeType" if the target is window from within an iframe, otherwise it will trigger a security error in some browsers like Firefox.
},
_autoCSS = function(vars, target) {
var css = {},
p;
for (p in vars) {
if (!_reservedProps[p] && (!(p in target) || p === "transform" || p === "x" || p === "y" || p === "width" || p === "height" || p === "className" || p === "border") && (!_plugins[p] || (_plugins[p] && _plugins[p]._autoCSS))) { //note: <img> elements contain read-only "x" and "y" properties. We should also prioritize editing css width/height rather than the element's properties.
css[p] = vars[p];
delete vars[p];
}
}
vars.css = css;
};
p = TweenLite.prototype = new Animation();
p.constructor = TweenLite;
p.kill()._gc = false;
//----TweenLite defaults, overwrite management, and root updates ----------------------------------------------------
p.ratio = 0;
p._firstPT = p._targets = p._overwrittenProps = p._startAt = null;
p._notifyPluginsOfEnabled = p._lazy = false;
TweenLite.version = "2.1.2";
TweenLite.defaultEase = p._ease = new Ease(null, null, 1, 1);
TweenLite.defaultOverwrite = "auto";
TweenLite.ticker = _ticker;
TweenLite.autoSleep = 120;
TweenLite.lagSmoothing = function(threshold, adjustedLag) {
_ticker.lagSmoothing(threshold, adjustedLag);
};
TweenLite.selector = window.$ || window.jQuery || function(e) {
var selector = window.$ || window.jQuery;
if (selector) {
TweenLite.selector = selector;
return selector(e);
}
if (!_doc) { //in some dev environments (like Angular 6), GSAP gets loaded before the document is defined! So re-query it here if/when necessary.
_doc = window.document;
}
return (!_doc) ? e : (_doc.querySelectorAll ? _doc.querySelectorAll(e) : _doc.getElementById((e.charAt(0) === "#") ? e.substr(1) : e));
};
var _lazyTweens = [],
_lazyLookup = {},
_numbersExp = /(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_relExp = /[\+-]=-?[\.\d]/,
//_nonNumbersExp = /(?:([\-+](?!(\d|=)))|[^\d\-+=e]|(e(?![\-+][\d])))+/ig,
_setRatio = function(v) {
var pt = this._firstPT,
min = 0.000001,
val;
while (pt) {
val = !pt.blob ? pt.c * v + pt.s : (v === 1 && this.end != null) ? this.end : v ? this.join("") : this.start;
if (pt.m) {
val = pt.m.call(this._tween, val, this._target || pt.t, this._tween);
} else if (val < min) if (val > -min && !pt.blob) { //prevents issues with converting very small numbers to strings in the browser
val = 0;
}
if (!pt.f) {
pt.t[pt.p] = val;
} else if (pt.fp) {
pt.t[pt.p](pt.fp, val);
} else {
pt.t[pt.p](val);
}
pt = pt._next;
}
},
_blobRound = function(v) {
return (((v * 1000) | 0) / 1000) + "";
},
//compares two strings (start/end), finds the numbers that are different and spits back an array representing the whole value but with the changing values isolated as elements. For example, "rgb(0,0,0)" and "rgb(100,50,0)" would become ["rgb(", 0, ",", 50, ",0)"]. Notice it merges the parts that are identical (performance optimization). The array also has a linked list of PropTweens attached starting with _firstPT that contain the tweening data (t, p, s, c, f, etc.). It also stores the starting value as a "start" property so that we can revert to it if/when necessary, like when a tween rewinds fully. If the quantity of numbers differs between the start and end, it will always prioritize the end value(s). The pt parameter is optional - it's for a PropTween that will be appended to the end of the linked list and is typically for actually setting the value after all of the elements have been updated (with array.join("")).
_blobDif = function(start, end, filter, pt) {
var a = [],
charIndex = 0,
s = "",
color = 0,
startNums, endNums, num, i, l, nonNumbers, currentNum;
a.start = start;
a.end = end;
start = a[0] = start + ""; //ensure values are strings
end = a[1] = end + "";
if (filter) {
filter(a); //pass an array with the starting and ending values and let the filter do whatever it needs to the values.
start = a[0];
end = a[1];
}
a.length = 0;
startNums = start.match(_numbersExp) || [];
endNums = end.match(_numbersExp) || [];
if (pt) {
pt._next = null;
pt.blob = 1;
a._firstPT = a._applyPT = pt; //apply last in the linked list (which means inserting it first)
}
l = endNums.length;
for (i = 0; i < l; i++) {
currentNum = endNums[i];
nonNumbers = end.substr(charIndex, end.indexOf(currentNum, charIndex)-charIndex);
s += (nonNumbers || !i) ? nonNumbers : ","; //note: SVG spec allows omission of comma/space when a negative sign is wedged between two numbers, like 2.5-5.3 instead of 2.5,-5.3 but when tweening, the negative value may switch to positive, so we insert the comma just in case.
charIndex += nonNumbers.length;
if (color) { //sense rgba() values and round them.
color = (color + 1) % 5;
} else if (nonNumbers.substr(-5) === "rgba(") {
color = 1;
}
if (currentNum === startNums[i] || startNums.length <= i) {
s += currentNum;
} else {
if (s) {
a.push(s);
s = "";
}
num = parseFloat(startNums[i]);
a.push(num);
a._firstPT = {_next: a._firstPT, t:a, p: a.length-1, s:num, c:((currentNum.charAt(1) === "=") ? parseInt(currentNum.charAt(0) + "1", 10) * parseFloat(currentNum.substr(2)) : (parseFloat(currentNum) - num)) || 0, f:0, m:(color && color < 4) ? Math.round : _blobRound}; //limiting to 3 decimal places and casting as a string can really help performance when array.join() is called!
//note: we don't set _prev because we'll never need to remove individual PropTweens from this list.
}
charIndex += currentNum.length;
}
s += end.substr(charIndex);
if (s) {
a.push(s);
}
a.setRatio = _setRatio;
if (_relExp.test(end)) { //if the end string contains relative values, delete it so that on the final render (in _setRatio()), we don't actually set it to the string with += or -= characters (forces it to use the calculated value).
a.end = null;
}
return a;
},
//note: "funcParam" is only necessary for function-based getters/setters that require an extra parameter like getAttribute("width") and setAttribute("width", value). In this example, funcParam would be "width". Used by AttrPlugin for example.
_addPropTween = function(target, prop, start, end, overwriteProp, mod, funcParam, stringFilter, index) {
if (typeof(end) === "function") {
end = end(index || 0, target);
}
var type = typeof(target[prop]),
getterName = (type !== "function") ? "" : ((prop.indexOf("set") || typeof(target["get" + prop.substr(3)]) !== "function") ? prop : "get" + prop.substr(3)),
s = (start !== "get") ? start : !getterName ? target[prop] : funcParam ? target[getterName](funcParam) : target[getterName](),
isRelative = (typeof(end) === "string" && end.charAt(1) === "="),
pt = {t:target, p:prop, s:s, f:(type === "function"), pg:0, n:overwriteProp || prop, m:(!mod ? 0 : (typeof(mod) === "function") ? mod : Math.round), pr:0, c:isRelative ? parseInt(end.charAt(0) + "1", 10) * parseFloat(end.substr(2)) : (parseFloat(end) - s) || 0},
blob;
if (typeof(s) !== "number" || (typeof(end) !== "number" && !isRelative)) {
if (funcParam || isNaN(s) || (!isRelative && isNaN(end)) || typeof(s) === "boolean" || typeof(end) === "boolean") {
//a blob (string that has multiple numbers in it)
pt.fp = funcParam;
blob = _blobDif(s, (isRelative ? (parseFloat(pt.s) + pt.c) + (pt.s + "").replace(/[0-9\-\.]/g, "") : end), stringFilter || TweenLite.defaultStringFilter, pt);
pt = {t: blob, p: "setRatio", s: 0, c: 1, f: 2, pg: 0, n: overwriteProp || prop, pr: 0, m: 0}; //"2" indicates it's a Blob property tween. Needed for RoundPropsPlugin for example.
} else {
pt.s = parseFloat(s);
if (!isRelative) {
pt.c = (parseFloat(end) - pt.s) || 0;
}
}
}
if (pt.c) { //only add it to the linked list if there's a change.
if ((pt._next = this._firstPT)) {
pt._next._prev = pt;
}
this._firstPT = pt;
return pt;
}
},
_internals = TweenLite._internals = {isArray:_isArray, isSelector:_isSelector, lazyTweens:_lazyTweens, blobDif:_blobDif}, //gives us a way to expose certain private values to other GreenSock classes without contaminating tha main TweenLite object.
_plugins = TweenLite._plugins = {},
_tweenLookup = _internals.tweenLookup = {},
_tweenLookupNum = 0,
_reservedProps = _internals.reservedProps = {ease:1, delay:1, overwrite:1, onComplete:1, onCompleteParams:1, onCompleteScope:1, useFrames:1, runBackwards:1, startAt:1, onUpdate:1, onUpdateParams:1, onUpdateScope:1, onStart:1, onStartParams:1, onStartScope:1, onReverseComplete:1, onReverseCompleteParams:1, onReverseCompleteScope:1, onRepeat:1, onRepeatParams:1, onRepeatScope:1, easeParams:1, yoyo:1, immediateRender:1, repeat:1, repeatDelay:1, data:1, paused:1, reversed:1, autoCSS:1, lazy:1, onOverwrite:1, callbackScope:1, stringFilter:1, id:1, yoyoEase:1, stagger:1},
_overwriteLookup = {none:0, all:1, auto:2, concurrent:3, allOnStart:4, preexisting:5, "true":1, "false":0},
_rootFramesTimeline = Animation._rootFramesTimeline = new SimpleTimeline(),
_rootTimeline = Animation._rootTimeline = new SimpleTimeline(),
_nextGCFrame = 30,
_lazyRender = _internals.lazyRender = function() {
var l = _lazyTweens.length,
i, tween;
_lazyLookup = {};
for (i = 0; i < l; i++) {
tween = _lazyTweens[i];
if (tween && tween._lazy !== false) {
tween.render(tween._lazy[0], tween._lazy[1], true);
tween._lazy = false;
}
}
_lazyTweens.length = 0;
};
_rootTimeline._startTime = _ticker.time;
_rootFramesTimeline._startTime = _ticker.frame;
_rootTimeline._active = _rootFramesTimeline._active = true;
setTimeout(_lazyRender, 1); //on some mobile devices, there isn't a "tick" before code runs which means any lazy renders wouldn't run before the next official "tick".
Animation._updateRoot = TweenLite.render = function() {
var i, a, p;
if (_lazyTweens.length) { //if code is run outside of the requestAnimationFrame loop, there may be tweens queued AFTER the engine refreshed, so we need to ensure any pending renders occur before we refresh again.
_lazyRender();
}
_rootTimeline.render((_ticker.time - _rootTimeline._startTime) * _rootTimeline._timeScale, false, false);
_rootFramesTimeline.render((_ticker.frame - _rootFramesTimeline._startTime) * _rootFramesTimeline._timeScale, false, false);
if (_lazyTweens.length) {
_lazyRender();
}
if (_ticker.frame >= _nextGCFrame) { //dump garbage every 120 frames or whatever the user sets TweenLite.autoSleep to
_nextGCFrame = _ticker.frame + (parseInt(TweenLite.autoSleep, 10) || 120);
for (p in _tweenLookup) {
a = _tweenLookup[p].tweens;
i = a.length;
while (--i > -1) {
if (a[i]._gc) {
a.splice(i, 1);
}
}
if (a.length === 0) {
delete _tweenLookup[p];
}
}
//if there are no more tweens in the root timelines, or if they're all paused, make the _timer sleep to reduce load on the CPU slightly
p = _rootTimeline._first;
if (!p || p._paused) if (TweenLite.autoSleep && !_rootFramesTimeline._first && _ticker._listeners.tick.length === 1) {
while (p && p._paused) {
p = p._next;
}
if (!p) {
_ticker.sleep();
}
}
}
};
_ticker.addEventListener("tick", Animation._updateRoot);
var _register = function(target, tween, scrub) {
var id = target._gsTweenID, a, i;
if (!_tweenLookup[id || (target._gsTweenID = id = "t" + (_tweenLookupNum++))]) {
_tweenLookup[id] = {target:target, tweens:[]};
}
if (tween) {
a = _tweenLookup[id].tweens;
a[(i = a.length)] = tween;
if (scrub) {
while (--i > -1) {
if (a[i] === tween) {
a.splice(i, 1);
}
}
}
}
return _tweenLookup[id].tweens;
},
_onOverwrite = function(overwrittenTween, overwritingTween, target, killedProps) {
var func = overwrittenTween.vars.onOverwrite, r1, r2;
if (func) {
r1 = func(overwrittenTween, overwritingTween, target, killedProps);
}
func = TweenLite.onOverwrite;
if (func) {
r2 = func(overwrittenTween, overwritingTween, target, killedProps);
}
return (r1 !== false && r2 !== false);
},
_applyOverwrite = function(target, tween, props, mode, siblings) {
var i, changed, curTween, l;
if (mode === 1 || mode >= 4) {
l = siblings.length;
for (i = 0; i < l; i++) {
if ((curTween = siblings[i]) !== tween) {
if (!curTween._gc) {
if (curTween._kill(null, target, tween)) {
changed = true;
}
}
} else if (mode === 5) {
break;
}
}
return changed;
}
//NOTE: Add tiny amount to overcome floating point errors that can cause the startTime to be VERY slightly off (when a tween's time() is set for example)
var startTime = tween._startTime + _tinyNum,
overlaps = [],
oCount = 0,
zeroDur = (tween._duration === 0),
globalStart;
i = siblings.length;
while (--i > -1) {
if ((curTween = siblings[i]) === tween || curTween._gc || curTween._paused) {
//ignore
} else if (curTween._timeline !== tween._timeline) {
globalStart = globalStart || _checkOverlap(tween, 0, zeroDur);
if (_checkOverlap(curTween, globalStart, zeroDur) === 0) {
overlaps[oCount++] = curTween;
}
} else if (curTween._startTime <= startTime) if (curTween._startTime + curTween.totalDuration() / curTween._timeScale > startTime) if (!((zeroDur || !curTween._initted) && startTime - curTween._startTime <= _tinyNum * 2)) {
overlaps[oCount++] = curTween;
}
}
i = oCount;
while (--i > -1) {
curTween = overlaps[i];
l = curTween._firstPT; //we need to discern if there were property tweens originally; if they all get removed in the next line's _kill() call, the tween should be killed. See https://github.com/greensock/GreenSock-JS/issues/278
if (mode === 2) if (curTween._kill(props, target, tween)) {
changed = true;
}
if (mode !== 2 || (!curTween._firstPT && curTween._initted && l)) {
if (mode !== 2 && !_onOverwrite(curTween, tween)) {
continue;
}
if (curTween._enabled(false, false)) { //if all property tweens have been overwritten, kill the tween.
changed = true;
}
}
}
return changed;
},
_checkOverlap = function(tween, reference, zeroDur) {
var tl = tween._timeline,
ts = tl._timeScale,
t = tween._startTime;
while (tl._timeline) {
t += tl._startTime;
ts *= tl._timeScale;
if (tl._paused) {
return -100;
}
tl = tl._timeline;
}
t /= ts;
return (t > reference) ? t - reference : ((zeroDur && t === reference) || (!tween._initted && t - reference < 2 * _tinyNum)) ? _tinyNum : ((t += tween.totalDuration() / tween._timeScale / ts) > reference + _tinyNum) ? 0 : t - reference - _tinyNum;
};
//---- TweenLite instance methods -----------------------------------------------------------------------------
p._init = function() {
var v = this.vars,
op = this._overwrittenProps,
dur = this._duration,
immediate = !!v.immediateRender,
ease = v.ease,
startAt = this._startAt,
i, initPlugins, pt, p, startVars, l;
if (v.startAt) {
if (startAt) {
startAt.render(-1, true); //if we've run a startAt previously (when the tween instantiated), we should revert it so that the values re-instantiate correctly particularly for relative tweens. Without this, a TweenLite.fromTo(obj, 1, {x:"+=100"}, {x:"-=100"}), for example, would actually jump to +=200 because the startAt would run twice, doubling the relative change.
startAt.kill();
}
startVars = {};
for (p in v.startAt) { //copy the properties/values into a new object to avoid collisions, like var to = {x:0}, from = {x:500}; timeline.fromTo(e, 1, from, to).fromTo(e, 1, to, from);
startVars[p] = v.startAt[p];
}
startVars.data = "isStart";
startVars.overwrite = false;
startVars.immediateRender = true;
startVars.lazy = (immediate && v.lazy !== false);
startVars.startAt = startVars.delay = null; //no nesting of startAt objects allowed (otherwise it could cause an infinite loop).
startVars.onUpdate = v.onUpdate;
startVars.onUpdateParams = v.onUpdateParams;
startVars.onUpdateScope = v.onUpdateScope || v.callbackScope || this;
this._startAt = TweenLite.to(this.target || {}, 0, startVars);
if (immediate) {
if (this._time > 0) {
this._startAt = null; //tweens that render immediately (like most from() and fromTo() tweens) shouldn't revert when their parent timeline's playhead goes backward past the startTime because the initial render could have happened anytime and it shouldn't be directly correlated to this tween's startTime. Imagine setting up a complex animation where the beginning states of various objects are rendered immediately but the tween doesn't happen for quite some time - if we revert to the starting values as soon as the playhead goes backward past the tween's startTime, it will throw things off visually. Reversion should only happen in TimelineLite/Max instances where immediateRender was false (which is the default in the convenience methods like from()).
} else if (dur !== 0) {
return; //we skip initialization here so that overwriting doesn't occur until the tween actually begins. Otherwise, if you create several immediateRender:true tweens of the same target/properties to drop into a TimelineLite or TimelineMax, the last one created would overwrite the first ones because they didn't get placed into the timeline yet before the first render occurs and kicks in overwriting.
}
}
} else if (v.runBackwards && dur !== 0) {
//from() tweens must be handled uniquely: their beginning values must be rendered but we don't want overwriting to occur yet (when time is still 0). Wait until the tween actually begins before doing all the routines like overwriting. At that time, we should render at the END of the tween to ensure that things initialize correctly (remember, from() tweens go backwards)
if (startAt) {
startAt.render(-1, true);
startAt.kill();
this._startAt = null;
} else {
if (this._time !== 0) { //in rare cases (like if a from() tween runs and then is invalidate()-ed), immediateRender could be true but the initial forced-render gets skipped, so there's no need to force the render in this context when the _time is greater than 0
immediate = false;
}
pt = {};
for (p in v) { //copy props into a new object and skip any reserved props, otherwise onComplete or onUpdate or onStart could fire. We should, however, permit autoCSS to go through.
if (!_reservedProps[p] || p === "autoCSS") {
pt[p] = v[p];
}
}
pt.overwrite = 0;
pt.data = "isFromStart"; //we tag the tween with as "isFromStart" so that if [inside a plugin] we need to only do something at the very END of a tween, we have a way of identifying this tween as merely the one that's setting the beginning values for a "from()" tween. For example, clearProps in CSSPlugin should only get applied at the very END of a tween and without this tag, from(...{height:100, clearProps:"height", delay:1}) would wipe the height at the beginning of the tween and after 1 second, it'd kick back in.
pt.lazy = (immediate && v.lazy !== false);
pt.immediateRender = immediate; //zero-duration tweens render immediately by default, but if we're not specifically instructed to render this tween immediately, we should skip this and merely _init() to record the starting values (rendering them immediately would push them to completion which is wasteful in that case - we'd have to render(-1) immediately after)
this._startAt = TweenLite.to(this.target, 0, pt);
if (!immediate) {
this._startAt._init(); //ensures that the initial values are recorded
this._startAt._enabled(false); //no need to have the tween render on the next cycle. Disable it because we'll always manually control the renders of the _startAt tween.
if (this.vars.immediateRender) {
this._startAt = null;
}
} else if (this._time === 0) {
return;
}
}
}
this._ease = ease = (!ease) ? TweenLite.defaultEase : (ease instanceof Ease) ? ease : (typeof(ease) === "function") ? new Ease(ease, v.easeParams) : _easeMap[ease] || TweenLite.defaultEase;
if (v.easeParams instanceof Array && ease.config) {
this._ease = ease.config.apply(ease, v.easeParams);
}
this._easeType = this._ease._type;
this._easePower = this._ease._power;
this._firstPT = null;
if (this._targets) {
l = this._targets.length;
for (i = 0; i < l; i++) {
if ( this._initProps( this._targets[i], (this._propLookup[i] = {}), this._siblings[i], (op ? op[i] : null), i) ) {
initPlugins = true;
}
}
} else {
initPlugins = this._initProps(this.target, this._propLookup, this._siblings, op, 0);
}
if (initPlugins) {
TweenLite._onPluginEvent("_onInitAllProps", this); //reorders the array in order of priority. Uses a static TweenPlugin method in order to minimize file size in TweenLite
}
if (op) if (!this._firstPT) if (typeof(this.target) !== "function") { //if all tweening properties have been overwritten, kill the tween. If the target is a function, it's probably a delayedCall so let it live.
this._enabled(false, false);
}
if (v.runBackwards) {
pt = this._firstPT;
while (pt) {
pt.s += pt.c;
pt.c = -pt.c;
pt = pt._next;
}
}
this._onUpdate = v.onUpdate;
this._initted = true;
};
p._initProps = function(target, propLookup, siblings, overwrittenProps, index) {
var p, i, initPlugins, plugin, pt, v;
if (target == null) {
return false;
}
if (_lazyLookup[target._gsTweenID]) {
_lazyRender(); //if other tweens of the same target have recently initted but haven't rendered yet, we've got to force the render so that the starting values are correct (imagine populating a timeline with a bunch of sequential tweens and then jumping to the end)
}
if (!this.vars.css) if (target.style) if (target !== window && target.nodeType) if (_plugins.css) if (this.vars.autoCSS !== false) { //it's so common to use TweenLite/Max to animate the css of DOM elements, we assume that if the target is a DOM element, that's what is intended (a convenience so that users don't have to wrap things in css:{}, although we still recommend it for a slight performance boost and better specificity). Note: we cannot check "nodeType" on the window inside an iframe.
_autoCSS(this.vars, target);
}
for (p in this.vars) {
v = this.vars[p];
if (_reservedProps[p]) {
if (v) if ((v instanceof Array) || (v.push && _isArray(v))) if (v.join("").indexOf("{self}") !== -1) {
this.vars[p] = v = this._swapSelfInParams(v, this);
}
} else if (_plugins[p] && (plugin = new _plugins[p]())._onInitTween(target, this.vars[p], this, index)) {
//t - target [object]
//p - property [string]
//s - start [number]
//c - change [number]
//f - isFunction [boolean]
//n - name [string]
//pg - isPlugin [boolean]
//pr - priority [number]
//m - mod [function | 0]
this._firstPT = pt = {_next:this._firstPT, t:plugin, p:"setRatio", s:0, c:1, f:1, n:p, pg:1, pr:plugin._priority, m:0};
i = plugin._overwriteProps.length;
while (--i > -1) {
propLookup[plugin._overwriteProps[i]] = this._firstPT;
}
if (plugin._priority || plugin._onInitAllProps) {
initPlugins = true;
}
if (plugin._onDisable || plugin._onEnable) {
this._notifyPluginsOfEnabled = true;
}
if (pt._next) {
pt._next._prev = pt;
}
} else {
propLookup[p] = _addPropTween.call(this, target, p, "get", v, p, 0, null, this.vars.stringFilter, index);
}
}
if (overwrittenProps) if (this._kill(overwrittenProps, target)) { //another tween may have tried to overwrite properties of this tween before init() was called (like if two tweens start at the same time, the one created second will run first)
return this._initProps(target, propLookup, siblings, overwrittenProps, index);
}
if (this._overwrite > 1) if (this._firstPT) if (siblings.length > 1) if (_applyOverwrite(target, this, propLookup, this._overwrite, siblings)) {
this._kill(propLookup, target);
return this._initProps(target, propLookup, siblings, overwrittenProps, index);
}
if (this._firstPT) if ((this.vars.lazy !== false && this._duration) || (this.vars.lazy && !this._duration)) { //zero duration tweens don't lazy render by default; everything else does.
_lazyLookup[target._gsTweenID] = true;
}
return initPlugins;
};
p.render = function(time, suppressEvents, force) {
var self = this,
prevTime = self._time,
duration = self._duration,
prevRawPrevTime = self._rawPrevTime,
isComplete, callback, pt, rawPrevTime;
if (time >= duration - _tinyNum && time >= 0) { //to work around occasional floating point math artifacts.
self._totalTime = self._time = duration;
self.ratio = self._ease._calcEnd ? self._ease.getRatio(1) : 1;
if (!self._reversed ) {
isComplete = true;
callback = "onComplete";
force = (force || self._timeline.autoRemoveChildren); //otherwise, if the animation is unpaused/activated after it's already finished, it doesn't get removed from the parent timeline.
}
if (duration === 0) if (self._initted || !self.vars.lazy || force) { //zero-duration tweens are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered.
if (self._startTime === self._timeline._duration) { //if a zero-duration tween is at the VERY end of a timeline and that timeline renders at its end, it will typically add a tiny bit of cushion to the render time to prevent rounding errors from getting in the way of tweens rendering their VERY end. If we then reverse() that timeline, the zero-duration tween will trigger its onReverseComplete even though technically the playhead didn't pass over it again. It's a very specific edge case we must accommodate.
time = 0;
}
if (prevRawPrevTime < 0 || (time <= 0 && time >= -_tinyNum) || (prevRawPrevTime === _tinyNum && self.data !== "isPause")) if (prevRawPrevTime !== time) { //note: when this.data is "isPause", it's a callback added by addPause() on a timeline that we should not be triggered when LEAVING its exact start time. In other words, tl.addPause(1).play(1) shouldn't pause.
force = true;
if (prevRawPrevTime > _tinyNum) {
callback = "onReverseComplete";
}
}
self._rawPrevTime = rawPrevTime = (!suppressEvents || time || prevRawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient.
}
} else if (time < _tinyNum) { //to work around occasional floating point math artifacts, round super small values to 0.
self._totalTime = self._time = 0;
self.ratio = self._ease._calcEnd ? self._ease.getRatio(0) : 0;
if (prevTime !== 0 || (duration === 0 && prevRawPrevTime > 0)) {
callback = "onReverseComplete";
isComplete = self._reversed;
}
if (time > -_tinyNum) {
time = 0;
} else if (time < 0) {
self._active = false;
if (duration === 0) if (self._initted || !self.vars.lazy || force) { //zero-duration tweens are tricky because we must discern the momentum/direction of time in order to determine whether the starting values should be rendered or the ending values. If the "playhead" of its timeline goes past the zero-duration tween in the forward direction or lands directly on it, the end values should be rendered, but if the timeline's "playhead" moves past it in the backward direction (from a postitive time to a negative time), the starting values must be rendered.
if (prevRawPrevTime >= 0 && !(prevRawPrevTime === _tinyNum && self.data === "isPause")) {
force = true;
}
self._rawPrevTime = rawPrevTime = (!suppressEvents || time || prevRawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient.
}
}
if (!self._initted || (self._startAt && self._startAt.progress())) { //if we render the very beginning (time == 0) of a fromTo(), we must force the render (normal tweens wouldn't need to render at a time of 0 when the prevTime was also 0). This is also mandatory to make sure overwriting kicks in immediately. Also, we check progress() because if startAt has already rendered at its end, we should force a render at its beginning. Otherwise, if you put the playhead directly on top of where a fromTo({immediateRender:false}) starts, and then move it backwards, the from() won't revert its values.
force = true;
}
} else {
self._totalTime = self._time = time;
if (self._easeType) {
var r = time / duration, type = self._easeType, pow = self._easePower;
if (type === 1 || (type === 3 && r >= 0.5)) {
r = 1 - r;
}
if (type === 3) {
r *= 2;
}
if (pow === 1) {
r *= r;
} else if (pow === 2) {
r *= r * r;
} else if (pow === 3) {
r *= r * r * r;
} else if (pow === 4) {
r *= r * r * r * r;
}
self.ratio = (type === 1) ? 1 - r : (type === 2) ? r : (time / duration < 0.5) ? r / 2 : 1 - (r / 2);
} else {
self.ratio = self._ease.getRatio(time / duration);
}
}
if (self._time === prevTime && !force) {
return;
} else if (!self._initted) {
self._init();
if (!self._initted || self._gc) { //immediateRender tweens typically won't initialize until the playhead advances (_time is greater than 0) in order to ensure that overwriting occurs properly. Also, if all of the tweening properties have been overwritten (which would cause _gc to be true, as set in _init()), we shouldn't continue otherwise an onStart callback could be called for example.
return;
} else if (!force && self._firstPT && ((self.vars.lazy !== false && self._duration) || (self.vars.lazy && !self._duration))) {
self._time = self._totalTime = prevTime;
self._rawPrevTime = prevRawPrevTime;
_lazyTweens.push(self);
self._lazy = [time, suppressEvents];
return;
}
//_ease is initially set to defaultEase, so now that init() has run, _ease is set properly and we need to recalculate the ratio. Overall this is faster than using conditional logic earlier in the method to avoid having to set ratio twice because we only init() once but renderTime() gets called VERY frequently.
if (self._time && !isComplete) {
self.ratio = self._ease.getRatio(self._time / duration);
} else if (isComplete && self._ease._calcEnd) {
self.ratio = self._ease.getRatio((self._time === 0) ? 0 : 1);
}
}
if (self._lazy !== false) { //in case a lazy render is pending, we should flush it because the new render is occurring now (imagine a lazy tween instantiating and then immediately the user calls tween.seek(tween.duration()), skipping to the end - the end render would be forced, and then if we didn't flush the lazy render, it'd fire AFTER the seek(), rendering it at the wrong time.
self._lazy = false;
}
if (!self._active) if (!self._paused && self._time !== prevTime && time >= 0) {
self._active = true; //so that if the user renders a tween (as opposed to the timeline rendering it), the timeline is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the tween already finished but the user manually re-renders it as halfway done.
}
if (prevTime === 0) {
if (self._startAt) {
if (time >= 0) {
self._startAt.render(time, true, force);
} else if (!callback) {
callback = "_dummyGS"; //if no callback is defined, use a dummy value just so that the condition at the end evaluates as true because _startAt should render AFTER the normal render loop when the time is negative. We could handle this in a more intuitive way, of course, but the render loop is the MOST important thing to optimize, so this technique allows us to avoid adding extra conditional logic in a high-frequency area.
}
}
if (self.vars.onStart) if (self._time !== 0 || duration === 0) if (!suppressEvents) {
self._callback("onStart");
}
}
pt = self._firstPT;
while (pt) {
if (pt.f) {
pt.t[pt.p](pt.c * self.ratio + pt.s);
} else {
pt.t[pt.p] = pt.c * self.ratio + pt.s;
}
pt = pt._next;
}
if (self._onUpdate) {
if (time < 0) if (self._startAt && time !== -0.0001) { //if the tween is positioned at the VERY beginning (_startTime 0) of its parent timeline, it's illegal for the playhead to go back further, so we should not render the recorded startAt values.
self._startAt.render(time, true, force); //note: for performance reasons, we tuck this conditional logic inside less traveled areas (most tweens don't have an onUpdate). We'd just have it at the end before the onComplete, but the values should be updated before any onUpdate is called, so we ALSO put it here and then if it's not called, we do so later near the onComplete.
}
if (!suppressEvents) if (self._time !== prevTime || isComplete || force) {
self._callback("onUpdate");
}
}
if (callback) if (!self._gc || force) { //check _gc because there's a chance that kill() could be called in an onUpdate
if (time < 0 && self._startAt && !self._onUpdate && time !== -0.0001) { //-0.0001 is a special value that we use when looping back to the beginning of a repeated TimelineMax, in which case we shouldn't render the _startAt values.
self._startAt.render(time, true, force);
}
if (isComplete) {
if (self._timeline.autoRemoveChildren) {
self._enabled(false, false);
}
self._active = false;
}
if (!suppressEvents && self.vars[callback]) {
self._callback(callback);
}
if (duration === 0 && self._rawPrevTime === _tinyNum && rawPrevTime !== _tinyNum) { //the onComplete or onReverseComplete could trigger movement of the playhead and for zero-duration tweens (which must discern direction) that land directly back on their start time, we don't want to fire again on the next render. Think of several addPause()'s in a timeline that forces the playhead to a certain spot, but what if it's already paused and another tween is tweening the "time" of the timeline? Each time it moves [forward] past that spot, it would move back, and since suppressEvents is true, it'd reset _rawPrevTime to _tinyNum so that when it begins again, the callback would fire (so ultimately it could bounce back and forth during that tween). Again, this is a very uncommon scenario, but possible nonetheless.
self._rawPrevTime = 0;
}
}
};
p._kill = function(vars, target, overwritingTween) {
if (vars === "all") {
vars = null;
}
if (vars == null) if (target == null || target === this.target) {
this._lazy = false;
return this._enabled(false, false);
}
target = (typeof(target) !== "string") ? (target || this._targets || this.target) : TweenLite.selector(target) || target;
var simultaneousOverwrite = (overwritingTween && this._time && overwritingTween._startTime === this._startTime && this._timeline === overwritingTween._timeline),
firstPT = this._firstPT,
i, overwrittenProps, p, pt, propLookup, changed, killProps, record, killed;
if ((_isArray(target) || _isSelector(target)) && typeof(target[0]) !== "number") {
i = target.length;
while (--i > -1) {
if (this._kill(vars, target[i], overwritingTween)) {
changed = true;
}
}
} else {
if (this._targets) {
i = this._targets.length;
while (--i > -1) {
if (target === this._targets[i]) {
propLookup = this._propLookup[i] || {};
this._overwrittenProps = this._overwrittenProps || [];
overwrittenProps = this._overwrittenProps[i] = vars ? this._overwrittenProps[i] || {} : "all";
break;
}
}
} else if (target !== this.target) {
return false;
} else {
propLookup = this._propLookup;
overwrittenProps = this._overwrittenProps = vars ? this._overwrittenProps || {} : "all";
}
if (propLookup) {
killProps = vars || propLookup;
record = (vars !== overwrittenProps && overwrittenProps !== "all" && vars !== propLookup && (typeof(vars) !== "object" || !vars._tempKill)); //_tempKill is a super-secret way to delete a particular tweening property but NOT have it remembered as an official overwritten property (like in BezierPlugin)
if (overwritingTween && (TweenLite.onOverwrite || this.vars.onOverwrite)) {
for (p in killProps) {
if (propLookup[p]) {
if (!killed) {
killed = [];
}
killed.push(p);
}
}
if ((killed || !vars) && !_onOverwrite(this, overwritingTween, target, killed)) { //if the onOverwrite returned false, that means the user wants to override the overwriting (cancel it).
return false;
}
}
for (p in killProps) {
if ((pt = propLookup[p])) {
if (simultaneousOverwrite) { //if another tween overwrites this one and they both start at exactly the same time, yet this tween has already rendered once (for example, at 0.001) because it's first in the queue, we should revert the values to where they were at 0 so that the starting values aren't contaminated on the overwriting tween.
if (pt.f) {
pt.t[pt.p](pt.s);
} else {
pt.t[pt.p] = pt.s;
}
changed = true;
}
if (pt.pg && pt.t._kill(killProps)) {
changed = true; //some plugins need to be notified so they can perform cleanup tasks first
}
if (!pt.pg || pt.t._overwriteProps.length === 0) {
if (pt._prev) {
pt._prev._next = pt._next;
} else if (pt === this._firstPT) {
this._firstPT = pt._next;
}
if (pt._next) {
pt._next._prev = pt._prev;
}
pt._next = pt._prev = null;
}
delete propLookup[p];
}
if (record) {
overwrittenProps[p] = 1;
}
}
if (!this._firstPT && this._initted && firstPT) { //if all tweening properties are killed, kill the tween. Without this line, if there's a tween with multiple targets and then you killTweensOf() each target individually, the tween would technically still remain active and fire its onComplete even though there aren't any more properties tweening.
this._enabled(false, false);
}
}
}
return changed;
};
p.invalidate = function() {
if (this._notifyPluginsOfEnabled) {
TweenLite._onPluginEvent("_onDisable", this);
}
var t = this._time;
this._firstPT = this._overwrittenProps = this._startAt = this._onUpdate = null;
this._notifyPluginsOfEnabled = this._active = this._lazy = false;
this._propLookup = (this._targets) ? {} : [];
Animation.prototype.invalidate.call(this);
if (this.vars.immediateRender) {
this._time = -_tinyNum; //forces a render without having to set the render() "force" parameter to true because we want to allow lazying by default (using the "force" parameter always forces an immediate full render)
this.render(t, false, this.vars.lazy !== false);
}
return this;
};
p._enabled = function(enabled, ignoreTimeline) {
if (!_tickerActive) {
_ticker.wake();
}
if (enabled && this._gc) {
var targets = this._targets,
i;
if (targets) {
i = targets.length;
while (--i > -1) {
this._siblings[i] = _register(targets[i], this, true);
}
} else {
this._siblings = _register(this.target, this, true);
}
}
Animation.prototype._enabled.call(this, enabled, ignoreTimeline);
if (this._notifyPluginsOfEnabled) if (this._firstPT) {
return TweenLite._onPluginEvent((enabled ? "_onEnable" : "_onDisable"), this);
}
return false;
};
//----TweenLite static methods -----------------------------------------------------
TweenLite.to = function(target, duration, vars) {
return new TweenLite(target, duration, vars);
};
TweenLite.from = function(target, duration, vars) {
vars.runBackwards = true;
vars.immediateRender = (vars.immediateRender != false);
return new TweenLite(target, duration, vars);
};
TweenLite.fromTo = function(target, duration, fromVars, toVars) {
toVars.startAt = fromVars;
toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false);
return new TweenLite(target, duration, toVars);
};
TweenLite.delayedCall = function(delay, callback, params, scope, useFrames) {
return new TweenLite(callback, 0, {delay:delay, onComplete:callback, onCompleteParams:params, callbackScope:scope, onReverseComplete:callback, onReverseCompleteParams:params, immediateRender:false, lazy:false, useFrames:useFrames, overwrite:0});
};
TweenLite.set = function(target, vars) {
return new TweenLite(target, 0, vars);
};
TweenLite.getTweensOf = function(target, onlyActive) {
if (target == null) { return []; }
target = (typeof(target) !== "string") ? target : TweenLite.selector(target) || target;
var i, a, j, t;
if ((_isArray(target) || _isSelector(target)) && typeof(target[0]) !== "number") {
i = target.length;
a = [];
while (--i > -1) {
a = a.concat(TweenLite.getTweensOf(target[i], onlyActive));
}
i = a.length;
//now get rid of any duplicates (tweens of arrays of objects could cause duplicates)
while (--i > -1) {
t = a[i];
j = i;
while (--j > -1) {
if (t === a[j]) {
a.splice(i, 1);
}
}
}
} else if (target._gsTweenID) {
a = _register(target).concat();
i = a.length;
while (--i > -1) {
if (a[i]._gc || (onlyActive && !a[i].isActive())) {
a.splice(i, 1);
}
}
}
return a || [];
};
TweenLite.killTweensOf = TweenLite.killDelayedCallsTo = function(target, onlyActive, vars) {
if (typeof(onlyActive) === "object") {
vars = onlyActive; //for backwards compatibility (before "onlyActive" parameter was inserted)
onlyActive = false;
}
var a = TweenLite.getTweensOf(target, onlyActive),
i = a.length;
while (--i > -1) {
a[i]._kill(vars, target);
}
};
/*
* ----------------------------------------------------------------
* TweenPlugin (could easily be split out as a separate file/class, but included for ease of use (so that people don't need to include another script call before loading plugins which is easy to forget)
* ----------------------------------------------------------------
*/
var TweenPlugin = _class("plugins.TweenPlugin", function(props, priority) {
this._overwriteProps = (props || "").split(",");
this._propName = this._overwriteProps[0];
this._priority = priority || 0;
this._super = TweenPlugin.prototype;
}, true);
p = TweenPlugin.prototype;
TweenPlugin.version = "1.19.0";
TweenPlugin.API = 2;
p._firstPT = null;
p._addTween = _addPropTween;
p.setRatio = _setRatio;
p._kill = function(lookup) {
var a = this._overwriteProps,
pt = this._firstPT,
i;
if (lookup[this._propName] != null) {
this._overwriteProps = [];
} else {
i = a.length;
while (--i > -1) {
if (lookup[a[i]] != null) {
a.splice(i, 1);
}
}
}
while (pt) {
if (lookup[pt.n] != null) {
if (pt._next) {
pt._next._prev = pt._prev;
}
if (pt._prev) {
pt._prev._next = pt._next;
pt._prev = null;
} else if (this._firstPT === pt) {
this._firstPT = pt._next;
}
}
pt = pt._next;
}
return false;
};
p._mod = p._roundProps = function(lookup) {
var pt = this._firstPT,
val;
while (pt) {
val = lookup[this._propName] || (pt.n != null && lookup[ pt.n.split(this._propName + "_").join("") ]);
if (val && typeof(val) === "function") { //some properties that are very plugin-specific add a prefix named after the _propName plus an underscore, so we need to ignore that extra stuff here.
if (pt.f === 2) {
pt.t._applyPT.m = val;
} else {
pt.m = val;
}
}
pt = pt._next;
}
};
TweenLite._onPluginEvent = function(type, tween) {
var pt = tween._firstPT,
changed, pt2, first, last, next;
if (type === "_onInitAllProps") {
//sorts the PropTween linked list in order of priority because some plugins need to render earlier/later than others, like MotionBlurPlugin applies its effects after all x/y/alpha tweens have rendered on each frame.
while (pt) {
next = pt._next;
pt2 = first;
while (pt2 && pt2.pr > pt.pr) {
pt2 = pt2._next;
}
if ((pt._prev = pt2 ? pt2._prev : last)) {
pt._prev._next = pt;
} else {
first = pt;
}
if ((pt._next = pt2)) {
pt2._prev = pt;
} else {
last = pt;
}
pt = next;
}
pt = tween._firstPT = first;
}
while (pt) {
if (pt.pg) if (typeof(pt.t[type]) === "function") if (pt.t[type]()) {
changed = true;
}
pt = pt._next;
}
return changed;
};
TweenPlugin.activate = function(plugins) {
var i = plugins.length;
while (--i > -1) {
if (plugins[i].API === TweenPlugin.API) {
_plugins[(new plugins[i]())._propName] = plugins[i];
}
}
return true;
};
//provides a more concise way to define plugins that have no dependencies besides TweenPlugin and TweenLite, wrapping common boilerplate stuff into one function (added in 1.9.0). You don't NEED to use this to define a plugin - the old way still works and can be useful in certain (rare) situations.
_gsDefine.plugin = function(config) {
if (!config || !config.propName || !config.init || !config.API) { throw "illegal plugin definition."; }
var propName = config.propName,
priority = config.priority || 0,
overwriteProps = config.overwriteProps,
map = {init:"_onInitTween", set:"setRatio", kill:"_kill", round:"_mod", mod:"_mod", initAll:"_onInitAllProps"},
Plugin = _class("plugins." + propName.charAt(0).toUpperCase() + propName.substr(1) + "Plugin",
function() {
TweenPlugin.call(this, propName, priority);
this._overwriteProps = overwriteProps || [];
}, (config.global === true)),
p = Plugin.prototype = new TweenPlugin(propName),
prop;
p.constructor = Plugin;
Plugin.API = config.API;
for (prop in map) {
if (typeof(config[prop]) === "function") {
p[map[prop]] = config[prop];
}
}
Plugin.version = config.version;
TweenPlugin.activate([Plugin]);
return Plugin;
};
//now run through all the dependencies discovered and if any are missing, log that to the console as a warning. This is why it's best to have TweenLite load last - it can check all the dependencies for you.
a = window._gsQueue;
if (a) {
for (i = 0; i < a.length; i++) {
a[i]();
}
for (p in _defLookup) {
if (!_defLookup[p].func) {
window.console.log("GSAP encountered missing dependency: " + p);
}
}
}
_tickerActive = false; //ensures that the first official animation forces a ticker.tick() to update the time when it is instantiated
return TweenLite;
})(_gsScope, "TweenLite");
var globals = _gsScope.GreenSockGlobals;
var nonGlobals = globals.com.greensock;
var SimpleTimeline = nonGlobals.core.SimpleTimeline;
var Animation = nonGlobals.core.Animation;
var Ease = globals.Ease;
var Linear = globals.Linear;
var Power0 = Linear;
var Power1 = globals.Power1;
var Power2 = globals.Power2;
var Power3 = globals.Power3;
var Power4 = globals.Power4;
var TweenPlugin = globals.TweenPlugin;
var EventDispatcher = nonGlobals.events.EventDispatcher;
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(540)(module), __webpack_require__(53)))
/***/ }),
/* 30 */
/***/ (function(module, exports, __webpack_require__) {
// 7.1.1 ToPrimitive(input [, PreferredType])
var isObject = __webpack_require__(6);
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
module.exports = function (it, S) {
if (!isObject(it)) return it;
var fn, val;
if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
throw TypeError("Can't convert object to primitive value");
};
/***/ }),
/* 31 */
/***/ (function(module, exports) {
// 7.2.1 RequireObjectCoercible(argument)
module.exports = function (it) {
if (it == undefined) throw TypeError("Can't call method on " + it);
return it;
};
/***/ }),
/* 32 */
/***/ (function(module, exports, __webpack_require__) {
// most Object methods by ES6 should accept primitives
var $export = __webpack_require__(0);
var core = __webpack_require__(24);
var fails = __webpack_require__(4);
module.exports = function (KEY, exec) {
var fn = (core.Object || {})[KEY] || Object[KEY];
var exp = {};
exp[KEY] = exec(fn);
$export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
};
/***/ }),
/* 33 */
/***/ (function(module, exports, __webpack_require__) {
// 0 -> Array#forEach
// 1 -> Array#map
// 2 -> Array#filter
// 3 -> Array#some
// 4 -> Array#every
// 5 -> Array#find
// 6 -> Array#findIndex
var ctx = __webpack_require__(25);
var IObject = __webpack_require__(60);
var toObject = __webpack_require__(12);
var toLength = __webpack_require__(9);
var asc = __webpack_require__(107);
module.exports = function (TYPE, $create) {
var IS_MAP = TYPE == 1;
var IS_FILTER = TYPE == 2;
var IS_SOME = TYPE == 3;
var IS_EVERY = TYPE == 4;
var IS_FIND_INDEX = TYPE == 6;
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
var create = $create || asc;
return function ($this, callbackfn, that) {
var O = toObject($this);
var self = IObject(O);
var f = ctx(callbackfn, that, 3);
var length = toLength(self.length);
var index = 0;
var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
var val, res;
for (;length > index; index++) if (NO_HOLES || index in self) {
val = self[index];
res = f(val, index, O);
if (TYPE) {
if (IS_MAP) result[index] = res; // map
else if (res) switch (TYPE) {
case 3: return true; // some
case 5: return val; // find
case 6: return index; // findIndex
case 2: result.push(val); // filter
} else if (IS_EVERY) return false; // every
}
}
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
};
};
/***/ }),
/* 34 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// resolves . and .. elements in a path array with directory names there
// must be no slashes, empty elements, or device names (c:\) in the array
// (so also no leading and trailing slashes - it does not distinguish
// relative and absolute paths)
function normalizeArray(parts, allowAboveRoot) {
// if the path tries to go above the root, `up` ends up > 0
var up = 0;
for (var i = parts.length - 1; i >= 0; i--) {
var last = parts[i];
if (last === '.') {
parts.splice(i, 1);
} else if (last === '..') {
parts.splice(i, 1);
up++;
} else if (up) {
parts.splice(i, 1);
up--;
}
}
// if the path is allowed to go above the root, restore leading ..s
if (allowAboveRoot) {
for (; up--; up) {
parts.unshift('..');
}
}
return parts;
}
// Split a filename into [root, dir, basename, ext], unix version
// 'root' is just a slash, or nothing.
var splitPathRe =
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
var splitPath = function(filename) {
return splitPathRe.exec(filename).slice(1);
};
// path.resolve([from ...], to)
// posix version
exports.resolve = function() {
var resolvedPath = '',
resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
var path = (i >= 0) ? arguments[i] : process.cwd();
// Skip empty and invalid entries
if (typeof path !== 'string') {
throw new TypeError('Arguments to path.resolve must be strings');
} else if (!path) {
continue;
}
resolvedPath = path + '/' + resolvedPath;
resolvedAbsolute = path.charAt(0) === '/';
}
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
// Normalize the path
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
return !!p;
}), !resolvedAbsolute).join('/');
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
};
// path.normalize(path)
// posix version
exports.normalize = function(path) {
var isAbsolute = exports.isAbsolute(path),
trailingSlash = substr(path, -1) === '/';
// Normalize the path
path = normalizeArray(filter(path.split('/'), function(p) {
return !!p;
}), !isAbsolute).join('/');
if (!path && !isAbsolute) {
path = '.';
}
if (path && trailingSlash) {
path += '/';
}
return (isAbsolute ? '/' : '') + path;
};
// posix version
exports.isAbsolute = function(path) {
return path.charAt(0) === '/';
};
// posix version
exports.join = function() {
var paths = Array.prototype.slice.call(arguments, 0);
return exports.normalize(filter(paths, function(p, index) {
if (typeof p !== 'string') {
throw new TypeError('Arguments to path.join must be strings');
}
return p;
}).join('/'));
};
// path.relative(from, to)
// posix version
exports.relative = function(from, to) {
from = exports.resolve(from).substr(1);
to = exports.resolve(to).substr(1);
function trim(arr) {
var start = 0;
for (; start < arr.length; start++) {
if (arr[start] !== '') break;
}
var end = arr.length - 1;
for (; end >= 0; end--) {
if (arr[end] !== '') break;
}
if (start > end) return [];
return arr.slice(start, end - start + 1);
}
var fromParts = trim(from.split('/'));
var toParts = trim(to.split('/'));
var length = Math.min(fromParts.length, toParts.length);
var samePartsLength = length;
for (var i = 0; i < length; i++) {
if (fromParts[i] !== toParts[i]) {
samePartsLength = i;
break;
}
}
var outputParts = [];
for (var i = samePartsLength; i < fromParts.length; i++) {
outputParts.push('..');
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join('/');
};
exports.sep = '/';
exports.delimiter = ':';
exports.dirname = function(path) {
var result = splitPath(path),
root = result[0],
dir = result[1];
if (!root && !dir) {
// No dirname whatsoever
return '.';
}
if (dir) {
// It has a dirname, strip trailing slash
dir = dir.substr(0, dir.length - 1);
}
return root + dir;
};
exports.basename = function(path, ext) {
var f = splitPath(path)[2];
// TODO: make this comparison case-insensitive on windows?
if (ext && f.substr(-1 * ext.length) === ext) {
f = f.substr(0, f.length - ext.length);
}
return f;
};
exports.extname = function(path) {
return splitPath(path)[3];
};
function filter (xs, f) {
if (xs.filter) return xs.filter(f);
var res = [];
for (var i = 0; i < xs.length; i++) {
if (f(xs[i], i, xs)) res.push(xs[i]);
}
return res;
}
// String.prototype.substr - negative index don't work in IE8
var substr = 'ab'.substr(-1) === 'b'
? function (str, start, len) { return str.substr(start, len) }
: function (str, start, len) {
if (start < 0) start = str.length + start;
return str.substr(start, len);
}
;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(471)))
/***/ }),
/* 35 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
if (__webpack_require__(10)) {
var LIBRARY = __webpack_require__(37);
var global = __webpack_require__(2);
var fails = __webpack_require__(4);
var $export = __webpack_require__(0);
var $typed = __webpack_require__(80);
var $buffer = __webpack_require__(115);
var ctx = __webpack_require__(25);
var anInstance = __webpack_require__(48);
var propertyDesc = __webpack_require__(41);
var hide = __webpack_require__(16);
var redefineAll = __webpack_require__(50);
var toInteger = __webpack_require__(27);
var toLength = __webpack_require__(9);
var toIndex = __webpack_require__(161);
var toAbsoluteIndex = __webpack_require__(44);
var toPrimitive = __webpack_require__(30);
var has = __webpack_require__(19);
var classof = __webpack_require__(55);
var isObject = __webpack_require__(6);
var toObject = __webpack_require__(12);
var isArrayIter = __webpack_require__(104);
var create = __webpack_require__(45);
var getPrototypeOf = __webpack_require__(22);
var gOPN = __webpack_require__(46).f;
var getIterFn = __webpack_require__(106);
var uid = __webpack_require__(42);
var wks = __webpack_require__(8);
var createArrayMethod = __webpack_require__(33);
var createArrayIncludes = __webpack_require__(70);
var speciesConstructor = __webpack_require__(63);
var ArrayIterators = __webpack_require__(109);
var Iterators = __webpack_require__(57);
var $iterDetect = __webpack_require__(75);
var setSpecies = __webpack_require__(47);
var arrayFill = __webpack_require__(108);
var arrayCopyWithin = __webpack_require__(150);
var $DP = __webpack_require__(11);
var $GOPD = __webpack_require__(21);
var dP = $DP.f;
var gOPD = $GOPD.f;
var RangeError = global.RangeError;
var TypeError = global.TypeError;
var Uint8Array = global.Uint8Array;
var ARRAY_BUFFER = 'ArrayBuffer';
var SHARED_BUFFER = 'Shared' + ARRAY_BUFFER;
var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';
var PROTOTYPE = 'prototype';
var ArrayProto = Array[PROTOTYPE];
var $ArrayBuffer = $buffer.ArrayBuffer;
var $DataView = $buffer.DataView;
var arrayForEach = createArrayMethod(0);
var arrayFilter = createArrayMethod(2);
var arraySome = createArrayMethod(3);
var arrayEvery = createArrayMethod(4);
var arrayFind = createArrayMethod(5);
var arrayFindIndex = createArrayMethod(6);
var arrayIncludes = createArrayIncludes(true);
var arrayIndexOf = createArrayIncludes(false);
var arrayValues = ArrayIterators.values;
var arrayKeys = ArrayIterators.keys;
var arrayEntries = ArrayIterators.entries;
var arrayLastIndexOf = ArrayProto.lastIndexOf;
var arrayReduce = ArrayProto.reduce;
var arrayReduceRight = ArrayProto.reduceRight;
var arrayJoin = ArrayProto.join;
var arraySort = ArrayProto.sort;
var arraySlice = ArrayProto.slice;
var arrayToString = ArrayProto.toString;
var arrayToLocaleString = ArrayProto.toLocaleString;
var ITERATOR = wks('iterator');
var TAG = wks('toStringTag');
var TYPED_CONSTRUCTOR = uid('typed_constructor');
var DEF_CONSTRUCTOR = uid('def_constructor');
var ALL_CONSTRUCTORS = $typed.CONSTR;
var TYPED_ARRAY = $typed.TYPED;
var VIEW = $typed.VIEW;
var WRONG_LENGTH = 'Wrong length!';
var $map = createArrayMethod(1, function (O, length) {
return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length);
});
var LITTLE_ENDIAN = fails(function () {
// eslint-disable-next-line no-undef
return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
});
var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function () {
new Uint8Array(1).set({});
});
var toOffset = function (it, BYTES) {
var offset = toInteger(it);
if (offset < 0 || offset % BYTES) throw RangeError('Wrong offset!');
return offset;
};
var validate = function (it) {
if (isObject(it) && TYPED_ARRAY in it) return it;
throw TypeError(it + ' is not a typed array!');
};
var allocate = function (C, length) {
if (!(isObject(C) && TYPED_CONSTRUCTOR in C)) {
throw TypeError('It is not a typed array constructor!');
} return new C(length);
};
var speciesFromList = function (O, list) {
return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list);
};
var fromList = function (C, list) {
var index = 0;
var length = list.length;
var result = allocate(C, length);
while (length > index) result[index] = list[index++];
return result;
};
var addGetter = function (it, key, internal) {
dP(it, key, { get: function () { return this._d[internal]; } });
};
var $from = function from(source /* , mapfn, thisArg */) {
var O = toObject(source);
var aLen = arguments.length;
var mapfn = aLen > 1 ? arguments[1] : undefined;
var mapping = mapfn !== undefined;
var iterFn = getIterFn(O);
var i, length, values, result, step, iterator;
if (iterFn != undefined && !isArrayIter(iterFn)) {
for (iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++) {
values.push(step.value);
} O = values;
}
if (mapping && aLen > 2) mapfn = ctx(mapfn, arguments[2], 2);
for (i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++) {
result[i] = mapping ? mapfn(O[i], i) : O[i];
}
return result;
};
var $of = function of(/* ...items */) {
var index = 0;
var length = arguments.length;
var result = allocate(this, length);
while (length > index) result[index] = arguments[index++];
return result;
};
// iOS Safari 6.x fails here
var TO_LOCALE_BUG = !!Uint8Array && fails(function () { arrayToLocaleString.call(new Uint8Array(1)); });
var $toLocaleString = function toLocaleString() {
return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments);
};
var proto = {
copyWithin: function copyWithin(target, start /* , end */) {
return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined);
},
every: function every(callbackfn /* , thisArg */) {
return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
},
fill: function fill(value /* , start, end */) { // eslint-disable-line no-unused-vars
return arrayFill.apply(validate(this), arguments);
},
filter: function filter(callbackfn /* , thisArg */) {
return speciesFromList(this, arrayFilter(validate(this), callbackfn,
arguments.length > 1 ? arguments[1] : undefined));
},
find: function find(predicate /* , thisArg */) {
return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
},
findIndex: function findIndex(predicate /* , thisArg */) {
return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
},
forEach: function forEach(callbackfn /* , thisArg */) {
arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
},
indexOf: function indexOf(searchElement /* , fromIndex */) {
return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
},
includes: function includes(searchElement /* , fromIndex */) {
return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
},
join: function join(separator) { // eslint-disable-line no-unused-vars
return arrayJoin.apply(validate(this), arguments);
},
lastIndexOf: function lastIndexOf(searchElement /* , fromIndex */) { // eslint-disable-line no-unused-vars
return arrayLastIndexOf.apply(validate(this), arguments);
},
map: function map(mapfn /* , thisArg */) {
return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined);
},
reduce: function reduce(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars
return arrayReduce.apply(validate(this), arguments);
},
reduceRight: function reduceRight(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars
return arrayReduceRight.apply(validate(this), arguments);
},
reverse: function reverse() {
var that = this;
var length = validate(that).length;
var middle = Math.floor(length / 2);
var index = 0;
var value;
while (index < middle) {
value = that[index];
that[index++] = that[--length];
that[length] = value;
} return that;
},
some: function some(callbackfn /* , thisArg */) {
return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
},
sort: function sort(comparefn) {
return arraySort.call(validate(this), comparefn);
},
subarray: function subarray(begin, end) {
var O = validate(this);
var length = O.length;
var $begin = toAbsoluteIndex(begin, length);
return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))(
O.buffer,
O.byteOffset + $begin * O.BYTES_PER_ELEMENT,
toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - $begin)
);
}
};
var $slice = function slice(start, end) {
return speciesFromList(this, arraySlice.call(validate(this), start, end));
};
var $set = function set(arrayLike /* , offset */) {
validate(this);
var offset = toOffset(arguments[1], 1);
var length = this.length;
var src = toObject(arrayLike);
var len = toLength(src.length);
var index = 0;
if (len + offset > length) throw RangeError(WRONG_LENGTH);
while (index < len) this[offset + index] = src[index++];
};
var $iterators = {
entries: function entries() {
return arrayEntries.call(validate(this));
},
keys: function keys() {
return arrayKeys.call(validate(this));
},
values: function values() {
return arrayValues.call(validate(this));
}
};
var isTAIndex = function (target, key) {
return isObject(target)
&& target[TYPED_ARRAY]
&& typeof key != 'symbol'
&& key in target
&& String(+key) == String(key);
};
var $getDesc = function getOwnPropertyDescriptor(target, key) {
return isTAIndex(target, key = toPrimitive(key, true))
? propertyDesc(2, target[key])
: gOPD(target, key);
};
var $setDesc = function defineProperty(target, key, desc) {
if (isTAIndex(target, key = toPrimitive(key, true))
&& isObject(desc)
&& has(desc, 'value')
&& !has(desc, 'get')
&& !has(desc, 'set')
// TODO: add validation descriptor w/o calling accessors
&& !desc.configurable
&& (!has(desc, 'writable') || desc.writable)
&& (!has(desc, 'enumerable') || desc.enumerable)
) {
target[key] = desc.value;
return target;
} return dP(target, key, desc);
};
if (!ALL_CONSTRUCTORS) {
$GOPD.f = $getDesc;
$DP.f = $setDesc;
}
$export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', {
getOwnPropertyDescriptor: $getDesc,
defineProperty: $setDesc
});
if (fails(function () { arrayToString.call({}); })) {
arrayToString = arrayToLocaleString = function toString() {
return arrayJoin.call(this);
};
}
var $TypedArrayPrototype$ = redefineAll({}, proto);
redefineAll($TypedArrayPrototype$, $iterators);
hide($TypedArrayPrototype$, ITERATOR, $iterators.values);
redefineAll($TypedArrayPrototype$, {
slice: $slice,
set: $set,
constructor: function () { /* noop */ },
toString: arrayToString,
toLocaleString: $toLocaleString
});
addGetter($TypedArrayPrototype$, 'buffer', 'b');
addGetter($TypedArrayPrototype$, 'byteOffset', 'o');
addGetter($TypedArrayPrototype$, 'byteLength', 'l');
addGetter($TypedArrayPrototype$, 'length', 'e');
dP($TypedArrayPrototype$, TAG, {
get: function () { return this[TYPED_ARRAY]; }
});
// eslint-disable-next-line max-statements
module.exports = function (KEY, BYTES, wrapper, CLAMPED) {
CLAMPED = !!CLAMPED;
var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array';
var GETTER = 'get' + KEY;
var SETTER = 'set' + KEY;
var TypedArray = global[NAME];
var Base = TypedArray || {};
var TAC = TypedArray && getPrototypeOf(TypedArray);
var FORCED = !TypedArray || !$typed.ABV;
var O = {};
var TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE];
var getter = function (that, index) {
var data = that._d;
return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN);
};
var setter = function (that, index, value) {
var data = that._d;
if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff;
data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN);
};
var addElement = function (that, index) {
dP(that, index, {
get: function () {
return getter(this, index);
},
set: function (value) {
return setter(this, index, value);
},
enumerable: true
});
};
if (FORCED) {
TypedArray = wrapper(function (that, data, $offset, $length) {
anInstance(that, TypedArray, NAME, '_d');
var index = 0;
var offset = 0;
var buffer, byteLength, length, klass;
if (!isObject(data)) {
length = toIndex(data);
byteLength = length * BYTES;
buffer = new $ArrayBuffer(byteLength);
} else if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {
buffer = data;
offset = toOffset($offset, BYTES);
var $len = data.byteLength;
if ($length === undefined) {
if ($len % BYTES) throw RangeError(WRONG_LENGTH);
byteLength = $len - offset;
if (byteLength < 0) throw RangeError(WRONG_LENGTH);
} else {
byteLength = toLength($length) * BYTES;
if (byteLength + offset > $len) throw RangeError(WRONG_LENGTH);
}
length = byteLength / BYTES;
} else if (TYPED_ARRAY in data) {
return fromList(TypedArray, data);
} else {
return $from.call(TypedArray, data);
}
hide(that, '_d', {
b: buffer,
o: offset,
l: byteLength,
e: length,
v: new $DataView(buffer)
});
while (index < length) addElement(that, index++);
});
TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$);
hide(TypedArrayPrototype, 'constructor', TypedArray);
} else if (!fails(function () {
TypedArray(1);
}) || !fails(function () {
new TypedArray(-1); // eslint-disable-line no-new
}) || !$iterDetect(function (iter) {
new TypedArray(); // eslint-disable-line no-new
new TypedArray(null); // eslint-disable-line no-new
new TypedArray(1.5); // eslint-disable-line no-new
new TypedArray(iter); // eslint-disable-line no-new
}, true)) {
TypedArray = wrapper(function (that, data, $offset, $length) {
anInstance(that, TypedArray, NAME);
var klass;
// `ws` module bug, temporarily remove validation length for Uint8Array
// https://github.com/websockets/ws/pull/645
if (!isObject(data)) return new Base(toIndex(data));
if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {
return $length !== undefined
? new Base(data, toOffset($offset, BYTES), $length)
: $offset !== undefined
? new Base(data, toOffset($offset, BYTES))
: new Base(data);
}
if (TYPED_ARRAY in data) return fromList(TypedArray, data);
return $from.call(TypedArray, data);
});
arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function (key) {
if (!(key in TypedArray)) hide(TypedArray, key, Base[key]);
});
TypedArray[PROTOTYPE] = TypedArrayPrototype;
if (!LIBRARY) TypedArrayPrototype.constructor = TypedArray;
}
var $nativeIterator = TypedArrayPrototype[ITERATOR];
var CORRECT_ITER_NAME = !!$nativeIterator
&& ($nativeIterator.name == 'values' || $nativeIterator.name == undefined);
var $iterator = $iterators.values;
hide(TypedArray, TYPED_CONSTRUCTOR, true);
hide(TypedArrayPrototype, TYPED_ARRAY, NAME);
hide(TypedArrayPrototype, VIEW, true);
hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray);
if (CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)) {
dP(TypedArrayPrototype, TAG, {
get: function () { return NAME; }
});
}
O[NAME] = TypedArray;
$export($export.G + $export.W + $export.F * (TypedArray != Base), O);
$export($export.S, NAME, {
BYTES_PER_ELEMENT: BYTES
});
$export($export.S + $export.F * fails(function () { Base.of.call(TypedArray, 1); }), NAME, {
from: $from,
of: $of
});
if (!(BYTES_PER_ELEMENT in TypedArrayPrototype)) hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES);
$export($export.P, NAME, proto);
setSpecies(NAME);
$export($export.P + $export.F * FORCED_SET, NAME, { set: $set });
$export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators);
if (!LIBRARY && TypedArrayPrototype.toString != arrayToString) TypedArrayPrototype.toString = arrayToString;
$export($export.P + $export.F * fails(function () {
new TypedArray(1).slice();
}), NAME, { slice: $slice });
$export($export.P + $export.F * (fails(function () {
return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString();
}) || !fails(function () {
TypedArrayPrototype.toLocaleString.call([1, 2]);
})), NAME, { toLocaleString: $toLocaleString });
Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator;
if (!LIBRARY && !CORRECT_ITER_NAME) hide(TypedArrayPrototype, ITERATOR, $iterator);
};
} else module.exports = function () { /* empty */ };
/***/ }),
/* 36 */
/***/ (function(module, exports, __webpack_require__) {
var Map = __webpack_require__(156);
var $export = __webpack_require__(0);
var shared = __webpack_require__(59)('metadata');
var store = shared.store || (shared.store = new (__webpack_require__(159))());
var getOrCreateMetadataMap = function (target, targetKey, create) {
var targetMetadata = store.get(target);
if (!targetMetadata) {
if (!create) return undefined;
store.set(target, targetMetadata = new Map());
}
var keyMetadata = targetMetadata.get(targetKey);
if (!keyMetadata) {
if (!create) return undefined;
targetMetadata.set(targetKey, keyMetadata = new Map());
} return keyMetadata;
};
var ordinaryHasOwnMetadata = function (MetadataKey, O, P) {
var metadataMap = getOrCreateMetadataMap(O, P, false);
return metadataMap === undefined ? false : metadataMap.has(MetadataKey);
};
var ordinaryGetOwnMetadata = function (MetadataKey, O, P) {
var metadataMap = getOrCreateMetadataMap(O, P, false);
return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey);
};
var ordinaryDefineOwnMetadata = function (MetadataKey, MetadataValue, O, P) {
getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue);
};
var ordinaryOwnMetadataKeys = function (target, targetKey) {
var metadataMap = getOrCreateMetadataMap(target, targetKey, false);
var keys = [];
if (metadataMap) metadataMap.forEach(function (_, key) { keys.push(key); });
return keys;
};
var toMetaKey = function (it) {
return it === undefined || typeof it == 'symbol' ? it : String(it);
};
var exp = function (O) {
$export($export.S, 'Reflect', O);
};
module.exports = {
store: store,
map: getOrCreateMetadataMap,
has: ordinaryHasOwnMetadata,
get: ordinaryGetOwnMetadata,
set: ordinaryDefineOwnMetadata,
keys: ordinaryOwnMetadataKeys,
key: toMetaKey,
exp: exp
};
/***/ }),
/* 37 */
/***/ (function(module, exports) {
module.exports = false;
/***/ }),
/* 38 */
/***/ (function(module, exports, __webpack_require__) {
var META = __webpack_require__(42)('meta');
var isObject = __webpack_require__(6);
var has = __webpack_require__(19);
var setDesc = __webpack_require__(11).f;
var id = 0;
var isExtensible = Object.isExtensible || function () {
return true;
};
var FREEZE = !__webpack_require__(4)(function () {
return isExtensible(Object.preventExtensions({}));
});
var setMeta = function (it) {
setDesc(it, META, { value: {
i: 'O' + ++id, // object ID
w: {} // weak collections IDs
} });
};
var fastKey = function (it, create) {
// return primitive with prefix
if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
if (!has(it, META)) {
// can't set metadata to uncaught frozen object
if (!isExtensible(it)) return 'F';
// not necessary to add metadata
if (!create) return 'E';
// add missing metadata
setMeta(it);
// return object ID
} return it[META].i;
};
var getWeak = function (it, create) {
if (!has(it, META)) {
// can't set metadata to uncaught frozen object
if (!isExtensible(it)) return true;
// not necessary to add metadata
if (!create) return false;
// add missing metadata
setMeta(it);
// return hash weak collections IDs
} return it[META].w;
};
// add metadata on freeze-family methods calling
var onFreeze = function (it) {
if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
return it;
};
var meta = module.exports = {
KEY: META,
NEED: false,
fastKey: fastKey,
getWeak: getWeak,
onFreeze: onFreeze
};
/***/ }),
/* 39 */
/***/ (function(module, exports, __webpack_require__) {
// 22.1.3.31 Array.prototype[@@unscopables]
var UNSCOPABLES = __webpack_require__(8)('unscopables');
var ArrayProto = Array.prototype;
if (ArrayProto[UNSCOPABLES] == undefined) __webpack_require__(16)(ArrayProto, UNSCOPABLES, {});
module.exports = function (key) {
ArrayProto[UNSCOPABLES][key] = true;
};
/***/ }),
/* 40 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _BaseTexture = __webpack_require__(58);
var _BaseTexture2 = _interopRequireDefault(_BaseTexture);
var _VideoBaseTexture = __webpack_require__(186);
var _VideoBaseTexture2 = _interopRequireDefault(_VideoBaseTexture);
var _TextureUvs = __webpack_require__(187);
var _TextureUvs2 = _interopRequireDefault(_TextureUvs);
var _eventemitter = __webpack_require__(52);
var _eventemitter2 = _interopRequireDefault(_eventemitter);
var _math = __webpack_require__(14);
var _utils = __webpack_require__(7);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* A texture stores the information that represents an image or part of an image. It cannot be added
* to the display list directly. Instead use it as the texture for a Sprite. If no frame is provided
* then the whole image is used.
*
* You can directly create a texture from an image and then reuse it multiple times like this :
*
* ```js
* let texture = PIXI.Texture.fromImage('assets/image.png');
* let sprite1 = new PIXI.Sprite(texture);
* let sprite2 = new PIXI.Sprite(texture);
* ```
*
* Textures made from SVGs, loaded or not, cannot be used before the file finishes processing.
* You can check for this by checking the sprite's _textureID property.
* ```js
* var texture = PIXI.Texture.fromImage('assets/image.svg');
* var sprite1 = new PIXI.Sprite(texture);
* //sprite1._textureID should not be undefined if the texture has finished processing the SVG file
* ```
* You can use a ticker or rAF to ensure your sprites load the finished textures after processing. See issue #3068.
*
* @class
* @extends EventEmitter
* @memberof PIXI
*/
var Texture = function (_EventEmitter) {
_inherits(Texture, _EventEmitter);
/**
* @param {PIXI.BaseTexture} baseTexture - The base texture source to create the texture from
* @param {PIXI.Rectangle} [frame] - The rectangle frame of the texture to show
* @param {PIXI.Rectangle} [orig] - The area of original texture
* @param {PIXI.Rectangle} [trim] - Trimmed rectangle of original texture
* @param {number} [rotate] - indicates how the texture was rotated by texture packer. See {@link PIXI.GroupD8}
* @param {PIXI.Point} [anchor] - Default anchor point used for sprite placement / rotation
*/
function Texture(baseTexture, frame, orig, trim, rotate, anchor) {
_classCallCheck(this, Texture);
/**
* Does this Texture have any frame data assigned to it?
*
* @member {boolean}
*/
var _this = _possibleConstructorReturn(this, _EventEmitter.call(this));
_this.noFrame = false;
if (!frame) {
_this.noFrame = true;
frame = new _math.Rectangle(0, 0, 1, 1);
}
if (baseTexture instanceof Texture) {
baseTexture = baseTexture.baseTexture;
}
/**
* The base texture that this texture uses.
*
* @member {PIXI.BaseTexture}
*/
_this.baseTexture = baseTexture;
/**
* This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering,
* irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)
*
* @member {PIXI.Rectangle}
*/
_this._frame = frame;
/**
* This is the trimmed area of original texture, before it was put in atlas
* Please call `_updateUvs()` after you change coordinates of `trim` manually.
*
* @member {PIXI.Rectangle}
*/
_this.trim = trim;
/**
* This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.
*
* @member {boolean}
*/
_this.valid = false;
/**
* This will let a renderer know that a texture has been updated (used mainly for webGL uv updates)
*
* @member {boolean}
*/
_this.requiresUpdate = false;
/**
* The WebGL UV data cache.
*
* @member {PIXI.TextureUvs}
* @private
*/
_this._uvs = null;
/**
* This is the area of original texture, before it was put in atlas
*
* @member {PIXI.Rectangle}
*/
_this.orig = orig || frame; // new Rectangle(0, 0, 1, 1);
_this._rotate = Number(rotate || 0);
if (rotate === true) {
// this is old texturepacker legacy, some games/libraries are passing "true" for rotated textures
_this._rotate = 2;
} else if (_this._rotate % 2 !== 0) {
throw new Error('attempt to use diamond-shaped UVs. If you are sure, set rotation manually');
}
if (baseTexture.hasLoaded) {
if (_this.noFrame) {
frame = new _math.Rectangle(0, 0, baseTexture.width, baseTexture.height);
// if there is no frame we should monitor for any base texture changes..
baseTexture.on('update', _this.onBaseTextureUpdated, _this);
}
_this.frame = frame;
} else {
baseTexture.once('loaded', _this.onBaseTextureLoaded, _this);
}
/**
* Anchor point that is used as default if sprite is created with this texture.
* Changing the `defaultAnchor` at a later point of time will not update Sprite's anchor point.
* @member {PIXI.Point}
* @default {0,0}
*/
_this.defaultAnchor = anchor ? new _math.Point(anchor.x, anchor.y) : new _math.Point(0, 0);
/**
* Fired when the texture is updated. This happens if the frame or the baseTexture is updated.
*
* @event PIXI.Texture#update
* @protected
* @param {PIXI.Texture} texture - Instance of texture being updated.
*/
_this._updateID = 0;
/**
* Contains data for uvs. May contain clamp settings and some matrices.
* Its a bit heavy, so by default that object is not created.
* @member {PIXI.TextureMatrix}
* @default null
*/
_this.transform = null;
/**
* The ids under which this Texture has been added to the texture cache. This is
* automatically set as long as Texture.addToCache is used, but may not be set if a
* Texture is added directly to the TextureCache array.
*
* @member {string[]}
*/
_this.textureCacheIds = [];
return _this;
}
/**
* Updates this texture on the gpu.
*
*/
Texture.prototype.update = function update() {
this.baseTexture.update();
};
/**
* Called when the base texture is loaded
*
* @private
* @param {PIXI.BaseTexture} baseTexture - The base texture.
*/
Texture.prototype.onBaseTextureLoaded = function onBaseTextureLoaded(baseTexture) {
this._updateID++;
// TODO this code looks confusing.. boo to abusing getters and setters!
if (this.noFrame) {
this.frame = new _math.Rectangle(0, 0, baseTexture.width, baseTexture.height);
} else {
this.frame = this._frame;
}
this.baseTexture.on('update', this.onBaseTextureUpdated, this);
this.emit('update', this);
};
/**
* Called when the base texture is updated
*
* @private
* @param {PIXI.BaseTexture} baseTexture - The base texture.
*/
Texture.prototype.onBaseTextureUpdated = function onBaseTextureUpdated(baseTexture) {
this._updateID++;
this._frame.width = baseTexture.width;
this._frame.height = baseTexture.height;
this.emit('update', this);
};
/**
* Destroys this texture
*
* @param {boolean} [destroyBase=false] Whether to destroy the base texture as well
*/
Texture.prototype.destroy = function destroy(destroyBase) {
if (this.baseTexture) {
if (destroyBase) {
// delete the texture if it exists in the texture cache..
// this only needs to be removed if the base texture is actually destroyed too..
if (_utils.TextureCache[this.baseTexture.imageUrl]) {
Texture.removeFromCache(this.baseTexture.imageUrl);
}
this.baseTexture.destroy();
}
this.baseTexture.off('update', this.onBaseTextureUpdated, this);
this.baseTexture.off('loaded', this.onBaseTextureLoaded, this);
this.baseTexture = null;
}
this._frame = null;
this._uvs = null;
this.trim = null;
this.orig = null;
this.valid = false;
Texture.removeFromCache(this);
this.textureCacheIds = null;
};
/**
* Creates a new texture object that acts the same as this one.
*
* @return {PIXI.Texture} The new texture
*/
Texture.prototype.clone = function clone() {
return new Texture(this.baseTexture, this.frame, this.orig, this.trim, this.rotate, this.defaultAnchor);
};
/**
* Updates the internal WebGL UV cache. Use it after you change `frame` or `trim` of the texture.
*/
Texture.prototype._updateUvs = function _updateUvs() {
if (!this._uvs) {
this._uvs = new _TextureUvs2.default();
}
this._uvs.set(this._frame, this.baseTexture, this.rotate);
this._updateID++;
};
/**
* Helper function that creates a Texture object from the given image url.
* If the image is not in the texture cache it will be created and loaded.
*
* @static
* @param {string} imageUrl - The image url of the texture
* @param {boolean} [crossorigin] - Whether requests should be treated as crossorigin
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values
* @param {number} [sourceScale=(auto)] - Scale for the original image, used with SVG images.
* @return {PIXI.Texture} The newly created texture
*/
Texture.fromImage = function fromImage(imageUrl, crossorigin, scaleMode, sourceScale) {
var texture = _utils.TextureCache[imageUrl];
if (!texture) {
texture = new Texture(_BaseTexture2.default.fromImage(imageUrl, crossorigin, scaleMode, sourceScale));
Texture.addToCache(texture, imageUrl);
}
return texture;
};
/**
* Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId
* The frame ids are created when a Texture packer file has been loaded
*
* @static
* @param {string} frameId - The frame Id of the texture in the cache
* @return {PIXI.Texture} The newly created texture
*/
Texture.fromFrame = function fromFrame(frameId) {
var texture = _utils.TextureCache[frameId];
if (!texture) {
throw new Error('The frameId "' + frameId + '" does not exist in the texture cache');
}
return texture;
};
/**
* Helper function that creates a new Texture based on the given canvas element.
*
* @static
* @param {HTMLCanvasElement} canvas - The canvas element source of the texture
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values
* @param {string} [origin='canvas'] - A string origin of who created the base texture
* @return {PIXI.Texture} The newly created texture
*/
Texture.fromCanvas = function fromCanvas(canvas, scaleMode) {
var origin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'canvas';
return new Texture(_BaseTexture2.default.fromCanvas(canvas, scaleMode, origin));
};
/**
* Helper function that creates a new Texture based on the given video element.
*
* @static
* @param {HTMLVideoElement|string} video - The URL or actual element of the video
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values
* @param {boolean} [crossorigin=(auto)] - Should use anonymous CORS? Defaults to true if the URL is not a data-URI.
* @param {boolean} [autoPlay=true] - Start playing video as soon as it is loaded
* @return {PIXI.Texture} The newly created texture
*/
Texture.fromVideo = function fromVideo(video, scaleMode, crossorigin, autoPlay) {
if (typeof video === 'string') {
return Texture.fromVideoUrl(video, scaleMode, crossorigin, autoPlay);
}
return new Texture(_VideoBaseTexture2.default.fromVideo(video, scaleMode, autoPlay));
};
/**
* Helper function that creates a new Texture based on the video url.
*
* @static
* @param {string} videoUrl - URL of the video
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values
* @param {boolean} [crossorigin=(auto)] - Should use anonymous CORS? Defaults to true if the URL is not a data-URI.
* @param {boolean} [autoPlay=true] - Start playing video as soon as it is loaded
* @return {PIXI.Texture} The newly created texture
*/
Texture.fromVideoUrl = function fromVideoUrl(videoUrl, scaleMode, crossorigin, autoPlay) {
return new Texture(_VideoBaseTexture2.default.fromUrl(videoUrl, scaleMode, crossorigin, autoPlay));
};
/**
* Helper function that creates a new Texture based on the source you provide.
* The source can be - frame id, image url, video url, canvas element, video element, base texture
*
* @static
* @param {number|string|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|PIXI.BaseTexture}
* source - Source to create texture from
* @return {PIXI.Texture} The newly created texture
*/
Texture.from = function from(source) {
// TODO auto detect cross origin..
// TODO pass in scale mode?
if (typeof source === 'string') {
var texture = _utils.TextureCache[source];
if (!texture) {
// check if its a video..
var isVideo = source.match(/\.(mp4|webm|ogg|h264|avi|mov)$/) !== null;
if (isVideo) {
return Texture.fromVideoUrl(source);
}
return Texture.fromImage(source);
}
return texture;
} else if (source instanceof HTMLImageElement) {
return new Texture(_BaseTexture2.default.from(source));
} else if (source instanceof HTMLCanvasElement) {
return Texture.fromCanvas(source, _settings2.default.SCALE_MODE, 'HTMLCanvasElement');
} else if (source instanceof HTMLVideoElement) {
return Texture.fromVideo(source);
} else if (source instanceof _BaseTexture2.default) {
return new Texture(source);
}
// lets assume its a texture!
return source;
};
/**
* Create a texture from a source and add to the cache.
*
* @static
* @param {HTMLImageElement|HTMLCanvasElement} source - The input source.
* @param {String} imageUrl - File name of texture, for cache and resolving resolution.
* @param {String} [name] - Human readible name for the texture cache. If no name is
* specified, only `imageUrl` will be used as the cache ID.
* @return {PIXI.Texture} Output texture
*/
Texture.fromLoader = function fromLoader(source, imageUrl, name) {
var baseTexture = new _BaseTexture2.default(source, undefined, (0, _utils.getResolutionOfUrl)(imageUrl));
var texture = new Texture(baseTexture);
baseTexture.imageUrl = imageUrl;
// No name, use imageUrl instead
if (!name) {
name = imageUrl;
}
// lets also add the frame to pixi's global cache for fromFrame and fromImage fucntions
_BaseTexture2.default.addToCache(texture.baseTexture, name);
Texture.addToCache(texture, name);
// also add references by url if they are different.
if (name !== imageUrl) {
_BaseTexture2.default.addToCache(texture.baseTexture, imageUrl);
Texture.addToCache(texture, imageUrl);
}
return texture;
};
/**
* Adds a Texture to the global TextureCache. This cache is shared across the whole PIXI object.
*
* @static
* @param {PIXI.Texture} texture - The Texture to add to the cache.
* @param {string} id - The id that the Texture will be stored against.
*/
Texture.addToCache = function addToCache(texture, id) {
if (id) {
if (texture.textureCacheIds.indexOf(id) === -1) {
texture.textureCacheIds.push(id);
}
// @if DEBUG
/* eslint-disable no-console */
if (_utils.TextureCache[id]) {
console.warn('Texture added to the cache with an id [' + id + '] that already had an entry');
}
/* eslint-enable no-console */
// @endif
_utils.TextureCache[id] = texture;
}
};
/**
* Remove a Texture from the global TextureCache.
*
* @static
* @param {string|PIXI.Texture} texture - id of a Texture to be removed, or a Texture instance itself
* @return {PIXI.Texture|null} The Texture that was removed
*/
Texture.removeFromCache = function removeFromCache(texture) {
if (typeof texture === 'string') {
var textureFromCache = _utils.TextureCache[texture];
if (textureFromCache) {
var index = textureFromCache.textureCacheIds.indexOf(texture);
if (index > -1) {
textureFromCache.textureCacheIds.splice(index, 1);
}
delete _utils.TextureCache[texture];
return textureFromCache;
}
} else if (texture && texture.textureCacheIds) {
for (var i = 0; i < texture.textureCacheIds.length; ++i) {
// Check that texture matches the one being passed in before deleting it from the cache.
if (_utils.TextureCache[texture.textureCacheIds[i]] === texture) {
delete _utils.TextureCache[texture.textureCacheIds[i]];
}
}
texture.textureCacheIds.length = 0;
return texture;
}
return null;
};
/**
* The frame specifies the region of the base texture that this texture uses.
* Please call `_updateUvs()` after you change coordinates of `frame` manually.
*
* @member {PIXI.Rectangle}
*/
_createClass(Texture, [{
key: 'frame',
get: function get() {
return this._frame;
},
set: function set(frame) // eslint-disable-line require-jsdoc
{
this._frame = frame;
this.noFrame = false;
var x = frame.x,
y = frame.y,
width = frame.width,
height = frame.height;
var xNotFit = x + width > this.baseTexture.width;
var yNotFit = y + height > this.baseTexture.height;
if (xNotFit || yNotFit) {
var relationship = xNotFit && yNotFit ? 'and' : 'or';
var errorX = 'X: ' + x + ' + ' + width + ' = ' + (x + width) + ' > ' + this.baseTexture.width;
var errorY = 'Y: ' + y + ' + ' + height + ' = ' + (y + height) + ' > ' + this.baseTexture.height;
throw new Error('Texture Error: frame does not fit inside the base Texture dimensions: ' + (errorX + ' ' + relationship + ' ' + errorY));
}
// this.valid = width && height && this.baseTexture.source && this.baseTexture.hasLoaded;
this.valid = width && height && this.baseTexture.hasLoaded;
if (!this.trim && !this.rotate) {
this.orig = frame;
}
if (this.valid) {
this._updateUvs();
}
}
/**
* Indicates whether the texture is rotated inside the atlas
* set to 2 to compensate for texture packer rotation
* set to 6 to compensate for spine packer rotation
* can be used to rotate or mirror sprites
* See {@link PIXI.GroupD8} for explanation
*
* @member {number}
*/
}, {
key: 'rotate',
get: function get() {
return this._rotate;
},
set: function set(rotate) // eslint-disable-line require-jsdoc
{
this._rotate = rotate;
if (this.valid) {
this._updateUvs();
}
}
/**
* The width of the Texture in pixels.
*
* @member {number}
*/
}, {
key: 'width',
get: function get() {
return this.orig.width;
}
/**
* The height of the Texture in pixels.
*
* @member {number}
*/
}, {
key: 'height',
get: function get() {
return this.orig.height;
}
}]);
return Texture;
}(_eventemitter2.default);
exports.default = Texture;
function createWhiteTexture() {
var canvas = document.createElement('canvas');
canvas.width = 10;
canvas.height = 10;
var context = canvas.getContext('2d');
context.fillStyle = 'white';
context.fillRect(0, 0, 10, 10);
return new Texture(new _BaseTexture2.default(canvas));
}
function removeAllHandlers(tex) {
tex.destroy = function _emptyDestroy() {/* empty */};
tex.on = function _emptyOn() {/* empty */};
tex.once = function _emptyOnce() {/* empty */};
tex.emit = function _emptyEmit() {/* empty */};
}
/**
* An empty texture, used often to not have to create multiple empty textures.
* Can not be destroyed.
*
* @static
* @constant
*/
Texture.EMPTY = new Texture(new _BaseTexture2.default());
removeAllHandlers(Texture.EMPTY);
removeAllHandlers(Texture.EMPTY.baseTexture);
/**
* A white texture of 10x10 size, used for graphics and other things
* Can not be destroyed.
*
* @static
* @constant
*/
Texture.WHITE = createWhiteTexture();
removeAllHandlers(Texture.WHITE);
removeAllHandlers(Texture.WHITE.baseTexture);
//# sourceMappingURL=Texture.js.map
/***/ }),
/* 41 */
/***/ (function(module, exports) {
module.exports = function (bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value: value
};
};
/***/ }),
/* 42 */
/***/ (function(module, exports) {
var id = 0;
var px = Math.random();
module.exports = function (key) {
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
/***/ }),
/* 43 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
var $keys = __webpack_require__(135);
var enumBugKeys = __webpack_require__(92);
module.exports = Object.keys || function keys(O) {
return $keys(O, enumBugKeys);
};
/***/ }),
/* 44 */
/***/ (function(module, exports, __webpack_require__) {
var toInteger = __webpack_require__(27);
var max = Math.max;
var min = Math.min;
module.exports = function (index, length) {
index = toInteger(index);
return index < 0 ? max(index + length, 0) : min(index, length);
};
/***/ }),
/* 45 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
var anObject = __webpack_require__(1);
var dPs = __webpack_require__(136);
var enumBugKeys = __webpack_require__(92);
var IE_PROTO = __webpack_require__(91)('IE_PROTO');
var Empty = function () { /* empty */ };
var PROTOTYPE = 'prototype';
// Create object with fake `null` prototype: use iframe Object with cleared prototype
var createDict = function () {
// Thrash, waste and sodomy: IE GC bug
var iframe = __webpack_require__(89)('iframe');
var i = enumBugKeys.length;
var lt = '<';
var gt = '>';
var iframeDocument;
iframe.style.display = 'none';
__webpack_require__(93).appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
return createDict();
};
module.exports = Object.create || function create(O, Properties) {
var result;
if (O !== null) {
Empty[PROTOTYPE] = anObject(O);
result = new Empty();
Empty[PROTOTYPE] = null;
// add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = createDict();
return Properties === undefined ? result : dPs(result, Properties);
};
/***/ }),
/* 46 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
var $keys = __webpack_require__(135);
var hiddenKeys = __webpack_require__(92).concat('length', 'prototype');
exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
return $keys(O, hiddenKeys);
};
/***/ }),
/* 47 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var global = __webpack_require__(2);
var dP = __webpack_require__(11);
var DESCRIPTORS = __webpack_require__(10);
var SPECIES = __webpack_require__(8)('species');
module.exports = function (KEY) {
var C = global[KEY];
if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
configurable: true,
get: function () { return this; }
});
};
/***/ }),
/* 48 */
/***/ (function(module, exports) {
module.exports = function (it, Constructor, name, forbiddenField) {
if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
throw TypeError(name + ': incorrect invocation!');
} return it;
};
/***/ }),
/* 49 */
/***/ (function(module, exports, __webpack_require__) {
var ctx = __webpack_require__(25);
var call = __webpack_require__(148);
var isArrayIter = __webpack_require__(104);
var anObject = __webpack_require__(1);
var toLength = __webpack_require__(9);
var getIterFn = __webpack_require__(106);
var BREAK = {};
var RETURN = {};
var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
var f = ctx(fn, that, entries ? 2 : 1);
var index = 0;
var length, step, iterator, result;
if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
// fast case for arrays with default iterator
if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
if (result === BREAK || result === RETURN) return result;
} else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
result = call(iterator, f, step.value, entries);
if (result === BREAK || result === RETURN) return result;
}
};
exports.BREAK = BREAK;
exports.RETURN = RETURN;
/***/ }),
/* 50 */
/***/ (function(module, exports, __webpack_require__) {
var redefine = __webpack_require__(17);
module.exports = function (target, src, safe) {
for (var key in src) redefine(target, key, src[key], safe);
return target;
};
/***/ }),
/* 51 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(6);
module.exports = function (it, TYPE) {
if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
return it;
};
/***/ }),
/* 52 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var has = Object.prototype.hasOwnProperty
, prefix = '~';
/**
* Constructor to create a storage for our `EE` objects.
* An `Events` instance is a plain object whose properties are event names.
*
* @constructor
* @api private
*/
function Events() {}
//
// We try to not inherit from `Object.prototype`. In some engines creating an
// instance in this way is faster than calling `Object.create(null)` directly.
// If `Object.create(null)` is not supported we prefix the event names with a
// character to make sure that the built-in object properties are not
// overridden or used as an attack vector.
//
if (Object.create) {
Events.prototype = Object.create(null);
//
// This hack is needed because the `__proto__` property is still inherited in
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
//
if (!new Events().__proto__) prefix = false;
}
/**
* Representation of a single event listener.
*
* @param {Function} fn The listener function.
* @param {Mixed} context The context to invoke the listener with.
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
* @constructor
* @api private
*/
function EE(fn, context, once) {
this.fn = fn;
this.context = context;
this.once = once || false;
}
/**
* Minimal `EventEmitter` interface that is molded against the Node.js
* `EventEmitter` interface.
*
* @constructor
* @api public
*/
function EventEmitter() {
this._events = new Events();
this._eventsCount = 0;
}
/**
* Return an array listing the events for which the emitter has registered
* listeners.
*
* @returns {Array}
* @api public
*/
EventEmitter.prototype.eventNames = function eventNames() {
var names = []
, events
, name;
if (this._eventsCount === 0) return names;
for (name in (events = this._events)) {
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
}
if (Object.getOwnPropertySymbols) {
return names.concat(Object.getOwnPropertySymbols(events));
}
return names;
};
/**
* Return the listeners registered for a given event.
*
* @param {String|Symbol} event The event name.
* @param {Boolean} exists Only check if there are listeners.
* @returns {Array|Boolean}
* @api public
*/
EventEmitter.prototype.listeners = function listeners(event, exists) {
var evt = prefix ? prefix + event : event
, available = this._events[evt];
if (exists) return !!available;
if (!available) return [];
if (available.fn) return [available.fn];
for (var i = 0, l = available.length, ee = new Array(l); i < l; i++) {
ee[i] = available[i].fn;
}
return ee;
};
/**
* Calls each of the listeners registered for a given event.
*
* @param {String|Symbol} event The event name.
* @returns {Boolean} `true` if the event had listeners, else `false`.
* @api public
*/
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return false;
var listeners = this._events[evt]
, len = arguments.length
, args
, i;
if (listeners.fn) {
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
switch (len) {
case 1: return listeners.fn.call(listeners.context), true;
case 2: return listeners.fn.call(listeners.context, a1), true;
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
}
for (i = 1, args = new Array(len -1); i < len; i++) {
args[i - 1] = arguments[i];
}
listeners.fn.apply(listeners.context, args);
} else {
var length = listeners.length
, j;
for (i = 0; i < length; i++) {
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
switch (len) {
case 1: listeners[i].fn.call(listeners[i].context); break;
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
default:
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
args[j - 1] = arguments[j];
}
listeners[i].fn.apply(listeners[i].context, args);
}
}
}
return true;
};
/**
* Add a listener for a given event.
*
* @param {String|Symbol} event The event name.
* @param {Function} fn The listener function.
* @param {Mixed} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @api public
*/
EventEmitter.prototype.on = function on(event, fn, context) {
var listener = new EE(fn, context || this)
, evt = prefix ? prefix + event : event;
if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
else if (!this._events[evt].fn) this._events[evt].push(listener);
else this._events[evt] = [this._events[evt], listener];
return this;
};
/**
* Add a one-time listener for a given event.
*
* @param {String|Symbol} event The event name.
* @param {Function} fn The listener function.
* @param {Mixed} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @api public
*/
EventEmitter.prototype.once = function once(event, fn, context) {
var listener = new EE(fn, context || this, true)
, evt = prefix ? prefix + event : event;
if (!this._events[evt]) this._events[evt] = listener, this._eventsCount++;
else if (!this._events[evt].fn) this._events[evt].push(listener);
else this._events[evt] = [this._events[evt], listener];
return this;
};
/**
* Remove the listeners of a given event.
*
* @param {String|Symbol} event The event name.
* @param {Function} fn Only remove the listeners that match this function.
* @param {Mixed} context Only remove the listeners that have this context.
* @param {Boolean} once Only remove one-time listeners.
* @returns {EventEmitter} `this`.
* @api public
*/
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return this;
if (!fn) {
if (--this._eventsCount === 0) this._events = new Events();
else delete this._events[evt];
return this;
}
var listeners = this._events[evt];
if (listeners.fn) {
if (
listeners.fn === fn
&& (!once || listeners.once)
&& (!context || listeners.context === context)
) {
if (--this._eventsCount === 0) this._events = new Events();
else delete this._events[evt];
}
} else {
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
if (
listeners[i].fn !== fn
|| (once && !listeners[i].once)
|| (context && listeners[i].context !== context)
) {
events.push(listeners[i]);
}
}
//
// Reset the array, or remove it completely if we have no more listeners.
//
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
else if (--this._eventsCount === 0) this._events = new Events();
else delete this._events[evt];
}
return this;
};
/**
* Remove all listeners, or those of the specified event.
*
* @param {String|Symbol} [event] The event name.
* @returns {EventEmitter} `this`.
* @api public
*/
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
var evt;
if (event) {
evt = prefix ? prefix + event : event;
if (this._events[evt]) {
if (--this._eventsCount === 0) this._events = new Events();
else delete this._events[evt];
}
} else {
this._events = new Events();
this._eventsCount = 0;
}
return this;
};
//
// Alias methods names because people roll like that.
//
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
//
// This function doesn't apply anymore.
//
EventEmitter.prototype.setMaxListeners = function setMaxListeners() {
return this;
};
//
// Expose the prefix.
//
EventEmitter.prefixed = prefix;
//
// Allow `EventEmitter` to be imported as module namespace.
//
EventEmitter.EventEmitter = EventEmitter;
//
// Expose the module.
//
if (true) {
module.exports = EventEmitter;
}
/***/ }),
/* 53 */
/***/ (function(module, exports) {
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1,eval)("this");
} catch(e) {
// This works if the window reference is available
if(typeof window === "object")
g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;
/***/ }),
/* 54 */
/***/ (function(module, exports, __webpack_require__) {
var def = __webpack_require__(11).f;
var has = __webpack_require__(19);
var TAG = __webpack_require__(8)('toStringTag');
module.exports = function (it, tag, stat) {
if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
};
/***/ }),
/* 55 */
/***/ (function(module, exports, __webpack_require__) {
// getting tag from 19.1.3.6 Object.prototype.toString()
var cof = __webpack_require__(26);
var TAG = __webpack_require__(8)('toStringTag');
// ES3 wrong here
var ARG = cof(function () { return arguments; }()) == 'Arguments';
// fallback for IE11 Script Access Denied error
var tryGet = function (it, key) {
try {
return it[key];
} catch (e) { /* empty */ }
};
module.exports = function (it) {
var O, T, B;
return it === undefined ? 'Undefined' : it === null ? 'Null'
// @@toStringTag case
: typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
// builtinTag case
: ARG ? cof(O)
// ES3 arguments fallback
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
};
/***/ }),
/* 56 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
var defined = __webpack_require__(31);
var fails = __webpack_require__(4);
var spaces = __webpack_require__(95);
var space = '[' + spaces + ']';
var non = '\u200b\u0085';
var ltrim = RegExp('^' + space + space + '*');
var rtrim = RegExp(space + space + '*$');
var exporter = function (KEY, exec, ALIAS) {
var exp = {};
var FORCE = fails(function () {
return !!spaces[KEY]() || non[KEY]() != non;
});
var fn = exp[KEY] = FORCE ? exec(trim) : spaces[KEY];
if (ALIAS) exp[ALIAS] = fn;
$export($export.P + $export.F * FORCE, 'String', exp);
};
// 1 -> String#trimLeft
// 2 -> String#trimRight
// 3 -> String#trim
var trim = exporter.trim = function (string, TYPE) {
string = String(defined(string));
if (TYPE & 1) string = string.replace(ltrim, '');
if (TYPE & 2) string = string.replace(rtrim, '');
return string;
};
module.exports = exporter;
/***/ }),
/* 57 */
/***/ (function(module, exports) {
module.exports = {};
/***/ }),
/* 58 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _utils = __webpack_require__(7);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
var _eventemitter = __webpack_require__(52);
var _eventemitter2 = _interopRequireDefault(_eventemitter);
var _determineCrossOrigin = __webpack_require__(184);
var _determineCrossOrigin2 = _interopRequireDefault(_determineCrossOrigin);
var _bitTwiddle = __webpack_require__(126);
var _bitTwiddle2 = _interopRequireDefault(_bitTwiddle);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* A texture stores the information that represents an image. All textures have a base texture.
*
* @class
* @extends EventEmitter
* @memberof PIXI
*/
var BaseTexture = function (_EventEmitter) {
_inherits(BaseTexture, _EventEmitter);
/**
* @param {HTMLImageElement|HTMLCanvasElement} [source] - the source object of the texture.
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values
* @param {number} [resolution=1] - The resolution / device pixel ratio of the texture
*/
function BaseTexture(source, scaleMode, resolution) {
_classCallCheck(this, BaseTexture);
var _this = _possibleConstructorReturn(this, _EventEmitter.call(this));
_this.uid = (0, _utils.uid)();
_this.touched = 0;
/**
* The resolution / device pixel ratio of the texture
*
* @member {number}
* @default 1
*/
_this.resolution = resolution || _settings2.default.RESOLUTION;
/**
* The width of the base texture set when the image has loaded
*
* @readonly
* @member {number}
*/
_this.width = 100;
/**
* The height of the base texture set when the image has loaded
*
* @readonly
* @member {number}
*/
_this.height = 100;
// TODO docs
// used to store the actual dimensions of the source
/**
* Used to store the actual width of the source of this texture
*
* @readonly
* @member {number}
*/
_this.realWidth = 100;
/**
* Used to store the actual height of the source of this texture
*
* @readonly
* @member {number}
*/
_this.realHeight = 100;
/**
* The scale mode to apply when scaling this texture
*
* @member {number}
* @default PIXI.settings.SCALE_MODE
* @see PIXI.SCALE_MODES
*/
_this.scaleMode = scaleMode !== undefined ? scaleMode : _settings2.default.SCALE_MODE;
/**
* Set to true once the base texture has successfully loaded.
*
* This is never true if the underlying source fails to load or has no texture data.
*
* @readonly
* @member {boolean}
*/
_this.hasLoaded = false;
/**
* Set to true if the source is currently loading.
*
* If an Image source is loading the 'loaded' or 'error' event will be
* dispatched when the operation ends. An underyling source that is
* immediately-available bypasses loading entirely.
*
* @readonly
* @member {boolean}
*/
_this.isLoading = false;
/**
* The image source that is used to create the texture.
*
* TODO: Make this a setter that calls loadSource();
*
* @readonly
* @member {HTMLImageElement|HTMLCanvasElement}
*/
_this.source = null; // set in loadSource, if at all
/**
* The image source that is used to create the texture. This is used to
* store the original Svg source when it is replaced with a canvas element.
*
* TODO: Currently not in use but could be used when re-scaling svg.
*
* @readonly
* @member {Image}
*/
_this.origSource = null; // set in loadSvg, if at all
/**
* Type of image defined in source, eg. `png` or `svg`
*
* @readonly
* @member {string}
*/
_this.imageType = null; // set in updateImageType
/**
* Scale for source image. Used with Svg images to scale them before rasterization.
*
* @readonly
* @member {number}
*/
_this.sourceScale = 1.0;
/**
* Controls if RGB channels should be pre-multiplied by Alpha (WebGL only)
* All blend modes, and shaders written for default value. Change it on your own risk.
*
* @member {boolean}
* @default true
*/
_this.premultipliedAlpha = true;
/**
* The image url of the texture
*
* @member {string}
*/
_this.imageUrl = null;
/**
* Whether or not the texture is a power of two, try to use power of two textures as much
* as you can
*
* @private
* @member {boolean}
*/
_this.isPowerOfTwo = false;
// used for webGL
/**
*
* Set this to true if a mipmap of this texture needs to be generated. This value needs
* to be set before the texture is used
* Also the texture must be a power of two size to work
*
* @member {boolean}
* @see PIXI.MIPMAP_TEXTURES
*/
_this.mipmap = _settings2.default.MIPMAP_TEXTURES;
/**
*
* WebGL Texture wrap mode
*
* @member {number}
* @see PIXI.WRAP_MODES
*/
_this.wrapMode = _settings2.default.WRAP_MODE;
/**
* A map of renderer IDs to webgl textures
*
* @private
* @member {object<number, WebGLTexture>}
*/
_this._glTextures = {};
_this._enabled = 0;
_this._virtalBoundId = -1;
/**
* If the object has been destroyed via destroy(). If true, it should not be used.
*
* @member {boolean}
* @private
* @readonly
*/
_this._destroyed = false;
/**
* The ids under which this BaseTexture has been added to the base texture cache. This is
* automatically set as long as BaseTexture.addToCache is used, but may not be set if a
* BaseTexture is added directly to the BaseTextureCache array.
*
* @member {string[]}
*/
_this.textureCacheIds = [];
// if no source passed don't try to load
if (source) {
_this.loadSource(source);
}
/**
* Fired when a not-immediately-available source finishes loading.
*
* @protected
* @event PIXI.BaseTexture#loaded
* @param {PIXI.BaseTexture} baseTexture - Resource loaded.
*/
/**
* Fired when a not-immediately-available source fails to load.
*
* @protected
* @event PIXI.BaseTexture#error
* @param {PIXI.BaseTexture} baseTexture - Resource errored.
*/
/**
* Fired when BaseTexture is updated.
*
* @protected
* @event PIXI.BaseTexture#update
* @param {PIXI.BaseTexture} baseTexture - Instance of texture being updated.
*/
/**
* Fired when BaseTexture is destroyed.
*
* @protected
* @event PIXI.BaseTexture#dispose
* @param {PIXI.BaseTexture} baseTexture - Instance of texture being destroyed.
*/
return _this;
}
/**
* Updates the texture on all the webgl renderers, this also assumes the src has changed.
*
* @fires PIXI.BaseTexture#update
*/
BaseTexture.prototype.update = function update() {
// Svg size is handled during load
if (this.imageType !== 'svg') {
this.realWidth = this.source.naturalWidth || this.source.videoWidth || this.source.width;
this.realHeight = this.source.naturalHeight || this.source.videoHeight || this.source.height;
this._updateDimensions();
}
this.emit('update', this);
};
/**
* Update dimensions from real values
*/
BaseTexture.prototype._updateDimensions = function _updateDimensions() {
this.width = this.realWidth / this.resolution;
this.height = this.realHeight / this.resolution;
this.isPowerOfTwo = _bitTwiddle2.default.isPow2(this.realWidth) && _bitTwiddle2.default.isPow2(this.realHeight);
};
/**
* Load a source.
*
* If the source is not-immediately-available, such as an image that needs to be
* downloaded, then the 'loaded' or 'error' event will be dispatched in the future
* and `hasLoaded` will remain false after this call.
*
* The logic state after calling `loadSource` directly or indirectly (eg. `fromImage`, `new BaseTexture`) is:
*
* if (texture.hasLoaded) {
* // texture ready for use
* } else if (texture.isLoading) {
* // listen to 'loaded' and/or 'error' events on texture
* } else {
* // not loading, not going to load UNLESS the source is reloaded
* // (it may still make sense to listen to the events)
* }
*
* @protected
* @param {HTMLImageElement|HTMLCanvasElement} source - the source object of the texture.
*/
BaseTexture.prototype.loadSource = function loadSource(source) {
var wasLoading = this.isLoading;
this.hasLoaded = false;
this.isLoading = false;
if (wasLoading && this.source) {
this.source.onload = null;
this.source.onerror = null;
}
var firstSourceLoaded = !this.source;
this.source = source;
// Apply source if loaded. Otherwise setup appropriate loading monitors.
if ((source.src && source.complete || source.getContext) && source.width && source.height) {
this._updateImageType();
if (this.imageType === 'svg') {
this._loadSvgSource();
} else {
this._sourceLoaded();
}
if (firstSourceLoaded) {
// send loaded event if previous source was null and we have been passed a pre-loaded IMG element
this.emit('loaded', this);
}
} else if (!source.getContext) {
// Image fail / not ready
this.isLoading = true;
var scope = this;
source.onload = function () {
scope._updateImageType();
source.onload = null;
source.onerror = null;
if (!scope.isLoading) {
return;
}
scope.isLoading = false;
scope._sourceLoaded();
if (scope.imageType === 'svg') {
scope._loadSvgSource();
return;
}
scope.emit('loaded', scope);
};
source.onerror = function () {
source.onload = null;
source.onerror = null;
if (!scope.isLoading) {
return;
}
scope.isLoading = false;
scope.emit('error', scope);
};
// Per http://www.w3.org/TR/html5/embedded-content-0.html#the-img-element
// "The value of `complete` can thus change while a script is executing."
// So complete needs to be re-checked after the callbacks have been added..
// NOTE: complete will be true if the image has no src so best to check if the src is set.
if (source.complete && source.src) {
// ..and if we're complete now, no need for callbacks
source.onload = null;
source.onerror = null;
if (scope.imageType === 'svg') {
scope._loadSvgSource();
return;
}
this.isLoading = false;
if (source.width && source.height) {
this._sourceLoaded();
// If any previous subscribers possible
if (wasLoading) {
this.emit('loaded', this);
}
}
// If any previous subscribers possible
else if (wasLoading) {
this.emit('error', this);
}
}
}
};
/**
* Updates type of the source image.
*/
BaseTexture.prototype._updateImageType = function _updateImageType() {
if (!this.imageUrl) {
return;
}
var dataUri = (0, _utils.decomposeDataUri)(this.imageUrl);
var imageType = void 0;
if (dataUri && dataUri.mediaType === 'image') {
// Check for subType validity
var firstSubType = dataUri.subType.split('+')[0];
imageType = (0, _utils.getUrlFileExtension)('.' + firstSubType);
if (!imageType) {
throw new Error('Invalid image type in data URI.');
}
} else {
imageType = (0, _utils.getUrlFileExtension)(this.imageUrl);
if (!imageType) {
imageType = 'png';
}
}
this.imageType = imageType;
};
/**
* Checks if `source` is an SVG image and whether it's loaded via a URL or a data URI. Then calls
* `_loadSvgSourceUsingDataUri` or `_loadSvgSourceUsingXhr`.
*/
BaseTexture.prototype._loadSvgSource = function _loadSvgSource() {
if (this.imageType !== 'svg') {
// Do nothing if source is not svg
return;
}
var dataUri = (0, _utils.decomposeDataUri)(this.imageUrl);
if (dataUri) {
this._loadSvgSourceUsingDataUri(dataUri);
} else {
// We got an URL, so we need to do an XHR to check the svg size
this._loadSvgSourceUsingXhr();
}
};
/**
* Reads an SVG string from data URI and then calls `_loadSvgSourceUsingString`.
*
* @param {string} dataUri - The data uri to load from.
*/
BaseTexture.prototype._loadSvgSourceUsingDataUri = function _loadSvgSourceUsingDataUri(dataUri) {
var svgString = void 0;
if (dataUri.encoding === 'base64') {
if (!atob) {
throw new Error('Your browser doesn\'t support base64 conversions.');
}
svgString = atob(dataUri.data);
} else {
svgString = dataUri.data;
}
this._loadSvgSourceUsingString(svgString);
};
/**
* Loads an SVG string from `imageUrl` using XHR and then calls `_loadSvgSourceUsingString`.
*/
BaseTexture.prototype._loadSvgSourceUsingXhr = function _loadSvgSourceUsingXhr() {
var _this2 = this;
var svgXhr = new XMLHttpRequest();
// This throws error on IE, so SVG Document can't be used
// svgXhr.responseType = 'document';
// This is not needed since we load the svg as string (breaks IE too)
// but overrideMimeType() can be used to force the response to be parsed as XML
// svgXhr.overrideMimeType('image/svg+xml');
svgXhr.onload = function () {
if (svgXhr.readyState !== svgXhr.DONE || svgXhr.status !== 200) {
throw new Error('Failed to load SVG using XHR.');
}
_this2._loadSvgSourceUsingString(svgXhr.response);
};
svgXhr.onerror = function () {
return _this2.emit('error', _this2);
};
svgXhr.open('GET', this.imageUrl, true);
svgXhr.send();
};
/**
* Loads texture using an SVG string. The original SVG Image is stored as `origSource` and the
* created canvas is the new `source`. The SVG is scaled using `sourceScale`. Called by
* `_loadSvgSourceUsingXhr` or `_loadSvgSourceUsingDataUri`.
*
* @param {string} svgString SVG source as string
*
* @fires PIXI.BaseTexture#loaded
*/
BaseTexture.prototype._loadSvgSourceUsingString = function _loadSvgSourceUsingString(svgString) {
var svgSize = (0, _utils.getSvgSize)(svgString);
var svgWidth = svgSize.width;
var svgHeight = svgSize.height;
if (!svgWidth || !svgHeight) {
throw new Error('The SVG image must have width and height defined (in pixels), canvas API needs them.');
}
// Scale realWidth and realHeight
this.realWidth = Math.round(svgWidth * this.sourceScale);
this.realHeight = Math.round(svgHeight * this.sourceScale);
this._updateDimensions();
// Create a canvas element
var canvas = document.createElement('canvas');
canvas.width = this.realWidth;
canvas.height = this.realHeight;
canvas._pixiId = 'canvas_' + (0, _utils.uid)();
// Draw the Svg to the canvas
canvas.getContext('2d').drawImage(this.source, 0, 0, svgWidth, svgHeight, 0, 0, this.realWidth, this.realHeight);
// Replace the original source image with the canvas
this.origSource = this.source;
this.source = canvas;
// Add also the canvas in cache (destroy clears by `imageUrl` and `source._pixiId`)
BaseTexture.addToCache(this, canvas._pixiId);
this.isLoading = false;
this._sourceLoaded();
this.emit('loaded', this);
};
/**
* Used internally to update the width, height, and some other tracking vars once
* a source has successfully loaded.
*
* @private
*/
BaseTexture.prototype._sourceLoaded = function _sourceLoaded() {
this.hasLoaded = true;
this.update();
};
/**
* Destroys this base texture
*
*/
BaseTexture.prototype.destroy = function destroy() {
if (this.imageUrl) {
delete _utils.TextureCache[this.imageUrl];
this.imageUrl = null;
if (!navigator.isCocoonJS) {
this.source.src = '';
}
}
this.source = null;
this.dispose();
BaseTexture.removeFromCache(this);
this.textureCacheIds = null;
this._destroyed = true;
};
/**
* Frees the texture from WebGL memory without destroying this texture object.
* This means you can still use the texture later which will upload it to GPU
* memory again.
*
* @fires PIXI.BaseTexture#dispose
*/
BaseTexture.prototype.dispose = function dispose() {
this.emit('dispose', this);
};
/**
* Changes the source image of the texture.
* The original source must be an Image element.
*
* @param {string} newSrc - the path of the image
*/
BaseTexture.prototype.updateSourceImage = function updateSourceImage(newSrc) {
this.source.src = newSrc;
this.loadSource(this.source);
};
/**
* Helper function that creates a base texture from the given image url.
* If the image is not in the base texture cache it will be created and loaded.
*
* @static
* @param {string} imageUrl - The image url of the texture
* @param {boolean} [crossorigin=(auto)] - Should use anonymous CORS? Defaults to true if the URL is not a data-URI.
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values
* @param {number} [sourceScale=(auto)] - Scale for the original image, used with Svg images.
* @return {PIXI.BaseTexture} The new base texture.
*/
BaseTexture.fromImage = function fromImage(imageUrl, crossorigin, scaleMode, sourceScale) {
var baseTexture = _utils.BaseTextureCache[imageUrl];
if (!baseTexture) {
// new Image() breaks tex loading in some versions of Chrome.
// See https://code.google.com/p/chromium/issues/detail?id=238071
var image = new Image(); // document.createElement('img');
if (crossorigin === undefined && imageUrl.indexOf('data:') !== 0) {
image.crossOrigin = (0, _determineCrossOrigin2.default)(imageUrl);
} else if (crossorigin) {
image.crossOrigin = typeof crossorigin === 'string' ? crossorigin : 'anonymous';
}
baseTexture = new BaseTexture(image, scaleMode);
baseTexture.imageUrl = imageUrl;
if (sourceScale) {
baseTexture.sourceScale = sourceScale;
}
// if there is an @2x at the end of the url we are going to assume its a highres image
baseTexture.resolution = (0, _utils.getResolutionOfUrl)(imageUrl);
image.src = imageUrl; // Setting this triggers load
BaseTexture.addToCache(baseTexture, imageUrl);
}
return baseTexture;
};
/**
* Helper function that creates a base texture from the given canvas element.
*
* @static
* @param {HTMLCanvasElement} canvas - The canvas element source of the texture
* @param {number} scaleMode - See {@link PIXI.SCALE_MODES} for possible values
* @param {string} [origin='canvas'] - A string origin of who created the base texture
* @return {PIXI.BaseTexture} The new base texture.
*/
BaseTexture.fromCanvas = function fromCanvas(canvas, scaleMode) {
var origin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'canvas';
if (!canvas._pixiId) {
canvas._pixiId = origin + '_' + (0, _utils.uid)();
}
var baseTexture = _utils.BaseTextureCache[canvas._pixiId];
if (!baseTexture) {
baseTexture = new BaseTexture(canvas, scaleMode);
BaseTexture.addToCache(baseTexture, canvas._pixiId);
}
return baseTexture;
};
/**
* Helper function that creates a base texture based on the source you provide.
* The source can be - image url, image element, canvas element. If the
* source is an image url or an image element and not in the base texture
* cache, it will be created and loaded.
*
* @static
* @param {string|HTMLImageElement|HTMLCanvasElement} source - The source to create base texture from.
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values
* @param {number} [sourceScale=(auto)] - Scale for the original image, used with Svg images.
* @return {PIXI.BaseTexture} The new base texture.
*/
BaseTexture.from = function from(source, scaleMode, sourceScale) {
if (typeof source === 'string') {
return BaseTexture.fromImage(source, undefined, scaleMode, sourceScale);
} else if (source instanceof HTMLImageElement) {
var imageUrl = source.src;
var baseTexture = _utils.BaseTextureCache[imageUrl];
if (!baseTexture) {
baseTexture = new BaseTexture(source, scaleMode);
baseTexture.imageUrl = imageUrl;
if (sourceScale) {
baseTexture.sourceScale = sourceScale;
}
// if there is an @2x at the end of the url we are going to assume its a highres image
baseTexture.resolution = (0, _utils.getResolutionOfUrl)(imageUrl);
BaseTexture.addToCache(baseTexture, imageUrl);
}
return baseTexture;
} else if (source instanceof HTMLCanvasElement) {
return BaseTexture.fromCanvas(source, scaleMode);
}
// lets assume its a base texture!
return source;
};
/**
* Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object.
*
* @static
* @param {PIXI.BaseTexture} baseTexture - The BaseTexture to add to the cache.
* @param {string} id - The id that the BaseTexture will be stored against.
*/
BaseTexture.addToCache = function addToCache(baseTexture, id) {
if (id) {
if (baseTexture.textureCacheIds.indexOf(id) === -1) {
baseTexture.textureCacheIds.push(id);
}
// @if DEBUG
/* eslint-disable no-console */
if (_utils.BaseTextureCache[id]) {
console.warn('BaseTexture added to the cache with an id [' + id + '] that already had an entry');
}
/* eslint-enable no-console */
// @endif
_utils.BaseTextureCache[id] = baseTexture;
}
};
/**
* Remove a BaseTexture from the global BaseTextureCache.
*
* @static
* @param {string|PIXI.BaseTexture} baseTexture - id of a BaseTexture to be removed, or a BaseTexture instance itself.
* @return {PIXI.BaseTexture|null} The BaseTexture that was removed.
*/
BaseTexture.removeFromCache = function removeFromCache(baseTexture) {
if (typeof baseTexture === 'string') {
var baseTextureFromCache = _utils.BaseTextureCache[baseTexture];
if (baseTextureFromCache) {
var index = baseTextureFromCache.textureCacheIds.indexOf(baseTexture);
if (index > -1) {
baseTextureFromCache.textureCacheIds.splice(index, 1);
}
delete _utils.BaseTextureCache[baseTexture];
return baseTextureFromCache;
}
} else if (baseTexture && baseTexture.textureCacheIds) {
for (var i = 0; i < baseTexture.textureCacheIds.length; ++i) {
delete _utils.BaseTextureCache[baseTexture.textureCacheIds[i]];
}
baseTexture.textureCacheIds.length = 0;
return baseTexture;
}
return null;
};
return BaseTexture;
}(_eventemitter2.default);
exports.default = BaseTexture;
//# sourceMappingURL=BaseTexture.js.map
/***/ }),
/* 59 */
/***/ (function(module, exports, __webpack_require__) {
var core = __webpack_require__(24);
var global = __webpack_require__(2);
var SHARED = '__core-js_shared__';
var store = global[SHARED] || (global[SHARED] = {});
(module.exports = function (key, value) {
return store[key] || (store[key] = value !== undefined ? value : {});
})('versions', []).push({
version: core.version,
mode: __webpack_require__(37) ? 'pure' : 'global',
copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
});
/***/ }),
/* 60 */
/***/ (function(module, exports, __webpack_require__) {
// fallback for non-array-like ES3 and non-enumerable old V8 strings
var cof = __webpack_require__(26);
// eslint-disable-next-line no-prototype-builtins
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
return cof(it) == 'String' ? it.split('') : Object(it);
};
/***/ }),
/* 61 */
/***/ (function(module, exports) {
exports.f = {}.propertyIsEnumerable;
/***/ }),
/* 62 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 21.2.5.3 get RegExp.prototype.flags
var anObject = __webpack_require__(1);
module.exports = function () {
var that = anObject(this);
var result = '';
if (that.global) result += 'g';
if (that.ignoreCase) result += 'i';
if (that.multiline) result += 'm';
if (that.unicode) result += 'u';
if (that.sticky) result += 'y';
return result;
};
/***/ }),
/* 63 */
/***/ (function(module, exports, __webpack_require__) {
// 7.3.20 SpeciesConstructor(O, defaultConstructor)
var anObject = __webpack_require__(1);
var aFunction = __webpack_require__(15);
var SPECIES = __webpack_require__(8)('species');
module.exports = function (O, D) {
var C = anObject(O).constructor;
var S;
return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
};
/***/ }),
/* 64 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _utils = __webpack_require__(7);
var _DisplayObject2 = __webpack_require__(181);
var _DisplayObject3 = _interopRequireDefault(_DisplayObject2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* A Container represents a collection of display objects.
* It is the base class of all display objects that act as a container for other objects.
*
*```js
* let container = new PIXI.Container();
* container.addChild(sprite);
* ```
*
* @class
* @extends PIXI.DisplayObject
* @memberof PIXI
*/
var Container = function (_DisplayObject) {
_inherits(Container, _DisplayObject);
/**
*
*/
function Container() {
_classCallCheck(this, Container);
/**
* The array of children of this container.
*
* @member {PIXI.DisplayObject[]}
* @readonly
*/
var _this = _possibleConstructorReturn(this, _DisplayObject.call(this));
_this.children = [];
return _this;
}
/**
* Overridable method that can be used by Container subclasses whenever the children array is modified
*
* @private
*/
Container.prototype.onChildrenChange = function onChildrenChange() {}
/* empty */
/**
* Adds one or more children to the container.
*
* Multiple items can be added like so: `myContainer.addChild(thingOne, thingTwo, thingThree)`
*
* @param {...PIXI.DisplayObject} child - The DisplayObject(s) to add to the container
* @return {PIXI.DisplayObject} The first child that was added.
*/
;
Container.prototype.addChild = function addChild(child) {
var argumentsLength = arguments.length;
// if there is only one argument we can bypass looping through the them
if (argumentsLength > 1) {
// loop through the arguments property and add all children
// use it the right way (.length and [i]) so that this function can still be optimised by JS runtimes
for (var i = 0; i < argumentsLength; i++) {
this.addChild(arguments[i]);
}
} else {
// if the child has a parent then lets remove it as PixiJS objects can only exist in one place
if (child.parent) {
child.parent.removeChild(child);
}
child.parent = this;
// ensure child transform will be recalculated
child.transform._parentID = -1;
this.children.push(child);
// ensure bounds will be recalculated
this._boundsID++;
// TODO - lets either do all callbacks or all events.. not both!
this.onChildrenChange(this.children.length - 1);
child.emit('added', this);
}
return child;
};
/**
* Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown
*
* @param {PIXI.DisplayObject} child - The child to add
* @param {number} index - The index to place the child in
* @return {PIXI.DisplayObject} The child that was added.
*/
Container.prototype.addChildAt = function addChildAt(child, index) {
if (index < 0 || index > this.children.length) {
throw new Error(child + 'addChildAt: The index ' + index + ' supplied is out of bounds ' + this.children.length);
}
if (child.parent) {
child.parent.removeChild(child);
}
child.parent = this;
// ensure child transform will be recalculated
child.transform._parentID = -1;
this.children.splice(index, 0, child);
// ensure bounds will be recalculated
this._boundsID++;
// TODO - lets either do all callbacks or all events.. not both!
this.onChildrenChange(index);
child.emit('added', this);
return child;
};
/**
* Swaps the position of 2 Display Objects within this container.
*
* @param {PIXI.DisplayObject} child - First display object to swap
* @param {PIXI.DisplayObject} child2 - Second display object to swap
*/
Container.prototype.swapChildren = function swapChildren(child, child2) {
if (child === child2) {
return;
}
var index1 = this.getChildIndex(child);
var index2 = this.getChildIndex(child2);
this.children[index1] = child2;
this.children[index2] = child;
this.onChildrenChange(index1 < index2 ? index1 : index2);
};
/**
* Returns the index position of a child DisplayObject instance
*
* @param {PIXI.DisplayObject} child - The DisplayObject instance to identify
* @return {number} The index position of the child display object to identify
*/
Container.prototype.getChildIndex = function getChildIndex(child) {
var index = this.children.indexOf(child);
if (index === -1) {
throw new Error('The supplied DisplayObject must be a child of the caller');
}
return index;
};
/**
* Changes the position of an existing child in the display object container
*
* @param {PIXI.DisplayObject} child - The child DisplayObject instance for which you want to change the index number
* @param {number} index - The resulting index number for the child display object
*/
Container.prototype.setChildIndex = function setChildIndex(child, index) {
if (index < 0 || index >= this.children.length) {
throw new Error('The index ' + index + ' supplied is out of bounds ' + this.children.length);
}
var currentIndex = this.getChildIndex(child);
(0, _utils.removeItems)(this.children, currentIndex, 1); // remove from old position
this.children.splice(index, 0, child); // add at new position
this.onChildrenChange(index);
};
/**
* Returns the child at the specified index
*
* @param {number} index - The index to get the child at
* @return {PIXI.DisplayObject} The child at the given index, if any.
*/
Container.prototype.getChildAt = function getChildAt(index) {
if (index < 0 || index >= this.children.length) {
throw new Error('getChildAt: Index (' + index + ') does not exist.');
}
return this.children[index];
};
/**
* Removes one or more children from the container.
*
* @param {...PIXI.DisplayObject} child - The DisplayObject(s) to remove
* @return {PIXI.DisplayObject} The first child that was removed.
*/
Container.prototype.removeChild = function removeChild(child) {
var argumentsLength = arguments.length;
// if there is only one argument we can bypass looping through the them
if (argumentsLength > 1) {
// loop through the arguments property and add all children
// use it the right way (.length and [i]) so that this function can still be optimised by JS runtimes
for (var i = 0; i < argumentsLength; i++) {
this.removeChild(arguments[i]);
}
} else {
var index = this.children.indexOf(child);
if (index === -1) return null;
child.parent = null;
// ensure child transform will be recalculated
child.transform._parentID = -1;
(0, _utils.removeItems)(this.children, index, 1);
// ensure bounds will be recalculated
this._boundsID++;
// TODO - lets either do all callbacks or all events.. not both!
this.onChildrenChange(index);
child.emit('removed', this);
}
return child;
};
/**
* Removes a child from the specified index position.
*
* @param {number} index - The index to get the child from
* @return {PIXI.DisplayObject} The child that was removed.
*/
Container.prototype.removeChildAt = function removeChildAt(index) {
var child = this.getChildAt(index);
// ensure child transform will be recalculated..
child.parent = null;
child.transform._parentID = -1;
(0, _utils.removeItems)(this.children, index, 1);
// ensure bounds will be recalculated
this._boundsID++;
// TODO - lets either do all callbacks or all events.. not both!
this.onChildrenChange(index);
child.emit('removed', this);
return child;
};
/**
* Removes all children from this container that are within the begin and end indexes.
*
* @param {number} [beginIndex=0] - The beginning position.
* @param {number} [endIndex=this.children.length] - The ending position. Default value is size of the container.
* @returns {DisplayObject[]} List of removed children
*/
Container.prototype.removeChildren = function removeChildren() {
var beginIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var endIndex = arguments[1];
var begin = beginIndex;
var end = typeof endIndex === 'number' ? endIndex : this.children.length;
var range = end - begin;
var removed = void 0;
if (range > 0 && range <= end) {
removed = this.children.splice(begin, range);
for (var i = 0; i < removed.length; ++i) {
removed[i].parent = null;
if (removed[i].transform) {
removed[i].transform._parentID = -1;
}
}
this._boundsID++;
this.onChildrenChange(beginIndex);
for (var _i = 0; _i < removed.length; ++_i) {
removed[_i].emit('removed', this);
}
return removed;
} else if (range === 0 && this.children.length === 0) {
return [];
}
throw new RangeError('removeChildren: numeric values are outside the acceptable range.');
};
/**
* Updates the transform on all children of this container for rendering
*/
Container.prototype.updateTransform = function updateTransform() {
this._boundsID++;
this.transform.updateTransform(this.parent.transform);
// TODO: check render flags, how to process stuff here
this.worldAlpha = this.alpha * this.parent.worldAlpha;
for (var i = 0, j = this.children.length; i < j; ++i) {
var child = this.children[i];
if (child.visible) {
child.updateTransform();
}
}
};
/**
* Recalculates the bounds of the container.
*
*/
Container.prototype.calculateBounds = function calculateBounds() {
this._bounds.clear();
this._calculateBounds();
for (var i = 0; i < this.children.length; i++) {
var child = this.children[i];
if (!child.visible || !child.renderable) {
continue;
}
child.calculateBounds();
// TODO: filter+mask, need to mask both somehow
if (child._mask) {
child._mask.calculateBounds();
this._bounds.addBoundsMask(child._bounds, child._mask._bounds);
} else if (child.filterArea) {
this._bounds.addBoundsArea(child._bounds, child.filterArea);
} else {
this._bounds.addBounds(child._bounds);
}
}
this._lastBoundsID = this._boundsID;
};
/**
* Recalculates the bounds of the object. Override this to
* calculate the bounds of the specific object (not including children).
*
*/
Container.prototype._calculateBounds = function _calculateBounds() {}
// FILL IN//
/**
* Renders the object using the WebGL renderer
*
* @param {PIXI.WebGLRenderer} renderer - The renderer
*/
;
Container.prototype.renderWebGL = function renderWebGL(renderer) {
// if the object is not visible or the alpha is 0 then no need to render this element
if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {
return;
}
// do a quick check to see if this element has a mask or a filter.
if (this._mask || this._filters) {
this.renderAdvancedWebGL(renderer);
} else {
this._renderWebGL(renderer);
// simple render children!
for (var i = 0, j = this.children.length; i < j; ++i) {
this.children[i].renderWebGL(renderer);
}
}
};
/**
* Render the object using the WebGL renderer and advanced features.
*
* @private
* @param {PIXI.WebGLRenderer} renderer - The renderer
*/
Container.prototype.renderAdvancedWebGL = function renderAdvancedWebGL(renderer) {
renderer.flush();
var filters = this._filters;
var mask = this._mask;
// push filter first as we need to ensure the stencil buffer is correct for any masking
if (filters) {
if (!this._enabledFilters) {
this._enabledFilters = [];
}
this._enabledFilters.length = 0;
for (var i = 0; i < filters.length; i++) {
if (filters[i].enabled) {
this._enabledFilters.push(filters[i]);
}
}
if (this._enabledFilters.length) {
renderer.filterManager.pushFilter(this, this._enabledFilters);
}
}
if (mask) {
renderer.maskManager.pushMask(this, this._mask);
}
// add this object to the batch, only rendered if it has a texture.
this._renderWebGL(renderer);
// now loop through the children and make sure they get rendered
for (var _i2 = 0, j = this.children.length; _i2 < j; _i2++) {
this.children[_i2].renderWebGL(renderer);
}
renderer.flush();
if (mask) {
renderer.maskManager.popMask(this, this._mask);
}
if (filters && this._enabledFilters && this._enabledFilters.length) {
renderer.filterManager.popFilter();
}
};
/**
* To be overridden by the subclasses.
*
* @private
* @param {PIXI.WebGLRenderer} renderer - The renderer
*/
Container.prototype._renderWebGL = function _renderWebGL(renderer) // eslint-disable-line no-unused-vars
{}
// this is where content itself gets rendered...
/**
* To be overridden by the subclass
*
* @private
* @param {PIXI.CanvasRenderer} renderer - The renderer
*/
;
Container.prototype._renderCanvas = function _renderCanvas(renderer) // eslint-disable-line no-unused-vars
{}
// this is where content itself gets rendered...
/**
* Renders the object using the Canvas renderer
*
* @param {PIXI.CanvasRenderer} renderer - The renderer
*/
;
Container.prototype.renderCanvas = function renderCanvas(renderer) {
// if not visible or the alpha is 0 then no need to render this
if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {
return;
}
if (this._mask) {
renderer.maskManager.pushMask(this._mask);
}
this._renderCanvas(renderer);
for (var i = 0, j = this.children.length; i < j; ++i) {
this.children[i].renderCanvas(renderer);
}
if (this._mask) {
renderer.maskManager.popMask(renderer);
}
};
/**
* Removes all internal references and listeners as well as removes children from the display list.
* Do not use a Container after calling `destroy`.
*
* @param {object|boolean} [options] - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [options.children=false] - if set to true, all the children will have their destroy
* method called as well. 'options' will be passed on to those calls.
* @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true
* Should it destroy the texture of the child sprite
* @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true
* Should it destroy the base texture of the child sprite
*/
Container.prototype.destroy = function destroy(options) {
_DisplayObject.prototype.destroy.call(this);
var destroyChildren = typeof options === 'boolean' ? options : options && options.children;
var oldChildren = this.removeChildren(0, this.children.length);
if (destroyChildren) {
for (var i = 0; i < oldChildren.length; ++i) {
oldChildren[i].destroy(options);
}
}
};
/**
* The width of the Container, setting this will actually modify the scale to achieve the value set
*
* @member {number}
*/
_createClass(Container, [{
key: 'width',
get: function get() {
return this.scale.x * this.getLocalBounds().width;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
var width = this.getLocalBounds().width;
if (width !== 0) {
this.scale.x = value / width;
} else {
this.scale.x = 1;
}
this._width = value;
}
/**
* The height of the Container, setting this will actually modify the scale to achieve the value set
*
* @member {number}
*/
}, {
key: 'height',
get: function get() {
return this.scale.y * this.getLocalBounds().height;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
var height = this.getLocalBounds().height;
if (height !== 0) {
this.scale.y = value / height;
} else {
this.scale.y = 1;
}
this._height = value;
}
}]);
return Container;
}(_DisplayObject3.default);
// performance increase to avoid using call.. (10x faster)
exports.default = Container;
Container.prototype.containerUpdateTransform = Container.prototype.updateTransform;
//# sourceMappingURL=Container.js.map
/***/ }),
/* 65 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _SystemRenderer2 = __webpack_require__(188);
var _SystemRenderer3 = _interopRequireDefault(_SystemRenderer2);
var _CanvasMaskManager = __webpack_require__(466);
var _CanvasMaskManager2 = _interopRequireDefault(_CanvasMaskManager);
var _CanvasRenderTarget = __webpack_require__(190);
var _CanvasRenderTarget2 = _interopRequireDefault(_CanvasRenderTarget);
var _mapCanvasBlendModesToPixi = __webpack_require__(467);
var _mapCanvasBlendModesToPixi2 = _interopRequireDefault(_mapCanvasBlendModesToPixi);
var _utils = __webpack_require__(7);
var _const = __webpack_require__(3);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* The CanvasRenderer draws the scene and all its content onto a 2d canvas. This renderer should
* be used for browsers that do not support WebGL. Don't forget to add the CanvasRenderer.view to
* your DOM or you will not see anything :)
*
* @class
* @memberof PIXI
* @extends PIXI.SystemRenderer
*/
var CanvasRenderer = function (_SystemRenderer) {
_inherits(CanvasRenderer, _SystemRenderer);
// eslint-disable-next-line valid-jsdoc
/**
* @param {object} [options] - The optional renderer parameters
* @param {number} [options.width=800] - the width of the screen
* @param {number} [options.height=600] - the height of the screen
* @param {HTMLCanvasElement} [options.view] - the canvas to use as a view, optional
* @param {boolean} [options.transparent=false] - If the render view is transparent, default false
* @param {boolean} [options.autoResize=false] - If the render view is automatically resized, default false
* @param {boolean} [options.antialias=false] - sets antialias (only applicable in chrome at the moment)
* @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer. The
* resolution of the renderer retina would be 2.
* @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation,
* enable this if you need to call toDataUrl on the webgl context.
* @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or
* not before the new render pass.
* @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area
* (shown if not transparent).
* @param {boolean} [options.roundPixels=false] - If true PixiJS will Math.floor() x/y values when rendering,
* stopping pixel interpolation.
*/
function CanvasRenderer(options, arg2, arg3) {
_classCallCheck(this, CanvasRenderer);
var _this = _possibleConstructorReturn(this, _SystemRenderer.call(this, 'Canvas', options, arg2, arg3));
_this.type = _const.RENDERER_TYPE.CANVAS;
/**
* The root canvas 2d context that everything is drawn with.
*
* @member {CanvasRenderingContext2D}
*/
_this.rootContext = _this.view.getContext('2d', { alpha: _this.transparent });
/**
* The currently active canvas 2d context (could change with renderTextures)
*
* @member {CanvasRenderingContext2D}
*/
_this.context = _this.rootContext;
/**
* Boolean flag controlling canvas refresh.
*
* @member {boolean}
*/
_this.refresh = true;
/**
* Instance of a CanvasMaskManager, handles masking when using the canvas renderer.
*
* @member {PIXI.CanvasMaskManager}
*/
_this.maskManager = new _CanvasMaskManager2.default(_this);
/**
* The canvas property used to set the canvas smoothing property.
*
* @member {string}
*/
_this.smoothProperty = 'imageSmoothingEnabled';
if (!_this.rootContext.imageSmoothingEnabled) {
if (_this.rootContext.webkitImageSmoothingEnabled) {
_this.smoothProperty = 'webkitImageSmoothingEnabled';
} else if (_this.rootContext.mozImageSmoothingEnabled) {
_this.smoothProperty = 'mozImageSmoothingEnabled';
} else if (_this.rootContext.oImageSmoothingEnabled) {
_this.smoothProperty = 'oImageSmoothingEnabled';
} else if (_this.rootContext.msImageSmoothingEnabled) {
_this.smoothProperty = 'msImageSmoothingEnabled';
}
}
_this.initPlugins();
_this.blendModes = (0, _mapCanvasBlendModesToPixi2.default)();
_this._activeBlendMode = null;
_this.renderingToScreen = false;
_this.resize(_this.options.width, _this.options.height);
/**
* Fired after rendering finishes.
*
* @event PIXI.CanvasRenderer#postrender
*/
/**
* Fired before rendering starts.
*
* @event PIXI.CanvasRenderer#prerender
*/
return _this;
}
/**
* Renders the object to this canvas view
*
* @param {PIXI.DisplayObject} displayObject - The object to be rendered
* @param {PIXI.RenderTexture} [renderTexture] - A render texture to be rendered to.
* If unset, it will render to the root context.
* @param {boolean} [clear=false] - Whether to clear the canvas before drawing
* @param {PIXI.Matrix} [transform] - A transformation to be applied
* @param {boolean} [skipUpdateTransform=false] - Whether to skip the update transform
*/
CanvasRenderer.prototype.render = function render(displayObject, renderTexture, clear, transform, skipUpdateTransform) {
if (!this.view) {
return;
}
// can be handy to know!
this.renderingToScreen = !renderTexture;
this.emit('prerender');
var rootResolution = this.resolution;
if (renderTexture) {
renderTexture = renderTexture.baseTexture || renderTexture;
if (!renderTexture._canvasRenderTarget) {
renderTexture._canvasRenderTarget = new _CanvasRenderTarget2.default(renderTexture.width, renderTexture.height, renderTexture.resolution);
renderTexture.source = renderTexture._canvasRenderTarget.canvas;
renderTexture.valid = true;
}
this.context = renderTexture._canvasRenderTarget.context;
this.resolution = renderTexture._canvasRenderTarget.resolution;
} else {
this.context = this.rootContext;
}
var context = this.context;
if (!renderTexture) {
this._lastObjectRendered = displayObject;
}
if (!skipUpdateTransform) {
// update the scene graph
var cacheParent = displayObject.parent;
var tempWt = this._tempDisplayObjectParent.transform.worldTransform;
if (transform) {
transform.copy(tempWt);
// lets not forget to flag the parent transform as dirty...
this._tempDisplayObjectParent.transform._worldID = -1;
} else {
tempWt.identity();
}
displayObject.parent = this._tempDisplayObjectParent;
displayObject.updateTransform();
displayObject.parent = cacheParent;
// displayObject.hitArea = //TODO add a temp hit area
}
context.save();
context.setTransform(1, 0, 0, 1, 0, 0);
context.globalAlpha = 1;
this._activeBlendMode = _const.BLEND_MODES.NORMAL;
context.globalCompositeOperation = this.blendModes[_const.BLEND_MODES.NORMAL];
if (navigator.isCocoonJS && this.view.screencanvas) {
context.fillStyle = 'black';
context.clear();
}
if (clear !== undefined ? clear : this.clearBeforeRender) {
if (this.renderingToScreen) {
if (this.transparent) {
context.clearRect(0, 0, this.width, this.height);
} else {
context.fillStyle = this._backgroundColorString;
context.fillRect(0, 0, this.width, this.height);
}
} // else {
// TODO: implement background for CanvasRenderTarget or RenderTexture?
// }
}
// TODO RENDER TARGET STUFF HERE..
var tempContext = this.context;
this.context = context;
displayObject.renderCanvas(this);
this.context = tempContext;
context.restore();
this.resolution = rootResolution;
this.emit('postrender');
};
/**
* Clear the canvas of renderer.
*
* @param {string} [clearColor] - Clear the canvas with this color, except the canvas is transparent.
*/
CanvasRenderer.prototype.clear = function clear(clearColor) {
var context = this.context;
clearColor = clearColor || this._backgroundColorString;
if (!this.transparent && clearColor) {
context.fillStyle = clearColor;
context.fillRect(0, 0, this.width, this.height);
} else {
context.clearRect(0, 0, this.width, this.height);
}
};
/**
* Sets the blend mode of the renderer.
*
* @param {number} blendMode - See {@link PIXI.BLEND_MODES} for valid values.
*/
CanvasRenderer.prototype.setBlendMode = function setBlendMode(blendMode) {
if (this._activeBlendMode === blendMode) {
return;
}
this._activeBlendMode = blendMode;
this.context.globalCompositeOperation = this.blendModes[blendMode];
};
/**
* Removes everything from the renderer and optionally removes the Canvas DOM element.
*
* @param {boolean} [removeView=false] - Removes the Canvas element from the DOM.
*/
CanvasRenderer.prototype.destroy = function destroy(removeView) {
this.destroyPlugins();
// call the base destroy
_SystemRenderer.prototype.destroy.call(this, removeView);
this.context = null;
this.refresh = true;
this.maskManager.destroy();
this.maskManager = null;
this.smoothProperty = null;
};
/**
* Resizes the canvas view to the specified width and height.
*
* @extends PIXI.SystemRenderer#resize
*
* @param {number} screenWidth - the new width of the screen
* @param {number} screenHeight - the new height of the screen
*/
CanvasRenderer.prototype.resize = function resize(screenWidth, screenHeight) {
_SystemRenderer.prototype.resize.call(this, screenWidth, screenHeight);
// reset the scale mode.. oddly this seems to be reset when the canvas is resized.
// surely a browser bug?? Let PixiJS fix that for you..
if (this.smoothProperty) {
this.rootContext[this.smoothProperty] = _settings2.default.SCALE_MODE === _const.SCALE_MODES.LINEAR;
}
};
/**
* Checks if blend mode has changed.
*/
CanvasRenderer.prototype.invalidateBlendMode = function invalidateBlendMode() {
this._activeBlendMode = this.blendModes.indexOf(this.context.globalCompositeOperation);
};
return CanvasRenderer;
}(_SystemRenderer3.default);
/**
* Collection of installed plugins. These are included by default in PIXI, but can be excluded
* by creating a custom build. Consult the README for more information about creating custom
* builds and excluding plugins.
* @name PIXI.CanvasRenderer#plugins
* @type {object}
* @readonly
* @property {PIXI.accessibility.AccessibilityManager} accessibility Support tabbing interactive elements.
* @property {PIXI.extract.CanvasExtract} extract Extract image data from renderer.
* @property {PIXI.interaction.InteractionManager} interaction Handles mouse, touch and pointer events.
* @property {PIXI.prepare.CanvasPrepare} prepare Pre-render display objects.
*/
/**
* Adds a plugin to the renderer.
*
* @method PIXI.CanvasRenderer#registerPlugin
* @param {string} pluginName - The name of the plugin.
* @param {Function} ctor - The constructor function or class for the plugin.
*/
exports.default = CanvasRenderer;
_utils.pluginTarget.mixin(CanvasRenderer);
//# sourceMappingURL=CanvasRenderer.js.map
/***/ }),
/* 66 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* @class
* @memberof PIXI
*/
var WebGLManager = function () {
/**
* @param {PIXI.WebGLRenderer} renderer - The renderer this manager works for.
*/
function WebGLManager(renderer) {
_classCallCheck(this, WebGLManager);
/**
* The renderer this manager works for.
*
* @member {PIXI.WebGLRenderer}
*/
this.renderer = renderer;
this.renderer.on('context', this.onContextChange, this);
}
/**
* Generic method called when there is a WebGL context change.
*
*/
WebGLManager.prototype.onContextChange = function onContextChange() {}
// do some codes init!
/**
* Generic destroy methods to be overridden by the subclass
*
*/
;
WebGLManager.prototype.destroy = function destroy() {
this.renderer.off('context', this.onContextChange, this);
this.renderer = null;
};
return WebGLManager;
}();
exports.default = WebGLManager;
//# sourceMappingURL=WebGLManager.js.map
/***/ }),
/* 67 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _pixiGlCore = __webpack_require__(23);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function checkPrecision(src, def) {
if (src instanceof Array) {
if (src[0].substring(0, 9) !== 'precision') {
var copy = src.slice(0);
copy.unshift('precision ' + def + ' float;');
return copy;
}
} else if (src.trim().substring(0, 9) !== 'precision') {
return 'precision ' + def + ' float;\n' + src;
}
return src;
}
/**
* Wrapper class, webGL Shader for Pixi.
* Adds precision string if vertexSrc or fragmentSrc have no mention of it.
*
* @class
* @extends GLShader
* @memberof PIXI
*/
var Shader = function (_GLShader) {
_inherits(Shader, _GLShader);
/**
*
* @param {WebGLRenderingContext} gl - The current WebGL rendering context
* @param {string|string[]} vertexSrc - The vertex shader source as an array of strings.
* @param {string|string[]} fragmentSrc - The fragment shader source as an array of strings.
* @param {object} [attributeLocations] - A key value pair showing which location eact attribute should sit.
e.g. {position:0, uvs:1}.
* @param {string} [precision] - The float precision of the shader. Options are 'lowp', 'mediump' or 'highp'.
*/
function Shader(gl, vertexSrc, fragmentSrc, attributeLocations, precision) {
_classCallCheck(this, Shader);
return _possibleConstructorReturn(this, _GLShader.call(this, gl, checkPrecision(vertexSrc, precision || _settings2.default.PRECISION_VERTEX), checkPrecision(fragmentSrc, precision || _settings2.default.PRECISION_FRAGMENT), undefined, attributeLocations));
}
return Shader;
}(_pixiGlCore.GLShader);
exports.default = Shader;
//# sourceMappingURL=Shader.js.map
/***/ }),
/* 68 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// import Loader from './Loader';
// import Resource from './Resource';
// import * as async from './async';
// import * as b64 from './b64';
/* eslint-disable no-undef */
var Loader = __webpack_require__(520).Loader;
var Resource = __webpack_require__(130).Resource;
var async = __webpack_require__(215);
var b64 = __webpack_require__(216);
/**
*
* @static
* @memberof Loader
* @member {Class<Resource>}
*/
Loader.Resource = Resource;
/**
*
* @static
* @memberof Loader
* @member {Class<async>}
*/
Loader.async = async;
/**
*
* @static
* @memberof Loader
* @member {Class<encodeBinary>}
*/
Loader.encodeBinary = b64;
/**
*
* @deprecated
* @see Loader.encodeBinary
*
* @static
* @memberof Loader
* @member {Class<encodeBinary>}
*/
Loader.base64 = b64;
// export manually, and also as default
module.exports = Loader;
// default & named export
module.exports.Loader = Loader;
module.exports.default = Loader;
//# sourceMappingURL=index.js.map
/***/ }),
/* 69 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _Texture = __webpack_require__(40);
var _Texture2 = _interopRequireDefault(_Texture);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var tempPoint = new core.Point();
var tempPolygon = new core.Polygon();
/**
* Base mesh class
* @class
* @extends PIXI.Container
* @memberof PIXI.mesh
*/
var Mesh = function (_core$Container) {
_inherits(Mesh, _core$Container);
/**
* @param {PIXI.Texture} texture - The texture to use
* @param {Float32Array} [vertices] - if you want to specify the vertices
* @param {Float32Array} [uvs] - if you want to specify the uvs
* @param {Uint16Array} [indices] - if you want to specify the indices
* @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts
*/
function Mesh(texture, vertices, uvs, indices, drawMode) {
_classCallCheck(this, Mesh);
/**
* The texture of the Mesh
*
* @member {PIXI.Texture}
* @default PIXI.Texture.EMPTY
* @private
*/
var _this = _possibleConstructorReturn(this, _core$Container.call(this));
_this._texture = texture || _Texture2.default.EMPTY;
/**
* The Uvs of the Mesh
*
* @member {Float32Array}
*/
_this.uvs = uvs || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
/**
* An array of vertices
*
* @member {Float32Array}
*/
_this.vertices = vertices || new Float32Array([0, 0, 100, 0, 100, 100, 0, 100]);
/**
* An array containing the indices of the vertices
*
* @member {Uint16Array}
*/
// TODO auto generate this based on draw mode!
_this.indices = indices || new Uint16Array([0, 1, 3, 2]);
/**
* Version of mesh uvs are dirty or not
*
* @member {number}
*/
_this.dirty = 0;
/**
* Version of mesh indices
*
* @member {number}
*/
_this.indexDirty = 0;
/**
* Version of mesh verticies array
*
* @member {number}
*/
_this.vertexDirty = 0;
/**
* For backwards compatibility the default is to re-upload verticies each render call.
* Set this to `false` and increase `vertexDirty` to manually re-upload the buffer.
*
* @member {boolean}
*/
_this.autoUpdate = true;
/**
* The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove
* any blend mode.
*
* @member {number}
* @default PIXI.BLEND_MODES.NORMAL
* @see PIXI.BLEND_MODES
*/
_this.blendMode = core.BLEND_MODES.NORMAL;
/**
* Triangles in canvas mode are automatically antialiased, use this value to force triangles
* to overlap a bit with each other.
*
* @member {number}
*/
_this.canvasPadding = core.settings.MESH_CANVAS_PADDING;
/**
* The way the Mesh should be drawn, can be any of the {@link PIXI.mesh.Mesh.DRAW_MODES} consts
*
* @member {number}
* @see PIXI.mesh.Mesh.DRAW_MODES
*/
_this.drawMode = drawMode || Mesh.DRAW_MODES.TRIANGLE_MESH;
/**
* The default shader that is used if a mesh doesn't have a more specific one.
*
* @member {PIXI.Shader}
*/
_this.shader = null;
/**
* The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any
* tint effect.
*
* @member {number}
*/
_this.tintRgb = new Float32Array([1, 1, 1]);
/**
* A map of renderer IDs to webgl render data
*
* @private
* @member {object<number, object>}
*/
_this._glDatas = {};
/**
* transform that is applied to UV to get the texture coords
* its updated independently from texture uvTransform
* updates of uvs are tied to that thing
*
* @member {PIXI.TextureMatrix}
* @private
*/
_this._uvTransform = new core.TextureMatrix(_this._texture);
/**
* whether or not upload uvTransform to shader
* if its false, then uvs should be pre-multiplied
* if you change it for generated mesh, please call 'refresh(true)'
* @member {boolean}
* @default false
*/
_this.uploadUvTransform = false;
/**
* Plugin that is responsible for rendering this element.
* Allows to customize the rendering process without overriding '_renderWebGL' & '_renderCanvas' methods.
* @member {string}
* @default 'mesh'
*/
_this.pluginName = 'mesh';
return _this;
}
/**
* Renders the object using the WebGL renderer
*
* @private
* @param {PIXI.WebGLRenderer} renderer - a reference to the WebGL renderer
*/
Mesh.prototype._renderWebGL = function _renderWebGL(renderer) {
this.refresh();
renderer.setObjectRenderer(renderer.plugins[this.pluginName]);
renderer.plugins[this.pluginName].render(this);
};
/**
* Renders the object using the Canvas renderer
*
* @private
* @param {PIXI.CanvasRenderer} renderer - The canvas renderer.
*/
Mesh.prototype._renderCanvas = function _renderCanvas(renderer) {
this.refresh();
renderer.plugins[this.pluginName].render(this);
};
/**
* When the texture is updated, this event will fire to update the scale and frame
*
* @private
*/
Mesh.prototype._onTextureUpdate = function _onTextureUpdate() {
this._uvTransform.texture = this._texture;
this.refresh();
};
/**
* multiplies uvs only if uploadUvTransform is false
* call it after you change uvs manually
* make sure that texture is valid
*/
Mesh.prototype.multiplyUvs = function multiplyUvs() {
if (!this.uploadUvTransform) {
this._uvTransform.multiplyUvs(this.uvs);
}
};
/**
* Refreshes uvs for generated meshes (rope, plane)
* sometimes refreshes vertices too
*
* @param {boolean} [forceUpdate=false] if true, matrices will be updated any case
*/
Mesh.prototype.refresh = function refresh(forceUpdate) {
if (this.autoUpdate) {
this.vertexDirty++;
}
if (this._uvTransform.update(forceUpdate)) {
this._refresh();
}
};
/**
* re-calculates mesh coords
* @protected
*/
Mesh.prototype._refresh = function _refresh() {}
/* empty */
/**
* Returns the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account.
*
*/
;
Mesh.prototype._calculateBounds = function _calculateBounds() {
// TODO - we can cache local bounds and use them if they are dirty (like graphics)
this._bounds.addVertices(this.transform, this.vertices, 0, this.vertices.length);
};
/**
* Tests if a point is inside this mesh. Works only for TRIANGLE_MESH
*
* @param {PIXI.Point} point - the point to test
* @return {boolean} the result of the test
*/
Mesh.prototype.containsPoint = function containsPoint(point) {
if (!this.getBounds().contains(point.x, point.y)) {
return false;
}
this.worldTransform.applyInverse(point, tempPoint);
var vertices = this.vertices;
var points = tempPolygon.points;
var indices = this.indices;
var len = this.indices.length;
var step = this.drawMode === Mesh.DRAW_MODES.TRIANGLES ? 3 : 1;
for (var i = 0; i + 2 < len; i += step) {
var ind0 = indices[i] * 2;
var ind1 = indices[i + 1] * 2;
var ind2 = indices[i + 2] * 2;
points[0] = vertices[ind0];
points[1] = vertices[ind0 + 1];
points[2] = vertices[ind1];
points[3] = vertices[ind1 + 1];
points[4] = vertices[ind2];
points[5] = vertices[ind2 + 1];
if (tempPolygon.contains(tempPoint.x, tempPoint.y)) {
return true;
}
}
return false;
};
/**
* The texture that the mesh uses.
*
* @member {PIXI.Texture}
*/
/**
* Destroys the Mesh object.
*
* @param {object|boolean} [options] - Options parameter. A boolean will act as if all
* options have been set to that value
* @param {boolean} [options.children=false] - if set to true, all the children will have
* their destroy method called as well. 'options' will be passed on to those calls.
* @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true
* Should it destroy the texture of the child sprite
* @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true
* Should it destroy the base texture of the child sprite
*/
Mesh.prototype.destroy = function destroy(options) {
// for each webgl data entry, destroy the WebGLGraphicsData
for (var id in this._glDatas) {
var data = this._glDatas[id];
if (data.destroy) {
data.destroy();
} else {
if (data.vertexBuffer) {
data.vertexBuffer.destroy();
data.vertexBuffer = null;
}
if (data.indexBuffer) {
data.indexBuffer.destroy();
data.indexBuffer = null;
}
if (data.uvBuffer) {
data.uvBuffer.destroy();
data.uvBuffer = null;
}
if (data.vao) {
data.vao.destroy();
data.vao = null;
}
}
}
this._glDatas = null;
_core$Container.prototype.destroy.call(this, options);
};
_createClass(Mesh, [{
key: 'texture',
get: function get() {
return this._texture;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (this._texture === value) {
return;
}
this._texture = value;
if (value) {
// wait for the texture to load
if (value.baseTexture.hasLoaded) {
this._onTextureUpdate();
} else {
value.once('update', this._onTextureUpdate, this);
}
}
}
/**
* The tint applied to the mesh. This is a hex value. A value of 0xFFFFFF will remove any tint effect.
*
* @member {number}
* @default 0xFFFFFF
*/
}, {
key: 'tint',
get: function get() {
return core.utils.rgb2hex(this.tintRgb);
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.tintRgb = core.utils.hex2rgb(value, this.tintRgb);
}
}]);
return Mesh;
}(core.Container);
/**
* Different drawing buffer modes supported
*
* @static
* @constant
* @type {object}
* @property {number} TRIANGLE_MESH
* @property {number} TRIANGLES
*/
exports.default = Mesh;
Mesh.DRAW_MODES = {
TRIANGLE_MESH: 0,
TRIANGLES: 1
};
//# sourceMappingURL=Mesh.js.map
/***/ }),
/* 70 */
/***/ (function(module, exports, __webpack_require__) {
// false -> Array#indexOf
// true -> Array#includes
var toIObject = __webpack_require__(20);
var toLength = __webpack_require__(9);
var toAbsoluteIndex = __webpack_require__(44);
module.exports = function (IS_INCLUDES) {
return function ($this, el, fromIndex) {
var O = toIObject($this);
var length = toLength(O.length);
var index = toAbsoluteIndex(fromIndex, length);
var value;
// Array#includes uses SameValueZero equality algorithm
// eslint-disable-next-line no-self-compare
if (IS_INCLUDES && el != el) while (length > index) {
value = O[index++];
// eslint-disable-next-line no-self-compare
if (value != value) return true;
// Array#indexOf ignores holes, Array#includes - not
} else for (;length > index; index++) if (IS_INCLUDES || index in O) {
if (O[index] === el) return IS_INCLUDES || index || 0;
} return !IS_INCLUDES && -1;
};
};
/***/ }),
/* 71 */
/***/ (function(module, exports) {
exports.f = Object.getOwnPropertySymbols;
/***/ }),
/* 72 */
/***/ (function(module, exports, __webpack_require__) {
// 7.2.2 IsArray(argument)
var cof = __webpack_require__(26);
module.exports = Array.isArray || function isArray(arg) {
return cof(arg) == 'Array';
};
/***/ }),
/* 73 */
/***/ (function(module, exports, __webpack_require__) {
var toInteger = __webpack_require__(27);
var defined = __webpack_require__(31);
// true -> String#at
// false -> String#codePointAt
module.exports = function (TO_STRING) {
return function (that, pos) {
var s = String(defined(that));
var i = toInteger(pos);
var l = s.length;
var a, b;
if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
a = s.charCodeAt(i);
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
? TO_STRING ? s.charAt(i) : a
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
};
};
/***/ }),
/* 74 */
/***/ (function(module, exports, __webpack_require__) {
// 7.2.8 IsRegExp(argument)
var isObject = __webpack_require__(6);
var cof = __webpack_require__(26);
var MATCH = __webpack_require__(8)('match');
module.exports = function (it) {
var isRegExp;
return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
};
/***/ }),
/* 75 */
/***/ (function(module, exports, __webpack_require__) {
var ITERATOR = __webpack_require__(8)('iterator');
var SAFE_CLOSING = false;
try {
var riter = [7][ITERATOR]();
riter['return'] = function () { SAFE_CLOSING = true; };
// eslint-disable-next-line no-throw-literal
Array.from(riter, function () { throw 2; });
} catch (e) { /* empty */ }
module.exports = function (exec, skipClosing) {
if (!skipClosing && !SAFE_CLOSING) return false;
var safe = false;
try {
var arr = [7];
var iter = arr[ITERATOR]();
iter.next = function () { return { done: safe = true }; };
arr[ITERATOR] = function () { return iter; };
exec(arr);
} catch (e) { /* empty */ }
return safe;
};
/***/ }),
/* 76 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var classof = __webpack_require__(55);
var builtinExec = RegExp.prototype.exec;
// `RegExpExec` abstract operation
// https://tc39.github.io/ecma262/#sec-regexpexec
module.exports = function (R, S) {
var exec = R.exec;
if (typeof exec === 'function') {
var result = exec.call(R, S);
if (typeof result !== 'object') {
throw new TypeError('RegExp exec method returned something other than an Object or null');
}
return result;
}
if (classof(R) !== 'RegExp') {
throw new TypeError('RegExp#exec called on incompatible receiver');
}
return builtinExec.call(R, S);
};
/***/ }),
/* 77 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
__webpack_require__(152);
var redefine = __webpack_require__(17);
var hide = __webpack_require__(16);
var fails = __webpack_require__(4);
var defined = __webpack_require__(31);
var wks = __webpack_require__(8);
var regexpExec = __webpack_require__(110);
var SPECIES = wks('species');
var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
// #replace needs built-in support for named groups.
// #match works fine because it just return the exec results, even if it has
// a "grops" property.
var re = /./;
re.exec = function () {
var result = [];
result.groups = { a: '7' };
return result;
};
return ''.replace(re, '$<a>') !== '7';
});
var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = (function () {
// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
var re = /(?:)/;
var originalExec = re.exec;
re.exec = function () { return originalExec.apply(this, arguments); };
var result = 'ab'.split(re);
return result.length === 2 && result[0] === 'a' && result[1] === 'b';
})();
module.exports = function (KEY, length, exec) {
var SYMBOL = wks(KEY);
var DELEGATES_TO_SYMBOL = !fails(function () {
// String methods call symbol-named RegEp methods
var O = {};
O[SYMBOL] = function () { return 7; };
return ''[KEY](O) != 7;
});
var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !fails(function () {
// Symbol-named RegExp methods call .exec
var execCalled = false;
var re = /a/;
re.exec = function () { execCalled = true; return null; };
if (KEY === 'split') {
// RegExp[@@split] doesn't call the regex's exec method, but first creates
// a new one. We need to return the patched regex when creating the new one.
re.constructor = {};
re.constructor[SPECIES] = function () { return re; };
}
re[SYMBOL]('');
return !execCalled;
}) : undefined;
if (
!DELEGATES_TO_SYMBOL ||
!DELEGATES_TO_EXEC ||
(KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
(KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
) {
var nativeRegExpMethod = /./[SYMBOL];
var fns = exec(
defined,
SYMBOL,
''[KEY],
function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) {
if (regexp.exec === regexpExec) {
if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
// The native String method already delegates to @@method (this
// polyfilled function), leasing to infinite recursion.
// We avoid it by directly calling the native @@method method.
return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
}
return { done: true, value: nativeMethod.call(str, regexp, arg2) };
}
return { done: false };
}
);
var strfn = fns[0];
var rxfn = fns[1];
redefine(String.prototype, KEY, strfn);
hide(RegExp.prototype, SYMBOL, length == 2
// 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
// 21.2.5.11 RegExp.prototype[@@split](string, limit)
? function (string, arg) { return rxfn.call(string, this, arg); }
// 21.2.5.6 RegExp.prototype[@@match](string)
// 21.2.5.9 RegExp.prototype[@@search](string)
: function (string) { return rxfn.call(string, this); }
);
}
};
/***/ }),
/* 78 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(2);
var navigator = global.navigator;
module.exports = navigator && navigator.userAgent || '';
/***/ }),
/* 79 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var global = __webpack_require__(2);
var $export = __webpack_require__(0);
var redefine = __webpack_require__(17);
var redefineAll = __webpack_require__(50);
var meta = __webpack_require__(38);
var forOf = __webpack_require__(49);
var anInstance = __webpack_require__(48);
var isObject = __webpack_require__(6);
var fails = __webpack_require__(4);
var $iterDetect = __webpack_require__(75);
var setToStringTag = __webpack_require__(54);
var inheritIfRequired = __webpack_require__(96);
module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
var Base = global[NAME];
var C = Base;
var ADDER = IS_MAP ? 'set' : 'add';
var proto = C && C.prototype;
var O = {};
var fixMethod = function (KEY) {
var fn = proto[KEY];
redefine(proto, KEY,
KEY == 'delete' ? function (a) {
return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
} : KEY == 'has' ? function has(a) {
return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
} : KEY == 'get' ? function get(a) {
return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
} : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; }
: function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; }
);
};
if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
new C().entries().next();
}))) {
// create collection constructor
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
redefineAll(C.prototype, methods);
meta.NEED = true;
} else {
var instance = new C();
// early implementations not supports chaining
var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
// V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });
// most early implementations doesn't supports iterables, most modern - not close it correctly
var ACCEPT_ITERABLES = $iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new
// for early implementations -0 and +0 not the same
var BUGGY_ZERO = !IS_WEAK && fails(function () {
// V8 ~ Chromium 42- fails only with 5+ elements
var $instance = new C();
var index = 5;
while (index--) $instance[ADDER](index, index);
return !$instance.has(-0);
});
if (!ACCEPT_ITERABLES) {
C = wrapper(function (target, iterable) {
anInstance(target, C, NAME);
var that = inheritIfRequired(new Base(), target, C);
if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
return that;
});
C.prototype = proto;
proto.constructor = C;
}
if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
fixMethod('delete');
fixMethod('has');
IS_MAP && fixMethod('get');
}
if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
// weak collections should not contains .clear method
if (IS_WEAK && proto.clear) delete proto.clear;
}
setToStringTag(C, NAME);
O[NAME] = C;
$export($export.G + $export.W + $export.F * (C != Base), O);
if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
return C;
};
/***/ }),
/* 80 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(2);
var hide = __webpack_require__(16);
var uid = __webpack_require__(42);
var TYPED = uid('typed_array');
var VIEW = uid('view');
var ABV = !!(global.ArrayBuffer && global.DataView);
var CONSTR = ABV;
var i = 0;
var l = 9;
var Typed;
var TypedArrayConstructors = (
'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array'
).split(',');
while (i < l) {
if (Typed = global[TypedArrayConstructors[i++]]) {
hide(Typed.prototype, TYPED, true);
hide(Typed.prototype, VIEW, true);
} else CONSTR = false;
}
module.exports = {
ABV: ABV,
CONSTR: CONSTR,
TYPED: TYPED,
VIEW: VIEW
};
/***/ }),
/* 81 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// Forced replacement prototype accessors methods
module.exports = __webpack_require__(37) || !__webpack_require__(4)(function () {
var K = Math.random();
// In FF throws only define methods
// eslint-disable-next-line no-undef, no-useless-call
__defineSetter__.call(null, K, function () { /* empty */ });
delete __webpack_require__(2)[K];
});
/***/ }),
/* 82 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://tc39.github.io/proposal-setmap-offrom/
var $export = __webpack_require__(0);
module.exports = function (COLLECTION) {
$export($export.S, COLLECTION, { of: function of() {
var length = arguments.length;
var A = new Array(length);
while (length--) A[length] = arguments[length];
return new this(A);
} });
};
/***/ }),
/* 83 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://tc39.github.io/proposal-setmap-offrom/
var $export = __webpack_require__(0);
var aFunction = __webpack_require__(15);
var ctx = __webpack_require__(25);
var forOf = __webpack_require__(49);
module.exports = function (COLLECTION) {
$export($export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
var mapFn = arguments[1];
var mapping, A, n, cb;
aFunction(this);
mapping = mapFn !== undefined;
if (mapping) aFunction(mapFn);
if (source == undefined) return new this();
A = [];
if (mapping) {
n = 0;
cb = ctx(mapFn, arguments[2], 2);
forOf(source, false, function (nextItem) {
A.push(cb(nextItem, n++));
});
} else {
forOf(source, false, A.push, A);
}
return new this(A);
} });
};
/***/ }),
/* 84 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _utils = __webpack_require__(7);
var _canUseNewCanvasBlendModes = __webpack_require__(191);
var _canUseNewCanvasBlendModes2 = _interopRequireDefault(_canUseNewCanvasBlendModes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Utility methods for Sprite/Texture tinting.
*
* @class
* @memberof PIXI
*/
var CanvasTinter = {
/**
* Basically this method just needs a sprite and a color and tints the sprite with the given color.
*
* @memberof PIXI.CanvasTinter
* @param {PIXI.Sprite} sprite - the sprite to tint
* @param {number} color - the color to use to tint the sprite with
* @return {HTMLCanvasElement} The tinted canvas
*/
getTintedTexture: function getTintedTexture(sprite, color) {
var texture = sprite._texture;
color = CanvasTinter.roundColor(color);
var stringColor = '#' + ('00000' + (color | 0).toString(16)).substr(-6);
texture.tintCache = texture.tintCache || {};
var cachedTexture = texture.tintCache[stringColor];
var canvas = void 0;
if (cachedTexture) {
if (cachedTexture.tintId === texture._updateID) {
return texture.tintCache[stringColor];
}
canvas = texture.tintCache[stringColor];
} else {
canvas = CanvasTinter.canvas || document.createElement('canvas');
}
CanvasTinter.tintMethod(texture, color, canvas);
canvas.tintId = texture._updateID;
if (CanvasTinter.convertTintToImage) {
// is this better?
var tintImage = new Image();
tintImage.src = canvas.toDataURL();
texture.tintCache[stringColor] = tintImage;
} else {
texture.tintCache[stringColor] = canvas;
// if we are not converting the texture to an image then we need to lose the reference to the canvas
CanvasTinter.canvas = null;
}
return canvas;
},
/**
* Tint a texture using the 'multiply' operation.
*
* @memberof PIXI.CanvasTinter
* @param {PIXI.Texture} texture - the texture to tint
* @param {number} color - the color to use to tint the sprite with
* @param {HTMLCanvasElement} canvas - the current canvas
*/
tintWithMultiply: function tintWithMultiply(texture, color, canvas) {
var context = canvas.getContext('2d');
var crop = texture._frame.clone();
var resolution = texture.baseTexture.resolution;
crop.x *= resolution;
crop.y *= resolution;
crop.width *= resolution;
crop.height *= resolution;
canvas.width = Math.ceil(crop.width);
canvas.height = Math.ceil(crop.height);
context.save();
context.fillStyle = '#' + ('00000' + (color | 0).toString(16)).substr(-6);
context.fillRect(0, 0, crop.width, crop.height);
context.globalCompositeOperation = 'multiply';
context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
context.globalCompositeOperation = 'destination-atop';
context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
context.restore();
},
/**
* Tint a texture using the 'overlay' operation.
*
* @memberof PIXI.CanvasTinter
* @param {PIXI.Texture} texture - the texture to tint
* @param {number} color - the color to use to tint the sprite with
* @param {HTMLCanvasElement} canvas - the current canvas
*/
tintWithOverlay: function tintWithOverlay(texture, color, canvas) {
var context = canvas.getContext('2d');
var crop = texture._frame.clone();
var resolution = texture.baseTexture.resolution;
crop.x *= resolution;
crop.y *= resolution;
crop.width *= resolution;
crop.height *= resolution;
canvas.width = Math.ceil(crop.width);
canvas.height = Math.ceil(crop.height);
context.save();
context.globalCompositeOperation = 'copy';
context.fillStyle = '#' + ('00000' + (color | 0).toString(16)).substr(-6);
context.fillRect(0, 0, crop.width, crop.height);
context.globalCompositeOperation = 'destination-atop';
context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
// context.globalCompositeOperation = 'copy';
context.restore();
},
/**
* Tint a texture pixel per pixel.
*
* @memberof PIXI.CanvasTinter
* @param {PIXI.Texture} texture - the texture to tint
* @param {number} color - the color to use to tint the sprite with
* @param {HTMLCanvasElement} canvas - the current canvas
*/
tintWithPerPixel: function tintWithPerPixel(texture, color, canvas) {
var context = canvas.getContext('2d');
var crop = texture._frame.clone();
var resolution = texture.baseTexture.resolution;
crop.x *= resolution;
crop.y *= resolution;
crop.width *= resolution;
crop.height *= resolution;
canvas.width = Math.ceil(crop.width);
canvas.height = Math.ceil(crop.height);
context.save();
context.globalCompositeOperation = 'copy';
context.drawImage(texture.baseTexture.source, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
context.restore();
var rgbValues = (0, _utils.hex2rgb)(color);
var r = rgbValues[0];
var g = rgbValues[1];
var b = rgbValues[2];
var pixelData = context.getImageData(0, 0, crop.width, crop.height);
var pixels = pixelData.data;
for (var i = 0; i < pixels.length; i += 4) {
pixels[i + 0] *= r;
pixels[i + 1] *= g;
pixels[i + 2] *= b;
}
context.putImageData(pixelData, 0, 0);
},
/**
* Rounds the specified color according to the CanvasTinter.cacheStepsPerColorChannel.
*
* @memberof PIXI.CanvasTinter
* @param {number} color - the color to round, should be a hex color
* @return {number} The rounded color.
*/
roundColor: function roundColor(color) {
var step = CanvasTinter.cacheStepsPerColorChannel;
var rgbValues = (0, _utils.hex2rgb)(color);
rgbValues[0] = Math.min(255, rgbValues[0] / step * step);
rgbValues[1] = Math.min(255, rgbValues[1] / step * step);
rgbValues[2] = Math.min(255, rgbValues[2] / step * step);
return (0, _utils.rgb2hex)(rgbValues);
},
/**
* Number of steps which will be used as a cap when rounding colors.
*
* @memberof PIXI.CanvasTinter
* @type {number}
*/
cacheStepsPerColorChannel: 8,
/**
* Tint cache boolean flag.
*
* @memberof PIXI.CanvasTinter
* @type {boolean}
*/
convertTintToImage: false,
/**
* Whether or not the Canvas BlendModes are supported, consequently the ability to tint using the multiply method.
*
* @memberof PIXI.CanvasTinter
* @type {boolean}
*/
canUseMultiply: (0, _canUseNewCanvasBlendModes2.default)(),
/**
* The tinting method that will be used.
*
* @memberof PIXI.CanvasTinter
* @type {tintMethodFunctionType}
*/
tintMethod: 0
};
CanvasTinter.tintMethod = CanvasTinter.canUseMultiply ? CanvasTinter.tintWithMultiply : CanvasTinter.tintWithPerPixel;
/**
* The tintMethod type.
*
* @memberof PIXI.CanvasTinter
* @callback tintMethodFunctionType
* @param texture {PIXI.Texture} the texture to tint
* @param color {number} the color to use to tint the sprite with
* @param canvas {HTMLCanvasElement} the current canvas
*/
exports.default = CanvasTinter;
//# sourceMappingURL=CanvasTinter.js.map
/***/ }),
/* 85 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _WebGLManager2 = __webpack_require__(66);
var _WebGLManager3 = _interopRequireDefault(_WebGLManager2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* Base for a common object renderer that can be used as a system renderer plugin.
*
* @class
* @extends PIXI.WebGLManager
* @memberof PIXI
*/
var ObjectRenderer = function (_WebGLManager) {
_inherits(ObjectRenderer, _WebGLManager);
function ObjectRenderer() {
_classCallCheck(this, ObjectRenderer);
return _possibleConstructorReturn(this, _WebGLManager.apply(this, arguments));
}
/**
* Starts the renderer and sets the shader
*
*/
ObjectRenderer.prototype.start = function start() {}
// set the shader..
/**
* Stops the renderer
*
*/
;
ObjectRenderer.prototype.stop = function stop() {
this.flush();
};
/**
* Stub method for rendering content and emptying the current batch.
*
*/
ObjectRenderer.prototype.flush = function flush() {}
// flush!
/**
* Renders an object
*
* @param {PIXI.DisplayObject} object - The object to render.
*/
;
ObjectRenderer.prototype.render = function render(object) // eslint-disable-line no-unused-vars
{
// render the object
};
return ObjectRenderer;
}(_WebGLManager3.default);
exports.default = ObjectRenderer;
//# sourceMappingURL=ObjectRenderer.js.map
/***/ }),
/* 86 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _SystemRenderer2 = __webpack_require__(188);
var _SystemRenderer3 = _interopRequireDefault(_SystemRenderer2);
var _MaskManager = __webpack_require__(469);
var _MaskManager2 = _interopRequireDefault(_MaskManager);
var _StencilManager = __webpack_require__(472);
var _StencilManager2 = _interopRequireDefault(_StencilManager);
var _FilterManager = __webpack_require__(473);
var _FilterManager2 = _interopRequireDefault(_FilterManager);
var _RenderTarget = __webpack_require__(87);
var _RenderTarget2 = _interopRequireDefault(_RenderTarget);
var _ObjectRenderer = __webpack_require__(85);
var _ObjectRenderer2 = _interopRequireDefault(_ObjectRenderer);
var _TextureManager = __webpack_require__(475);
var _TextureManager2 = _interopRequireDefault(_TextureManager);
var _BaseTexture = __webpack_require__(58);
var _BaseTexture2 = _interopRequireDefault(_BaseTexture);
var _TextureGarbageCollector = __webpack_require__(476);
var _TextureGarbageCollector2 = _interopRequireDefault(_TextureGarbageCollector);
var _WebGLState = __webpack_require__(477);
var _WebGLState2 = _interopRequireDefault(_WebGLState);
var _mapWebGLDrawModesToPixi = __webpack_require__(479);
var _mapWebGLDrawModesToPixi2 = _interopRequireDefault(_mapWebGLDrawModesToPixi);
var _validateContext = __webpack_require__(480);
var _validateContext2 = _interopRequireDefault(_validateContext);
var _utils = __webpack_require__(7);
var _pixiGlCore = __webpack_require__(23);
var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore);
var _const = __webpack_require__(3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var CONTEXT_UID = 0;
/**
* The WebGLRenderer draws the scene and all its content onto a webGL enabled canvas. This renderer
* should be used for browsers that support webGL. This Render works by automatically managing webGLBatchs.
* So no need for Sprite Batches or Sprite Clouds.
* Don't forget to add the view to your DOM or you will not see anything :)
*
* @class
* @memberof PIXI
* @extends PIXI.SystemRenderer
*/
var WebGLRenderer = function (_SystemRenderer) {
_inherits(WebGLRenderer, _SystemRenderer);
// eslint-disable-next-line valid-jsdoc
/**
*
* @param {object} [options] - The optional renderer parameters
* @param {number} [options.width=800] - the width of the screen
* @param {number} [options.height=600] - the height of the screen
* @param {HTMLCanvasElement} [options.view] - the canvas to use as a view, optional
* @param {boolean} [options.transparent=false] - If the render view is transparent, default false
* @param {boolean} [options.autoResize=false] - If the render view is automatically resized, default false
* @param {boolean} [options.antialias=false] - sets antialias. If not available natively then FXAA
* antialiasing is used
* @param {boolean} [options.forceFXAA=false] - forces FXAA antialiasing to be used over native.
* FXAA is faster, but may not always look as great
* @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer.
* The resolution of the renderer retina would be 2.
* @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear
* the canvas or not before the new render pass. If you wish to set this to false, you *must* set
* preserveDrawingBuffer to `true`.
* @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation,
* enable this if you need to call toDataUrl on the webgl context.
* @param {boolean} [options.roundPixels=false] - If true PixiJS will Math.floor() x/y values when
* rendering, stopping pixel interpolation.
* @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area
* (shown if not transparent).
* @param {boolean} [options.legacy=false] - If true PixiJS will aim to ensure compatibility
* with older / less advanced devices. If you experience unexplained flickering try setting this to true.
* @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance"
* for devices with dual graphics card
*/
function WebGLRenderer(options, arg2, arg3) {
_classCallCheck(this, WebGLRenderer);
var _this = _possibleConstructorReturn(this, _SystemRenderer.call(this, 'WebGL', options, arg2, arg3));
_this.legacy = _this.options.legacy;
if (_this.legacy) {
_pixiGlCore2.default.VertexArrayObject.FORCE_NATIVE = true;
}
/**
* The type of this renderer as a standardised const
*
* @member {number}
* @see PIXI.RENDERER_TYPE
*/
_this.type = _const.RENDERER_TYPE.WEBGL;
_this.handleContextLost = _this.handleContextLost.bind(_this);
_this.handleContextRestored = _this.handleContextRestored.bind(_this);
_this.view.addEventListener('webglcontextlost', _this.handleContextLost, false);
_this.view.addEventListener('webglcontextrestored', _this.handleContextRestored, false);
/**
* The options passed in to create a new webgl context.
*
* @member {object}
* @private
*/
_this._contextOptions = {
alpha: _this.transparent,
antialias: _this.options.antialias,
premultipliedAlpha: _this.transparent && _this.transparent !== 'notMultiplied',
stencil: true,
preserveDrawingBuffer: _this.options.preserveDrawingBuffer,
powerPreference: _this.options.powerPreference
};
_this._backgroundColorRgba[3] = _this.transparent ? 0 : 1;
/**
* Manages the masks using the stencil buffer.
*
* @member {PIXI.MaskManager}
*/
_this.maskManager = new _MaskManager2.default(_this);
/**
* Manages the stencil buffer.
*
* @member {PIXI.StencilManager}
*/
_this.stencilManager = new _StencilManager2.default(_this);
/**
* An empty renderer.
*
* @member {PIXI.ObjectRenderer}
*/
_this.emptyRenderer = new _ObjectRenderer2.default(_this);
/**
* The currently active ObjectRenderer.
*
* @member {PIXI.ObjectRenderer}
*/
_this.currentRenderer = _this.emptyRenderer;
/**
* Manages textures
* @member {PIXI.TextureManager}
*/
_this.textureManager = null;
/**
* Manages the filters.
*
* @member {PIXI.FilterManager}
*/
_this.filterManager = null;
_this.initPlugins();
/**
* The current WebGL rendering context, it is created here
*
* @member {WebGLRenderingContext}
*/
// initialize the context so it is ready for the managers.
if (_this.options.context) {
// checks to see if a context is valid..
(0, _validateContext2.default)(_this.options.context);
}
_this.gl = _this.options.context || _pixiGlCore2.default.createContext(_this.view, _this._contextOptions);
_this.CONTEXT_UID = CONTEXT_UID++;
/**
* The currently active ObjectRenderer.
*
* @member {PIXI.WebGLState}
*/
_this.state = new _WebGLState2.default(_this.gl);
_this.renderingToScreen = true;
/**
* Holds the current state of textures bound to the GPU.
* @type {Array}
*/
_this.boundTextures = null;
/**
* Holds the current shader
*
* @member {PIXI.Shader}
*/
_this._activeShader = null;
_this._activeVao = null;
/**
* Holds the current render target
*
* @member {PIXI.RenderTarget}
*/
_this._activeRenderTarget = null;
_this._initContext();
// map some webGL blend and drawmodes..
_this.drawModes = (0, _mapWebGLDrawModesToPixi2.default)(_this.gl);
_this._nextTextureLocation = 0;
_this.setBlendMode(0);
/**
* Fired after rendering finishes.
*
* @event PIXI.WebGLRenderer#postrender
*/
/**
* Fired before rendering starts.
*
* @event PIXI.WebGLRenderer#prerender
*/
/**
* Fired when the WebGL context is set.
*
* @event PIXI.WebGLRenderer#context
* @param {WebGLRenderingContext} gl - WebGL context.
*/
return _this;
}
/**
* Creates the WebGL context
*
* @private
*/
WebGLRenderer.prototype._initContext = function _initContext() {
var gl = this.gl;
// restore a context if it was previously lost
if (gl.isContextLost() && gl.getExtension('WEBGL_lose_context')) {
gl.getExtension('WEBGL_lose_context').restoreContext();
}
var maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
this._activeShader = null;
this._activeVao = null;
this.boundTextures = new Array(maxTextures);
this.emptyTextures = new Array(maxTextures);
/**
* Did someone temper with textures state? We'll overwrite them when we need to unbind something.
* @member {boolean}
* @private
*/
this._unknownBoundTextures = false;
// create a texture manager...
this.textureManager = new _TextureManager2.default(this);
this.filterManager = new _FilterManager2.default(this);
this.textureGC = new _TextureGarbageCollector2.default(this);
this.state.resetToDefault();
this.rootRenderTarget = new _RenderTarget2.default(gl, this.width, this.height, null, this.resolution, true);
this.rootRenderTarget.clearColor = this._backgroundColorRgba;
this.bindRenderTarget(this.rootRenderTarget);
// now lets fill up the textures with empty ones!
var emptyGLTexture = new _pixiGlCore2.default.GLTexture.fromData(gl, null, 1, 1);
var tempObj = { _glTextures: {} };
tempObj._glTextures[this.CONTEXT_UID] = {};
for (var i = 0; i < maxTextures; i++) {
var empty = new _BaseTexture2.default();
empty._glTextures[this.CONTEXT_UID] = emptyGLTexture;
this.boundTextures[i] = tempObj;
this.emptyTextures[i] = empty;
this.bindTexture(null, i);
}
this.emit('context', gl);
// setup the width/height properties and gl viewport
this.resize(this.screen.width, this.screen.height);
};
/**
* Renders the object to its webGL view
*
* @param {PIXI.DisplayObject} displayObject - the object to be rendered
* @param {PIXI.RenderTexture} renderTexture - The render texture to render to.
* @param {boolean} [clear] - Should the canvas be cleared before the new render
* @param {PIXI.Matrix} [transform] - A transform to apply to the render texture before rendering.
* @param {boolean} [skipUpdateTransform] - Should we skip the update transform pass?
*/
WebGLRenderer.prototype.render = function render(displayObject, renderTexture, clear, transform, skipUpdateTransform) {
// can be handy to know!
this.renderingToScreen = !renderTexture;
this.emit('prerender');
// no point rendering if our context has been blown up!
if (!this.gl || this.gl.isContextLost()) {
return;
}
this._nextTextureLocation = 0;
if (!renderTexture) {
this._lastObjectRendered = displayObject;
}
if (!skipUpdateTransform) {
// update the scene graph
var cacheParent = displayObject.parent;
displayObject.parent = this._tempDisplayObjectParent;
displayObject.updateTransform();
displayObject.parent = cacheParent;
// displayObject.hitArea = //TODO add a temp hit area
}
this.bindRenderTexture(renderTexture, transform);
this.currentRenderer.start();
if (clear !== undefined ? clear : this.clearBeforeRender) {
this._activeRenderTarget.clear();
}
displayObject.renderWebGL(this);
// apply transform..
this.currentRenderer.flush();
// this.setObjectRenderer(this.emptyRenderer);
this.textureGC.update();
this.emit('postrender');
};
/**
* Changes the current renderer to the one given in parameter
*
* @param {PIXI.ObjectRenderer} objectRenderer - The object renderer to use.
*/
WebGLRenderer.prototype.setObjectRenderer = function setObjectRenderer(objectRenderer) {
if (this.currentRenderer === objectRenderer) {
return;
}
this.currentRenderer.stop();
this.currentRenderer = objectRenderer;
this.currentRenderer.start();
};
/**
* This should be called if you wish to do some custom rendering
* It will basically render anything that may be batched up such as sprites
*
*/
WebGLRenderer.prototype.flush = function flush() {
this.setObjectRenderer(this.emptyRenderer);
};
/**
* Resizes the webGL view to the specified width and height.
*
* @param {number} screenWidth - the new width of the screen
* @param {number} screenHeight - the new height of the screen
*/
WebGLRenderer.prototype.resize = function resize(screenWidth, screenHeight) {
// if(width * this.resolution === this.width && height * this.resolution === this.height)return;
_SystemRenderer3.default.prototype.resize.call(this, screenWidth, screenHeight);
this.rootRenderTarget.resize(screenWidth, screenHeight);
if (this._activeRenderTarget === this.rootRenderTarget) {
this.rootRenderTarget.activate();
if (this._activeShader) {
this._activeShader.uniforms.projectionMatrix = this.rootRenderTarget.projectionMatrix.toArray(true);
}
}
};
/**
* Resizes the webGL view to the specified width and height.
*
* @param {number} blendMode - the desired blend mode
*/
WebGLRenderer.prototype.setBlendMode = function setBlendMode(blendMode) {
this.state.setBlendMode(blendMode);
};
/**
* Erases the active render target and fills the drawing area with a colour
*
* @param {number} [clearColor] - The colour
*/
WebGLRenderer.prototype.clear = function clear(clearColor) {
this._activeRenderTarget.clear(clearColor);
};
/**
* Sets the transform of the active render target to the given matrix
*
* @param {PIXI.Matrix} matrix - The transformation matrix
*/
WebGLRenderer.prototype.setTransform = function setTransform(matrix) {
this._activeRenderTarget.transform = matrix;
};
/**
* Erases the render texture and fills the drawing area with a colour
*
* @param {PIXI.RenderTexture} renderTexture - The render texture to clear
* @param {number} [clearColor] - The colour
* @return {PIXI.WebGLRenderer} Returns itself.
*/
WebGLRenderer.prototype.clearRenderTexture = function clearRenderTexture(renderTexture, clearColor) {
var baseTexture = renderTexture.baseTexture;
var renderTarget = baseTexture._glRenderTargets[this.CONTEXT_UID];
if (renderTarget) {
renderTarget.clear(clearColor);
}
return this;
};
/**
* Binds a render texture for rendering
*
* @param {PIXI.RenderTexture} renderTexture - The render texture to render
* @param {PIXI.Matrix} transform - The transform to be applied to the render texture
* @return {PIXI.WebGLRenderer} Returns itself.
*/
WebGLRenderer.prototype.bindRenderTexture = function bindRenderTexture(renderTexture, transform) {
var renderTarget = void 0;
if (renderTexture) {
var baseTexture = renderTexture.baseTexture;
if (!baseTexture._glRenderTargets[this.CONTEXT_UID]) {
// bind the current texture
this.textureManager.updateTexture(baseTexture, 0);
}
this.unbindTexture(baseTexture);
renderTarget = baseTexture._glRenderTargets[this.CONTEXT_UID];
renderTarget.setFrame(renderTexture.frame);
} else {
renderTarget = this.rootRenderTarget;
}
renderTarget.transform = transform;
this.bindRenderTarget(renderTarget);
return this;
};
/**
* Changes the current render target to the one given in parameter
*
* @param {PIXI.RenderTarget} renderTarget - the new render target
* @return {PIXI.WebGLRenderer} Returns itself.
*/
WebGLRenderer.prototype.bindRenderTarget = function bindRenderTarget(renderTarget) {
if (renderTarget !== this._activeRenderTarget) {
this._activeRenderTarget = renderTarget;
renderTarget.activate();
if (this._activeShader) {
this._activeShader.uniforms.projectionMatrix = renderTarget.projectionMatrix.toArray(true);
}
this.stencilManager.setMaskStack(renderTarget.stencilMaskStack);
}
return this;
};
/**
* Changes the current shader to the one given in parameter
*
* @param {PIXI.Shader} shader - the new shader
* @param {boolean} [autoProject=true] - Whether automatically set the projection matrix
* @return {PIXI.WebGLRenderer} Returns itself.
*/
WebGLRenderer.prototype.bindShader = function bindShader(shader, autoProject) {
// TODO cache
if (this._activeShader !== shader) {
this._activeShader = shader;
shader.bind();
// `autoProject` normally would be a default parameter set to true
// but because of how Babel transpiles default parameters
// it hinders the performance of this method.
if (autoProject !== false) {
// automatically set the projection matrix
shader.uniforms.projectionMatrix = this._activeRenderTarget.projectionMatrix.toArray(true);
}
}
return this;
};
/**
* Binds the texture. This will return the location of the bound texture.
* It may not be the same as the one you pass in. This is due to optimisation that prevents
* needless binding of textures. For example if the texture is already bound it will return the
* current location of the texture instead of the one provided. To bypass this use force location
*
* @param {PIXI.Texture} texture - the new texture
* @param {number} location - the suggested texture location
* @param {boolean} forceLocation - force the location
* @return {number} bound texture location
*/
WebGLRenderer.prototype.bindTexture = function bindTexture(texture, location, forceLocation) {
texture = texture || this.emptyTextures[location];
texture = texture.baseTexture || texture;
texture.touched = this.textureGC.count;
if (!forceLocation) {
// TODO - maybe look into adding boundIds.. save us the loop?
for (var i = 0; i < this.boundTextures.length; i++) {
if (this.boundTextures[i] === texture) {
return i;
}
}
if (location === undefined) {
this._nextTextureLocation++;
this._nextTextureLocation %= this.boundTextures.length;
location = this.boundTextures.length - this._nextTextureLocation - 1;
}
} else {
location = location || 0;
}
var gl = this.gl;
var glTexture = texture._glTextures[this.CONTEXT_UID];
if (!glTexture) {
// this will also bind the texture..
this.textureManager.updateTexture(texture, location);
} else {
// bind the current texture
this.boundTextures[location] = texture;
gl.activeTexture(gl.TEXTURE0 + location);
gl.bindTexture(gl.TEXTURE_2D, glTexture.texture);
}
return location;
};
/**
* unbinds the texture ...
*
* @param {PIXI.Texture} texture - the texture to unbind
* @return {PIXI.WebGLRenderer} Returns itself.
*/
WebGLRenderer.prototype.unbindTexture = function unbindTexture(texture) {
var gl = this.gl;
texture = texture.baseTexture || texture;
if (this._unknownBoundTextures) {
this._unknownBoundTextures = false;
// someone changed webGL state,
// we have to be sure that our texture does not appear in multitexture renderer samplers
for (var i = 0; i < this.boundTextures.length; i++) {
if (this.boundTextures[i] === this.emptyTextures[i]) {
gl.activeTexture(gl.TEXTURE0 + i);
gl.bindTexture(gl.TEXTURE_2D, this.emptyTextures[i]._glTextures[this.CONTEXT_UID].texture);
}
}
}
for (var _i = 0; _i < this.boundTextures.length; _i++) {
if (this.boundTextures[_i] === texture) {
this.boundTextures[_i] = this.emptyTextures[_i];
gl.activeTexture(gl.TEXTURE0 + _i);
gl.bindTexture(gl.TEXTURE_2D, this.emptyTextures[_i]._glTextures[this.CONTEXT_UID].texture);
}
}
return this;
};
/**
* Creates a new VAO from this renderer's context and state.
*
* @return {VertexArrayObject} The new VAO.
*/
WebGLRenderer.prototype.createVao = function createVao() {
return new _pixiGlCore2.default.VertexArrayObject(this.gl, this.state.attribState);
};
/**
* Changes the current Vao to the one given in parameter
*
* @param {PIXI.VertexArrayObject} vao - the new Vao
* @return {PIXI.WebGLRenderer} Returns itself.
*/
WebGLRenderer.prototype.bindVao = function bindVao(vao) {
if (this._activeVao === vao) {
return this;
}
if (vao) {
vao.bind();
} else if (this._activeVao) {
// TODO this should always be true i think?
this._activeVao.unbind();
}
this._activeVao = vao;
return this;
};
/**
* Resets the WebGL state so you can render things however you fancy!
*
* @return {PIXI.WebGLRenderer} Returns itself.
*/
WebGLRenderer.prototype.reset = function reset() {
this.setObjectRenderer(this.emptyRenderer);
this.bindVao(null);
this._activeShader = null;
this._activeRenderTarget = this.rootRenderTarget;
this._unknownBoundTextures = true;
for (var i = 0; i < this.boundTextures.length; i++) {
this.boundTextures[i] = this.emptyTextures[i];
}
// bind the main frame buffer (the screen);
this.rootRenderTarget.activate();
this.state.resetToDefault();
return this;
};
/**
* Handles a lost webgl context
*
* @private
* @param {WebGLContextEvent} event - The context lost event.
*/
WebGLRenderer.prototype.handleContextLost = function handleContextLost(event) {
event.preventDefault();
};
/**
* Handles a restored webgl context
*
* @private
*/
WebGLRenderer.prototype.handleContextRestored = function handleContextRestored() {
this.textureManager.removeAll();
this.filterManager.destroy(true);
this._initContext();
};
/**
* Removes everything from the renderer (event listeners, spritebatch, etc...)
*
* @param {boolean} [removeView=false] - Removes the Canvas element from the DOM.
* See: https://github.com/pixijs/pixi.js/issues/2233
*/
WebGLRenderer.prototype.destroy = function destroy(removeView) {
this.destroyPlugins();
// remove listeners
this.view.removeEventListener('webglcontextlost', this.handleContextLost);
this.view.removeEventListener('webglcontextrestored', this.handleContextRestored);
this.textureManager.destroy();
// call base destroy
_SystemRenderer.prototype.destroy.call(this, removeView);
this.uid = 0;
// destroy the managers
this.maskManager.destroy();
this.stencilManager.destroy();
this.filterManager.destroy();
this.maskManager = null;
this.filterManager = null;
this.textureManager = null;
this.currentRenderer = null;
this.handleContextLost = null;
this.handleContextRestored = null;
this._contextOptions = null;
this.gl.useProgram(null);
if (this.gl.getExtension('WEBGL_lose_context')) {
this.gl.getExtension('WEBGL_lose_context').loseContext();
}
this.gl = null;
// this = null;
};
return WebGLRenderer;
}(_SystemRenderer3.default);
/**
* Collection of installed plugins. These are included by default in PIXI, but can be excluded
* by creating a custom build. Consult the README for more information about creating custom
* builds and excluding plugins.
* @name PIXI.WebGLRenderer#plugins
* @type {object}
* @readonly
* @property {PIXI.accessibility.AccessibilityManager} accessibility Support tabbing interactive elements.
* @property {PIXI.extract.WebGLExtract} extract Extract image data from renderer.
* @property {PIXI.interaction.InteractionManager} interaction Handles mouse, touch and pointer events.
* @property {PIXI.prepare.WebGLPrepare} prepare Pre-render display objects.
*/
/**
* Adds a plugin to the renderer.
*
* @method PIXI.WebGLRenderer#registerPlugin
* @param {string} pluginName - The name of the plugin.
* @param {Function} ctor - The constructor function or class for the plugin.
*/
exports.default = WebGLRenderer;
_utils.pluginTarget.mixin(WebGLRenderer);
//# sourceMappingURL=WebGLRenderer.js.map
/***/ }),
/* 87 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _math = __webpack_require__(14);
var _const = __webpack_require__(3);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
var _pixiGlCore = __webpack_require__(23);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* @class
* @memberof PIXI
*/
var RenderTarget = function () {
/**
* @param {WebGLRenderingContext} gl - The current WebGL drawing context
* @param {number} [width=0] - the horizontal range of the filter
* @param {number} [height=0] - the vertical range of the filter
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values
* @param {number} [resolution=1] - The current resolution / device pixel ratio
* @param {boolean} [root=false] - Whether this object is the root element or not
*/
function RenderTarget(gl, width, height, scaleMode, resolution, root) {
_classCallCheck(this, RenderTarget);
// TODO Resolution could go here ( eg low res blurs )
/**
* The current WebGL drawing context.
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
// next time to create a frame buffer and texture
/**
* A frame buffer
*
* @member {PIXI.glCore.GLFramebuffer}
*/
this.frameBuffer = null;
/**
* The texture
*
* @member {PIXI.glCore.GLTexture}
*/
this.texture = null;
/**
* The background colour of this render target, as an array of [r,g,b,a] values
*
* @member {number[]}
*/
this.clearColor = [0, 0, 0, 0];
/**
* The size of the object as a rectangle
*
* @member {PIXI.Rectangle}
*/
this.size = new _math.Rectangle(0, 0, 1, 1);
/**
* The current resolution / device pixel ratio
*
* @member {number}
* @default 1
*/
this.resolution = resolution || _settings2.default.RESOLUTION;
/**
* The projection matrix
*
* @member {PIXI.Matrix}
*/
this.projectionMatrix = new _math.Matrix();
/**
* The object's transform
*
* @member {PIXI.Matrix}
*/
this.transform = null;
/**
* The frame.
*
* @member {PIXI.Rectangle}
*/
this.frame = null;
/**
* The stencil buffer stores masking data for the render target
*
* @member {glCore.GLBuffer}
*/
this.defaultFrame = new _math.Rectangle();
this.destinationFrame = null;
this.sourceFrame = null;
/**
* The stencil buffer stores masking data for the render target
*
* @member {glCore.GLBuffer}
*/
this.stencilBuffer = null;
/**
* The data structure for the stencil masks
*
* @member {PIXI.Graphics[]}
*/
this.stencilMaskStack = [];
/**
* Stores filter data for the render target
*
* @member {object[]}
*/
this.filterData = null;
/**
* The key for pooled texture of FilterSystem
* @private
* @member {string}
*/
this.filterPoolKey = '';
/**
* The scale mode.
*
* @member {number}
* @default PIXI.settings.SCALE_MODE
* @see PIXI.SCALE_MODES
*/
this.scaleMode = scaleMode !== undefined ? scaleMode : _settings2.default.SCALE_MODE;
/**
* Whether this object is the root element or not
*
* @member {boolean}
* @default false
*/
this.root = root || false;
if (!this.root) {
this.frameBuffer = _pixiGlCore.GLFramebuffer.createRGBA(gl, 100, 100);
if (this.scaleMode === _const.SCALE_MODES.NEAREST) {
this.frameBuffer.texture.enableNearestScaling();
} else {
this.frameBuffer.texture.enableLinearScaling();
}
/*
A frame buffer needs a target to render to..
create a texture and bind it attach it to the framebuffer..
*/
// this is used by the base texture
this.texture = this.frameBuffer.texture;
} else {
// make it a null framebuffer..
this.frameBuffer = new _pixiGlCore.GLFramebuffer(gl, 100, 100);
this.frameBuffer.framebuffer = null;
}
this.setFrame();
this.resize(width, height);
}
/**
* Clears the filter texture.
*
* @param {number[]} [clearColor=this.clearColor] - Array of [r,g,b,a] to clear the framebuffer
*/
RenderTarget.prototype.clear = function clear(clearColor) {
var cc = clearColor || this.clearColor;
this.frameBuffer.clear(cc[0], cc[1], cc[2], cc[3]); // r,g,b,a);
};
/**
* Binds the stencil buffer.
*
*/
RenderTarget.prototype.attachStencilBuffer = function attachStencilBuffer() {
// TODO check if stencil is done?
/**
* The stencil buffer is used for masking in pixi
* lets create one and then add attach it to the framebuffer..
*/
if (!this.root) {
this.frameBuffer.enableStencil();
}
};
/**
* Sets the frame of the render target.
*
* @param {Rectangle} destinationFrame - The destination frame.
* @param {Rectangle} sourceFrame - The source frame.
*/
RenderTarget.prototype.setFrame = function setFrame(destinationFrame, sourceFrame) {
this.destinationFrame = destinationFrame || this.destinationFrame || this.defaultFrame;
this.sourceFrame = sourceFrame || this.sourceFrame || this.destinationFrame;
};
/**
* Binds the buffers and initialises the viewport.
*
*/
RenderTarget.prototype.activate = function activate() {
// TODO refactor usage of frame..
var gl = this.gl;
// make sure the texture is unbound!
this.frameBuffer.bind();
this.calculateProjection(this.destinationFrame, this.sourceFrame);
if (this.transform) {
this.projectionMatrix.append(this.transform);
}
// TODO add a check as them may be the same!
if (this.destinationFrame !== this.sourceFrame) {
gl.enable(gl.SCISSOR_TEST);
gl.scissor(this.destinationFrame.x | 0, this.destinationFrame.y | 0, this.destinationFrame.width * this.resolution | 0, this.destinationFrame.height * this.resolution | 0);
} else {
gl.disable(gl.SCISSOR_TEST);
}
// TODO - does not need to be updated all the time??
gl.viewport(this.destinationFrame.x | 0, this.destinationFrame.y | 0, this.destinationFrame.width * this.resolution | 0, this.destinationFrame.height * this.resolution | 0);
};
/**
* Updates the projection matrix based on a projection frame (which is a rectangle)
*
* @param {Rectangle} destinationFrame - The destination frame.
* @param {Rectangle} sourceFrame - The source frame.
*/
RenderTarget.prototype.calculateProjection = function calculateProjection(destinationFrame, sourceFrame) {
var pm = this.projectionMatrix;
sourceFrame = sourceFrame || destinationFrame;
pm.identity();
// TODO: make dest scale source
if (!this.root) {
pm.a = 1 / destinationFrame.width * 2;
pm.d = 1 / destinationFrame.height * 2;
pm.tx = -1 - sourceFrame.x * pm.a;
pm.ty = -1 - sourceFrame.y * pm.d;
} else {
pm.a = 1 / destinationFrame.width * 2;
pm.d = -1 / destinationFrame.height * 2;
pm.tx = -1 - sourceFrame.x * pm.a;
pm.ty = 1 - sourceFrame.y * pm.d;
}
};
/**
* Resizes the texture to the specified width and height
*
* @param {number} width - the new width of the texture
* @param {number} height - the new height of the texture
*/
RenderTarget.prototype.resize = function resize(width, height) {
width = width | 0;
height = height | 0;
if (this.size.width === width && this.size.height === height) {
return;
}
this.size.width = width;
this.size.height = height;
this.defaultFrame.width = width;
this.defaultFrame.height = height;
this.frameBuffer.resize(width * this.resolution, height * this.resolution);
var projectionFrame = this.frame || this.size;
this.calculateProjection(projectionFrame);
};
/**
* Destroys the render target.
*
*/
RenderTarget.prototype.destroy = function destroy() {
if (this.frameBuffer.stencil) {
this.gl.deleteRenderbuffer(this.frameBuffer.stencil);
}
this.frameBuffer.destroy();
this.frameBuffer = null;
this.texture = null;
};
return RenderTarget;
}();
exports.default = RenderTarget;
//# sourceMappingURL=RenderTarget.js.map
/***/ }),
/* 88 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = function (graphicsData, webGLData, webGLDataNativeLines) {
if (graphicsData.nativeLines) {
buildNativeLine(graphicsData, webGLDataNativeLines);
} else {
buildLine(graphicsData, webGLData);
}
};
var _math = __webpack_require__(14);
var _utils = __webpack_require__(7);
/**
* Builds a line to draw using the poligon method.
*
* Ignored from docs since it is not directly exposed.
*
* @ignore
* @private
* @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties
* @param {object} webGLData - an object containing all the webGL-specific information to create this shape
*/
function buildLine(graphicsData, webGLData) {
// TODO OPTIMISE!
var points = graphicsData.points;
if (points.length === 0) {
return;
}
// if the line width is an odd number add 0.5 to align to a whole pixel
// commenting this out fixes #711 and #1620
// if (graphicsData.lineWidth%2)
// {
// for (i = 0; i < points.length; i++)
// {
// points[i] += 0.5;
// }
// }
// get first and last point.. figure out the middle!
var firstPoint = new _math.Point(points[0], points[1]);
var lastPoint = new _math.Point(points[points.length - 2], points[points.length - 1]);
// if the first point is the last point - gonna have issues :)
if (firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) {
// need to clone as we are going to slightly modify the shape..
points = points.slice();
points.pop();
points.pop();
lastPoint = new _math.Point(points[points.length - 2], points[points.length - 1]);
var midPointX = lastPoint.x + (firstPoint.x - lastPoint.x) * 0.5;
var midPointY = lastPoint.y + (firstPoint.y - lastPoint.y) * 0.5;
points.unshift(midPointX, midPointY);
points.push(midPointX, midPointY);
}
var verts = webGLData.points;
var indices = webGLData.indices;
var length = points.length / 2;
var indexCount = points.length;
var indexStart = verts.length / 6;
// DRAW the Line
var width = graphicsData.lineWidth / 2;
// sort color
var color = (0, _utils.hex2rgb)(graphicsData.lineColor);
var alpha = graphicsData.lineAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
var p1x = points[0];
var p1y = points[1];
var p2x = points[2];
var p2y = points[3];
var p3x = 0;
var p3y = 0;
var perpx = -(p1y - p2y);
var perpy = p1x - p2x;
var perp2x = 0;
var perp2y = 0;
var perp3x = 0;
var perp3y = 0;
var dist = Math.sqrt(perpx * perpx + perpy * perpy);
perpx /= dist;
perpy /= dist;
perpx *= width;
perpy *= width;
var ratio = graphicsData.lineAlignment; // 0.5;
var r1 = (1 - ratio) * 2;
var r2 = ratio * 2;
// start
verts.push(p1x - perpx * r1, p1y - perpy * r1, r, g, b, alpha);
verts.push(p1x + perpx * r2, p1y + perpy * r2, r, g, b, alpha);
for (var i = 1; i < length - 1; ++i) {
p1x = points[(i - 1) * 2];
p1y = points[(i - 1) * 2 + 1];
p2x = points[i * 2];
p2y = points[i * 2 + 1];
p3x = points[(i + 1) * 2];
p3y = points[(i + 1) * 2 + 1];
perpx = -(p1y - p2y);
perpy = p1x - p2x;
dist = Math.sqrt(perpx * perpx + perpy * perpy);
perpx /= dist;
perpy /= dist;
perpx *= width;
perpy *= width;
perp2x = -(p2y - p3y);
perp2y = p2x - p3x;
dist = Math.sqrt(perp2x * perp2x + perp2y * perp2y);
perp2x /= dist;
perp2y /= dist;
perp2x *= width;
perp2y *= width;
var a1 = -perpy + p1y - (-perpy + p2y);
var b1 = -perpx + p2x - (-perpx + p1x);
var c1 = (-perpx + p1x) * (-perpy + p2y) - (-perpx + p2x) * (-perpy + p1y);
var a2 = -perp2y + p3y - (-perp2y + p2y);
var b2 = -perp2x + p2x - (-perp2x + p3x);
var c2 = (-perp2x + p3x) * (-perp2y + p2y) - (-perp2x + p2x) * (-perp2y + p3y);
var denom = a1 * b2 - a2 * b1;
if (Math.abs(denom) < 0.1) {
denom += 10.1;
verts.push(p2x - perpx * r1, p2y - perpy * r1, r, g, b, alpha);
verts.push(p2x + perpx * r2, p2y + perpy * r2, r, g, b, alpha);
continue;
}
var px = (b1 * c2 - b2 * c1) / denom;
var py = (a2 * c1 - a1 * c2) / denom;
var pdist = (px - p2x) * (px - p2x) + (py - p2y) * (py - p2y);
if (pdist > 196 * width * width) {
perp3x = perpx - perp2x;
perp3y = perpy - perp2y;
dist = Math.sqrt(perp3x * perp3x + perp3y * perp3y);
perp3x /= dist;
perp3y /= dist;
perp3x *= width;
perp3y *= width;
verts.push(p2x - perp3x * r1, p2y - perp3y * r1);
verts.push(r, g, b, alpha);
verts.push(p2x + perp3x * r2, p2y + perp3y * r2);
verts.push(r, g, b, alpha);
verts.push(p2x - perp3x * r2 * r1, p2y - perp3y * r1);
verts.push(r, g, b, alpha);
indexCount++;
} else {
verts.push(p2x + (px - p2x) * r1, p2y + (py - p2y) * r1);
verts.push(r, g, b, alpha);
verts.push(p2x - (px - p2x) * r2, p2y - (py - p2y) * r2);
verts.push(r, g, b, alpha);
}
}
p1x = points[(length - 2) * 2];
p1y = points[(length - 2) * 2 + 1];
p2x = points[(length - 1) * 2];
p2y = points[(length - 1) * 2 + 1];
perpx = -(p1y - p2y);
perpy = p1x - p2x;
dist = Math.sqrt(perpx * perpx + perpy * perpy);
perpx /= dist;
perpy /= dist;
perpx *= width;
perpy *= width;
verts.push(p2x - perpx * r1, p2y - perpy * r1);
verts.push(r, g, b, alpha);
verts.push(p2x + perpx * r2, p2y + perpy * r2);
verts.push(r, g, b, alpha);
indices.push(indexStart);
for (var _i = 0; _i < indexCount; ++_i) {
indices.push(indexStart++);
}
indices.push(indexStart - 1);
}
/**
* Builds a line to draw using the gl.drawArrays(gl.LINES) method
*
* Ignored from docs since it is not directly exposed.
*
* @ignore
* @private
* @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties
* @param {object} webGLData - an object containing all the webGL-specific information to create this shape
*/
/**
* Builds a line to draw
*
* Ignored from docs since it is not directly exposed.
*
* @ignore
* @private
* @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties
* @param {object} webGLData - an object containing all the webGL-specific information to create this shape
* @param {object} webGLDataNativeLines - an object containing all the webGL-specific information to create nativeLines
*/
function buildNativeLine(graphicsData, webGLData) {
var i = 0;
var points = graphicsData.points;
if (points.length === 0) return;
var verts = webGLData.points;
var length = points.length / 2;
// sort color
var color = (0, _utils.hex2rgb)(graphicsData.lineColor);
var alpha = graphicsData.lineAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
for (i = 1; i < length; i++) {
var p1x = points[(i - 1) * 2];
var p1y = points[(i - 1) * 2 + 1];
var p2x = points[i * 2];
var p2y = points[i * 2 + 1];
verts.push(p1x, p1y);
verts.push(r, g, b, alpha);
verts.push(p2x, p2y);
verts.push(r, g, b, alpha);
}
}
//# sourceMappingURL=buildLine.js.map
/***/ }),
/* 89 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(6);
var document = __webpack_require__(2).document;
// typeof document.createElement is 'object' in old IE
var is = isObject(document) && isObject(document.createElement);
module.exports = function (it) {
return is ? document.createElement(it) : {};
};
/***/ }),
/* 90 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(2);
var core = __webpack_require__(24);
var LIBRARY = __webpack_require__(37);
var wksExt = __webpack_require__(134);
var defineProperty = __webpack_require__(11).f;
module.exports = function (name) {
var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
};
/***/ }),
/* 91 */
/***/ (function(module, exports, __webpack_require__) {
var shared = __webpack_require__(59)('keys');
var uid = __webpack_require__(42);
module.exports = function (key) {
return shared[key] || (shared[key] = uid(key));
};
/***/ }),
/* 92 */
/***/ (function(module, exports) {
// IE 8- don't enum bug keys
module.exports = (
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
).split(',');
/***/ }),
/* 93 */
/***/ (function(module, exports, __webpack_require__) {
var document = __webpack_require__(2).document;
module.exports = document && document.documentElement;
/***/ }),
/* 94 */
/***/ (function(module, exports, __webpack_require__) {
// Works with __proto__ only. Old v8 can't work with null proto objects.
/* eslint-disable no-proto */
var isObject = __webpack_require__(6);
var anObject = __webpack_require__(1);
var check = function (O, proto) {
anObject(O);
if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
};
module.exports = {
set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
function (test, buggy, set) {
try {
set = __webpack_require__(25)(Function.call, __webpack_require__(21).f(Object.prototype, '__proto__').set, 2);
set(test, []);
buggy = !(test instanceof Array);
} catch (e) { buggy = true; }
return function setPrototypeOf(O, proto) {
check(O, proto);
if (buggy) O.__proto__ = proto;
else set(O, proto);
return O;
};
}({}, false) : undefined),
check: check
};
/***/ }),
/* 95 */
/***/ (function(module, exports) {
module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
/***/ }),
/* 96 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(6);
var setPrototypeOf = __webpack_require__(94).set;
module.exports = function (that, target, C) {
var S = target.constructor;
var P;
if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
setPrototypeOf(that, P);
} return that;
};
/***/ }),
/* 97 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var toInteger = __webpack_require__(27);
var defined = __webpack_require__(31);
module.exports = function repeat(count) {
var str = String(defined(this));
var res = '';
var n = toInteger(count);
if (n < 0 || n == Infinity) throw RangeError("Count can't be negative");
for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) res += str;
return res;
};
/***/ }),
/* 98 */
/***/ (function(module, exports) {
// 20.2.2.28 Math.sign(x)
module.exports = Math.sign || function sign(x) {
// eslint-disable-next-line no-self-compare
return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
};
/***/ }),
/* 99 */
/***/ (function(module, exports) {
// 20.2.2.14 Math.expm1(x)
var $expm1 = Math.expm1;
module.exports = (!$expm1
// Old FF bug
|| $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168
// Tor Browser bug
|| $expm1(-2e-17) != -2e-17
) ? function expm1(x) {
return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1;
} : $expm1;
/***/ }),
/* 100 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var LIBRARY = __webpack_require__(37);
var $export = __webpack_require__(0);
var redefine = __webpack_require__(17);
var hide = __webpack_require__(16);
var Iterators = __webpack_require__(57);
var $iterCreate = __webpack_require__(101);
var setToStringTag = __webpack_require__(54);
var getPrototypeOf = __webpack_require__(22);
var ITERATOR = __webpack_require__(8)('iterator');
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
var FF_ITERATOR = '@@iterator';
var KEYS = 'keys';
var VALUES = 'values';
var returnThis = function () { return this; };
module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
$iterCreate(Constructor, NAME, next);
var getMethod = function (kind) {
if (!BUGGY && kind in proto) return proto[kind];
switch (kind) {
case KEYS: return function keys() { return new Constructor(this, kind); };
case VALUES: return function values() { return new Constructor(this, kind); };
} return function entries() { return new Constructor(this, kind); };
};
var TAG = NAME + ' Iterator';
var DEF_VALUES = DEFAULT == VALUES;
var VALUES_BUG = false;
var proto = Base.prototype;
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
var $default = $native || getMethod(DEFAULT);
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
var methods, key, IteratorPrototype;
// Fix native
if ($anyNative) {
IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
// Set @@toStringTag to native iterators
setToStringTag(IteratorPrototype, TAG, true);
// fix for some old engines
if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
}
}
// fix Array#{values, @@iterator}.name in V8 / FF
if (DEF_VALUES && $native && $native.name !== VALUES) {
VALUES_BUG = true;
$default = function values() { return $native.call(this); };
}
// Define iterator
if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
hide(proto, ITERATOR, $default);
}
// Plug for library
Iterators[NAME] = $default;
Iterators[TAG] = returnThis;
if (DEFAULT) {
methods = {
values: DEF_VALUES ? $default : getMethod(VALUES),
keys: IS_SET ? $default : getMethod(KEYS),
entries: $entries
};
if (FORCED) for (key in methods) {
if (!(key in proto)) redefine(proto, key, methods[key]);
} else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
}
return methods;
};
/***/ }),
/* 101 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var create = __webpack_require__(45);
var descriptor = __webpack_require__(41);
var setToStringTag = __webpack_require__(54);
var IteratorPrototype = {};
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
__webpack_require__(16)(IteratorPrototype, __webpack_require__(8)('iterator'), function () { return this; });
module.exports = function (Constructor, NAME, next) {
Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
setToStringTag(Constructor, NAME + ' Iterator');
};
/***/ }),
/* 102 */
/***/ (function(module, exports, __webpack_require__) {
// helper for String#{startsWith, endsWith, includes}
var isRegExp = __webpack_require__(74);
var defined = __webpack_require__(31);
module.exports = function (that, searchString, NAME) {
if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
return String(defined(that));
};
/***/ }),
/* 103 */
/***/ (function(module, exports, __webpack_require__) {
var MATCH = __webpack_require__(8)('match');
module.exports = function (KEY) {
var re = /./;
try {
'/./'[KEY](re);
} catch (e) {
try {
re[MATCH] = false;
return !'/./'[KEY](re);
} catch (f) { /* empty */ }
} return true;
};
/***/ }),
/* 104 */
/***/ (function(module, exports, __webpack_require__) {
// check on default Array iterator
var Iterators = __webpack_require__(57);
var ITERATOR = __webpack_require__(8)('iterator');
var ArrayProto = Array.prototype;
module.exports = function (it) {
return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
};
/***/ }),
/* 105 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $defineProperty = __webpack_require__(11);
var createDesc = __webpack_require__(41);
module.exports = function (object, index, value) {
if (index in object) $defineProperty.f(object, index, createDesc(0, value));
else object[index] = value;
};
/***/ }),
/* 106 */
/***/ (function(module, exports, __webpack_require__) {
var classof = __webpack_require__(55);
var ITERATOR = __webpack_require__(8)('iterator');
var Iterators = __webpack_require__(57);
module.exports = __webpack_require__(24).getIteratorMethod = function (it) {
if (it != undefined) return it[ITERATOR]
|| it['@@iterator']
|| Iterators[classof(it)];
};
/***/ }),
/* 107 */
/***/ (function(module, exports, __webpack_require__) {
// 9.4.2.3 ArraySpeciesCreate(originalArray, length)
var speciesConstructor = __webpack_require__(321);
module.exports = function (original, length) {
return new (speciesConstructor(original))(length);
};
/***/ }),
/* 108 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
var toObject = __webpack_require__(12);
var toAbsoluteIndex = __webpack_require__(44);
var toLength = __webpack_require__(9);
module.exports = function fill(value /* , start = 0, end = @length */) {
var O = toObject(this);
var length = toLength(O.length);
var aLen = arguments.length;
var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length);
var end = aLen > 2 ? arguments[2] : undefined;
var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
while (endPos > index) O[index++] = value;
return O;
};
/***/ }),
/* 109 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var addToUnscopables = __webpack_require__(39);
var step = __webpack_require__(151);
var Iterators = __webpack_require__(57);
var toIObject = __webpack_require__(20);
// 22.1.3.4 Array.prototype.entries()
// 22.1.3.13 Array.prototype.keys()
// 22.1.3.29 Array.prototype.values()
// 22.1.3.30 Array.prototype[@@iterator]()
module.exports = __webpack_require__(100)(Array, 'Array', function (iterated, kind) {
this._t = toIObject(iterated); // target
this._i = 0; // next index
this._k = kind; // kind
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
}, function () {
var O = this._t;
var kind = this._k;
var index = this._i++;
if (!O || index >= O.length) {
this._t = undefined;
return step(1);
}
if (kind == 'keys') return step(0, index);
if (kind == 'values') return step(0, O[index]);
return step(0, [index, O[index]]);
}, 'values');
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
Iterators.Arguments = Iterators.Array;
addToUnscopables('keys');
addToUnscopables('values');
addToUnscopables('entries');
/***/ }),
/* 110 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var regexpFlags = __webpack_require__(62);
var nativeExec = RegExp.prototype.exec;
// This always refers to the native implementation, because the
// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
// which loads this file before patching the method.
var nativeReplace = String.prototype.replace;
var patchedExec = nativeExec;
var LAST_INDEX = 'lastIndex';
var UPDATES_LAST_INDEX_WRONG = (function () {
var re1 = /a/,
re2 = /b*/g;
nativeExec.call(re1, 'a');
nativeExec.call(re2, 'a');
return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0;
})();
// nonparticipating capturing group, copied from es5-shim's String#split patch.
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
if (PATCH) {
patchedExec = function exec(str) {
var re = this;
var lastIndex, reCopy, match, i;
if (NPCG_INCLUDED) {
reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
}
if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX];
match = nativeExec.call(re, str);
if (UPDATES_LAST_INDEX_WRONG && match) {
re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex;
}
if (NPCG_INCLUDED && match && match.length > 1) {
// Fix browsers whose `exec` methods don't consistently return `undefined`
// for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
// eslint-disable-next-line no-loop-func
nativeReplace.call(match[0], reCopy, function () {
for (i = 1; i < arguments.length - 2; i++) {
if (arguments[i] === undefined) match[i] = undefined;
}
});
}
return match;
};
}
module.exports = patchedExec;
/***/ }),
/* 111 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var at = __webpack_require__(73)(true);
// `AdvanceStringIndex` abstract operation
// https://tc39.github.io/ecma262/#sec-advancestringindex
module.exports = function (S, index, unicode) {
return index + (unicode ? at(S, index).length : 1);
};
/***/ }),
/* 112 */
/***/ (function(module, exports, __webpack_require__) {
var ctx = __webpack_require__(25);
var invoke = __webpack_require__(141);
var html = __webpack_require__(93);
var cel = __webpack_require__(89);
var global = __webpack_require__(2);
var process = global.process;
var setTask = global.setImmediate;
var clearTask = global.clearImmediate;
var MessageChannel = global.MessageChannel;
var Dispatch = global.Dispatch;
var counter = 0;
var queue = {};
var ONREADYSTATECHANGE = 'onreadystatechange';
var defer, channel, port;
var run = function () {
var id = +this;
// eslint-disable-next-line no-prototype-builtins
if (queue.hasOwnProperty(id)) {
var fn = queue[id];
delete queue[id];
fn();
}
};
var listener = function (event) {
run.call(event.data);
};
// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
if (!setTask || !clearTask) {
setTask = function setImmediate(fn) {
var args = [];
var i = 1;
while (arguments.length > i) args.push(arguments[i++]);
queue[++counter] = function () {
// eslint-disable-next-line no-new-func
invoke(typeof fn == 'function' ? fn : Function(fn), args);
};
defer(counter);
return counter;
};
clearTask = function clearImmediate(id) {
delete queue[id];
};
// Node.js 0.8-
if (__webpack_require__(26)(process) == 'process') {
defer = function (id) {
process.nextTick(ctx(run, id, 1));
};
// Sphere (JS game engine) Dispatch API
} else if (Dispatch && Dispatch.now) {
defer = function (id) {
Dispatch.now(ctx(run, id, 1));
};
// Browsers with MessageChannel, includes WebWorkers
} else if (MessageChannel) {
channel = new MessageChannel();
port = channel.port2;
channel.port1.onmessage = listener;
defer = ctx(port.postMessage, port, 1);
// Browsers with postMessage, skip WebWorkers
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
} else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
defer = function (id) {
global.postMessage(id + '', '*');
};
global.addEventListener('message', listener, false);
// IE8-
} else if (ONREADYSTATECHANGE in cel('script')) {
defer = function (id) {
html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
html.removeChild(this);
run.call(id);
};
};
// Rest old browsers
} else {
defer = function (id) {
setTimeout(ctx(run, id, 1), 0);
};
}
}
module.exports = {
set: setTask,
clear: clearTask
};
/***/ }),
/* 113 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(2);
var macrotask = __webpack_require__(112).set;
var Observer = global.MutationObserver || global.WebKitMutationObserver;
var process = global.process;
var Promise = global.Promise;
var isNode = __webpack_require__(26)(process) == 'process';
module.exports = function () {
var head, last, notify;
var flush = function () {
var parent, fn;
if (isNode && (parent = process.domain)) parent.exit();
while (head) {
fn = head.fn;
head = head.next;
try {
fn();
} catch (e) {
if (head) notify();
else last = undefined;
throw e;
}
} last = undefined;
if (parent) parent.enter();
};
// Node.js
if (isNode) {
notify = function () {
process.nextTick(flush);
};
// browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
} else if (Observer && !(global.navigator && global.navigator.standalone)) {
var toggle = true;
var node = document.createTextNode('');
new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
notify = function () {
node.data = toggle = !toggle;
};
// environments with maybe non-completely correct, but existent Promise
} else if (Promise && Promise.resolve) {
// Promise.resolve without an argument throws an error in LG WebOS 2
var promise = Promise.resolve(undefined);
notify = function () {
promise.then(flush);
};
// for other environments - macrotask based on:
// - setImmediate
// - MessageChannel
// - window.postMessag
// - onreadystatechange
// - setTimeout
} else {
notify = function () {
// strange IE + webpack dev server bug - use .call(global)
macrotask.call(global, flush);
};
}
return function (fn) {
var task = { fn: fn, next: undefined };
if (last) last.next = task;
if (!head) {
head = task;
notify();
} last = task;
};
};
/***/ }),
/* 114 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 25.4.1.5 NewPromiseCapability(C)
var aFunction = __webpack_require__(15);
function PromiseCapability(C) {
var resolve, reject;
this.promise = new C(function ($$resolve, $$reject) {
if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
resolve = $$resolve;
reject = $$reject;
});
this.resolve = aFunction(resolve);
this.reject = aFunction(reject);
}
module.exports.f = function (C) {
return new PromiseCapability(C);
};
/***/ }),
/* 115 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var global = __webpack_require__(2);
var DESCRIPTORS = __webpack_require__(10);
var LIBRARY = __webpack_require__(37);
var $typed = __webpack_require__(80);
var hide = __webpack_require__(16);
var redefineAll = __webpack_require__(50);
var fails = __webpack_require__(4);
var anInstance = __webpack_require__(48);
var toInteger = __webpack_require__(27);
var toLength = __webpack_require__(9);
var toIndex = __webpack_require__(161);
var gOPN = __webpack_require__(46).f;
var dP = __webpack_require__(11).f;
var arrayFill = __webpack_require__(108);
var setToStringTag = __webpack_require__(54);
var ARRAY_BUFFER = 'ArrayBuffer';
var DATA_VIEW = 'DataView';
var PROTOTYPE = 'prototype';
var WRONG_LENGTH = 'Wrong length!';
var WRONG_INDEX = 'Wrong index!';
var $ArrayBuffer = global[ARRAY_BUFFER];
var $DataView = global[DATA_VIEW];
var Math = global.Math;
var RangeError = global.RangeError;
// eslint-disable-next-line no-shadow-restricted-names
var Infinity = global.Infinity;
var BaseBuffer = $ArrayBuffer;
var abs = Math.abs;
var pow = Math.pow;
var floor = Math.floor;
var log = Math.log;
var LN2 = Math.LN2;
var BUFFER = 'buffer';
var BYTE_LENGTH = 'byteLength';
var BYTE_OFFSET = 'byteOffset';
var $BUFFER = DESCRIPTORS ? '_b' : BUFFER;
var $LENGTH = DESCRIPTORS ? '_l' : BYTE_LENGTH;
var $OFFSET = DESCRIPTORS ? '_o' : BYTE_OFFSET;
// IEEE754 conversions based on https://github.com/feross/ieee754
function packIEEE754(value, mLen, nBytes) {
var buffer = new Array(nBytes);
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0;
var i = 0;
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
var e, m, c;
value = abs(value);
// eslint-disable-next-line no-self-compare
if (value != value || value === Infinity) {
// eslint-disable-next-line no-self-compare
m = value != value ? 1 : 0;
e = eMax;
} else {
e = floor(log(value) / LN2);
if (value * (c = pow(2, -e)) < 1) {
e--;
c *= 2;
}
if (e + eBias >= 1) {
value += rt / c;
} else {
value += rt * pow(2, 1 - eBias);
}
if (value * c >= 2) {
e++;
c /= 2;
}
if (e + eBias >= eMax) {
m = 0;
e = eMax;
} else if (e + eBias >= 1) {
m = (value * c - 1) * pow(2, mLen);
e = e + eBias;
} else {
m = value * pow(2, eBias - 1) * pow(2, mLen);
e = 0;
}
}
for (; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8);
e = e << mLen | m;
eLen += mLen;
for (; eLen > 0; buffer[i++] = e & 255, e /= 256, eLen -= 8);
buffer[--i] |= s * 128;
return buffer;
}
function unpackIEEE754(buffer, mLen, nBytes) {
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var nBits = eLen - 7;
var i = nBytes - 1;
var s = buffer[i--];
var e = s & 127;
var m;
s >>= 7;
for (; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8);
m = e & (1 << -nBits) - 1;
e >>= -nBits;
nBits += mLen;
for (; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8);
if (e === 0) {
e = 1 - eBias;
} else if (e === eMax) {
return m ? NaN : s ? -Infinity : Infinity;
} else {
m = m + pow(2, mLen);
e = e - eBias;
} return (s ? -1 : 1) * m * pow(2, e - mLen);
}
function unpackI32(bytes) {
return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
}
function packI8(it) {
return [it & 0xff];
}
function packI16(it) {
return [it & 0xff, it >> 8 & 0xff];
}
function packI32(it) {
return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff];
}
function packF64(it) {
return packIEEE754(it, 52, 8);
}
function packF32(it) {
return packIEEE754(it, 23, 4);
}
function addGetter(C, key, internal) {
dP(C[PROTOTYPE], key, { get: function () { return this[internal]; } });
}
function get(view, bytes, index, isLittleEndian) {
var numIndex = +index;
var intIndex = toIndex(numIndex);
if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);
var store = view[$BUFFER]._b;
var start = intIndex + view[$OFFSET];
var pack = store.slice(start, start + bytes);
return isLittleEndian ? pack : pack.reverse();
}
function set(view, bytes, index, conversion, value, isLittleEndian) {
var numIndex = +index;
var intIndex = toIndex(numIndex);
if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);
var store = view[$BUFFER]._b;
var start = intIndex + view[$OFFSET];
var pack = conversion(+value);
for (var i = 0; i < bytes; i++) store[start + i] = pack[isLittleEndian ? i : bytes - i - 1];
}
if (!$typed.ABV) {
$ArrayBuffer = function ArrayBuffer(length) {
anInstance(this, $ArrayBuffer, ARRAY_BUFFER);
var byteLength = toIndex(length);
this._b = arrayFill.call(new Array(byteLength), 0);
this[$LENGTH] = byteLength;
};
$DataView = function DataView(buffer, byteOffset, byteLength) {
anInstance(this, $DataView, DATA_VIEW);
anInstance(buffer, $ArrayBuffer, DATA_VIEW);
var bufferLength = buffer[$LENGTH];
var offset = toInteger(byteOffset);
if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset!');
byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);
if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);
this[$BUFFER] = buffer;
this[$OFFSET] = offset;
this[$LENGTH] = byteLength;
};
if (DESCRIPTORS) {
addGetter($ArrayBuffer, BYTE_LENGTH, '_l');
addGetter($DataView, BUFFER, '_b');
addGetter($DataView, BYTE_LENGTH, '_l');
addGetter($DataView, BYTE_OFFSET, '_o');
}
redefineAll($DataView[PROTOTYPE], {
getInt8: function getInt8(byteOffset) {
return get(this, 1, byteOffset)[0] << 24 >> 24;
},
getUint8: function getUint8(byteOffset) {
return get(this, 1, byteOffset)[0];
},
getInt16: function getInt16(byteOffset /* , littleEndian */) {
var bytes = get(this, 2, byteOffset, arguments[1]);
return (bytes[1] << 8 | bytes[0]) << 16 >> 16;
},
getUint16: function getUint16(byteOffset /* , littleEndian */) {
var bytes = get(this, 2, byteOffset, arguments[1]);
return bytes[1] << 8 | bytes[0];
},
getInt32: function getInt32(byteOffset /* , littleEndian */) {
return unpackI32(get(this, 4, byteOffset, arguments[1]));
},
getUint32: function getUint32(byteOffset /* , littleEndian */) {
return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0;
},
getFloat32: function getFloat32(byteOffset /* , littleEndian */) {
return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4);
},
getFloat64: function getFloat64(byteOffset /* , littleEndian */) {
return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8);
},
setInt8: function setInt8(byteOffset, value) {
set(this, 1, byteOffset, packI8, value);
},
setUint8: function setUint8(byteOffset, value) {
set(this, 1, byteOffset, packI8, value);
},
setInt16: function setInt16(byteOffset, value /* , littleEndian */) {
set(this, 2, byteOffset, packI16, value, arguments[2]);
},
setUint16: function setUint16(byteOffset, value /* , littleEndian */) {
set(this, 2, byteOffset, packI16, value, arguments[2]);
},
setInt32: function setInt32(byteOffset, value /* , littleEndian */) {
set(this, 4, byteOffset, packI32, value, arguments[2]);
},
setUint32: function setUint32(byteOffset, value /* , littleEndian */) {
set(this, 4, byteOffset, packI32, value, arguments[2]);
},
setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) {
set(this, 4, byteOffset, packF32, value, arguments[2]);
},
setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) {
set(this, 8, byteOffset, packF64, value, arguments[2]);
}
});
} else {
if (!fails(function () {
$ArrayBuffer(1);
}) || !fails(function () {
new $ArrayBuffer(-1); // eslint-disable-line no-new
}) || fails(function () {
new $ArrayBuffer(); // eslint-disable-line no-new
new $ArrayBuffer(1.5); // eslint-disable-line no-new
new $ArrayBuffer(NaN); // eslint-disable-line no-new
return $ArrayBuffer.name != ARRAY_BUFFER;
})) {
$ArrayBuffer = function ArrayBuffer(length) {
anInstance(this, $ArrayBuffer);
return new BaseBuffer(toIndex(length));
};
var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE];
for (var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j;) {
if (!((key = keys[j++]) in $ArrayBuffer)) hide($ArrayBuffer, key, BaseBuffer[key]);
}
if (!LIBRARY) ArrayBufferProto.constructor = $ArrayBuffer;
}
// iOS Safari 7.x bug
var view = new $DataView(new $ArrayBuffer(2));
var $setInt8 = $DataView[PROTOTYPE].setInt8;
view.setInt8(0, 2147483648);
view.setInt8(1, 2147483649);
if (view.getInt8(0) || !view.getInt8(1)) redefineAll($DataView[PROTOTYPE], {
setInt8: function setInt8(byteOffset, value) {
$setInt8.call(this, byteOffset, value << 24 >> 24);
},
setUint8: function setUint8(byteOffset, value) {
$setInt8.call(this, byteOffset, value << 24 >> 24);
}
}, true);
}
setToStringTag($ArrayBuffer, ARRAY_BUFFER);
setToStringTag($DataView, DATA_VIEW);
hide($DataView[PROTOTYPE], $typed.VIEW, true);
exports[ARRAY_BUFFER] = $ArrayBuffer;
exports[DATA_VIEW] = $DataView;
/***/ }),
/* 116 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(global) {
exports.__esModule = true;
exports.loader = exports.prepare = exports.particles = exports.mesh = exports.loaders = exports.interaction = exports.filters = exports.extras = exports.extract = exports.accessibility = undefined;
var _polyfill = __webpack_require__(435);
Object.keys(_polyfill).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _polyfill[key];
}
});
});
var _core = __webpack_require__(5);
Object.keys(_core).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _core[key];
}
});
});
var _deprecation = __webpack_require__(497);
var _deprecation2 = _interopRequireDefault(_deprecation);
var _accessibility = __webpack_require__(498);
var accessibility = _interopRequireWildcard(_accessibility);
var _extract = __webpack_require__(500);
var extract = _interopRequireWildcard(_extract);
var _extras = __webpack_require__(202);
var extras = _interopRequireWildcard(_extras);
var _filters = __webpack_require__(510);
var filters = _interopRequireWildcard(_filters);
var _interaction = __webpack_require__(517);
var interaction = _interopRequireWildcard(_interaction);
var _loaders = __webpack_require__(519);
var loaders = _interopRequireWildcard(_loaders);
var _mesh = __webpack_require__(523);
var mesh = _interopRequireWildcard(_mesh);
var _particles = __webpack_require__(528);
var particles = _interopRequireWildcard(_particles);
var _prepare = __webpack_require__(533);
var prepare = _interopRequireWildcard(_prepare);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// export core
_core.utils.mixins.performMixins();
/**
* Alias for {@link PIXI.loaders.shared}.
* @name loader
* @memberof PIXI
* @type {PIXI.loader.Loader}
*/
// handle mixins now, after all code has been added, including deprecation
// export libs
// import polyfills. Done as an export to make sure polyfills are imported first
var loader = loaders.shared || null;
exports.accessibility = accessibility;
exports.extract = extract;
exports.extras = extras;
exports.filters = filters;
exports.interaction = interaction;
exports.loaders = loaders;
exports.mesh = mesh;
exports.particles = particles;
exports.prepare = prepare;
exports.loader = loader;
// Apply the deprecations
if (typeof _deprecation2.default === 'function') {
(0, _deprecation2.default)(exports);
}
// Always export PixiJS globally.
global.PIXI = exports; // eslint-disable-line
//# sourceMappingURL=index.js.map
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(53)))
/***/ }),
/* 117 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* The Point object represents a location in a two-dimensional coordinate system, where x represents
* the horizontal axis and y represents the vertical axis.
*
* @class
* @memberof PIXI
*/
var Point = function () {
/**
* @param {number} [x=0] - position of the point on the x axis
* @param {number} [y=0] - position of the point on the y axis
*/
function Point() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
_classCallCheck(this, Point);
/**
* @member {number}
* @default 0
*/
this.x = x;
/**
* @member {number}
* @default 0
*/
this.y = y;
}
/**
* Creates a clone of this point
*
* @return {PIXI.Point} a copy of the point
*/
Point.prototype.clone = function clone() {
return new Point(this.x, this.y);
};
/**
* Copies x and y from the given point
*
* @param {PIXI.Point} p - The point to copy.
*/
Point.prototype.copy = function copy(p) {
this.set(p.x, p.y);
};
/**
* Returns true if the given point is equal to this point
*
* @param {PIXI.Point} p - The point to check
* @returns {boolean} Whether the given point equal to this point
*/
Point.prototype.equals = function equals(p) {
return p.x === this.x && p.y === this.y;
};
/**
* Sets the point to a new x and y position.
* If y is omitted, both x and y will be set to x.
*
* @param {number} [x=0] - position of the point on the x axis
* @param {number} [y=0] - position of the point on the y axis
*/
Point.prototype.set = function set(x, y) {
this.x = x || 0;
this.y = y || (y !== 0 ? this.x : 0);
};
return Point;
}();
exports.default = Point;
//# sourceMappingURL=Point.js.map
/***/ }),
/* 118 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _Point = __webpack_require__(117);
var _Point2 = _interopRequireDefault(_Point);
var _const = __webpack_require__(3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* The PixiJS Matrix class as an object, which makes it a lot faster,
* here is a representation of it :
* | a | c | tx|
* | b | d | ty|
* | 0 | 0 | 1 |
*
* @class
* @memberof PIXI
*/
var Matrix = function () {
/**
* @param {number} [a=1] - x scale
* @param {number} [b=0] - x skew
* @param {number} [c=0] - y skew
* @param {number} [d=1] - y scale
* @param {number} [tx=0] - x translation
* @param {number} [ty=0] - y translation
*/
function Matrix() {
var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var c = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var d = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
var tx = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
var ty = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
_classCallCheck(this, Matrix);
/**
* @member {number}
* @default 1
*/
this.a = a;
/**
* @member {number}
* @default 0
*/
this.b = b;
/**
* @member {number}
* @default 0
*/
this.c = c;
/**
* @member {number}
* @default 1
*/
this.d = d;
/**
* @member {number}
* @default 0
*/
this.tx = tx;
/**
* @member {number}
* @default 0
*/
this.ty = ty;
this.array = null;
}
/**
* Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
*
* a = array[0]
* b = array[1]
* c = array[3]
* d = array[4]
* tx = array[2]
* ty = array[5]
*
* @param {number[]} array - The array that the matrix will be populated from.
*/
Matrix.prototype.fromArray = function fromArray(array) {
this.a = array[0];
this.b = array[1];
this.c = array[3];
this.d = array[4];
this.tx = array[2];
this.ty = array[5];
};
/**
* sets the matrix properties
*
* @param {number} a - Matrix component
* @param {number} b - Matrix component
* @param {number} c - Matrix component
* @param {number} d - Matrix component
* @param {number} tx - Matrix component
* @param {number} ty - Matrix component
*
* @return {PIXI.Matrix} This matrix. Good for chaining method calls.
*/
Matrix.prototype.set = function set(a, b, c, d, tx, ty) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.tx = tx;
this.ty = ty;
return this;
};
/**
* Creates an array from the current Matrix object.
*
* @param {boolean} transpose - Whether we need to transpose the matrix or not
* @param {Float32Array} [out=new Float32Array(9)] - If provided the array will be assigned to out
* @return {number[]} the newly created array which contains the matrix
*/
Matrix.prototype.toArray = function toArray(transpose, out) {
if (!this.array) {
this.array = new Float32Array(9);
}
var array = out || this.array;
if (transpose) {
array[0] = this.a;
array[1] = this.b;
array[2] = 0;
array[3] = this.c;
array[4] = this.d;
array[5] = 0;
array[6] = this.tx;
array[7] = this.ty;
array[8] = 1;
} else {
array[0] = this.a;
array[1] = this.c;
array[2] = this.tx;
array[3] = this.b;
array[4] = this.d;
array[5] = this.ty;
array[6] = 0;
array[7] = 0;
array[8] = 1;
}
return array;
};
/**
* Get a new position with the current transformation applied.
* Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)
*
* @param {PIXI.Point} pos - The origin
* @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
* @return {PIXI.Point} The new point, transformed through this matrix
*/
Matrix.prototype.apply = function apply(pos, newPos) {
newPos = newPos || new _Point2.default();
var x = pos.x;
var y = pos.y;
newPos.x = this.a * x + this.c * y + this.tx;
newPos.y = this.b * x + this.d * y + this.ty;
return newPos;
};
/**
* Get a new position with the inverse of the current transformation applied.
* Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)
*
* @param {PIXI.Point} pos - The origin
* @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
* @return {PIXI.Point} The new point, inverse-transformed through this matrix
*/
Matrix.prototype.applyInverse = function applyInverse(pos, newPos) {
newPos = newPos || new _Point2.default();
var id = 1 / (this.a * this.d + this.c * -this.b);
var x = pos.x;
var y = pos.y;
newPos.x = this.d * id * x + -this.c * id * y + (this.ty * this.c - this.tx * this.d) * id;
newPos.y = this.a * id * y + -this.b * id * x + (-this.ty * this.a + this.tx * this.b) * id;
return newPos;
};
/**
* Translates the matrix on the x and y.
*
* @param {number} x How much to translate x by
* @param {number} y How much to translate y by
* @return {PIXI.Matrix} This matrix. Good for chaining method calls.
*/
Matrix.prototype.translate = function translate(x, y) {
this.tx += x;
this.ty += y;
return this;
};
/**
* Applies a scale transformation to the matrix.
*
* @param {number} x The amount to scale horizontally
* @param {number} y The amount to scale vertically
* @return {PIXI.Matrix} This matrix. Good for chaining method calls.
*/
Matrix.prototype.scale = function scale(x, y) {
this.a *= x;
this.d *= y;
this.c *= x;
this.b *= y;
this.tx *= x;
this.ty *= y;
return this;
};
/**
* Applies a rotation transformation to the matrix.
*
* @param {number} angle - The angle in radians.
* @return {PIXI.Matrix} This matrix. Good for chaining method calls.
*/
Matrix.prototype.rotate = function rotate(angle) {
var cos = Math.cos(angle);
var sin = Math.sin(angle);
var a1 = this.a;
var c1 = this.c;
var tx1 = this.tx;
this.a = a1 * cos - this.b * sin;
this.b = a1 * sin + this.b * cos;
this.c = c1 * cos - this.d * sin;
this.d = c1 * sin + this.d * cos;
this.tx = tx1 * cos - this.ty * sin;
this.ty = tx1 * sin + this.ty * cos;
return this;
};
/**
* Appends the given Matrix to this Matrix.
*
* @param {PIXI.Matrix} matrix - The matrix to append.
* @return {PIXI.Matrix} This matrix. Good for chaining method calls.
*/
Matrix.prototype.append = function append(matrix) {
var a1 = this.a;
var b1 = this.b;
var c1 = this.c;
var d1 = this.d;
this.a = matrix.a * a1 + matrix.b * c1;
this.b = matrix.a * b1 + matrix.b * d1;
this.c = matrix.c * a1 + matrix.d * c1;
this.d = matrix.c * b1 + matrix.d * d1;
this.tx = matrix.tx * a1 + matrix.ty * c1 + this.tx;
this.ty = matrix.tx * b1 + matrix.ty * d1 + this.ty;
return this;
};
/**
* Sets the matrix based on all the available properties
*
* @param {number} x - Position on the x axis
* @param {number} y - Position on the y axis
* @param {number} pivotX - Pivot on the x axis
* @param {number} pivotY - Pivot on the y axis
* @param {number} scaleX - Scale on the x axis
* @param {number} scaleY - Scale on the y axis
* @param {number} rotation - Rotation in radians
* @param {number} skewX - Skew on the x axis
* @param {number} skewY - Skew on the y axis
* @return {PIXI.Matrix} This matrix. Good for chaining method calls.
*/
Matrix.prototype.setTransform = function setTransform(x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) {
this.a = Math.cos(rotation + skewY) * scaleX;
this.b = Math.sin(rotation + skewY) * scaleX;
this.c = -Math.sin(rotation - skewX) * scaleY;
this.d = Math.cos(rotation - skewX) * scaleY;
this.tx = x - (pivotX * this.a + pivotY * this.c);
this.ty = y - (pivotX * this.b + pivotY * this.d);
return this;
};
/**
* Prepends the given Matrix to this Matrix.
*
* @param {PIXI.Matrix} matrix - The matrix to prepend
* @return {PIXI.Matrix} This matrix. Good for chaining method calls.
*/
Matrix.prototype.prepend = function prepend(matrix) {
var tx1 = this.tx;
if (matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1) {
var a1 = this.a;
var c1 = this.c;
this.a = a1 * matrix.a + this.b * matrix.c;
this.b = a1 * matrix.b + this.b * matrix.d;
this.c = c1 * matrix.a + this.d * matrix.c;
this.d = c1 * matrix.b + this.d * matrix.d;
}
this.tx = tx1 * matrix.a + this.ty * matrix.c + matrix.tx;
this.ty = tx1 * matrix.b + this.ty * matrix.d + matrix.ty;
return this;
};
/**
* Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
*
* @param {PIXI.Transform|PIXI.TransformStatic} transform - The transform to apply the properties to.
* @return {PIXI.Transform|PIXI.TransformStatic} The transform with the newly applied properties
*/
Matrix.prototype.decompose = function decompose(transform) {
// sort out rotation / skew..
var a = this.a;
var b = this.b;
var c = this.c;
var d = this.d;
var skewX = -Math.atan2(-c, d);
var skewY = Math.atan2(b, a);
var delta = Math.abs(skewX + skewY);
if (delta < 0.00001 || Math.abs(_const.PI_2 - delta) < 0.00001) {
transform.rotation = skewY;
transform.skew.x = transform.skew.y = 0;
} else {
transform.rotation = 0;
transform.skew.x = skewX;
transform.skew.y = skewY;
}
// next set scale
transform.scale.x = Math.sqrt(a * a + b * b);
transform.scale.y = Math.sqrt(c * c + d * d);
// next set position
transform.position.x = this.tx;
transform.position.y = this.ty;
return transform;
};
/**
* Inverts this matrix
*
* @return {PIXI.Matrix} This matrix. Good for chaining method calls.
*/
Matrix.prototype.invert = function invert() {
var a1 = this.a;
var b1 = this.b;
var c1 = this.c;
var d1 = this.d;
var tx1 = this.tx;
var n = a1 * d1 - b1 * c1;
this.a = d1 / n;
this.b = -b1 / n;
this.c = -c1 / n;
this.d = a1 / n;
this.tx = (c1 * this.ty - d1 * tx1) / n;
this.ty = -(a1 * this.ty - b1 * tx1) / n;
return this;
};
/**
* Resets this Matix to an identity (default) matrix.
*
* @return {PIXI.Matrix} This matrix. Good for chaining method calls.
*/
Matrix.prototype.identity = function identity() {
this.a = 1;
this.b = 0;
this.c = 0;
this.d = 1;
this.tx = 0;
this.ty = 0;
return this;
};
/**
* Creates a new Matrix object with the same values as this one.
*
* @return {PIXI.Matrix} A copy of this matrix. Good for chaining method calls.
*/
Matrix.prototype.clone = function clone() {
var matrix = new Matrix();
matrix.a = this.a;
matrix.b = this.b;
matrix.c = this.c;
matrix.d = this.d;
matrix.tx = this.tx;
matrix.ty = this.ty;
return matrix;
};
/**
* Changes the values of the given matrix to be the same as the ones in this matrix
*
* @param {PIXI.Matrix} matrix - The matrix to copy from.
* @return {PIXI.Matrix} The matrix given in parameter with its values updated.
*/
Matrix.prototype.copy = function copy(matrix) {
matrix.a = this.a;
matrix.b = this.b;
matrix.c = this.c;
matrix.d = this.d;
matrix.tx = this.tx;
matrix.ty = this.ty;
return matrix;
};
/**
* A default (identity) matrix
*
* @static
* @const
*/
_createClass(Matrix, null, [{
key: 'IDENTITY',
get: function get() {
return new Matrix();
}
/**
* A temp matrix
*
* @static
* @const
*/
}, {
key: 'TEMP_MATRIX',
get: function get() {
return new Matrix();
}
}]);
return Matrix;
}();
exports.default = Matrix;
//# sourceMappingURL=Matrix.js.map
/***/ }),
/* 119 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _const = __webpack_require__(3);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Rectangle object is an area defined by its position, as indicated by its top-left corner
* point (x, y) and by its width and its height.
*
* @class
* @memberof PIXI
*/
var Rectangle = function () {
/**
* @param {number} [x=0] - The X coordinate of the upper-left corner of the rectangle
* @param {number} [y=0] - The Y coordinate of the upper-left corner of the rectangle
* @param {number} [width=0] - The overall width of this rectangle
* @param {number} [height=0] - The overall height of this rectangle
*/
function Rectangle() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var width = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var height = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
_classCallCheck(this, Rectangle);
/**
* @member {number}
* @default 0
*/
this.x = Number(x);
/**
* @member {number}
* @default 0
*/
this.y = Number(y);
/**
* @member {number}
* @default 0
*/
this.width = Number(width);
/**
* @member {number}
* @default 0
*/
this.height = Number(height);
/**
* The type of the object, mainly used to avoid `instanceof` checks
*
* @member {number}
* @readOnly
* @default PIXI.SHAPES.RECT
* @see PIXI.SHAPES
*/
this.type = _const.SHAPES.RECT;
}
/**
* returns the left edge of the rectangle
*
* @member {number}
*/
/**
* Creates a clone of this Rectangle
*
* @return {PIXI.Rectangle} a copy of the rectangle
*/
Rectangle.prototype.clone = function clone() {
return new Rectangle(this.x, this.y, this.width, this.height);
};
/**
* Copies another rectangle to this one.
*
* @param {PIXI.Rectangle} rectangle - The rectangle to copy.
* @return {PIXI.Rectangle} Returns itself.
*/
Rectangle.prototype.copy = function copy(rectangle) {
this.x = rectangle.x;
this.y = rectangle.y;
this.width = rectangle.width;
this.height = rectangle.height;
return this;
};
/**
* Checks whether the x and y coordinates given are contained within this Rectangle
*
* @param {number} x - The X coordinate of the point to test
* @param {number} y - The Y coordinate of the point to test
* @return {boolean} Whether the x/y coordinates are within this Rectangle
*/
Rectangle.prototype.contains = function contains(x, y) {
if (this.width <= 0 || this.height <= 0) {
return false;
}
if (x >= this.x && x < this.x + this.width) {
if (y >= this.y && y < this.y + this.height) {
return true;
}
}
return false;
};
/**
* Pads the rectangle making it grow in all directions.
*
* @param {number} paddingX - The horizontal padding amount.
* @param {number} [paddingY] - The vertical padding amount.
*/
Rectangle.prototype.pad = function pad(paddingX, paddingY) {
paddingX = paddingX || 0;
paddingY = paddingY || (paddingY !== 0 ? paddingX : 0);
this.x -= paddingX;
this.y -= paddingY;
this.width += paddingX * 2;
this.height += paddingY * 2;
};
/**
* Fits this rectangle around the passed one.
*
* @param {PIXI.Rectangle} rectangle - The rectangle to fit.
*/
Rectangle.prototype.fit = function fit(rectangle) {
var x1 = Math.max(this.x, rectangle.x);
var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width);
var y1 = Math.max(this.y, rectangle.y);
var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);
this.x = x1;
this.width = Math.max(x2 - x1, 0);
this.y = y1;
this.height = Math.max(y2 - y1, 0);
};
/**
* Enlarges this rectangle to include the passed rectangle.
*
* @param {PIXI.Rectangle} rectangle - The rectangle to include.
*/
Rectangle.prototype.enlarge = function enlarge(rectangle) {
var x1 = Math.min(this.x, rectangle.x);
var x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width);
var y1 = Math.min(this.y, rectangle.y);
var y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);
this.x = x1;
this.width = x2 - x1;
this.y = y1;
this.height = y2 - y1;
};
/**
* Enlarges rectangle that way its corners lie on grid
*
* @param {number} [resolution=1] resolution
* @param {number} [eps=0.001] precision
*/
Rectangle.prototype.ceil = function ceil() {
var resolution = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var eps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.001;
var x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution;
var y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;
this.x = Math.floor((this.x + eps) * resolution) / resolution;
this.y = Math.floor((this.y + eps) * resolution) / resolution;
this.width = x2 - this.x;
this.height = y2 - this.y;
};
_createClass(Rectangle, [{
key: 'left',
get: function get() {
return this.x;
}
/**
* returns the right edge of the rectangle
*
* @member {number}
*/
}, {
key: 'right',
get: function get() {
return this.x + this.width;
}
/**
* returns the top edge of the rectangle
*
* @member {number}
*/
}, {
key: 'top',
get: function get() {
return this.y;
}
/**
* returns the bottom edge of the rectangle
*
* @member {number}
*/
}, {
key: 'bottom',
get: function get() {
return this.y + this.height;
}
/**
* A constant empty rectangle.
*
* @static
* @constant
*/
}], [{
key: 'EMPTY',
get: function get() {
return new Rectangle(0, 0, 0, 0);
}
}]);
return Rectangle;
}();
exports.default = Rectangle;
//# sourceMappingURL=Rectangle.js.map
/***/ }),
/* 120 */
/***/ (function(module, exports) {
var mapType = function(gl, type)
{
if(!GL_TABLE)
{
var typeNames = Object.keys(GL_TO_GLSL_TYPES);
GL_TABLE = {};
for(var i = 0; i < typeNames.length; ++i)
{
var tn = typeNames[i];
GL_TABLE[ gl[tn] ] = GL_TO_GLSL_TYPES[tn];
}
}
return GL_TABLE[type];
};
var GL_TABLE = null;
var GL_TO_GLSL_TYPES = {
'FLOAT': 'float',
'FLOAT_VEC2': 'vec2',
'FLOAT_VEC3': 'vec3',
'FLOAT_VEC4': 'vec4',
'INT': 'int',
'INT_VEC2': 'ivec2',
'INT_VEC3': 'ivec3',
'INT_VEC4': 'ivec4',
'BOOL': 'bool',
'BOOL_VEC2': 'bvec2',
'BOOL_VEC3': 'bvec3',
'BOOL_VEC4': 'bvec4',
'FLOAT_MAT2': 'mat2',
'FLOAT_MAT3': 'mat3',
'FLOAT_MAT4': 'mat4',
'SAMPLER_2D': 'sampler2D'
};
module.exports = mapType;
/***/ }),
/* 121 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _math = __webpack_require__(14);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* 'Builder' pattern for bounds rectangles
* Axis-Aligned Bounding Box
* It is not a shape! Its mutable thing, no 'EMPTY' or that kind of problems
*
* @class
* @memberof PIXI
*/
var Bounds = function () {
/**
*
*/
function Bounds() {
_classCallCheck(this, Bounds);
/**
* @member {number}
* @default 0
*/
this.minX = Infinity;
/**
* @member {number}
* @default 0
*/
this.minY = Infinity;
/**
* @member {number}
* @default 0
*/
this.maxX = -Infinity;
/**
* @member {number}
* @default 0
*/
this.maxY = -Infinity;
this.rect = null;
}
/**
* Checks if bounds are empty.
*
* @return {boolean} True if empty.
*/
Bounds.prototype.isEmpty = function isEmpty() {
return this.minX > this.maxX || this.minY > this.maxY;
};
/**
* Clears the bounds and resets.
*
*/
Bounds.prototype.clear = function clear() {
this.updateID++;
this.minX = Infinity;
this.minY = Infinity;
this.maxX = -Infinity;
this.maxY = -Infinity;
};
/**
* Can return Rectangle.EMPTY constant, either construct new rectangle, either use your rectangle
* It is not guaranteed that it will return tempRect
*
* @param {PIXI.Rectangle} rect - temporary object will be used if AABB is not empty
* @returns {PIXI.Rectangle} A rectangle of the bounds
*/
Bounds.prototype.getRectangle = function getRectangle(rect) {
if (this.minX > this.maxX || this.minY > this.maxY) {
return _math.Rectangle.EMPTY;
}
rect = rect || new _math.Rectangle(0, 0, 1, 1);
rect.x = this.minX;
rect.y = this.minY;
rect.width = this.maxX - this.minX;
rect.height = this.maxY - this.minY;
return rect;
};
/**
* This function should be inlined when its possible.
*
* @param {PIXI.Point} point - The point to add.
*/
Bounds.prototype.addPoint = function addPoint(point) {
this.minX = Math.min(this.minX, point.x);
this.maxX = Math.max(this.maxX, point.x);
this.minY = Math.min(this.minY, point.y);
this.maxY = Math.max(this.maxY, point.y);
};
/**
* Adds a quad, not transformed
*
* @param {Float32Array} vertices - The verts to add.
*/
Bounds.prototype.addQuad = function addQuad(vertices) {
var minX = this.minX;
var minY = this.minY;
var maxX = this.maxX;
var maxY = this.maxY;
var x = vertices[0];
var y = vertices[1];
minX = x < minX ? x : minX;
minY = y < minY ? y : minY;
maxX = x > maxX ? x : maxX;
maxY = y > maxY ? y : maxY;
x = vertices[2];
y = vertices[3];
minX = x < minX ? x : minX;
minY = y < minY ? y : minY;
maxX = x > maxX ? x : maxX;
maxY = y > maxY ? y : maxY;
x = vertices[4];
y = vertices[5];
minX = x < minX ? x : minX;
minY = y < minY ? y : minY;
maxX = x > maxX ? x : maxX;
maxY = y > maxY ? y : maxY;
x = vertices[6];
y = vertices[7];
minX = x < minX ? x : minX;
minY = y < minY ? y : minY;
maxX = x > maxX ? x : maxX;
maxY = y > maxY ? y : maxY;
this.minX = minX;
this.minY = minY;
this.maxX = maxX;
this.maxY = maxY;
};
/**
* Adds sprite frame, transformed.
*
* @param {PIXI.TransformBase} transform - TODO
* @param {number} x0 - TODO
* @param {number} y0 - TODO
* @param {number} x1 - TODO
* @param {number} y1 - TODO
*/
Bounds.prototype.addFrame = function addFrame(transform, x0, y0, x1, y1) {
var matrix = transform.worldTransform;
var a = matrix.a;
var b = matrix.b;
var c = matrix.c;
var d = matrix.d;
var tx = matrix.tx;
var ty = matrix.ty;
var minX = this.minX;
var minY = this.minY;
var maxX = this.maxX;
var maxY = this.maxY;
var x = a * x0 + c * y0 + tx;
var y = b * x0 + d * y0 + ty;
minX = x < minX ? x : minX;
minY = y < minY ? y : minY;
maxX = x > maxX ? x : maxX;
maxY = y > maxY ? y : maxY;
x = a * x1 + c * y0 + tx;
y = b * x1 + d * y0 + ty;
minX = x < minX ? x : minX;
minY = y < minY ? y : minY;
maxX = x > maxX ? x : maxX;
maxY = y > maxY ? y : maxY;
x = a * x0 + c * y1 + tx;
y = b * x0 + d * y1 + ty;
minX = x < minX ? x : minX;
minY = y < minY ? y : minY;
maxX = x > maxX ? x : maxX;
maxY = y > maxY ? y : maxY;
x = a * x1 + c * y1 + tx;
y = b * x1 + d * y1 + ty;
minX = x < minX ? x : minX;
minY = y < minY ? y : minY;
maxX = x > maxX ? x : maxX;
maxY = y > maxY ? y : maxY;
this.minX = minX;
this.minY = minY;
this.maxX = maxX;
this.maxY = maxY;
};
/**
* Add an array of vertices
*
* @param {PIXI.TransformBase} transform - TODO
* @param {Float32Array} vertices - TODO
* @param {number} beginOffset - TODO
* @param {number} endOffset - TODO
*/
Bounds.prototype.addVertices = function addVertices(transform, vertices, beginOffset, endOffset) {
var matrix = transform.worldTransform;
var a = matrix.a;
var b = matrix.b;
var c = matrix.c;
var d = matrix.d;
var tx = matrix.tx;
var ty = matrix.ty;
var minX = this.minX;
var minY = this.minY;
var maxX = this.maxX;
var maxY = this.maxY;
for (var i = beginOffset; i < endOffset; i += 2) {
var rawX = vertices[i];
var rawY = vertices[i + 1];
var x = a * rawX + c * rawY + tx;
var y = d * rawY + b * rawX + ty;
minX = x < minX ? x : minX;
minY = y < minY ? y : minY;
maxX = x > maxX ? x : maxX;
maxY = y > maxY ? y : maxY;
}
this.minX = minX;
this.minY = minY;
this.maxX = maxX;
this.maxY = maxY;
};
/**
* Adds other Bounds
*
* @param {PIXI.Bounds} bounds - TODO
*/
Bounds.prototype.addBounds = function addBounds(bounds) {
var minX = this.minX;
var minY = this.minY;
var maxX = this.maxX;
var maxY = this.maxY;
this.minX = bounds.minX < minX ? bounds.minX : minX;
this.minY = bounds.minY < minY ? bounds.minY : minY;
this.maxX = bounds.maxX > maxX ? bounds.maxX : maxX;
this.maxY = bounds.maxY > maxY ? bounds.maxY : maxY;
};
/**
* Adds other Bounds, masked with Bounds
*
* @param {PIXI.Bounds} bounds - TODO
* @param {PIXI.Bounds} mask - TODO
*/
Bounds.prototype.addBoundsMask = function addBoundsMask(bounds, mask) {
var _minX = bounds.minX > mask.minX ? bounds.minX : mask.minX;
var _minY = bounds.minY > mask.minY ? bounds.minY : mask.minY;
var _maxX = bounds.maxX < mask.maxX ? bounds.maxX : mask.maxX;
var _maxY = bounds.maxY < mask.maxY ? bounds.maxY : mask.maxY;
if (_minX <= _maxX && _minY <= _maxY) {
var minX = this.minX;
var minY = this.minY;
var maxX = this.maxX;
var maxY = this.maxY;
this.minX = _minX < minX ? _minX : minX;
this.minY = _minY < minY ? _minY : minY;
this.maxX = _maxX > maxX ? _maxX : maxX;
this.maxY = _maxY > maxY ? _maxY : maxY;
}
};
/**
* Adds other Bounds, masked with Rectangle
*
* @param {PIXI.Bounds} bounds - TODO
* @param {PIXI.Rectangle} area - TODO
*/
Bounds.prototype.addBoundsArea = function addBoundsArea(bounds, area) {
var _minX = bounds.minX > area.x ? bounds.minX : area.x;
var _minY = bounds.minY > area.y ? bounds.minY : area.y;
var _maxX = bounds.maxX < area.x + area.width ? bounds.maxX : area.x + area.width;
var _maxY = bounds.maxY < area.y + area.height ? bounds.maxY : area.y + area.height;
if (_minX <= _maxX && _minY <= _maxY) {
var minX = this.minX;
var minY = this.minY;
var maxX = this.maxX;
var maxY = this.maxY;
this.minX = _minX < minX ? _minX : minX;
this.minY = _minY < minY ? _minY : minY;
this.maxX = _maxX > maxX ? _maxX : maxX;
this.maxY = _maxY > maxY ? _maxY : maxY;
}
};
return Bounds;
}();
exports.default = Bounds;
//# sourceMappingURL=Bounds.js.map
/***/ }),
/* 122 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;!function(e){var n=/iPhone/i,t=/iPod/i,r=/iPad/i,a=/\bAndroid(?:.+)Mobile\b/i,p=/Android/i,l=/\bAndroid(?:.+)SD4930UR\b/i,b=/\bAndroid(?:.+)(?:KF[A-Z]{2,4})\b/i,f=/Windows Phone/i,u=/\bWindows(?:.+)ARM\b/i,c=/BlackBerry/i,s=/BB10/i,v=/Opera Mini/i,h=/\b(CriOS|Chrome)(?:.+)Mobile/i,w=/\Mobile(?:.+)Firefox\b/i;function m(e,i){return e.test(i)}function i(e){var i=e||("undefined"!=typeof navigator?navigator.userAgent:""),o=i.split("[FBAN");void 0!==o[1]&&(i=o[0]),void 0!==(o=i.split("Twitter"))[1]&&(i=o[0]);var d={apple:{phone:m(n,i)&&!m(f,i),ipod:m(t,i),tablet:!m(n,i)&&m(r,i)&&!m(f,i),device:(m(n,i)||m(t,i)||m(r,i))&&!m(f,i)},amazon:{phone:m(l,i),tablet:!m(l,i)&&m(b,i),device:m(l,i)||m(b,i)},android:{phone:!m(f,i)&&m(l,i)||!m(f,i)&&m(a,i),tablet:!m(f,i)&&!m(l,i)&&!m(a,i)&&(m(b,i)||m(p,i)),device:!m(f,i)&&(m(l,i)||m(b,i)||m(a,i)||m(p,i))},windows:{phone:m(f,i),tablet:m(u,i),device:m(f,i)||m(u,i)},other:{blackberry:m(c,i),blackberry10:m(s,i),opera:m(v,i),firefox:m(w,i),chrome:m(h,i),device:m(c,i)||m(s,i)||m(v,i)||m(w,i)||m(h,i)}};return d.any=d.apple.device||d.android.device||d.windows.device||d.other.device,d.phone=d.apple.phone||d.android.phone||d.windows.phone,d.tablet=d.apple.tablet||d.android.tablet||d.windows.tablet,d}"undefined"!=typeof module&&module.exports&&"undefined"==typeof window?module.exports=i:"undefined"!=typeof module&&module.exports&&"undefined"!=typeof window?module.exports=i(): true?!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (e.isMobile=i()),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)):e.isMobile=i()}(this);
/***/ }),
/* 123 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _math = __webpack_require__(14);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Generic class to deal with traditional 2D matrix transforms
*
* @class
* @memberof PIXI
*/
var TransformBase = function () {
/**
*
*/
function TransformBase() {
_classCallCheck(this, TransformBase);
/**
* The global matrix transform. It can be swapped temporarily by some functions like getLocalBounds()
*
* @member {PIXI.Matrix}
*/
this.worldTransform = new _math.Matrix();
/**
* The local matrix transform
*
* @member {PIXI.Matrix}
*/
this.localTransform = new _math.Matrix();
this._worldID = 0;
this._parentID = 0;
}
/**
* TransformBase does not have decomposition, so this function wont do anything
*/
TransformBase.prototype.updateLocalTransform = function updateLocalTransform() {}
// empty
/**
* Updates the values of the object and applies the parent's transform.
*
* @param {PIXI.TransformBase} parentTransform - The transform of the parent of this object
*/
;
TransformBase.prototype.updateTransform = function updateTransform(parentTransform) {
var pt = parentTransform.worldTransform;
var wt = this.worldTransform;
var lt = this.localTransform;
// concat the parent matrix with the objects transform.
wt.a = lt.a * pt.a + lt.b * pt.c;
wt.b = lt.a * pt.b + lt.b * pt.d;
wt.c = lt.c * pt.a + lt.d * pt.c;
wt.d = lt.c * pt.b + lt.d * pt.d;
wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx;
wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty;
this._worldID++;
};
return TransformBase;
}();
/**
* Updates the values of the object and applies the parent's transform.
* @param parentTransform {PIXI.Transform} The transform of the parent of this object
*
*/
exports.default = TransformBase;
TransformBase.prototype.updateWorldTransform = TransformBase.prototype.updateTransform;
TransformBase.IDENTITY = new TransformBase();
//# sourceMappingURL=TransformBase.js.map
/***/ }),
/* 124 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = earcut;
module.exports.default = earcut;
function earcut(data, holeIndices, dim) {
dim = dim || 2;
var hasHoles = holeIndices && holeIndices.length,
outerLen = hasHoles ? holeIndices[0] * dim : data.length,
outerNode = linkedList(data, 0, outerLen, dim, true),
triangles = [];
if (!outerNode || outerNode.next === outerNode.prev) return triangles;
var minX, minY, maxX, maxY, x, y, invSize;
if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
// if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
if (data.length > 80 * dim) {
minX = maxX = data[0];
minY = maxY = data[1];
for (var i = dim; i < outerLen; i += dim) {
x = data[i];
y = data[i + 1];
if (x < minX) minX = x;
if (y < minY) minY = y;
if (x > maxX) maxX = x;
if (y > maxY) maxY = y;
}
// minX, minY and invSize are later used to transform coords into integers for z-order calculation
invSize = Math.max(maxX - minX, maxY - minY);
invSize = invSize !== 0 ? 1 / invSize : 0;
}
earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
return triangles;
}
// create a circular doubly linked list from polygon points in the specified winding order
function linkedList(data, start, end, dim, clockwise) {
var i, last;
if (clockwise === (signedArea(data, start, end, dim) > 0)) {
for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
} else {
for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
}
if (last && equals(last, last.next)) {
removeNode(last);
last = last.next;
}
return last;
}
// eliminate colinear or duplicate points
function filterPoints(start, end) {
if (!start) return start;
if (!end) end = start;
var p = start,
again;
do {
again = false;
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
removeNode(p);
p = end = p.prev;
if (p === p.next) break;
again = true;
} else {
p = p.next;
}
} while (again || p !== end);
return end;
}
// main ear slicing loop which triangulates a polygon (given as a linked list)
function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
if (!ear) return;
// interlink polygon nodes in z-order
if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
var stop = ear,
prev, next;
// iterate through ears, slicing them one by one
while (ear.prev !== ear.next) {
prev = ear.prev;
next = ear.next;
if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
// cut off the triangle
triangles.push(prev.i / dim);
triangles.push(ear.i / dim);
triangles.push(next.i / dim);
removeNode(ear);
// skipping the next vertex leads to less sliver triangles
ear = next.next;
stop = next.next;
continue;
}
ear = next;
// if we looped through the whole remaining polygon and can't find any more ears
if (ear === stop) {
// try filtering points and slicing again
if (!pass) {
earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
// if this didn't work, try curing all small self-intersections locally
} else if (pass === 1) {
ear = cureLocalIntersections(ear, triangles, dim);
earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
// as a last resort, try splitting the remaining polygon into two
} else if (pass === 2) {
splitEarcut(ear, triangles, dim, minX, minY, invSize);
}
break;
}
}
}
// check whether a polygon node forms a valid ear with adjacent nodes
function isEar(ear) {
var a = ear.prev,
b = ear,
c = ear.next;
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
// now make sure we don't have other points inside the potential ear
var p = ear.next.next;
while (p !== ear.prev) {
if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
area(p.prev, p, p.next) >= 0) return false;
p = p.next;
}
return true;
}
function isEarHashed(ear, minX, minY, invSize) {
var a = ear.prev,
b = ear,
c = ear.next;
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
// triangle bbox; min & max are calculated like this for speed
var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x),
minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y),
maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x),
maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y);
// z-order range for the current triangle bbox;
var minZ = zOrder(minTX, minTY, minX, minY, invSize),
maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
var p = ear.prevZ,
n = ear.nextZ;
// look for points inside the triangle in both directions
while (p && p.z >= minZ && n && n.z <= maxZ) {
if (p !== ear.prev && p !== ear.next &&
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
area(p.prev, p, p.next) >= 0) return false;
p = p.prevZ;
if (n !== ear.prev && n !== ear.next &&
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
area(n.prev, n, n.next) >= 0) return false;
n = n.nextZ;
}
// look for remaining points in decreasing z-order
while (p && p.z >= minZ) {
if (p !== ear.prev && p !== ear.next &&
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
area(p.prev, p, p.next) >= 0) return false;
p = p.prevZ;
}
// look for remaining points in increasing z-order
while (n && n.z <= maxZ) {
if (n !== ear.prev && n !== ear.next &&
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
area(n.prev, n, n.next) >= 0) return false;
n = n.nextZ;
}
return true;
}
// go through all polygon nodes and cure small local self-intersections
function cureLocalIntersections(start, triangles, dim) {
var p = start;
do {
var a = p.prev,
b = p.next.next;
if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
triangles.push(a.i / dim);
triangles.push(p.i / dim);
triangles.push(b.i / dim);
// remove two nodes involved
removeNode(p);
removeNode(p.next);
p = start = b;
}
p = p.next;
} while (p !== start);
return p;
}
// try splitting polygon into two and triangulate them independently
function splitEarcut(start, triangles, dim, minX, minY, invSize) {
// look for a valid diagonal that divides the polygon into two
var a = start;
do {
var b = a.next.next;
while (b !== a.prev) {
if (a.i !== b.i && isValidDiagonal(a, b)) {
// split the polygon in two by the diagonal
var c = splitPolygon(a, b);
// filter colinear points around the cuts
a = filterPoints(a, a.next);
c = filterPoints(c, c.next);
// run earcut on each half
earcutLinked(a, triangles, dim, minX, minY, invSize);
earcutLinked(c, triangles, dim, minX, minY, invSize);
return;
}
b = b.next;
}
a = a.next;
} while (a !== start);
}
// link every hole into the outer loop, producing a single-ring polygon without holes
function eliminateHoles(data, holeIndices, outerNode, dim) {
var queue = [],
i, len, start, end, list;
for (i = 0, len = holeIndices.length; i < len; i++) {
start = holeIndices[i] * dim;
end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
list = linkedList(data, start, end, dim, false);
if (list === list.next) list.steiner = true;
queue.push(getLeftmost(list));
}
queue.sort(compareX);
// process holes from left to right
for (i = 0; i < queue.length; i++) {
eliminateHole(queue[i], outerNode);
outerNode = filterPoints(outerNode, outerNode.next);
}
return outerNode;
}
function compareX(a, b) {
return a.x - b.x;
}
// find a bridge between vertices that connects hole with an outer ring and and link it
function eliminateHole(hole, outerNode) {
outerNode = findHoleBridge(hole, outerNode);
if (outerNode) {
var b = splitPolygon(outerNode, hole);
filterPoints(b, b.next);
}
}
// David Eberly's algorithm for finding a bridge between hole and outer polygon
function findHoleBridge(hole, outerNode) {
var p = outerNode,
hx = hole.x,
hy = hole.y,
qx = -Infinity,
m;
// find a segment intersected by a ray from the hole's leftmost point to the left;
// segment's endpoint with lesser x will be potential connection point
do {
if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
if (x <= hx && x > qx) {
qx = x;
if (x === hx) {
if (hy === p.y) return p;
if (hy === p.next.y) return p.next;
}
m = p.x < p.next.x ? p : p.next;
}
}
p = p.next;
} while (p !== outerNode);
if (!m) return null;
if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint
// look for points inside the triangle of hole point, segment intersection and endpoint;
// if there are no points found, we have a valid connection;
// otherwise choose the point of the minimum angle with the ray as connection point
var stop = m,
mx = m.x,
my = m.y,
tanMin = Infinity,
tan;
p = m.next;
while (p !== stop) {
if (hx >= p.x && p.x >= mx && hx !== p.x &&
pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) {
m = p;
tanMin = tan;
}
}
p = p.next;
}
return m;
}
// interlink polygon nodes in z-order
function indexCurve(start, minX, minY, invSize) {
var p = start;
do {
if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize);
p.prevZ = p.prev;
p.nextZ = p.next;
p = p.next;
} while (p !== start);
p.prevZ.nextZ = null;
p.prevZ = null;
sortLinked(p);
}
// Simon Tatham's linked list merge sort algorithm
// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
function sortLinked(list) {
var i, p, q, e, tail, numMerges, pSize, qSize,
inSize = 1;
do {
p = list;
list = null;
tail = null;
numMerges = 0;
while (p) {
numMerges++;
q = p;
pSize = 0;
for (i = 0; i < inSize; i++) {
pSize++;
q = q.nextZ;
if (!q) break;
}
qSize = inSize;
while (pSize > 0 || (qSize > 0 && q)) {
if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
e = p;
p = p.nextZ;
pSize--;
} else {
e = q;
q = q.nextZ;
qSize--;
}
if (tail) tail.nextZ = e;
else list = e;
e.prevZ = tail;
tail = e;
}
p = q;
}
tail.nextZ = null;
inSize *= 2;
} while (numMerges > 1);
return list;
}
// z-order of a point given coords and inverse of the longer side of data bbox
function zOrder(x, y, minX, minY, invSize) {
// coords are transformed into non-negative 15-bit integer range
x = 32767 * (x - minX) * invSize;
y = 32767 * (y - minY) * invSize;
x = (x | (x << 8)) & 0x00FF00FF;
x = (x | (x << 4)) & 0x0F0F0F0F;
x = (x | (x << 2)) & 0x33333333;
x = (x | (x << 1)) & 0x55555555;
y = (y | (y << 8)) & 0x00FF00FF;
y = (y | (y << 4)) & 0x0F0F0F0F;
y = (y | (y << 2)) & 0x33333333;
y = (y | (y << 1)) & 0x55555555;
return x | (y << 1);
}
// find the leftmost node of a polygon ring
function getLeftmost(start) {
var p = start,
leftmost = start;
do {
if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;
p = p.next;
} while (p !== start);
return leftmost;
}
// check if a point lies within a convex triangle
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
(ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
(bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
}
// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
function isValidDiagonal(a, b) {
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) &&
locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b);
}
// signed area of a triangle
function area(p, q, r) {
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
}
// check if two points are equal
function equals(p1, p2) {
return p1.x === p2.x && p1.y === p2.y;
}
// check if two segments intersect
function intersects(p1, q1, p2, q2) {
if ((equals(p1, q1) && equals(p2, q2)) ||
(equals(p1, q2) && equals(p2, q1))) return true;
return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 &&
area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
}
// check if a polygon diagonal intersects any polygon segments
function intersectsPolygon(a, b) {
var p = a;
do {
if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
intersects(p, p.next, a, b)) return true;
p = p.next;
} while (p !== a);
return false;
}
// check if a polygon diagonal is locally inside the polygon
function locallyInside(a, b) {
return area(a.prev, a, a.next) < 0 ?
area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
}
// check if the middle point of a polygon diagonal is inside the polygon
function middleInside(a, b) {
var p = a,
inside = false,
px = (a.x + b.x) / 2,
py = (a.y + b.y) / 2;
do {
if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
(px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
inside = !inside;
p = p.next;
} while (p !== a);
return inside;
}
// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
// if one belongs to the outer ring and another to a hole, it merges it into a single ring
function splitPolygon(a, b) {
var a2 = new Node(a.i, a.x, a.y),
b2 = new Node(b.i, b.x, b.y),
an = a.next,
bp = b.prev;
a.next = b;
b.prev = a;
a2.next = an;
an.prev = a2;
b2.next = a2;
a2.prev = b2;
bp.next = b2;
b2.prev = bp;
return b2;
}
// create a node and optionally link it with previous one (in a circular doubly linked list)
function insertNode(i, x, y, last) {
var p = new Node(i, x, y);
if (!last) {
p.prev = p;
p.next = p;
} else {
p.next = last.next;
p.prev = last;
last.next.prev = p;
last.next = p;
}
return p;
}
function removeNode(p) {
p.next.prev = p.prev;
p.prev.next = p.next;
if (p.prevZ) p.prevZ.nextZ = p.nextZ;
if (p.nextZ) p.nextZ.prevZ = p.prevZ;
}
function Node(i, x, y) {
// vertex index in coordinates array
this.i = i;
// vertex coordinates
this.x = x;
this.y = y;
// previous and next vertex nodes in a polygon ring
this.prev = null;
this.next = null;
// z-order curve value
this.z = null;
// previous and next nodes in z-order
this.prevZ = null;
this.nextZ = null;
// indicates whether this is a steiner point
this.steiner = false;
}
// return a percentage difference between the polygon area and its triangulation area;
// used to verify correctness of triangulation
earcut.deviation = function (data, holeIndices, dim, triangles) {
var hasHoles = holeIndices && holeIndices.length;
var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
if (hasHoles) {
for (var i = 0, len = holeIndices.length; i < len; i++) {
var start = holeIndices[i] * dim;
var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
polygonArea -= Math.abs(signedArea(data, start, end, dim));
}
}
var trianglesArea = 0;
for (i = 0; i < triangles.length; i += 3) {
var a = triangles[i] * dim;
var b = triangles[i + 1] * dim;
var c = triangles[i + 2] * dim;
trianglesArea += Math.abs(
(data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
(data[a] - data[b]) * (data[c + 1] - data[a + 1]));
}
return polygonArea === 0 && trianglesArea === 0 ? 0 :
Math.abs((trianglesArea - polygonArea) / polygonArea);
};
function signedArea(data, start, end, dim) {
var sum = 0;
for (var i = start, j = end - dim; i < end; i += dim) {
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
j = i;
}
return sum;
}
// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
earcut.flatten = function (data) {
var dim = data[0][0].length,
result = {vertices: [], holes: [], dimensions: dim},
holeIndex = 0;
for (var i = 0; i < data.length; i++) {
for (var j = 0; j < data[i].length; j++) {
for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
}
if (i > 0) {
holeIndex += data[i - 1].length;
result.holes.push(holeIndex);
}
}
return result;
};
/***/ }),
/* 125 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _math = __webpack_require__(14);
var _utils = __webpack_require__(7);
var _const = __webpack_require__(3);
var _Texture = __webpack_require__(40);
var _Texture2 = _interopRequireDefault(_Texture);
var _Container2 = __webpack_require__(64);
var _Container3 = _interopRequireDefault(_Container2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var tempPoint = new _math.Point();
/**
* The Sprite object is the base for all textured objects that are rendered to the screen
*
* A sprite can be created directly from an image like this:
*
* ```js
* let sprite = new PIXI.Sprite.fromImage('assets/image.png');
* ```
*
* The more efficient way to create sprites is using a {@link PIXI.Spritesheet}:
*
* ```js
* PIXI.loader.add("assets/spritesheet.json").load(setup);
*
* function setup() {
* let sheet = PIXI.loader.resources["assets/spritesheet.json"].spritesheet;
* let sprite = new PIXI.Sprite(sheet.textures["image.png"]);
* ...
* }
* ```
*
* @class
* @extends PIXI.Container
* @memberof PIXI
*/
var Sprite = function (_Container) {
_inherits(Sprite, _Container);
/**
* @param {PIXI.Texture} texture - The texture for this sprite
*/
function Sprite(texture) {
_classCallCheck(this, Sprite);
/**
* The anchor sets the origin point of the texture.
* The default is 0,0 or taken from the {@link PIXI.Texture#defaultAnchor|Texture}
* passed to the constructor. A value of 0,0 means the texture's origin is the top left.
* Setting the anchor to 0.5,0.5 means the texture's origin is centered.
* Setting the anchor to 1,1 would mean the texture's origin point will be the bottom right corner.
* Note: Updating the {@link PIXI.Texture#defaultAnchor} after a Texture is
* created does _not_ update the Sprite's anchor values.
*
* @member {PIXI.ObservablePoint}
* @private
*/
var _this = _possibleConstructorReturn(this, _Container.call(this));
_this._anchor = new _math.ObservablePoint(_this._onAnchorUpdate, _this, texture ? texture.defaultAnchor.x : 0, texture ? texture.defaultAnchor.y : 0);
/**
* The texture that the sprite is using
*
* @private
* @member {PIXI.Texture}
*/
_this._texture = null;
/**
* The width of the sprite (this is initially set by the texture)
*
* @private
* @member {number}
*/
_this._width = 0;
/**
* The height of the sprite (this is initially set by the texture)
*
* @private
* @member {number}
*/
_this._height = 0;
/**
* The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect.
*
* @private
* @member {number}
* @default 0xFFFFFF
*/
_this._tint = null;
_this._tintRGB = null;
_this.tint = 0xFFFFFF;
/**
* The blend mode to be applied to the sprite. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode.
*
* @member {number}
* @default PIXI.BLEND_MODES.NORMAL
* @see PIXI.BLEND_MODES
*/
_this.blendMode = _const.BLEND_MODES.NORMAL;
/**
* The shader that will be used to render the sprite. Set to null to remove a current shader.
*
* @member {PIXI.Filter|PIXI.Shader}
*/
_this.shader = null;
/**
* An internal cached value of the tint.
*
* @private
* @member {number}
* @default 0xFFFFFF
*/
_this.cachedTint = 0xFFFFFF;
// call texture setter
_this.texture = texture || _Texture2.default.EMPTY;
/**
* this is used to store the vertex data of the sprite (basically a quad)
*
* @private
* @member {Float32Array}
*/
_this.vertexData = new Float32Array(8);
/**
* This is used to calculate the bounds of the object IF it is a trimmed sprite
*
* @private
* @member {Float32Array}
*/
_this.vertexTrimmedData = null;
_this._transformID = -1;
_this._textureID = -1;
_this._transformTrimmedID = -1;
_this._textureTrimmedID = -1;
/**
* Plugin that is responsible for rendering this element.
* Allows to customize the rendering process without overriding '_renderWebGL' & '_renderCanvas' methods.
*
* @member {string}
* @default 'sprite'
*/
_this.pluginName = 'sprite';
return _this;
}
/**
* When the texture is updated, this event will fire to update the scale and frame
*
* @private
*/
Sprite.prototype._onTextureUpdate = function _onTextureUpdate() {
this._textureID = -1;
this._textureTrimmedID = -1;
this.cachedTint = 0xFFFFFF;
// so if _width is 0 then width was not set..
if (this._width) {
this.scale.x = (0, _utils.sign)(this.scale.x) * this._width / this._texture.orig.width;
}
if (this._height) {
this.scale.y = (0, _utils.sign)(this.scale.y) * this._height / this._texture.orig.height;
}
};
/**
* Called when the anchor position updates.
*
* @private
*/
Sprite.prototype._onAnchorUpdate = function _onAnchorUpdate() {
this._transformID = -1;
this._transformTrimmedID = -1;
};
/**
* calculates worldTransform * vertices, store it in vertexData
*/
Sprite.prototype.calculateVertices = function calculateVertices() {
if (this._transformID === this.transform._worldID && this._textureID === this._texture._updateID) {
return;
}
this._transformID = this.transform._worldID;
this._textureID = this._texture._updateID;
// set the vertex data
var texture = this._texture;
var wt = this.transform.worldTransform;
var a = wt.a;
var b = wt.b;
var c = wt.c;
var d = wt.d;
var tx = wt.tx;
var ty = wt.ty;
var vertexData = this.vertexData;
var trim = texture.trim;
var orig = texture.orig;
var anchor = this._anchor;
var w0 = 0;
var w1 = 0;
var h0 = 0;
var h1 = 0;
if (trim) {
// if the sprite is trimmed and is not a tilingsprite then we need to add the extra
// space before transforming the sprite coords.
w1 = trim.x - anchor._x * orig.width;
w0 = w1 + trim.width;
h1 = trim.y - anchor._y * orig.height;
h0 = h1 + trim.height;
} else {
w1 = -anchor._x * orig.width;
w0 = w1 + orig.width;
h1 = -anchor._y * orig.height;
h0 = h1 + orig.height;
}
// xy
vertexData[0] = a * w1 + c * h1 + tx;
vertexData[1] = d * h1 + b * w1 + ty;
// xy
vertexData[2] = a * w0 + c * h1 + tx;
vertexData[3] = d * h1 + b * w0 + ty;
// xy
vertexData[4] = a * w0 + c * h0 + tx;
vertexData[5] = d * h0 + b * w0 + ty;
// xy
vertexData[6] = a * w1 + c * h0 + tx;
vertexData[7] = d * h0 + b * w1 + ty;
};
/**
* calculates worldTransform * vertices for a non texture with a trim. store it in vertexTrimmedData
* This is used to ensure that the true width and height of a trimmed texture is respected
*/
Sprite.prototype.calculateTrimmedVertices = function calculateTrimmedVertices() {
if (!this.vertexTrimmedData) {
this.vertexTrimmedData = new Float32Array(8);
} else if (this._transformTrimmedID === this.transform._worldID && this._textureTrimmedID === this._texture._updateID) {
return;
}
this._transformTrimmedID = this.transform._worldID;
this._textureTrimmedID = this._texture._updateID;
// lets do some special trim code!
var texture = this._texture;
var vertexData = this.vertexTrimmedData;
var orig = texture.orig;
var anchor = this._anchor;
// lets calculate the new untrimmed bounds..
var wt = this.transform.worldTransform;
var a = wt.a;
var b = wt.b;
var c = wt.c;
var d = wt.d;
var tx = wt.tx;
var ty = wt.ty;
var w1 = -anchor._x * orig.width;
var w0 = w1 + orig.width;
var h1 = -anchor._y * orig.height;
var h0 = h1 + orig.height;
// xy
vertexData[0] = a * w1 + c * h1 + tx;
vertexData[1] = d * h1 + b * w1 + ty;
// xy
vertexData[2] = a * w0 + c * h1 + tx;
vertexData[3] = d * h1 + b * w0 + ty;
// xy
vertexData[4] = a * w0 + c * h0 + tx;
vertexData[5] = d * h0 + b * w0 + ty;
// xy
vertexData[6] = a * w1 + c * h0 + tx;
vertexData[7] = d * h0 + b * w1 + ty;
};
/**
*
* Renders the object using the WebGL renderer
*
* @private
* @param {PIXI.WebGLRenderer} renderer - The webgl renderer to use.
*/
Sprite.prototype._renderWebGL = function _renderWebGL(renderer) {
this.calculateVertices();
renderer.setObjectRenderer(renderer.plugins[this.pluginName]);
renderer.plugins[this.pluginName].render(this);
};
/**
* Renders the object using the Canvas renderer
*
* @private
* @param {PIXI.CanvasRenderer} renderer - The renderer
*/
Sprite.prototype._renderCanvas = function _renderCanvas(renderer) {
renderer.plugins[this.pluginName].render(this);
};
/**
* Updates the bounds of the sprite.
*
* @private
*/
Sprite.prototype._calculateBounds = function _calculateBounds() {
var trim = this._texture.trim;
var orig = this._texture.orig;
// First lets check to see if the current texture has a trim..
if (!trim || trim.width === orig.width && trim.height === orig.height) {
// no trim! lets use the usual calculations..
this.calculateVertices();
this._bounds.addQuad(this.vertexData);
} else {
// lets calculate a special trimmed bounds...
this.calculateTrimmedVertices();
this._bounds.addQuad(this.vertexTrimmedData);
}
};
/**
* Gets the local bounds of the sprite object.
*
* @param {PIXI.Rectangle} rect - The output rectangle.
* @return {PIXI.Rectangle} The bounds.
*/
Sprite.prototype.getLocalBounds = function getLocalBounds(rect) {
// we can do a fast local bounds if the sprite has no children!
if (this.children.length === 0) {
this._bounds.minX = this._texture.orig.width * -this._anchor._x;
this._bounds.minY = this._texture.orig.height * -this._anchor._y;
this._bounds.maxX = this._texture.orig.width * (1 - this._anchor._x);
this._bounds.maxY = this._texture.orig.height * (1 - this._anchor._y);
if (!rect) {
if (!this._localBoundsRect) {
this._localBoundsRect = new _math.Rectangle();
}
rect = this._localBoundsRect;
}
return this._bounds.getRectangle(rect);
}
return _Container.prototype.getLocalBounds.call(this, rect);
};
/**
* Tests if a point is inside this sprite
*
* @param {PIXI.Point} point - the point to test
* @return {boolean} the result of the test
*/
Sprite.prototype.containsPoint = function containsPoint(point) {
this.worldTransform.applyInverse(point, tempPoint);
var width = this._texture.orig.width;
var height = this._texture.orig.height;
var x1 = -width * this.anchor.x;
var y1 = 0;
if (tempPoint.x >= x1 && tempPoint.x < x1 + width) {
y1 = -height * this.anchor.y;
if (tempPoint.y >= y1 && tempPoint.y < y1 + height) {
return true;
}
}
return false;
};
/**
* Destroys this sprite and optionally its texture and children
*
* @param {object|boolean} [options] - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [options.children=false] - if set to true, all the children will have their destroy
* method called as well. 'options' will be passed on to those calls.
* @param {boolean} [options.texture=false] - Should it destroy the current texture of the sprite as well
* @param {boolean} [options.baseTexture=false] - Should it destroy the base texture of the sprite as well
*/
Sprite.prototype.destroy = function destroy(options) {
_Container.prototype.destroy.call(this, options);
this._texture.off('update', this._onTextureUpdate, this);
this._anchor = null;
var destroyTexture = typeof options === 'boolean' ? options : options && options.texture;
if (destroyTexture) {
var destroyBaseTexture = typeof options === 'boolean' ? options : options && options.baseTexture;
this._texture.destroy(!!destroyBaseTexture);
}
this._texture = null;
this.shader = null;
};
// some helper functions..
/**
* Helper function that creates a new sprite based on the source you provide.
* The source can be - frame id, image url, video url, canvas element, video element, base texture
*
* @static
* @param {number|string|PIXI.BaseTexture|HTMLCanvasElement|HTMLVideoElement} source Source to create texture from
* @return {PIXI.Sprite} The newly created sprite
*/
Sprite.from = function from(source) {
return new Sprite(_Texture2.default.from(source));
};
/**
* Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId
* The frame ids are created when a Texture packer file has been loaded
*
* @static
* @param {string} frameId - The frame Id of the texture in the cache
* @return {PIXI.Sprite} A new Sprite using a texture from the texture cache matching the frameId
*/
Sprite.fromFrame = function fromFrame(frameId) {
var texture = _utils.TextureCache[frameId];
if (!texture) {
throw new Error('The frameId "' + frameId + '" does not exist in the texture cache');
}
return new Sprite(texture);
};
/**
* Helper function that creates a sprite that will contain a texture based on an image url
* If the image is not in the texture cache it will be loaded
*
* @static
* @param {string} imageId - The image url of the texture
* @param {boolean} [crossorigin=(auto)] - if you want to specify the cross-origin parameter
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - if you want to specify the scale mode,
* see {@link PIXI.SCALE_MODES} for possible values
* @return {PIXI.Sprite} A new Sprite using a texture from the texture cache matching the image id
*/
Sprite.fromImage = function fromImage(imageId, crossorigin, scaleMode) {
return new Sprite(_Texture2.default.fromImage(imageId, crossorigin, scaleMode));
};
/**
* The width of the sprite, setting this will actually modify the scale to achieve the value set
*
* @member {number}
*/
_createClass(Sprite, [{
key: 'width',
get: function get() {
return Math.abs(this.scale.x) * this._texture.orig.width;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
var s = (0, _utils.sign)(this.scale.x) || 1;
this.scale.x = s * value / this._texture.orig.width;
this._width = value;
}
/**
* The height of the sprite, setting this will actually modify the scale to achieve the value set
*
* @member {number}
*/
}, {
key: 'height',
get: function get() {
return Math.abs(this.scale.y) * this._texture.orig.height;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
var s = (0, _utils.sign)(this.scale.y) || 1;
this.scale.y = s * value / this._texture.orig.height;
this._height = value;
}
/**
* The anchor sets the origin point of the texture.
* The default is 0,0 or taken from the {@link PIXI.Texture|Texture} passed to the constructor.
* Setting the texture at a later point of time does not change