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 the anchor.
*
* 0,0 means the texture's origin is the top left, 0.5,0.5 is the center, 1,1 the bottom right corner.
*
* @member {PIXI.ObservablePoint}
*/
}, {
key: 'anchor',
get: function get() {
return this._anchor;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._anchor.copy(value);
}
/**
* The tint applied to the sprite. This is a hex value.
* A value of 0xFFFFFF will remove any tint effect.
*
* @member {number}
* @default 0xFFFFFF
*/
}, {
key: 'tint',
get: function get() {
return this._tint;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._tint = value;
this._tintRGB = (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16);
}
/**
* The texture that the sprite is using
*
* @member {PIXI.Texture}
*/
}, {
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 || _Texture2.default.EMPTY;
this.cachedTint = 0xFFFFFF;
this._textureID = -1;
this._textureTrimmedID = -1;
if (value) {
// wait for the texture to load
if (value.baseTexture.hasLoaded) {
this._onTextureUpdate();
} else {
value.once('update', this._onTextureUpdate, this);
}
}
}
}]);
return Sprite;
}(_Container3.default);
exports.default = Sprite;
//# sourceMappingURL=Sprite.js.map
/***/ }),
/* 126 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Bit twiddling hacks for JavaScript.
*
* Author: Mikola Lysenko
*
* Ported from Stanford bit twiddling hack library:
* http://graphics.stanford.edu/~seander/bithacks.html
*/
"use restrict";
//Number of bits in an integer
var INT_BITS = 32;
//Constants
exports.INT_BITS = INT_BITS;
exports.INT_MAX = 0x7fffffff;
exports.INT_MIN = -1<<(INT_BITS-1);
//Returns -1, 0, +1 depending on sign of x
exports.sign = function(v) {
return (v > 0) - (v < 0);
}
//Computes absolute value of integer
exports.abs = function(v) {
var mask = v >> (INT_BITS-1);
return (v ^ mask) - mask;
}
//Computes minimum of integers x and y
exports.min = function(x, y) {
return y ^ ((x ^ y) & -(x < y));
}
//Computes maximum of integers x and y
exports.max = function(x, y) {
return x ^ ((x ^ y) & -(x < y));
}
//Checks if a number is a power of two
exports.isPow2 = function(v) {
return !(v & (v-1)) && (!!v);
}
//Computes log base 2 of v
exports.log2 = function(v) {
var r, shift;
r = (v > 0xFFFF) << 4; v >>>= r;
shift = (v > 0xFF ) << 3; v >>>= shift; r |= shift;
shift = (v > 0xF ) << 2; v >>>= shift; r |= shift;
shift = (v > 0x3 ) << 1; v >>>= shift; r |= shift;
return r | (v >> 1);
}
//Computes log base 10 of v
exports.log10 = function(v) {
return (v >= 1000000000) ? 9 : (v >= 100000000) ? 8 : (v >= 10000000) ? 7 :
(v >= 1000000) ? 6 : (v >= 100000) ? 5 : (v >= 10000) ? 4 :
(v >= 1000) ? 3 : (v >= 100) ? 2 : (v >= 10) ? 1 : 0;
}
//Counts number of bits
exports.popCount = function(v) {
v = v - ((v >>> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >>> 2) & 0x33333333);
return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24;
}
//Counts number of trailing zeros
function countTrailingZeros(v) {
var c = 32;
v &= -v;
if (v) c--;
if (v & 0x0000FFFF) c -= 16;
if (v & 0x00FF00FF) c -= 8;
if (v & 0x0F0F0F0F) c -= 4;
if (v & 0x33333333) c -= 2;
if (v & 0x55555555) c -= 1;
return c;
}
exports.countTrailingZeros = countTrailingZeros;
//Rounds to next power of 2
exports.nextPow2 = function(v) {
v += v === 0;
--v;
v |= v >>> 1;
v |= v >>> 2;
v |= v >>> 4;
v |= v >>> 8;
v |= v >>> 16;
return v + 1;
}
//Rounds down to previous power of 2
exports.prevPow2 = function(v) {
v |= v >>> 1;
v |= v >>> 2;
v |= v >>> 4;
v |= v >>> 8;
v |= v >>> 16;
return v - (v>>>1);
}
//Computes parity of word
exports.parity = function(v) {
v ^= v >>> 16;
v ^= v >>> 8;
v ^= v >>> 4;
v &= 0xf;
return (0x6996 >>> v) & 1;
}
var REVERSE_TABLE = new Array(256);
(function(tab) {
for(var i=0; i<256; ++i) {
var v = i, r = i, s = 7;
for (v >>>= 1; v; v >>>= 1) {
r <<= 1;
r |= v & 1;
--s;
}
tab[i] = (r << s) & 0xff;
}
})(REVERSE_TABLE);
//Reverse bits in a 32 bit word
exports.reverse = function(v) {
return (REVERSE_TABLE[ v & 0xff] << 24) |
(REVERSE_TABLE[(v >>> 8) & 0xff] << 16) |
(REVERSE_TABLE[(v >>> 16) & 0xff] << 8) |
REVERSE_TABLE[(v >>> 24) & 0xff];
}
//Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes
exports.interleave2 = function(x, y) {
x &= 0xFFFF;
x = (x | (x << 8)) & 0x00FF00FF;
x = (x | (x << 4)) & 0x0F0F0F0F;
x = (x | (x << 2)) & 0x33333333;
x = (x | (x << 1)) & 0x55555555;
y &= 0xFFFF;
y = (y | (y << 8)) & 0x00FF00FF;
y = (y | (y << 4)) & 0x0F0F0F0F;
y = (y | (y << 2)) & 0x33333333;
y = (y | (y << 1)) & 0x55555555;
return x | (y << 1);
}
//Extracts the nth interleaved component
exports.deinterleave2 = function(v, n) {
v = (v >>> n) & 0x55555555;
v = (v | (v >>> 1)) & 0x33333333;
v = (v | (v >>> 2)) & 0x0F0F0F0F;
v = (v | (v >>> 4)) & 0x00FF00FF;
v = (v | (v >>> 16)) & 0x000FFFF;
return (v << 16) >> 16;
}
//Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes
exports.interleave3 = function(x, y, z) {
x &= 0x3FF;
x = (x | (x<<16)) & 4278190335;
x = (x | (x<<8)) & 251719695;
x = (x | (x<<4)) & 3272356035;
x = (x | (x<<2)) & 1227133513;
y &= 0x3FF;
y = (y | (y<<16)) & 4278190335;
y = (y | (y<<8)) & 251719695;
y = (y | (y<<4)) & 3272356035;
y = (y | (y<<2)) & 1227133513;
x |= (y << 1);
z &= 0x3FF;
z = (z | (z<<16)) & 4278190335;
z = (z | (z<<8)) & 251719695;
z = (z | (z<<4)) & 3272356035;
z = (z | (z<<2)) & 1227133513;
return x | (z << 2);
}
//Extracts nth interleaved component of a 3-tuple
exports.deinterleave3 = function(v, n) {
v = (v >>> n) & 1227133513;
v = (v | (v>>>2)) & 3272356035;
v = (v | (v>>>4)) & 251719695;
v = (v | (v>>>8)) & 4278190335;
v = (v | (v>>>16)) & 0x3FF;
return (v<<22)>>22;
}
//Computes next combination in colexicographic order (this is mistakenly called nextPermutation on the bit twiddling hacks page)
exports.nextCombination = function(v) {
var t = v | (v - 1);
return (t + 1) | (((~t & -~t) - 1) >>> (countTrailingZeros(v) + 1));
}
/***/ }),
/* 127 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.Ticker = exports.shared = undefined;
var _Ticker = __webpack_require__(463);
var _Ticker2 = _interopRequireDefault(_Ticker);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* The shared ticker instance used by {@link PIXI.extras.AnimatedSprite}.
* and by {@link PIXI.interaction.InteractionManager}.
* The property {@link PIXI.ticker.Ticker#autoStart} is set to `true`
* for this instance. Please follow the examples for usage, including
* how to opt-out of auto-starting the shared ticker.
*
* @example
* let ticker = PIXI.ticker.shared;
* // Set this to prevent starting this ticker when listeners are added.
* // By default this is true only for the PIXI.ticker.shared instance.
* ticker.autoStart = false;
* // FYI, call this to ensure the ticker is stopped. It should be stopped
* // if you have not attempted to render anything yet.
* ticker.stop();
* // Call this when you are ready for a running shared ticker.
* ticker.start();
*
* @example
* // You may use the shared ticker to render...
* let renderer = PIXI.autoDetectRenderer(800, 600);
* let stage = new PIXI.Container();
* let interactionManager = PIXI.interaction.InteractionManager(renderer);
* document.body.appendChild(renderer.view);
* ticker.add(function (time) {
* renderer.render(stage);
* });
*
* @example
* // Or you can just update it manually.
* ticker.autoStart = false;
* ticker.stop();
* function animate(time) {
* ticker.update(time);
* renderer.render(stage);
* requestAnimationFrame(animate);
* }
* animate(performance.now());
*
* @type {PIXI.ticker.Ticker}
* @memberof PIXI.ticker
*/
var shared = new _Ticker2.default();
shared.autoStart = true;
shared.destroy = function () {
// protect destroying shared ticker
// this is used by other internal systems
// like AnimatedSprite and InteractionManager
};
/**
* This namespace contains an API for interacting with PIXI's internal global update loop.
*
* This ticker is used for rendering, {@link PIXI.extras.AnimatedSprite AnimatedSprite},
* {@link PIXI.interaction.InteractionManager InteractionManager} and many other time-based PIXI systems.
* @example
* const ticker = new PIXI.ticker.Ticker();
* ticker.stop();
* ticker.add((deltaTime) => {
* // do something every frame
* });
* ticker.start();
* @namespace PIXI.ticker
*/
exports.shared = shared;
exports.Ticker = _Ticker2.default;
//# sourceMappingURL=index.js.map
/***/ }),
/* 128 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _BaseRenderTexture = __webpack_require__(189);
var _BaseRenderTexture2 = _interopRequireDefault(_BaseRenderTexture);
var _Texture2 = __webpack_require__(40);
var _Texture3 = _interopRequireDefault(_Texture2);
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 RenderTexture is a special texture that allows any PixiJS display object to be rendered to it.
*
* __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded
* otherwise black rectangles will be drawn instead.
*
* A RenderTexture takes a snapshot of any Display Object given to its render method. For example:
*
* ```js
* let renderer = PIXI.autoDetectRenderer(1024, 1024);
* let renderTexture = PIXI.RenderTexture.create(800, 600);
* let sprite = PIXI.Sprite.fromImage("spinObj_01.png");
*
* sprite.position.x = 800/2;
* sprite.position.y = 600/2;
* sprite.anchor.x = 0.5;
* sprite.anchor.y = 0.5;
*
* renderer.render(sprite, renderTexture);
* ```
*
* The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0
* you can clear the transform
*
* ```js
*
* sprite.setTransform()
*
* let renderTexture = new PIXI.RenderTexture.create(100, 100);
*
* renderer.render(sprite, renderTexture); // Renders to center of RenderTexture
* ```
*
* @class
* @extends PIXI.Texture
* @memberof PIXI
*/
var RenderTexture = function (_Texture) {
_inherits(RenderTexture, _Texture);
/**
* @param {PIXI.BaseRenderTexture} baseRenderTexture - The renderer used for this RenderTexture
* @param {PIXI.Rectangle} [frame] - The rectangle frame of the texture to show
*/
function RenderTexture(baseRenderTexture, frame) {
_classCallCheck(this, RenderTexture);
// support for legacy..
var _legacyRenderer = null;
if (!(baseRenderTexture instanceof _BaseRenderTexture2.default)) {
/* eslint-disable prefer-rest-params, no-console */
var width = arguments[1];
var height = arguments[2];
var scaleMode = arguments[3];
var resolution = arguments[4];
// we have an old render texture..
console.warn('Please use RenderTexture.create(' + width + ', ' + height + ') instead of the ctor directly.');
_legacyRenderer = arguments[0];
/* eslint-enable prefer-rest-params, no-console */
frame = null;
baseRenderTexture = new _BaseRenderTexture2.default(width, height, scaleMode, resolution);
}
/**
* The base texture object that this texture uses
*
* @member {BaseTexture}
*/
var _this = _possibleConstructorReturn(this, _Texture.call(this, baseRenderTexture, frame));
_this.legacyRenderer = _legacyRenderer;
/**
* This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.
*
* @member {boolean}
*/
_this.valid = true;
_this._updateUvs();
return _this;
}
/**
* Resizes the RenderTexture.
*
* @param {number} width - The width to resize to.
* @param {number} height - The height to resize to.
* @param {boolean} doNotResizeBaseTexture - Should the baseTexture.width and height values be resized as well?
*/
RenderTexture.prototype.resize = function resize(width, height, doNotResizeBaseTexture) {
width = Math.ceil(width);
height = Math.ceil(height);
// TODO - could be not required..
this.valid = width > 0 && height > 0;
this._frame.width = this.orig.width = width;
this._frame.height = this.orig.height = height;
if (!doNotResizeBaseTexture) {
this.baseTexture.resize(width, height);
}
this._updateUvs();
};
/**
* A short hand way of creating a render texture.
*
* @param {number} [width=100] - The width of the render texture
* @param {number} [height=100] - The height of the render 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 being generated
* @return {PIXI.RenderTexture} The new render texture
*/
RenderTexture.create = function create(width, height, scaleMode, resolution) {
return new RenderTexture(new _BaseRenderTexture2.default(width, height, scaleMode, resolution));
};
return RenderTexture;
}(_Texture3.default);
exports.default = RenderTexture;
//# sourceMappingURL=RenderTexture.js.map
/***/ }),
/* 129 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = createIndicesForQuads;
/**
* Generic Mask Stack data structure
*
* @memberof PIXI
* @function createIndicesForQuads
* @private
* @param {number} size - Number of quads
* @return {Uint16Array} indices
*/
function createIndicesForQuads(size) {
// the total number of indices in our array, there are 6 points per quad.
var totalIndices = size * 6;
var indices = new Uint16Array(totalIndices);
// fill the indices with the quads to draw
for (var i = 0, j = 0; i < totalIndices; i += 6, j += 4) {
indices[i + 0] = j + 0;
indices[i + 1] = j + 1;
indices[i + 2] = j + 2;
indices[i + 3] = j + 0;
indices[i + 4] = j + 2;
indices[i + 5] = j + 3;
}
return indices;
}
//# sourceMappingURL=createIndicesForQuads.js.map
/***/ }),
/* 130 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.Resource = undefined;
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 _parseUri = __webpack_require__(214);
var _parseUri2 = _interopRequireDefault(_parseUri);
var _miniSignals = __webpack_require__(213);
var _miniSignals2 = _interopRequireDefault(_miniSignals);
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"); } }
// tests if CORS is supported in XHR, if not we need to use XDR
var useXdr = !!(window.XDomainRequest && !('withCredentials' in new XMLHttpRequest()));
var tempAnchor = null;
// some status constants
var STATUS_NONE = 0;
var STATUS_OK = 200;
var STATUS_EMPTY = 204;
var STATUS_IE_BUG_EMPTY = 1223;
var STATUS_TYPE_OK = 2;
// noop
function _noop() {} /* empty */
/**
* Manages the state and loading of a resource and all child resources.
*
* @class
*/
var Resource = exports.Resource = function () {
/**
* Sets the load type to be used for a specific extension.
*
* @static
* @param {string} extname - The extension to set the type for, e.g. "png" or "fnt"
* @param {Resource.LOAD_TYPE} loadType - The load type to set it to.
*/
Resource.setExtensionLoadType = function setExtensionLoadType(extname, loadType) {
setExtMap(Resource._loadTypeMap, extname, loadType);
};
/**
* Sets the load type to be used for a specific extension.
*
* @static
* @param {string} extname - The extension to set the type for, e.g. "png" or "fnt"
* @param {Resource.XHR_RESPONSE_TYPE} xhrType - The xhr type to set it to.
*/
Resource.setExtensionXhrType = function setExtensionXhrType(extname, xhrType) {
setExtMap(Resource._xhrTypeMap, extname, xhrType);
};
/**
* @param {string} name - The name of the resource to load.
* @param {string|string[]} url - The url for this resource, for audio/video loads you can pass
* an array of sources.
* @param {object} [options] - The options for the load.
* @param {string|boolean} [options.crossOrigin] - Is this request cross-origin? Default is to
* determine automatically.
* @param {number} [options.timeout=0] - A timeout in milliseconds for the load. If the load takes
* longer than this time it is cancelled and the load is considered a failure. If this value is
* set to `0` then there is no explicit timeout.
* @param {Resource.LOAD_TYPE} [options.loadType=Resource.LOAD_TYPE.XHR] - How should this resource
* be loaded?
* @param {Resource.XHR_RESPONSE_TYPE} [options.xhrType=Resource.XHR_RESPONSE_TYPE.DEFAULT] - How
* should the data being loaded be interpreted when using XHR?
* @param {Resource.IMetadata} [options.metadata] - Extra configuration for middleware and the Resource object.
*/
function Resource(name, url, options) {
_classCallCheck(this, Resource);
if (typeof name !== 'string' || typeof url !== 'string') {
throw new Error('Both name and url are required for constructing a resource.');
}
options = options || {};
/**
* The state flags of this resource.
*
* @private
* @member {number}
*/
this._flags = 0;
// set data url flag, needs to be set early for some _determineX checks to work.
this._setFlag(Resource.STATUS_FLAGS.DATA_URL, url.indexOf('data:') === 0);
/**
* The name of this resource.
*
* @readonly
* @member {string}
*/
this.name = name;
/**
* The url used to load this resource.
*
* @readonly
* @member {string}
*/
this.url = url;
/**
* The extension used to load this resource.
*
* @readonly
* @member {string}
*/
this.extension = this._getExtension();
/**
* The data that was loaded by the resource.
*
* @member {any}
*/
this.data = null;
/**
* Is this request cross-origin? If unset, determined automatically.
*
* @member {string}
*/
this.crossOrigin = options.crossOrigin === true ? 'anonymous' : options.crossOrigin;
/**
* A timeout in milliseconds for the load. If the load takes longer than this time
* it is cancelled and the load is considered a failure. If this value is set to `0`
* then there is no explicit timeout.
*
* @member {number}
*/
this.timeout = options.timeout || 0;
/**
* The method of loading to use for this resource.
*
* @member {Resource.LOAD_TYPE}
*/
this.loadType = options.loadType || this._determineLoadType();
/**
* The type used to load the resource via XHR. If unset, determined automatically.
*
* @member {string}
*/
this.xhrType = options.xhrType;
/**
* Extra info for middleware, and controlling specifics about how the resource loads.
*
* Note that if you pass in a `loadElement`, the Resource class takes ownership of it.
* Meaning it will modify it as it sees fit.
*
* @member {Resource.IMetadata}
*/
this.metadata = options.metadata || {};
/**
* The error that occurred while loading (if any).
*
* @readonly
* @member {Error}
*/
this.error = null;
/**
* The XHR object that was used to load this resource. This is only set
* when `loadType` is `Resource.LOAD_TYPE.XHR`.
*
* @readonly
* @member {XMLHttpRequest}
*/
this.xhr = null;
/**
* The child resources this resource owns.
*
* @readonly
* @member {Resource[]}
*/
this.children = [];
/**
* The resource type.
*
* @readonly
* @member {Resource.TYPE}
*/
this.type = Resource.TYPE.UNKNOWN;
/**
* The progress chunk owned by this resource.
*
* @readonly
* @member {number}
*/
this.progressChunk = 0;
/**
* The `dequeue` method that will be used a storage place for the async queue dequeue method
* used privately by the loader.
*
* @private
* @member {function}
*/
this._dequeue = _noop;
/**
* Used a storage place for the on load binding used privately by the loader.
*
* @private
* @member {function}
*/
this._onLoadBinding = null;
/**
* The timer for element loads to check if they timeout.
*
* @private
* @member {number}
*/
this._elementTimer = 0;
/**
* The `complete` function bound to this resource's context.
*
* @private
* @member {function}
*/
this._boundComplete = this.complete.bind(this);
/**
* The `_onError` function bound to this resource's context.
*
* @private
* @member {function}
*/
this._boundOnError = this._onError.bind(this);
/**
* The `_onProgress` function bound to this resource's context.
*
* @private
* @member {function}
*/
this._boundOnProgress = this._onProgress.bind(this);
/**
* The `_onTimeout` function bound to this resource's context.
*
* @private
* @member {function}
*/
this._boundOnTimeout = this._onTimeout.bind(this);
// xhr callbacks
this._boundXhrOnError = this._xhrOnError.bind(this);
this._boundXhrOnTimeout = this._xhrOnTimeout.bind(this);
this._boundXhrOnAbort = this._xhrOnAbort.bind(this);
this._boundXhrOnLoad = this._xhrOnLoad.bind(this);
/**
* Dispatched when the resource beings to load.
*
* The callback looks like {@link Resource.OnStartSignal}.
*
* @member {Signal<Resource.OnStartSignal>}
*/
this.onStart = new _miniSignals2.default();
/**
* Dispatched each time progress of this resource load updates.
* Not all resources types and loader systems can support this event
* so sometimes it may not be available. If the resource
* is being loaded on a modern browser, using XHR, and the remote server
* properly sets Content-Length headers, then this will be available.
*
* The callback looks like {@link Resource.OnProgressSignal}.
*
* @member {Signal<Resource.OnProgressSignal>}
*/
this.onProgress = new _miniSignals2.default();
/**
* Dispatched once this resource has loaded, if there was an error it will
* be in the `error` property.
*
* The callback looks like {@link Resource.OnCompleteSignal}.
*
* @member {Signal<Resource.OnCompleteSignal>}
*/
this.onComplete = new _miniSignals2.default();
/**
* Dispatched after this resource has had all the *after* middleware run on it.
*
* The callback looks like {@link Resource.OnCompleteSignal}.
*
* @member {Signal<Resource.OnCompleteSignal>}
*/
this.onAfterMiddleware = new _miniSignals2.default();
}
/**
* When the resource starts to load.
*
* @memberof Resource
* @callback OnStartSignal
* @param {Resource} resource - The resource that the event happened on.
*/
/**
* When the resource reports loading progress.
*
* @memberof Resource
* @callback OnProgressSignal
* @param {Resource} resource - The resource that the event happened on.
* @param {number} percentage - The progress of the load in the range [0, 1].
*/
/**
* When the resource finishes loading.
*
* @memberof Resource
* @callback OnCompleteSignal
* @param {Resource} resource - The resource that the event happened on.
*/
/**
* @memberof Resource
* @typedef {object} IMetadata
* @property {HTMLImageElement|HTMLAudioElement|HTMLVideoElement} [loadElement=null] - The
* element to use for loading, instead of creating one.
* @property {boolean} [skipSource=false] - Skips adding source(s) to the load element. This
* is useful if you want to pass in a `loadElement` that you already added load sources to.
* @property {string|string[]} [mimeType] - The mime type to use for the source element
* of a video/audio elment. If the urls are an array, you can pass this as an array as well
* where each index is the mime type to use for the corresponding url index.
*/
/**
* Stores whether or not this url is a data url.
*
* @readonly
* @member {boolean}
*/
/**
* Marks the resource as complete.
*
*/
Resource.prototype.complete = function complete() {
this._clearEvents();
this._finish();
};
/**
* Aborts the loading of this resource, with an optional message.
*
* @param {string} message - The message to use for the error
*/
Resource.prototype.abort = function abort(message) {
// abort can be called multiple times, ignore subsequent calls.
if (this.error) {
return;
}
// store error
this.error = new Error(message);
// clear events before calling aborts
this._clearEvents();
// abort the actual loading
if (this.xhr) {
this.xhr.abort();
} else if (this.xdr) {
this.xdr.abort();
} else if (this.data) {
// single source
if (this.data.src) {
this.data.src = Resource.EMPTY_GIF;
}
// multi-source
else {
while (this.data.firstChild) {
this.data.removeChild(this.data.firstChild);
}
}
}
// done now.
this._finish();
};
/**
* Kicks off loading of this resource. This method is asynchronous.
*
* @param {Resource.OnCompleteSignal} [cb] - Optional callback to call once the resource is loaded.
*/
Resource.prototype.load = function load(cb) {
var _this = this;
if (this.isLoading) {
return;
}
if (this.isComplete) {
if (cb) {
setTimeout(function () {
return cb(_this);
}, 1);
}
return;
} else if (cb) {
this.onComplete.once(cb);
}
this._setFlag(Resource.STATUS_FLAGS.LOADING, true);
this.onStart.dispatch(this);
// if unset, determine the value
if (this.crossOrigin === false || typeof this.crossOrigin !== 'string') {
this.crossOrigin = this._determineCrossOrigin(this.url);
}
switch (this.loadType) {
case Resource.LOAD_TYPE.IMAGE:
this.type = Resource.TYPE.IMAGE;
this._loadElement('image');
break;
case Resource.LOAD_TYPE.AUDIO:
this.type = Resource.TYPE.AUDIO;
this._loadSourceElement('audio');
break;
case Resource.LOAD_TYPE.VIDEO:
this.type = Resource.TYPE.VIDEO;
this._loadSourceElement('video');
break;
case Resource.LOAD_TYPE.XHR:
/* falls through */
default:
if (useXdr && this.crossOrigin) {
this._loadXdr();
} else {
this._loadXhr();
}
break;
}
};
/**
* Checks if the flag is set.
*
* @private
* @param {number} flag - The flag to check.
* @return {boolean} True if the flag is set.
*/
Resource.prototype._hasFlag = function _hasFlag(flag) {
return (this._flags & flag) !== 0;
};
/**
* (Un)Sets the flag.
*
* @private
* @param {number} flag - The flag to (un)set.
* @param {boolean} value - Whether to set or (un)set the flag.
*/
Resource.prototype._setFlag = function _setFlag(flag, value) {
this._flags = value ? this._flags | flag : this._flags & ~flag;
};
/**
* Clears all the events from the underlying loading source.
*
* @private
*/
Resource.prototype._clearEvents = function _clearEvents() {
clearTimeout(this._elementTimer);
if (this.data && this.data.removeEventListener) {
this.data.removeEventListener('error', this._boundOnError, false);
this.data.removeEventListener('load', this._boundComplete, false);
this.data.removeEventListener('progress', this._boundOnProgress, false);
this.data.removeEventListener('canplaythrough', this._boundComplete, false);
}
if (this.xhr) {
if (this.xhr.removeEventListener) {
this.xhr.removeEventListener('error', this._boundXhrOnError, false);
this.xhr.removeEventListener('timeout', this._boundXhrOnTimeout, false);
this.xhr.removeEventListener('abort', this._boundXhrOnAbort, false);
this.xhr.removeEventListener('progress', this._boundOnProgress, false);
this.xhr.removeEventListener('load', this._boundXhrOnLoad, false);
} else {
this.xhr.onerror = null;
this.xhr.ontimeout = null;
this.xhr.onprogress = null;
this.xhr.onload = null;
}
}
};
/**
* Finalizes the load.
*
* @private
*/
Resource.prototype._finish = function _finish() {
if (this.isComplete) {
throw new Error('Complete called again for an already completed resource.');
}
this._setFlag(Resource.STATUS_FLAGS.COMPLETE, true);
this._setFlag(Resource.STATUS_FLAGS.LOADING, false);
this.onComplete.dispatch(this);
};
/**
* Loads this resources using an element that has a single source,
* like an HTMLImageElement.
*
* @private
* @param {string} type - The type of element to use.
*/
Resource.prototype._loadElement = function _loadElement(type) {
if (this.metadata.loadElement) {
this.data = this.metadata.loadElement;
} else if (type === 'image' && typeof window.Image !== 'undefined') {
this.data = new Image();
} else {
this.data = document.createElement(type);
}
if (this.crossOrigin) {
this.data.crossOrigin = this.crossOrigin;
}
if (!this.metadata.skipSource) {
this.data.src = this.url;
}
this.data.addEventListener('error', this._boundOnError, false);
this.data.addEventListener('load', this._boundComplete, false);
this.data.addEventListener('progress', this._boundOnProgress, false);
if (this.timeout) {
this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout);
}
};
/**
* Loads this resources using an element that has multiple sources,
* like an HTMLAudioElement or HTMLVideoElement.
*
* @private
* @param {string} type - The type of element to use.
*/
Resource.prototype._loadSourceElement = function _loadSourceElement(type) {
if (this.metadata.loadElement) {
this.data = this.metadata.loadElement;
} else if (type === 'audio' && typeof window.Audio !== 'undefined') {
this.data = new Audio();
} else {
this.data = document.createElement(type);
}
if (this.data === null) {
this.abort('Unsupported element: ' + type);
return;
}
if (this.crossOrigin) {
this.data.crossOrigin = this.crossOrigin;
}
if (!this.metadata.skipSource) {
// support for CocoonJS Canvas+ runtime, lacks document.createElement('source')
if (navigator.isCocoonJS) {
this.data.src = Array.isArray(this.url) ? this.url[0] : this.url;
} else if (Array.isArray(this.url)) {
var mimeTypes = this.metadata.mimeType;
for (var i = 0; i < this.url.length; ++i) {
this.data.appendChild(this._createSource(type, this.url[i], Array.isArray(mimeTypes) ? mimeTypes[i] : mimeTypes));
}
} else {
var _mimeTypes = this.metadata.mimeType;
this.data.appendChild(this._createSource(type, this.url, Array.isArray(_mimeTypes) ? _mimeTypes[0] : _mimeTypes));
}
}
this.data.addEventListener('error', this._boundOnError, false);
this.data.addEventListener('load', this._boundComplete, false);
this.data.addEventListener('progress', this._boundOnProgress, false);
this.data.addEventListener('canplaythrough', this._boundComplete, false);
this.data.load();
if (this.timeout) {
this._elementTimer = setTimeout(this._boundOnTimeout, this.timeout);
}
};
/**
* Loads this resources using an XMLHttpRequest.
*
* @private
*/
Resource.prototype._loadXhr = function _loadXhr() {
// if unset, determine the value
if (typeof this.xhrType !== 'string') {
this.xhrType = this._determineXhrType();
}
var xhr = this.xhr = new XMLHttpRequest();
// set the request type and url
xhr.open('GET', this.url, true);
xhr.timeout = this.timeout;
// load json as text and parse it ourselves. We do this because some browsers
// *cough* safari *cough* can't deal with it.
if (this.xhrType === Resource.XHR_RESPONSE_TYPE.JSON || this.xhrType === Resource.XHR_RESPONSE_TYPE.DOCUMENT) {
xhr.responseType = Resource.XHR_RESPONSE_TYPE.TEXT;
} else {
xhr.responseType = this.xhrType;
}
xhr.addEventListener('error', this._boundXhrOnError, false);
xhr.addEventListener('timeout', this._boundXhrOnTimeout, false);
xhr.addEventListener('abort', this._boundXhrOnAbort, false);
xhr.addEventListener('progress', this._boundOnProgress, false);
xhr.addEventListener('load', this._boundXhrOnLoad, false);
xhr.send();
};
/**
* Loads this resources using an XDomainRequest. This is here because we need to support IE9 (gross).
*
* @private
*/
Resource.prototype._loadXdr = function _loadXdr() {
// if unset, determine the value
if (typeof this.xhrType !== 'string') {
this.xhrType = this._determineXhrType();
}
var xdr = this.xhr = new XDomainRequest(); // eslint-disable-line no-undef
// XDomainRequest has a few quirks. Occasionally it will abort requests
// A way to avoid this is to make sure ALL callbacks are set even if not used
// More info here: http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9
xdr.timeout = this.timeout || 5000; // XDR needs a timeout value or it breaks in IE9
xdr.onerror = this._boundXhrOnError;
xdr.ontimeout = this._boundXhrOnTimeout;
xdr.onprogress = this._boundOnProgress;
xdr.onload = this._boundXhrOnLoad;
xdr.open('GET', this.url, true);
// Note: The xdr.send() call is wrapped in a timeout to prevent an
// issue with the interface where some requests are lost if multiple
// XDomainRequests are being sent at the same time.
// Some info here: https://github.com/photonstorm/phaser/issues/1248
setTimeout(function () {
return xdr.send();
}, 1);
};
/**
* Creates a source used in loading via an element.
*
* @private
* @param {string} type - The element type (video or audio).
* @param {string} url - The source URL to load from.
* @param {string} [mime] - The mime type of the video
* @return {HTMLSourceElement} The source element.
*/
Resource.prototype._createSource = function _createSource(type, url, mime) {
if (!mime) {
mime = type + '/' + this._getExtension(url);
}
var source = document.createElement('source');
source.src = url;
source.type = mime;
return source;
};
/**
* Called if a load errors out.
*
* @param {Event} event - The error event from the element that emits it.
* @private
*/
Resource.prototype._onError = function _onError(event) {
this.abort('Failed to load element using: ' + event.target.nodeName);
};
/**
* Called if a load progress event fires for an element or xhr/xdr.
*
* @private
* @param {XMLHttpRequestProgressEvent|Event} event - Progress event.
*/
Resource.prototype._onProgress = function _onProgress(event) {
if (event && event.lengthComputable) {
this.onProgress.dispatch(this, event.loaded / event.total);
}
};
/**
* Called if a timeout event fires for an element.
*
* @private
*/
Resource.prototype._onTimeout = function _onTimeout() {
this.abort('Load timed out.');
};
/**
* Called if an error event fires for xhr/xdr.
*
* @private
*/
Resource.prototype._xhrOnError = function _xhrOnError() {
var xhr = this.xhr;
this.abort(reqType(xhr) + ' Request failed. Status: ' + xhr.status + ', text: "' + xhr.statusText + '"');
};
/**
* Called if an error event fires for xhr/xdr.
*
* @private
*/
Resource.prototype._xhrOnTimeout = function _xhrOnTimeout() {
var xhr = this.xhr;
this.abort(reqType(xhr) + ' Request timed out.');
};
/**
* Called if an abort event fires for xhr/xdr.
*
* @private
*/
Resource.prototype._xhrOnAbort = function _xhrOnAbort() {
var xhr = this.xhr;
this.abort(reqType(xhr) + ' Request was aborted by the user.');
};
/**
* Called when data successfully loads from an xhr/xdr request.
*
* @private
* @param {XMLHttpRequestLoadEvent|Event} event - Load event
*/
Resource.prototype._xhrOnLoad = function _xhrOnLoad() {
var xhr = this.xhr;
var text = '';
var status = typeof xhr.status === 'undefined' ? STATUS_OK : xhr.status; // XDR has no `.status`, assume 200.
// responseText is accessible only if responseType is '' or 'text' and on older browsers
if (xhr.responseType === '' || xhr.responseType === 'text' || typeof xhr.responseType === 'undefined') {
text = xhr.responseText;
}
// status can be 0 when using the `file://` protocol so we also check if a response is set.
// If it has a response, we assume 200; otherwise a 0 status code with no contents is an aborted request.
if (status === STATUS_NONE && (text.length > 0 || xhr.responseType === Resource.XHR_RESPONSE_TYPE.BUFFER)) {
status = STATUS_OK;
}
// handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request
else if (status === STATUS_IE_BUG_EMPTY) {
status = STATUS_EMPTY;
}
var statusType = status / 100 | 0;
if (statusType === STATUS_TYPE_OK) {
// if text, just return it
if (this.xhrType === Resource.XHR_RESPONSE_TYPE.TEXT) {
this.data = text;
this.type = Resource.TYPE.TEXT;
}
// if json, parse into json object
else if (this.xhrType === Resource.XHR_RESPONSE_TYPE.JSON) {
try {
this.data = JSON.parse(text);
this.type = Resource.TYPE.JSON;
} catch (e) {
this.abort('Error trying to parse loaded json: ' + e);
return;
}
}
// if xml, parse into an xml document or div element
else if (this.xhrType === Resource.XHR_RESPONSE_TYPE.DOCUMENT) {
try {
if (window.DOMParser) {
var domparser = new DOMParser();
this.data = domparser.parseFromString(text, 'text/xml');
} else {
var div = document.createElement('div');
div.innerHTML = text;
this.data = div;
}
this.type = Resource.TYPE.XML;
} catch (e) {
this.abort('Error trying to parse loaded xml: ' + e);
return;
}
}
// other types just return the response
else {
this.data = xhr.response || text;
}
} else {
this.abort('[' + xhr.status + '] ' + xhr.statusText + ': ' + xhr.responseURL);
return;
}
this.complete();
};
/**
* Sets the `crossOrigin` property for this resource based on if the url
* for this resource is cross-origin. If crossOrigin was manually set, this
* function does nothing.
*
* @private
* @param {string} url - The url to test.
* @param {object} [loc=window.location] - The location object to test against.
* @return {string} The crossOrigin value to use (or empty string for none).
*/
Resource.prototype._determineCrossOrigin = function _determineCrossOrigin(url, loc) {
// data: and javascript: urls are considered same-origin
if (url.indexOf('data:') === 0) {
return '';
}
// A sandboxed iframe without the 'allow-same-origin' attribute will have a special
// origin designed not to match window.location.origin, and will always require
// crossOrigin requests regardless of whether the location matches.
if (window.origin !== window.location.origin) {
return 'anonymous';
}
// default is window.location
loc = loc || window.location;
if (!tempAnchor) {
tempAnchor = document.createElement('a');
}
// let the browser determine the full href for the url of this resource and then
// parse with the node url lib, we can't use the properties of the anchor element
// because they don't work in IE9 :(
tempAnchor.href = url;
url = (0, _parseUri2.default)(tempAnchor.href, { strictMode: true });
var samePort = !url.port && loc.port === '' || url.port === loc.port;
var protocol = url.protocol ? url.protocol + ':' : '';
// if cross origin
if (url.host !== loc.hostname || !samePort || protocol !== loc.protocol) {
return 'anonymous';
}
return '';
};
/**
* Determines the responseType of an XHR request based on the extension of the
* resource being loaded.
*
* @private
* @return {Resource.XHR_RESPONSE_TYPE} The responseType to use.
*/
Resource.prototype._determineXhrType = function _determineXhrType() {
return Resource._xhrTypeMap[this.extension] || Resource.XHR_RESPONSE_TYPE.TEXT;
};
/**
* Determines the loadType of a resource based on the extension of the
* resource being loaded.
*
* @private
* @return {Resource.LOAD_TYPE} The loadType to use.
*/
Resource.prototype._determineLoadType = function _determineLoadType() {
return Resource._loadTypeMap[this.extension] || Resource.LOAD_TYPE.XHR;
};
/**
* Extracts the extension (sans '.') of the file being loaded by the resource.
*
* @private
* @return {string} The extension.
*/
Resource.prototype._getExtension = function _getExtension() {
var url = this.url;
var ext = '';
if (this.isDataUrl) {
var slashIndex = url.indexOf('/');
ext = url.substring(slashIndex + 1, url.indexOf(';', slashIndex));
} else {
var queryStart = url.indexOf('?');
var hashStart = url.indexOf('#');
var index = Math.min(queryStart > -1 ? queryStart : url.length, hashStart > -1 ? hashStart : url.length);
url = url.substring(0, index);
ext = url.substring(url.lastIndexOf('.') + 1);
}
return ext.toLowerCase();
};
/**
* Determines the mime type of an XHR request based on the responseType of
* resource being loaded.
*
* @private
* @param {Resource.XHR_RESPONSE_TYPE} type - The type to get a mime type for.
* @return {string} The mime type to use.
*/
Resource.prototype._getMimeFromXhrType = function _getMimeFromXhrType(type) {
switch (type) {
case Resource.XHR_RESPONSE_TYPE.BUFFER:
return 'application/octet-binary';
case Resource.XHR_RESPONSE_TYPE.BLOB:
return 'application/blob';
case Resource.XHR_RESPONSE_TYPE.DOCUMENT:
return 'application/xml';
case Resource.XHR_RESPONSE_TYPE.JSON:
return 'application/json';
case Resource.XHR_RESPONSE_TYPE.DEFAULT:
case Resource.XHR_RESPONSE_TYPE.TEXT:
/* falls through */
default:
return 'text/plain';
}
};
_createClass(Resource, [{
key: 'isDataUrl',
get: function get() {
return this._hasFlag(Resource.STATUS_FLAGS.DATA_URL);
}
/**
* Describes if this resource has finished loading. Is true when the resource has completely
* loaded.
*
* @readonly
* @member {boolean}
*/
}, {
key: 'isComplete',
get: function get() {
return this._hasFlag(Resource.STATUS_FLAGS.COMPLETE);
}
/**
* Describes if this resource is currently loading. Is true when the resource starts loading,
* and is false again when complete.
*
* @readonly
* @member {boolean}
*/
}, {
key: 'isLoading',
get: function get() {
return this._hasFlag(Resource.STATUS_FLAGS.LOADING);
}
}]);
return Resource;
}();
/**
* The types of resources a resource could represent.
*
* @static
* @readonly
* @enum {number}
*/
Resource.STATUS_FLAGS = {
NONE: 0,
DATA_URL: 1 << 0,
COMPLETE: 1 << 1,
LOADING: 1 << 2
};
/**
* The types of resources a resource could represent.
*
* @static
* @readonly
* @enum {number}
*/
Resource.TYPE = {
UNKNOWN: 0,
JSON: 1,
XML: 2,
IMAGE: 3,
AUDIO: 4,
VIDEO: 5,
TEXT: 6
};
/**
* The types of loading a resource can use.
*
* @static
* @readonly
* @enum {number}
*/
Resource.LOAD_TYPE = {
/** Uses XMLHttpRequest to load the resource. */
XHR: 1,
/** Uses an `Image` object to load the resource. */
IMAGE: 2,
/** Uses an `Audio` object to load the resource. */
AUDIO: 3,
/** Uses a `Video` object to load the resource. */
VIDEO: 4
};
/**
* The XHR ready states, used internally.
*
* @static
* @readonly
* @enum {string}
*/
Resource.XHR_RESPONSE_TYPE = {
/** string */
DEFAULT: 'text',
/** ArrayBuffer */
BUFFER: 'arraybuffer',
/** Blob */
BLOB: 'blob',
/** Document */
DOCUMENT: 'document',
/** Object */
JSON: 'json',
/** String */
TEXT: 'text'
};
Resource._loadTypeMap = {
// images
gif: Resource.LOAD_TYPE.IMAGE,
png: Resource.LOAD_TYPE.IMAGE,
bmp: Resource.LOAD_TYPE.IMAGE,
jpg: Resource.LOAD_TYPE.IMAGE,
jpeg: Resource.LOAD_TYPE.IMAGE,
tif: Resource.LOAD_TYPE.IMAGE,
tiff: Resource.LOAD_TYPE.IMAGE,
webp: Resource.LOAD_TYPE.IMAGE,
tga: Resource.LOAD_TYPE.IMAGE,
svg: Resource.LOAD_TYPE.IMAGE,
'svg+xml': Resource.LOAD_TYPE.IMAGE, // for SVG data urls
// audio
mp3: Resource.LOAD_TYPE.AUDIO,
ogg: Resource.LOAD_TYPE.AUDIO,
wav: Resource.LOAD_TYPE.AUDIO,
// videos
mp4: Resource.LOAD_TYPE.VIDEO,
webm: Resource.LOAD_TYPE.VIDEO
};
Resource._xhrTypeMap = {
// xml
xhtml: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
html: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
htm: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
xml: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
tmx: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
svg: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
// This was added to handle Tiled Tileset XML, but .tsx is also a TypeScript React Component.
// Since it is way less likely for people to be loading TypeScript files instead of Tiled files,
// this should probably be fine.
tsx: Resource.XHR_RESPONSE_TYPE.DOCUMENT,
// images
gif: Resource.XHR_RESPONSE_TYPE.BLOB,
png: Resource.XHR_RESPONSE_TYPE.BLOB,
bmp: Resource.XHR_RESPONSE_TYPE.BLOB,
jpg: Resource.XHR_RESPONSE_TYPE.BLOB,
jpeg: Resource.XHR_RESPONSE_TYPE.BLOB,
tif: Resource.XHR_RESPONSE_TYPE.BLOB,
tiff: Resource.XHR_RESPONSE_TYPE.BLOB,
webp: Resource.XHR_RESPONSE_TYPE.BLOB,
tga: Resource.XHR_RESPONSE_TYPE.BLOB,
// json
json: Resource.XHR_RESPONSE_TYPE.JSON,
// text
text: Resource.XHR_RESPONSE_TYPE.TEXT,
txt: Resource.XHR_RESPONSE_TYPE.TEXT,
// fonts
ttf: Resource.XHR_RESPONSE_TYPE.BUFFER,
otf: Resource.XHR_RESPONSE_TYPE.BUFFER
};
// We can't set the `src` attribute to empty string, so on abort we set it to this 1px transparent gif
Resource.EMPTY_GIF = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
/**
* Quick helper to set a value on one of the extension maps. Ensures there is no
* dot at the start of the extension.
*
* @ignore
* @param {object} map - The map to set on.
* @param {string} extname - The extension (or key) to set.
* @param {number} val - The value to set.
*/
function setExtMap(map, extname, val) {
if (extname && extname.indexOf('.') === 0) {
extname = extname.substring(1);
}
if (!extname) {
return;
}
map[extname] = val;
}
/**
* Quick helper to get string xhr type.
*
* @ignore
* @param {XMLHttpRequest|XDomainRequest} xhr - The request to check.
* @return {string} The type.
*/
function reqType(xhr) {
return xhr.toString().replace('object ', '');
}
// Backwards compat
if (true) {
module.exports.default = Resource; // eslint-disable-line no-undef
}
//# sourceMappingURL=Resource.js.map
/***/ }),
/* 131 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _CountLimiter = __webpack_require__(220);
var _CountLimiter2 = _interopRequireDefault(_CountLimiter);
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"); } }
var SharedTicker = core.ticker.shared;
/**
* Default number of uploads per frame using prepare plugin.
*
* @static
* @memberof PIXI.settings
* @name UPLOADS_PER_FRAME
* @type {number}
* @default 4
*/
core.settings.UPLOADS_PER_FRAME = 4;
/**
* The prepare manager provides functionality to upload content to the GPU. BasePrepare handles
* basic queuing functionality and is extended by {@link PIXI.prepare.WebGLPrepare} and {@link PIXI.prepare.CanvasPrepare}
* to provide preparation capabilities specific to their respective renderers.
*
* @example
* // Create a sprite
* const sprite = new PIXI.Sprite.fromImage('something.png');
*
* // Load object into GPU
* app.renderer.plugins.prepare.upload(sprite, () => {
*
* //Texture(s) has been uploaded to GPU
* app.stage.addChild(sprite);
*
* })
*
* @abstract
* @class
* @memberof PIXI.prepare
*/
var BasePrepare = function () {
/**
* @param {PIXI.SystemRenderer} renderer - A reference to the current renderer
*/
function BasePrepare(renderer) {
var _this = this;
_classCallCheck(this, BasePrepare);
/**
* The limiter to be used to control how quickly items are prepared.
* @type {PIXI.prepare.CountLimiter|PIXI.prepare.TimeLimiter}
*/
this.limiter = new _CountLimiter2.default(core.settings.UPLOADS_PER_FRAME);
/**
* Reference to the renderer.
* @type {PIXI.SystemRenderer}
* @protected
*/
this.renderer = renderer;
/**
* The only real difference between CanvasPrepare and WebGLPrepare is what they pass
* to upload hooks. That different parameter is stored here.
* @type {PIXI.prepare.CanvasPrepare|PIXI.WebGLRenderer}
* @protected
*/
this.uploadHookHelper = null;
/**
* Collection of items to uploads at once.
* @type {Array<*>}
* @private
*/
this.queue = [];
/**
* Collection of additional hooks for finding assets.
* @type {Array<Function>}
* @private
*/
this.addHooks = [];
/**
* Collection of additional hooks for processing assets.
* @type {Array<Function>}
* @private
*/
this.uploadHooks = [];
/**
* Callback to call after completed.
* @type {Array<Function>}
* @private
*/
this.completes = [];
/**
* If prepare is ticking (running).
* @type {boolean}
* @private
*/
this.ticking = false;
/**
* 'bound' call for prepareItems().
* @type {Function}
* @private
*/
this.delayedTick = function () {
// unlikely, but in case we were destroyed between tick() and delayedTick()
if (!_this.queue) {
return;
}
_this.prepareItems();
};
// hooks to find the correct texture
this.registerFindHook(findText);
this.registerFindHook(findTextStyle);
this.registerFindHook(findMultipleBaseTextures);
this.registerFindHook(findBaseTexture);
this.registerFindHook(findTexture);
// upload hooks
this.registerUploadHook(drawText);
this.registerUploadHook(calculateTextStyle);
}
/**
* Upload all the textures and graphics to the GPU.
*
* @param {Function|PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} item -
* Either the container or display object to search for items to upload, the items to upload themselves,
* or the callback function, if items have been added using `prepare.add`.
* @param {Function} [done] - Optional callback when all queued uploads have completed
*/
BasePrepare.prototype.upload = function upload(item, done) {
if (typeof item === 'function') {
done = item;
item = null;
}
// If a display object, search for items
// that we could upload
if (item) {
this.add(item);
}
// Get the items for upload from the display
if (this.queue.length) {
if (done) {
this.completes.push(done);
}
if (!this.ticking) {
this.ticking = true;
SharedTicker.addOnce(this.tick, this, core.UPDATE_PRIORITY.UTILITY);
}
} else if (done) {
done();
}
};
/**
* Handle tick update
*
* @private
*/
BasePrepare.prototype.tick = function tick() {
setTimeout(this.delayedTick, 0);
};
/**
* Actually prepare items. This is handled outside of the tick because it will take a while
* and we do NOT want to block the current animation frame from rendering.
*
* @private
*/
BasePrepare.prototype.prepareItems = function prepareItems() {
this.limiter.beginFrame();
// Upload the graphics
while (this.queue.length && this.limiter.allowedToUpload()) {
var item = this.queue[0];
var uploaded = false;
if (item && !item._destroyed) {
for (var i = 0, len = this.uploadHooks.length; i < len; i++) {
if (this.uploadHooks[i](this.uploadHookHelper, item)) {
this.queue.shift();
uploaded = true;
break;
}
}
}
if (!uploaded) {
this.queue.shift();
}
}
// We're finished
if (!this.queue.length) {
this.ticking = false;
var completes = this.completes.slice(0);
this.completes.length = 0;
for (var _i = 0, _len = completes.length; _i < _len; _i++) {
completes[_i]();
}
} else {
// if we are not finished, on the next rAF do this again
SharedTicker.addOnce(this.tick, this, core.UPDATE_PRIORITY.UTILITY);
}
};
/**
* Adds hooks for finding items.
*
* @param {Function} addHook - Function call that takes two parameters: `item:*, queue:Array`
* function must return `true` if it was able to add item to the queue.
* @return {PIXI.BasePrepare} Instance of plugin for chaining.
*/
BasePrepare.prototype.registerFindHook = function registerFindHook(addHook) {
if (addHook) {
this.addHooks.push(addHook);
}
return this;
};
/**
* Adds hooks for uploading items.
*
* @param {Function} uploadHook - Function call that takes two parameters: `prepare:CanvasPrepare, item:*` and
* function must return `true` if it was able to handle upload of item.
* @return {PIXI.BasePrepare} Instance of plugin for chaining.
*/
BasePrepare.prototype.registerUploadHook = function registerUploadHook(uploadHook) {
if (uploadHook) {
this.uploadHooks.push(uploadHook);
}
return this;
};
/**
* Manually add an item to the uploading queue.
*
* @param {PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text|*} item - Object to
* add to the queue
* @return {PIXI.CanvasPrepare} Instance of plugin for chaining.
*/
BasePrepare.prototype.add = function add(item) {
// Add additional hooks for finding elements on special
// types of objects that
for (var i = 0, len = this.addHooks.length; i < len; i++) {
if (this.addHooks[i](item, this.queue)) {
break;
}
}
// Get childen recursively
if (item instanceof core.Container) {
for (var _i2 = item.children.length - 1; _i2 >= 0; _i2--) {
this.add(item.children[_i2]);
}
}
return this;
};
/**
* Destroys the plugin, don't use after this.
*
*/
BasePrepare.prototype.destroy = function destroy() {
if (this.ticking) {
SharedTicker.remove(this.tick, this);
}
this.ticking = false;
this.addHooks = null;
this.uploadHooks = null;
this.renderer = null;
this.completes = null;
this.queue = null;
this.limiter = null;
this.uploadHookHelper = null;
};
return BasePrepare;
}();
/**
* Built-in hook to find multiple textures from objects like AnimatedSprites.
*
* @private
* @param {PIXI.DisplayObject} item - Display object to check
* @param {Array<*>} queue - Collection of items to upload
* @return {boolean} if a PIXI.Texture object was found.
*/
exports.default = BasePrepare;
function findMultipleBaseTextures(item, queue) {
var result = false;
// Objects with mutliple textures
if (item && item._textures && item._textures.length) {
for (var i = 0; i < item._textures.length; i++) {
if (item._textures[i] instanceof core.Texture) {
var baseTexture = item._textures[i].baseTexture;
if (queue.indexOf(baseTexture) === -1) {
queue.push(baseTexture);
result = true;
}
}
}
}
return result;
}
/**
* Built-in hook to find BaseTextures from Sprites.
*
* @private
* @param {PIXI.DisplayObject} item - Display object to check
* @param {Array<*>} queue - Collection of items to upload
* @return {boolean} if a PIXI.Texture object was found.
*/
function findBaseTexture(item, queue) {
// Objects with textures, like Sprites/Text
if (item instanceof core.BaseTexture) {
if (queue.indexOf(item) === -1) {
queue.push(item);
}
return true;
}
return false;
}
/**
* Built-in hook to find textures from objects.
*
* @private
* @param {PIXI.DisplayObject} item - Display object to check
* @param {Array<*>} queue - Collection of items to upload
* @return {boolean} if a PIXI.Texture object was found.
*/
function findTexture(item, queue) {
if (item._texture && item._texture instanceof core.Texture) {
var texture = item._texture.baseTexture;
if (queue.indexOf(texture) === -1) {
queue.push(texture);
}
return true;
}
return false;
}
/**
* Built-in hook to draw PIXI.Text to its texture.
*
* @private
* @param {PIXI.WebGLRenderer|PIXI.CanvasPrepare} helper - Not used by this upload handler
* @param {PIXI.DisplayObject} item - Item to check
* @return {boolean} If item was uploaded.
*/
function drawText(helper, item) {
if (item instanceof core.Text) {
// updating text will return early if it is not dirty
item.updateText(true);
return true;
}
return false;
}
/**
* Built-in hook to calculate a text style for a PIXI.Text object.
*
* @private
* @param {PIXI.WebGLRenderer|PIXI.CanvasPrepare} helper - Not used by this upload handler
* @param {PIXI.DisplayObject} item - Item to check
* @return {boolean} If item was uploaded.
*/
function calculateTextStyle(helper, item) {
if (item instanceof core.TextStyle) {
var font = item.toFontString();
core.TextMetrics.measureFont(font);
return true;
}
return false;
}
/**
* Built-in hook to find Text objects.
*
* @private
* @param {PIXI.DisplayObject} item - Display object to check
* @param {Array<*>} queue - Collection of items to upload
* @return {boolean} if a PIXI.Text object was found.
*/
function findText(item, queue) {
if (item instanceof core.Text) {
// push the text style to prepare it - this can be really expensive
if (queue.indexOf(item.style) === -1) {
queue.push(item.style);
}
// also push the text object so that we can render it (to canvas/texture) if needed
if (queue.indexOf(item) === -1) {
queue.push(item);
}
// also push the Text's texture for upload to GPU
var texture = item._texture.baseTexture;
if (queue.indexOf(texture) === -1) {
queue.push(texture);
}
return true;
}
return false;
}
/**
* Built-in hook to find TextStyle objects.
*
* @private
* @param {PIXI.TextStyle} item - Display object to check
* @param {Array<*>} queue - Collection of items to upload
* @return {boolean} if a PIXI.TextStyle object was found.
*/
function findTextStyle(item, queue) {
if (item instanceof core.TextStyle) {
if (queue.indexOf(item) === -1) {
queue.push(item);
}
return true;
}
return false;
}
//# sourceMappingURL=BasePrepare.js.map
/***/ }),
/* 132 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export TimelineLite */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return TimelineLite; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/*!
* 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 */
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine("TimelineLite", ["core.Animation","core.SimpleTimeline","TweenLite"], function() {
var TimelineLite = function(vars) {
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["i" /* SimpleTimeline */].call(this, vars);
var self = this,
v = self.vars,
val, p;
self._labels = {};
self.autoRemoveChildren = !!v.autoRemoveChildren;
self.smoothChildTiming = !!v.smoothChildTiming;
self._sortChildren = true;
self._onUpdate = v.onUpdate;
for (p in v) {
val = v[p];
if (_isArray(val)) if (val.join("").indexOf("{self}") !== -1) {
v[p] = self._swapSelfInParams(val);
}
}
if (_isArray(v.tweens)) {
self.add(v.tweens, 0, v.align, v.stagger);
}
},
_tinyNum = 0.00000001,
TweenLiteInternals = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */]._internals,
_internals = TimelineLite._internals = {},
_isSelector = TweenLiteInternals.isSelector,
_isArray = TweenLiteInternals.isArray,
_lazyTweens = TweenLiteInternals.lazyTweens,
_lazyRender = TweenLiteInternals.lazyRender,
_globals = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine.globals,
_copy = function(vars) {
var copy = {}, p;
for (p in vars) {
copy[p] = vars[p];
}
return copy;
},
_applyCycle = function(vars, targets, i) {
var alt = vars.cycle,
p, val;
for (p in alt) {
val = alt[p];
vars[p] = (typeof(val) === "function") ? val(i, targets[i], targets) : val[i % val.length];
}
delete vars.cycle;
},
_pauseCallback = _internals.pauseCallback = function() {},
_slice = function(a) { //don't use [].slice 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;
},
_defaultImmediateRender = function(tl, toVars, fromVars, defaultFalse) { //default to immediateRender:true unless otherwise set in toVars, fromVars or if defaultFalse is passed in as true
var ir = "immediateRender";
if (!(ir in toVars)) {
toVars[ir] = !((fromVars && fromVars[ir] === false) || defaultFalse);
}
return toVars;
},
//for distributing values across an array. Can accept a number, a function or (most commonly) a function which can contain the following properties: {base, amount, from, ease, grid, axis, length, each}. Returns a function that expects the following parameters: index, target, array. Recognizes the following
_distribute = function(v) {
if (typeof(v) === "function") {
return v;
}
var vars = (typeof(v) === "object") ? v : {each:v}, //n:1 is just to indicate v was a number; we leverage that later to set v according to the length we get. If a number is passed in, we treat it like the old stagger value where 0.1, for example, would mean that things would be distributed with 0.1 between each element in the array rather than a total "amount" that's chunked out among them all.
ease = vars.ease,
from = vars.from || 0,
base = vars.base || 0,
cache = {},
isFromKeyword = isNaN(from),
axis = vars.axis,
ratio = {center:0.5, end:1}[from] || 0;
return function(i, target, a) {
var l = (a || vars).length,
distances = cache[l],
originX, originY, x, y, d, j, max, min, wrap;
if (!distances) {
wrap = (vars.grid === "auto") ? 0 : (vars.grid || [Infinity])[0];
if (!wrap) {
max = -Infinity;
while (max < (max = a[wrap++].getBoundingClientRect().left) && wrap < l) { }
wrap--;
}
distances = cache[l] = [];
originX = isFromKeyword ? (Math.min(wrap, l) * ratio) - 0.5 : from % wrap;
originY = isFromKeyword ? l * ratio / wrap - 0.5 : (from / wrap) | 0;
max = 0;
min = Infinity;
for (j = 0; j < l; j++) {
x = (j % wrap) - originX;
y = originY - ((j / wrap) | 0);
distances[j] = d = !axis ? Math.sqrt(x * x + y * y) : Math.abs((axis === "y") ? y : x);
if (d > max) {
max = d;
}
if (d < min) {
min = d;
}
}
distances.max = max - min;
distances.min = min;
distances.v = l = vars.amount || (vars.each * (wrap > l ? l : !axis ? Math.max(wrap, l / wrap) : axis === "y" ? l / wrap : wrap)) || 0;
distances.b = (l < 0) ? base - l : base;
}
l = (distances[i] - distances.min) / distances.max;
return distances.b + (ease ? ease.getRatio(l) : l) * distances.v;
};
},
p = TimelineLite.prototype = new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["i" /* SimpleTimeline */]();
TimelineLite.version = "2.1.2";
TimelineLite.distribute = _distribute;
p.constructor = TimelineLite;
p.kill()._gc = p._forcingPlayhead = p._hasPause = false;
/* might use later...
//translates a local time inside an animation to the corresponding time on the root/global timeline, factoring in all nesting and timeScales.
function localToGlobal(time, animation) {
while (animation) {
time = (time / animation._timeScale) + animation._startTime;
animation = animation.timeline;
}
return time;
}
//translates the supplied time on the root/global timeline into the corresponding local time inside a particular animation, factoring in all nesting and timeScales
function globalToLocal(time, animation) {
var scale = 1;
time -= localToGlobal(0, animation);
while (animation) {
scale *= animation._timeScale;
animation = animation.timeline;
}
return time * scale;
}
*/
p.to = function(target, duration, vars, position) {
var Engine = (vars.repeat && _globals.TweenMax) || __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */];
return duration ? this.add( new Engine(target, duration, vars), position) : this.set(target, vars, position);
};
p.from = function(target, duration, vars, position) {
return this.add( ((vars.repeat && _globals.TweenMax) || __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */]).from(target, duration, _defaultImmediateRender(this, vars)), position);
};
p.fromTo = function(target, duration, fromVars, toVars, position) {
var Engine = (toVars.repeat && _globals.TweenMax) || __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */];
toVars = _defaultImmediateRender(this, toVars, fromVars);
return duration ? this.add( Engine.fromTo(target, duration, fromVars, toVars), position) : this.set(target, toVars, position);
};
p.staggerTo = function(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
var tl = new TimelineLite({onComplete:onCompleteAll, onCompleteParams:onCompleteAllParams, callbackScope:onCompleteAllScope, smoothChildTiming:this.smoothChildTiming}),
staggerFunc = _distribute(vars.stagger || stagger),
startAt = vars.startAt,
cycle = vars.cycle,
copy, i;
if (typeof(targets) === "string") {
targets = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].selector(targets) || targets;
}
targets = targets || [];
if (_isSelector(targets)) { //if the targets object is a selector, translate it into an array.
targets = _slice(targets);
}
for (i = 0; i < targets.length; i++) {
copy = _copy(vars);
if (startAt) {
copy.startAt = _copy(startAt);
if (startAt.cycle) {
_applyCycle(copy.startAt, targets, i);
}
}
if (cycle) {
_applyCycle(copy, targets, i);
if (copy.duration != null) {
duration = copy.duration;
delete copy.duration;
}
}
tl.to(targets[i], duration, copy, staggerFunc(i, targets[i], targets));
}
return this.add(tl, position);
};
p.staggerFrom = function(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
vars.runBackwards = true;
return this.staggerTo(targets, duration, _defaultImmediateRender(this, vars), stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope);
};
p.staggerFromTo = function(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
toVars.startAt = fromVars;
return this.staggerTo(targets, duration, _defaultImmediateRender(this, toVars, fromVars), stagger, position, onCompleteAll, onCompleteAllParams, onCompleteAllScope);
};
p.call = function(callback, params, scope, position) {
return this.add( __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].delayedCall(0, callback, params, scope), position);
};
p.set = function(target, vars, position) {
return this.add( new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */](target, 0, _defaultImmediateRender(this, vars, null, true)), position);
};
TimelineLite.exportRoot = function(vars, ignoreDelayedCalls) {
vars = vars || {};
if (vars.smoothChildTiming == null) {
vars.smoothChildTiming = true;
}
var tl = new TimelineLite(vars),
root = tl._timeline,
hasNegativeStart, time, tween, next;
if (ignoreDelayedCalls == null) {
ignoreDelayedCalls = true;
}
root._remove(tl, true);
tl._startTime = 0;
tl._rawPrevTime = tl._time = tl._totalTime = root._time;
tween = root._first;
while (tween) {
next = tween._next;
if (!ignoreDelayedCalls || !(tween instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */] && tween.target === tween.vars.onComplete)) {
time = tween._startTime - tween._delay;
if (time < 0) {
hasNegativeStart = 1;
}
tl.add(tween, time);
}
tween = next;
}
root.add(tl, 0);
if (hasNegativeStart) { //calling totalDuration() will force the adjustment necessary to shift the children forward so none of them start before zero, and moves the timeline backwards the same amount, so the playhead is still aligned where it should be globally, but the timeline doesn't have illegal children that start before zero.
tl.totalDuration();
}
return tl;
};
p.add = function(value, position, align, stagger) {
var self = this,
curTime, l, i, child, tl, beforeRawTime;
if (typeof(position) !== "number") {
position = self._parseTimeOrLabel(position, 0, true, value);
}
if (!(value instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */])) {
if ((value instanceof Array) || (value && value.push && _isArray(value))) {
align = align || "normal";
stagger = stagger || 0;
curTime = position;
l = value.length;
for (i = 0; i < l; i++) {
if (_isArray(child = value[i])) {
child = new TimelineLite({tweens:child});
}
self.add(child, curTime);
if (typeof(child) !== "string" && typeof(child) !== "function") {
if (align === "sequence") {
curTime = child._startTime + (child.totalDuration() / child._timeScale);
} else if (align === "start") {
child._startTime -= child.delay();
}
}
curTime += stagger;
}
return self._uncache(true);
} else if (typeof(value) === "string") {
return self.addLabel(value, position);
} else if (typeof(value) === "function") {
value = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].delayedCall(0, value);
} else {
throw("Cannot add " + value + " into the timeline; it is not a tween, timeline, function, or string.");
}
}
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["i" /* SimpleTimeline */].prototype.add.call(self, value, position);
if (value._time || (!value._duration && value._initted)) { //in case, for example, the _startTime is moved on a tween that has already rendered. Imagine it's at its end state, then the startTime is moved WAY later (after the end of this timeline), it should render at its beginning.
curTime = (self.rawTime() - value._startTime) * value._timeScale;
if (!value._duration || Math.abs(Math.max(0, Math.min(value.totalDuration(), curTime))) - value._totalTime > 0.00001) {
value.render(curTime, false, false);
}
}
//if the timeline has already ended but the inserted tween/timeline extends the duration, we should enable this timeline again so that it renders properly. We should also align the playhead with the parent timeline's when appropriate.
if (self._gc || self._time === self._duration) if (!self._paused) if (self._duration < self.duration()) {
//in case any of the ancestors had completed but should now be enabled...
tl = self;
beforeRawTime = (tl.rawTime() > value._startTime); //if the tween is placed on the timeline so that it starts BEFORE the current rawTime, we should align the playhead (move the timeline). This is because sometimes users will create a timeline, let it finish, and much later append a tween and expect it to run instead of jumping to its end state. While technically one could argue that it should jump to its end state, that's not what users intuitively expect.
while (tl._timeline) {
if (beforeRawTime && tl._timeline.smoothChildTiming) {
tl.totalTime(tl._totalTime, true); //moves the timeline (shifts its startTime) if necessary, and also enables it.
} else if (tl._gc) {
tl._enabled(true, false);
}
tl = tl._timeline;
}
}
return self;
};
p.remove = function(value) {
if (value instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */]) {
this._remove(value, false);
var tl = value._timeline = value.vars.useFrames ? __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */]._rootFramesTimeline : __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */]._rootTimeline; //now that it's removed, default it to the root timeline so that if it gets played again, it doesn't jump back into this timeline.
value._startTime = (value._paused ? value._pauseTime : tl._time) - ((!value._reversed ? value._totalTime : value.totalDuration() - value._totalTime) / value._timeScale); //ensure that if it gets played again, the timing is correct.
return this;
} else if (value instanceof Array || (value && value.push && _isArray(value))) {
var i = value.length;
while (--i > -1) {
this.remove(value[i]);
}
return this;
} else if (typeof(value) === "string") {
return this.removeLabel(value);
}
return this.kill(null, value);
};
p._remove = function(tween, skipDisable) {
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["i" /* SimpleTimeline */].prototype._remove.call(this, tween, skipDisable);
var last = this._last;
if (!last) {
this._time = this._totalTime = this._duration = this._totalDuration = 0;
} else if (this._time > this.duration()) {
this._time = this._duration;
this._totalTime = this._totalDuration;
}
return this;
};
p.append = function(value, offsetOrLabel) {
return this.add(value, this._parseTimeOrLabel(null, offsetOrLabel, true, value));
};
p.insert = p.insertMultiple = function(value, position, align, stagger) {
return this.add(value, position || 0, align, stagger);
};
p.appendMultiple = function(tweens, offsetOrLabel, align, stagger) {
return this.add(tweens, this._parseTimeOrLabel(null, offsetOrLabel, true, tweens), align, stagger);
};
p.addLabel = function(label, position) {
this._labels[label] = this._parseTimeOrLabel(position);
return this;
};
p.addPause = function(position, callback, params, scope) {
var t = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].delayedCall(0, _pauseCallback, params, scope || this);
t.vars.onComplete = t.vars.onReverseComplete = callback;
t.data = "isPause";
this._hasPause = true;
return this.add(t, position);
};
p.removeLabel = function(label) {
delete this._labels[label];
return this;
};
p.getLabelTime = function(label) {
return (this._labels[label] != null) ? this._labels[label] : -1;
};
p._parseTimeOrLabel = function(timeOrLabel, offsetOrLabel, appendIfAbsent, ignore) {
var clippedDuration, i;
//if we're about to add a tween/timeline (or an array of them) that's already a child of this timeline, we should remove it first so that it doesn't contaminate the duration().
if (ignore instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */] && ignore.timeline === this) {
this.remove(ignore);
} else if (ignore && ((ignore instanceof Array) || (ignore.push && _isArray(ignore)))) {
i = ignore.length;
while (--i > -1) {
if (ignore[i] instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */] && ignore[i].timeline === this) {
this.remove(ignore[i]);
}
}
}
clippedDuration = (typeof(timeOrLabel) === "number" && !offsetOrLabel) ? 0 : (this.duration() > 99999999999) ? this.recent().endTime(false) : this._duration; //in case there's a child that infinitely repeats, users almost never intend for the insertion point of a new child to be based on a SUPER long value like that so we clip it and assume the most recently-added child's endTime should be used instead.
if (typeof(offsetOrLabel) === "string") {
return this._parseTimeOrLabel(offsetOrLabel, (appendIfAbsent && typeof(timeOrLabel) === "number" && this._labels[offsetOrLabel] == null) ? timeOrLabel - clippedDuration : 0, appendIfAbsent);
}
offsetOrLabel = offsetOrLabel || 0;
if (typeof(timeOrLabel) === "string" && (isNaN(timeOrLabel) || this._labels[timeOrLabel] != null)) { //if the string is a number like "1", check to see if there's a label with that name, otherwise interpret it as a number (absolute value).
i = timeOrLabel.indexOf("=");
if (i === -1) {
if (this._labels[timeOrLabel] == null) {
return appendIfAbsent ? (this._labels[timeOrLabel] = clippedDuration + offsetOrLabel) : offsetOrLabel;
}
return this._labels[timeOrLabel] + offsetOrLabel;
}
offsetOrLabel = parseInt(timeOrLabel.charAt(i-1) + "1", 10) * Number(timeOrLabel.substr(i+1));
timeOrLabel = (i > 1) ? this._parseTimeOrLabel(timeOrLabel.substr(0, i-1), 0, appendIfAbsent) : clippedDuration;
} else if (timeOrLabel == null) {
timeOrLabel = clippedDuration;
}
return Number(timeOrLabel) + offsetOrLabel;
};
p.seek = function(position, suppressEvents) {
return this.totalTime((typeof(position) === "number") ? position : this._parseTimeOrLabel(position), (suppressEvents !== false));
};
p.stop = function() {
return this.paused(true);
};
p.gotoAndPlay = function(position, suppressEvents) {
return this.play(position, suppressEvents);
};
p.gotoAndStop = function(position, suppressEvents) {
return this.pause(position, suppressEvents);
};
p.render = function(time, suppressEvents, force) {
if (this._gc) {
this._enabled(true, false);
}
var self = this,
prevTime = self._time,
totalDur = (!self._dirty) ? self._totalDuration : self.totalDuration(),
prevStart = self._startTime,
prevTimeScale = self._timeScale,
prevPaused = self._paused,
tween, isComplete, next, callback, internalForce, pauseTween, curTime, pauseTime;
if (prevTime !== self._time) { //if totalDuration() finds a child with a negative startTime and smoothChildTiming is true, things get shifted around internally so we need to adjust the time accordingly. For example, if a tween starts at -30 we must shift EVERYTHING forward 30 seconds and move this timeline's startTime backward by 30 seconds so that things align with the playhead (no jump).
time += self._time - prevTime;
}
if (time >= totalDur - _tinyNum && time >= 0) { //to work around occasional floating point math artifacts.
self._totalTime = self._time = totalDur;
if (!self._reversed) if (!self._hasPausedChild()) {
isComplete = true;
callback = "onComplete";
internalForce = !!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 (self._duration === 0) if ((time <= 0 && time >= -_tinyNum) || self._rawPrevTime < 0 || self._rawPrevTime === _tinyNum) if (self._rawPrevTime !== time && self._first) {
internalForce = true;
if (self._rawPrevTime > _tinyNum) {
callback = "onReverseComplete";
}
}
}
self._rawPrevTime = (self._duration || !suppressEvents || time || self._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or 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.
time = totalDur + 0.0001; //to avoid occasional floating point rounding errors - sometimes child tweens/timelines were not being fully completed (their progress might be 0.999999999999998 instead of 1 because when _time - tween._startTime is performed, floating point errors would return a value that was SLIGHTLY off). Try (999999999999.7 - 999999999999) * 1 = 0.699951171875 instead of 0.7.
} else if (time < _tinyNum) { //to work around occasional floating point math artifacts, round super small values to 0.
self._totalTime = self._time = 0;
if (time > -_tinyNum) {
time = 0;
}
if (prevTime !== 0 || (self._duration === 0 && self._rawPrevTime !== _tinyNum && (self._rawPrevTime > 0 || (time < 0 && self._rawPrevTime >= 0)))) {
callback = "onReverseComplete";
isComplete = self._reversed;
}
if (time < 0) {
self._active = false;
if (self._timeline.autoRemoveChildren && self._reversed) { //ensures proper GC if a timeline is resumed after it's finished reversing.
internalForce = isComplete = true;
callback = "onReverseComplete";
} else if (self._rawPrevTime >= 0 && self._first) { //when going back beyond the start, force a render so that zero-duration tweens that sit at the very beginning render their start values properly. Otherwise, if the parent timeline's playhead lands exactly at this timeline's startTime, and then moves backwards, the zero-duration tweens at the beginning would still be at their end state.
internalForce = true;
}
self._rawPrevTime = time;
} else {
self._rawPrevTime = (self._duration || !suppressEvents || time || self._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or 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 (time === 0 && isComplete) { //if there's a zero-duration tween at the very beginning of a timeline and the playhead lands EXACTLY at time 0, that tween will correctly render its end values, but we need to keep the timeline alive for one more render so that the beginning values render properly as the parent's playhead keeps moving beyond the begining. Imagine obj.x starts at 0 and then we do tl.set(obj, {x:100}).to(obj, 1, {x:200}) and then later we tl.reverse()...the goal is to have obj.x revert to 0. If the playhead happens to land on exactly 0, without this chunk of code, it'd complete the timeline and remove it from the rendering queue (not good).
tween = self._first;
while (tween && tween._startTime === 0) {
if (!tween._duration) {
isComplete = false;
}
tween = tween._next;
}
}
time = 0; //to avoid occasional floating point rounding errors (could cause problems especially with zero-duration tweens at the very beginning of the timeline)
if (!self._initted) {
internalForce = true;
}
}
} else {
if (self._hasPause && !self._forcingPlayhead && !suppressEvents) {
if (time >= prevTime) {
tween = self._first;
while (tween && tween._startTime <= time && !pauseTween) {
if (!tween._duration) if (tween.data === "isPause" && !tween.ratio && !(tween._startTime === 0 && self._rawPrevTime === 0)) {
pauseTween = tween;
}
tween = tween._next;
}
} else {
tween = self._last;
while (tween && tween._startTime >= time && !pauseTween) {
if (!tween._duration) if (tween.data === "isPause" && tween._rawPrevTime > 0) {
pauseTween = tween;
}
tween = tween._prev;
}
}
if (pauseTween) {
self._time = self._totalTime = time = pauseTween._startTime;
pauseTime = self._startTime + (time / self._timeScale);
}
}
self._totalTime = self._time = self._rawPrevTime = time;
}
if ((self._time === prevTime || !self._first) && !force && !internalForce && !pauseTween) {
return;
} else if (!self._initted) {
self._initted = true;
}
if (!self._active) if (!self._paused && self._time !== prevTime && time > 0) {
self._active = true; //so that if the user renders the timeline (as opposed to the parent timeline rendering it), it is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the timeline already finished but the user manually re-renders it as halfway done, for example.
}
if (prevTime === 0) if (self.vars.onStart) if (self._time !== 0 || !self._duration) if (!suppressEvents) {
self._callback("onStart");
}
curTime = self._time;
if (curTime >= prevTime) {
tween = self._first;
while (tween) {
next = tween._next; //record it here because the value could change after rendering...
if (curTime !== self._time || (self._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete
break;
} else if (tween._active || (tween._startTime <= curTime && !tween._paused && !tween._gc)) {
if (pauseTween === tween) {
self.pause();
self._pauseTime = pauseTime; //so that when we resume(), it's starting from exactly the right spot (the pause() method uses the rawTime for the parent, but that may be a bit too far ahead)
}
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;
}
} else {
tween = self._last;
while (tween) {
next = tween._prev; //record it here because the value could change after rendering...
if (curTime !== self._time || (self._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete
break;
} else if (tween._active || (tween._startTime <= prevTime && !tween._paused && !tween._gc)) {
if (pauseTween === tween) {
pauseTween = tween._prev; //the linked list is organized by _startTime, thus it's possible that a tween could start BEFORE the pause and end after it, in which case it would be positioned before the pause tween in the linked list, but we should render it before we pause() the timeline and cease rendering. This is only a concern when going in reverse.
while (pauseTween && pauseTween.endTime() > self._time) {
pauseTween.render( (pauseTween._reversed ? pauseTween.totalDuration() - ((time - pauseTween._startTime) * pauseTween._timeScale) : (time - pauseTween._startTime) * pauseTween._timeScale), suppressEvents, force);
pauseTween = pauseTween._prev;
}
pauseTween = null;
self.pause();
self._pauseTime = pauseTime; //so that when we resume(), it's starting from exactly the right spot (the pause() method uses the rawTime for the parent, but that may be a bit too far ahead)
}
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;
}
}
if (self._onUpdate) if (!suppressEvents) {
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onUpdate on a timeline that reports/checks tweened values.
_lazyRender();
}
self._callback("onUpdate");
}
if (callback) if (!self._gc) if (prevStart === self._startTime || prevTimeScale !== self._timeScale) if (self._time === 0 || totalDur >= self.totalDuration()) { //if one of the tweens that was rendered altered this timeline's startTime (like if an onComplete reversed the timeline), it probably isn't complete. If it is, don't worry, because whatever call altered the startTime would complete if it was necessary at the new time. The only exception is the timeScale property. Also check _gc because there's a chance that kill() could be called in an onUpdate
if (isComplete) {
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onComplete on a timeline that reports/checks tweened values.
_lazyRender();
}
if (self._timeline.autoRemoveChildren) {
self._enabled(false, false);
}
self._active = false;
}
if (!suppressEvents && self.vars[callback]) {
self._callback(callback);
}
}
};
p._hasPausedChild = function() {
var tween = this._first;
while (tween) {
if (tween._paused || ((tween instanceof TimelineLite) && tween._hasPausedChild())) {
return true;
}
tween = tween._next;
}
return false;
};
p.getChildren = function(nested, tweens, timelines, ignoreBeforeTime) {
ignoreBeforeTime = ignoreBeforeTime || -9999999999;
var a = [],
tween = this._first,
cnt = 0;
while (tween) {
if (tween._startTime < ignoreBeforeTime) {
//do nothing
} else if (tween instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */]) {
if (tweens !== false) {
a[cnt++] = tween;
}
} else {
if (timelines !== false) {
a[cnt++] = tween;
}
if (nested !== false) {
a = a.concat(tween.getChildren(true, tweens, timelines));
cnt = a.length;
}
}
tween = tween._next;
}
return a;
};
p.getTweensOf = function(target, nested) {
var disabled = this._gc,
a = [],
cnt = 0,
tweens, i;
if (disabled) {
this._enabled(true, true); //getTweensOf() filters out disabled tweens, and we have to mark them as _gc = true when the timeline completes in order to allow clean garbage collection, so temporarily re-enable the timeline here.
}
tweens = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].getTweensOf(target);
i = tweens.length;
while (--i > -1) {
if (tweens[i].timeline === this || (nested && this._contains(tweens[i]))) {
a[cnt++] = tweens[i];
}
}
if (disabled) {
this._enabled(false, true);
}
return a;
};
p.recent = function() {
return this._recent;
};
p._contains = function(tween) {
var tl = tween.timeline;
while (tl) {
if (tl === this) {
return true;
}
tl = tl.timeline;
}
return false;
};
p.shiftChildren = function(amount, adjustLabels, ignoreBeforeTime) {
ignoreBeforeTime = ignoreBeforeTime || 0;
var tween = this._first,
labels = this._labels,
p;
while (tween) {
if (tween._startTime >= ignoreBeforeTime) {
tween._startTime += amount;
}
tween = tween._next;
}
if (adjustLabels) {
for (p in labels) {
if (labels[p] >= ignoreBeforeTime) {
labels[p] += amount;
}
}
}
return this._uncache(true);
};
p._kill = function(vars, target) {
if (!vars && !target) {
return this._enabled(false, false);
}
var tweens = (!target) ? this.getChildren(true, true, false) : this.getTweensOf(target),
i = tweens.length,
changed = false;
while (--i > -1) {
if (tweens[i]._kill(vars, target)) {
changed = true;
}
}
return changed;
};
p.clear = function(labels) {
var tweens = this.getChildren(false, true, true),
i = tweens.length;
this._time = this._totalTime = 0;
while (--i > -1) {
tweens[i]._enabled(false, false);
}
if (labels !== false) {
this._labels = {};
}
return this._uncache(true);
};
p.invalidate = function() {
var tween = this._first;
while (tween) {
tween.invalidate();
tween = tween._next;
}
return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */].prototype.invalidate.call(this);;
};
p._enabled = function(enabled, ignoreTimeline) {
if (enabled === this._gc) {
var tween = this._first;
while (tween) {
tween._enabled(enabled, true);
tween = tween._next;
}
}
return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["i" /* SimpleTimeline */].prototype._enabled.call(this, enabled, ignoreTimeline);
};
p.totalTime = function(time, suppressEvents, uncapped) {
this._forcingPlayhead = true;
var val = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */].prototype.totalTime.apply(this, arguments);
this._forcingPlayhead = false;
return val;
};
p.duration = function(value) {
if (!arguments.length) {
if (this._dirty) {
this.totalDuration(); //just triggers recalculation
}
return this._duration;
}
if (this.duration() !== 0 && value !== 0) {
this.timeScale(this._duration / value);
}
return this;
};
p.totalDuration = function(value) {
if (!arguments.length) {
if (this._dirty) {
var max = 0,
self = this,
tween = self._last,
prevStart = 999999999999,
prev, end;
while (tween) {
prev = tween._prev; //record it here in case the tween changes position in the sequence...
if (tween._dirty) {
tween.totalDuration(); //could change the tween._startTime, so make sure the tween's cache is clean before analyzing it.
}
if (tween._startTime > prevStart && self._sortChildren && !tween._paused && !self._calculatingDuration) { //in case one of the tweens shifted out of order, it needs to be re-inserted into the correct position in the sequence
self._calculatingDuration = 1; //prevent endless recursive calls - there are methods that get triggered that check duration/totalDuration when we add(), like _parseTimeOrLabel().
self.add(tween, tween._startTime - tween._delay);
self._calculatingDuration = 0;
} else {
prevStart = tween._startTime;
}
if (tween._startTime < 0 && !tween._paused) { //children aren't allowed to have negative startTimes unless smoothChildTiming is true, so adjust here if one is found.
max -= tween._startTime;
if (self._timeline.smoothChildTiming) {
self._startTime += tween._startTime / self._timeScale;
self._time -= tween._startTime;
self._totalTime -= tween._startTime;
self._rawPrevTime -= tween._startTime;
}
self.shiftChildren(-tween._startTime, false, -9999999999);
prevStart = 0;
}
end = tween._startTime + (tween._totalDuration / tween._timeScale);
if (end > max) {
max = end;
}
tween = prev;
}
self._duration = self._totalDuration = max;
self._dirty = false;
}
return this._totalDuration;
}
return (value && this.totalDuration()) ? this.timeScale(this._totalDuration / value) : this;
};
p.paused = function(value) {
if (value === false && this._paused) { //if there's a pause directly at the spot from where we're unpausing, skip it.
var tween = this._first;
while (tween) {
if (tween._startTime === this._time && tween.data === "isPause") {
tween._rawPrevTime = 0; //remember, _rawPrevTime is how zero-duration tweens/callbacks sense directionality and determine whether or not to fire. If _rawPrevTime is the same as _startTime on the next render, it won't fire.
}
tween = tween._next;
}
}
return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */].prototype.paused.apply(this, arguments);
};
p.usesFrames = function() {
var tl = this._timeline;
while (tl._timeline) {
tl = tl._timeline;
}
return (tl === __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */]._rootFramesTimeline);
};
p.rawTime = function(wrapRepeats) {
return (wrapRepeats && (this._paused || (this._repeat && this.time() > 0 && this.totalProgress() < 1))) ? this._totalTime % (this._duration + this._repeatDelay) : this._paused ? this._totalTime : (this._timeline.rawTime(wrapRepeats) - this._startTime) * this._timeScale;
};
return TimelineLite;
}, true);
var TimelineLite = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].TimelineLite;
/***/ }),
/* 133 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = !__webpack_require__(10) && !__webpack_require__(4)(function () {
return Object.defineProperty(__webpack_require__(89)('div'), 'a', { get: function () { return 7; } }).a != 7;
});
/***/ }),
/* 134 */
/***/ (function(module, exports, __webpack_require__) {
exports.f = __webpack_require__(8);
/***/ }),
/* 135 */
/***/ (function(module, exports, __webpack_require__) {
var has = __webpack_require__(19);
var toIObject = __webpack_require__(20);
var arrayIndexOf = __webpack_require__(70)(false);
var IE_PROTO = __webpack_require__(91)('IE_PROTO');
module.exports = function (object, names) {
var O = toIObject(object);
var i = 0;
var result = [];
var key;
for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
// Don't enum bug & hidden keys
while (names.length > i) if (has(O, key = names[i++])) {
~arrayIndexOf(result, key) || result.push(key);
}
return result;
};
/***/ }),
/* 136 */
/***/ (function(module, exports, __webpack_require__) {
var dP = __webpack_require__(11);
var anObject = __webpack_require__(1);
var getKeys = __webpack_require__(43);
module.exports = __webpack_require__(10) ? Object.defineProperties : function defineProperties(O, Properties) {
anObject(O);
var keys = getKeys(Properties);
var length = keys.length;
var i = 0;
var P;
while (length > i) dP.f(O, P = keys[i++], Properties[P]);
return O;
};
/***/ }),
/* 137 */
/***/ (function(module, exports, __webpack_require__) {
// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
var toIObject = __webpack_require__(20);
var gOPN = __webpack_require__(46).f;
var toString = {}.toString;
var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
? Object.getOwnPropertyNames(window) : [];
var getWindowNames = function (it) {
try {
return gOPN(it);
} catch (e) {
return windowNames.slice();
}
};
module.exports.f = function getOwnPropertyNames(it) {
return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
};
/***/ }),
/* 138 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 19.1.2.1 Object.assign(target, source, ...)
var getKeys = __webpack_require__(43);
var gOPS = __webpack_require__(71);
var pIE = __webpack_require__(61);
var toObject = __webpack_require__(12);
var IObject = __webpack_require__(60);
var $assign = Object.assign;
// should work with symbols and should have deterministic property order (V8 bug)
module.exports = !$assign || __webpack_require__(4)(function () {
var A = {};
var B = {};
// eslint-disable-next-line no-undef
var S = Symbol();
var K = 'abcdefghijklmnopqrst';
A[S] = 7;
K.split('').forEach(function (k) { B[k] = k; });
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
var T = toObject(target);
var aLen = arguments.length;
var index = 1;
var getSymbols = gOPS.f;
var isEnum = pIE.f;
while (aLen > index) {
var S = IObject(arguments[index++]);
var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
var length = keys.length;
var j = 0;
var key;
while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
} return T;
} : $assign;
/***/ }),
/* 139 */
/***/ (function(module, exports) {
// 7.2.9 SameValue(x, y)
module.exports = Object.is || function is(x, y) {
// eslint-disable-next-line no-self-compare
return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
};
/***/ }),
/* 140 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var aFunction = __webpack_require__(15);
var isObject = __webpack_require__(6);
var invoke = __webpack_require__(141);
var arraySlice = [].slice;
var factories = {};
var construct = function (F, len, args) {
if (!(len in factories)) {
for (var n = [], i = 0; i < len; i++) n[i] = 'a[' + i + ']';
// eslint-disable-next-line no-new-func
factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')');
} return factories[len](F, args);
};
module.exports = Function.bind || function bind(that /* , ...args */) {
var fn = aFunction(this);
var partArgs = arraySlice.call(arguments, 1);
var bound = function (/* args... */) {
var args = partArgs.concat(arraySlice.call(arguments));
return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that);
};
if (isObject(fn.prototype)) bound.prototype = fn.prototype;
return bound;
};
/***/ }),
/* 141 */
/***/ (function(module, exports) {
// fast apply, http://jsperf.lnkit.com/fast-apply/5
module.exports = function (fn, args, that) {
var un = that === undefined;
switch (args.length) {
case 0: return un ? fn()
: fn.call(that);
case 1: return un ? fn(args[0])
: fn.call(that, args[0]);
case 2: return un ? fn(args[0], args[1])
: fn.call(that, args[0], args[1]);
case 3: return un ? fn(args[0], args[1], args[2])
: fn.call(that, args[0], args[1], args[2]);
case 4: return un ? fn(args[0], args[1], args[2], args[3])
: fn.call(that, args[0], args[1], args[2], args[3]);
} return fn.apply(that, args);
};
/***/ }),
/* 142 */
/***/ (function(module, exports, __webpack_require__) {
var $parseInt = __webpack_require__(2).parseInt;
var $trim = __webpack_require__(56).trim;
var ws = __webpack_require__(95);
var hex = /^[-+]?0[xX]/;
module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? function parseInt(str, radix) {
var string = $trim(String(str), 3);
return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
} : $parseInt;
/***/ }),
/* 143 */
/***/ (function(module, exports, __webpack_require__) {
var $parseFloat = __webpack_require__(2).parseFloat;
var $trim = __webpack_require__(56).trim;
module.exports = 1 / $parseFloat(__webpack_require__(95) + '-0') !== -Infinity ? function parseFloat(str) {
var string = $trim(String(str), 3);
var result = $parseFloat(string);
return result === 0 && string.charAt(0) == '-' ? -0 : result;
} : $parseFloat;
/***/ }),
/* 144 */
/***/ (function(module, exports, __webpack_require__) {
var cof = __webpack_require__(26);
module.exports = function (it, msg) {
if (typeof it != 'number' && cof(it) != 'Number') throw TypeError(msg);
return +it;
};
/***/ }),
/* 145 */
/***/ (function(module, exports, __webpack_require__) {
// 20.1.2.3 Number.isInteger(number)
var isObject = __webpack_require__(6);
var floor = Math.floor;
module.exports = function isInteger(it) {
return !isObject(it) && isFinite(it) && floor(it) === it;
};
/***/ }),
/* 146 */
/***/ (function(module, exports) {
// 20.2.2.20 Math.log1p(x)
module.exports = Math.log1p || function log1p(x) {
return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x);
};
/***/ }),
/* 147 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.16 Math.fround(x)
var sign = __webpack_require__(98);
var pow = Math.pow;
var EPSILON = pow(2, -52);
var EPSILON32 = pow(2, -23);
var MAX32 = pow(2, 127) * (2 - EPSILON32);
var MIN32 = pow(2, -126);
var roundTiesToEven = function (n) {
return n + 1 / EPSILON - 1 / EPSILON;
};
module.exports = Math.fround || function fround(x) {
var $abs = Math.abs(x);
var $sign = sign(x);
var a, result;
if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
a = (1 + EPSILON32 / EPSILON) * $abs;
result = a - (a - $abs);
// eslint-disable-next-line no-self-compare
if (result > MAX32 || result != result) return $sign * Infinity;
return $sign * result;
};
/***/ }),
/* 148 */
/***/ (function(module, exports, __webpack_require__) {
// call something on iterator step with safe closing on error
var anObject = __webpack_require__(1);
module.exports = function (iterator, fn, value, entries) {
try {
return entries ? fn(anObject(value)[0], value[1]) : fn(value);
// 7.4.6 IteratorClose(iterator, completion)
} catch (e) {
var ret = iterator['return'];
if (ret !== undefined) anObject(ret.call(iterator));
throw e;
}
};
/***/ }),
/* 149 */
/***/ (function(module, exports, __webpack_require__) {
var aFunction = __webpack_require__(15);
var toObject = __webpack_require__(12);
var IObject = __webpack_require__(60);
var toLength = __webpack_require__(9);
module.exports = function (that, callbackfn, aLen, memo, isRight) {
aFunction(callbackfn);
var O = toObject(that);
var self = IObject(O);
var length = toLength(O.length);
var index = isRight ? length - 1 : 0;
var i = isRight ? -1 : 1;
if (aLen < 2) for (;;) {
if (index in self) {
memo = self[index];
index += i;
break;
}
index += i;
if (isRight ? index < 0 : length <= index) {
throw TypeError('Reduce of empty array with no initial value');
}
}
for (;isRight ? index >= 0 : length > index; index += i) if (index in self) {
memo = callbackfn(memo, self[index], index, O);
}
return memo;
};
/***/ }),
/* 150 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
var toObject = __webpack_require__(12);
var toAbsoluteIndex = __webpack_require__(44);
var toLength = __webpack_require__(9);
module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {
var O = toObject(this);
var len = toLength(O.length);
var to = toAbsoluteIndex(target, len);
var from = toAbsoluteIndex(start, len);
var end = arguments.length > 2 ? arguments[2] : undefined;
var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
var inc = 1;
if (from < to && to < from + count) {
inc = -1;
from += count - 1;
to += count - 1;
}
while (count-- > 0) {
if (from in O) O[to] = O[from];
else delete O[to];
to += inc;
from += inc;
} return O;
};
/***/ }),
/* 151 */
/***/ (function(module, exports) {
module.exports = function (done, value) {
return { value: value, done: !!done };
};
/***/ }),
/* 152 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var regexpExec = __webpack_require__(110);
__webpack_require__(0)({
target: 'RegExp',
proto: true,
forced: regexpExec !== /./.exec
}, {
exec: regexpExec
});
/***/ }),
/* 153 */
/***/ (function(module, exports, __webpack_require__) {
// 21.2.5.3 get RegExp.prototype.flags()
if (__webpack_require__(10) && /./g.flags != 'g') __webpack_require__(11).f(RegExp.prototype, 'flags', {
configurable: true,
get: __webpack_require__(62)
});
/***/ }),
/* 154 */
/***/ (function(module, exports) {
module.exports = function (exec) {
try {
return { e: false, v: exec() };
} catch (e) {
return { e: true, v: e };
}
};
/***/ }),
/* 155 */
/***/ (function(module, exports, __webpack_require__) {
var anObject = __webpack_require__(1);
var isObject = __webpack_require__(6);
var newPromiseCapability = __webpack_require__(114);
module.exports = function (C, x) {
anObject(C);
if (isObject(x) && x.constructor === C) return x;
var promiseCapability = newPromiseCapability.f(C);
var resolve = promiseCapability.resolve;
resolve(x);
return promiseCapability.promise;
};
/***/ }),
/* 156 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var strong = __webpack_require__(157);
var validate = __webpack_require__(51);
var MAP = 'Map';
// 23.1 Map Objects
module.exports = __webpack_require__(79)(MAP, function (get) {
return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
}, {
// 23.1.3.6 Map.prototype.get(key)
get: function get(key) {
var entry = strong.getEntry(validate(this, MAP), key);
return entry && entry.v;
},
// 23.1.3.9 Map.prototype.set(key, value)
set: function set(key, value) {
return strong.def(validate(this, MAP), key === 0 ? 0 : key, value);
}
}, strong, true);
/***/ }),
/* 157 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var dP = __webpack_require__(11).f;
var create = __webpack_require__(45);
var redefineAll = __webpack_require__(50);
var ctx = __webpack_require__(25);
var anInstance = __webpack_require__(48);
var forOf = __webpack_require__(49);
var $iterDefine = __webpack_require__(100);
var step = __webpack_require__(151);
var setSpecies = __webpack_require__(47);
var DESCRIPTORS = __webpack_require__(10);
var fastKey = __webpack_require__(38).fastKey;
var validate = __webpack_require__(51);
var SIZE = DESCRIPTORS ? '_s' : 'size';
var getEntry = function (that, key) {
// fast case
var index = fastKey(key);
var entry;
if (index !== 'F') return that._i[index];
// frozen object case
for (entry = that._f; entry; entry = entry.n) {
if (entry.k == key) return entry;
}
};
module.exports = {
getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
var C = wrapper(function (that, iterable) {
anInstance(that, C, NAME, '_i');
that._t = NAME; // collection type
that._i = create(null); // index
that._f = undefined; // first entry
that._l = undefined; // last entry
that[SIZE] = 0; // size
if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
});
redefineAll(C.prototype, {
// 23.1.3.1 Map.prototype.clear()
// 23.2.3.2 Set.prototype.clear()
clear: function clear() {
for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
entry.r = true;
if (entry.p) entry.p = entry.p.n = undefined;
delete data[entry.i];
}
that._f = that._l = undefined;
that[SIZE] = 0;
},
// 23.1.3.3 Map.prototype.delete(key)
// 23.2.3.4 Set.prototype.delete(value)
'delete': function (key) {
var that = validate(this, NAME);
var entry = getEntry(that, key);
if (entry) {
var next = entry.n;
var prev = entry.p;
delete that._i[entry.i];
entry.r = true;
if (prev) prev.n = next;
if (next) next.p = prev;
if (that._f == entry) that._f = next;
if (that._l == entry) that._l = prev;
that[SIZE]--;
} return !!entry;
},
// 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
// 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
forEach: function forEach(callbackfn /* , that = undefined */) {
validate(this, NAME);
var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
var entry;
while (entry = entry ? entry.n : this._f) {
f(entry.v, entry.k, this);
// revert to the last existing entry
while (entry && entry.r) entry = entry.p;
}
},
// 23.1.3.7 Map.prototype.has(key)
// 23.2.3.7 Set.prototype.has(value)
has: function has(key) {
return !!getEntry(validate(this, NAME), key);
}
});
if (DESCRIPTORS) dP(C.prototype, 'size', {
get: function () {
return validate(this, NAME)[SIZE];
}
});
return C;
},
def: function (that, key, value) {
var entry = getEntry(that, key);
var prev, index;
// change existing entry
if (entry) {
entry.v = value;
// create new entry
} else {
that._l = entry = {
i: index = fastKey(key, true), // <- index
k: key, // <- key
v: value, // <- value
p: prev = that._l, // <- previous entry
n: undefined, // <- next entry
r: false // <- removed
};
if (!that._f) that._f = entry;
if (prev) prev.n = entry;
that[SIZE]++;
// add to index
if (index !== 'F') that._i[index] = entry;
} return that;
},
getEntry: getEntry,
setStrong: function (C, NAME, IS_MAP) {
// add .keys, .values, .entries, [@@iterator]
// 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
$iterDefine(C, NAME, function (iterated, kind) {
this._t = validate(iterated, NAME); // target
this._k = kind; // kind
this._l = undefined; // previous
}, function () {
var that = this;
var kind = that._k;
var entry = that._l;
// revert to the last existing entry
while (entry && entry.r) entry = entry.p;
// get next entry
if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
// or finish the iteration
that._t = undefined;
return step(1);
}
// return step by kind
if (kind == 'keys') return step(0, entry.k);
if (kind == 'values') return step(0, entry.v);
return step(0, [entry.k, entry.v]);
}, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
// add [@@species], 23.1.2.2, 23.2.2.2
setSpecies(NAME);
}
};
/***/ }),
/* 158 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var strong = __webpack_require__(157);
var validate = __webpack_require__(51);
var SET = 'Set';
// 23.2 Set Objects
module.exports = __webpack_require__(79)(SET, function (get) {
return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
}, {
// 23.2.3.1 Set.prototype.add(value)
add: function add(value) {
return strong.def(validate(this, SET), value = value === 0 ? 0 : value, value);
}
}, strong);
/***/ }),
/* 159 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var global = __webpack_require__(2);
var each = __webpack_require__(33)(0);
var redefine = __webpack_require__(17);
var meta = __webpack_require__(38);
var assign = __webpack_require__(138);
var weak = __webpack_require__(160);
var isObject = __webpack_require__(6);
var validate = __webpack_require__(51);
var NATIVE_WEAK_MAP = __webpack_require__(51);
var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
var WEAK_MAP = 'WeakMap';
var getWeak = meta.getWeak;
var isExtensible = Object.isExtensible;
var uncaughtFrozenStore = weak.ufstore;
var InternalMap;
var wrapper = function (get) {
return function WeakMap() {
return get(this, arguments.length > 0 ? arguments[0] : undefined);
};
};
var methods = {
// 23.3.3.3 WeakMap.prototype.get(key)
get: function get(key) {
if (isObject(key)) {
var data = getWeak(key);
if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
return data ? data[this._i] : undefined;
}
},
// 23.3.3.5 WeakMap.prototype.set(key, value)
set: function set(key, value) {
return weak.def(validate(this, WEAK_MAP), key, value);
}
};
// 23.3 WeakMap Objects
var $WeakMap = module.exports = __webpack_require__(79)(WEAK_MAP, wrapper, methods, weak, true, true);
// IE11 WeakMap frozen keys fix
if (NATIVE_WEAK_MAP && IS_IE11) {
InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
assign(InternalMap.prototype, methods);
meta.NEED = true;
each(['delete', 'has', 'get', 'set'], function (key) {
var proto = $WeakMap.prototype;
var method = proto[key];
redefine(proto, key, function (a, b) {
// store frozen objects on internal weakmap shim
if (isObject(a) && !isExtensible(a)) {
if (!this._f) this._f = new InternalMap();
var result = this._f[key](a, b);
return key == 'set' ? this : result;
// store all the rest on native weakmap
} return method.call(this, a, b);
});
});
}
/***/ }),
/* 160 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var redefineAll = __webpack_require__(50);
var getWeak = __webpack_require__(38).getWeak;
var anObject = __webpack_require__(1);
var isObject = __webpack_require__(6);
var anInstance = __webpack_require__(48);
var forOf = __webpack_require__(49);
var createArrayMethod = __webpack_require__(33);
var $has = __webpack_require__(19);
var validate = __webpack_require__(51);
var arrayFind = createArrayMethod(5);
var arrayFindIndex = createArrayMethod(6);
var id = 0;
// fallback for uncaught frozen keys
var uncaughtFrozenStore = function (that) {
return that._l || (that._l = new UncaughtFrozenStore());
};
var UncaughtFrozenStore = function () {
this.a = [];
};
var findUncaughtFrozen = function (store, key) {
return arrayFind(store.a, function (it) {
return it[0] === key;
});
};
UncaughtFrozenStore.prototype = {
get: function (key) {
var entry = findUncaughtFrozen(this, key);
if (entry) return entry[1];
},
has: function (key) {
return !!findUncaughtFrozen(this, key);
},
set: function (key, value) {
var entry = findUncaughtFrozen(this, key);
if (entry) entry[1] = value;
else this.a.push([key, value]);
},
'delete': function (key) {
var index = arrayFindIndex(this.a, function (it) {
return it[0] === key;
});
if (~index) this.a.splice(index, 1);
return !!~index;
}
};
module.exports = {
getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
var C = wrapper(function (that, iterable) {
anInstance(that, C, NAME, '_i');
that._t = NAME; // collection type
that._i = id++; // collection id
that._l = undefined; // leak store for uncaught frozen objects
if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
});
redefineAll(C.prototype, {
// 23.3.3.2 WeakMap.prototype.delete(key)
// 23.4.3.3 WeakSet.prototype.delete(value)
'delete': function (key) {
if (!isObject(key)) return false;
var data = getWeak(key);
if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
return data && $has(data, this._i) && delete data[this._i];
},
// 23.3.3.4 WeakMap.prototype.has(key)
// 23.4.3.4 WeakSet.prototype.has(value)
has: function has(key) {
if (!isObject(key)) return false;
var data = getWeak(key);
if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
return data && $has(data, this._i);
}
});
return C;
},
def: function (that, key, value) {
var data = getWeak(anObject(key), true);
if (data === true) uncaughtFrozenStore(that).set(key, value);
else data[that._i] = value;
return that;
},
ufstore: uncaughtFrozenStore
};
/***/ }),
/* 161 */
/***/ (function(module, exports, __webpack_require__) {
// https://tc39.github.io/ecma262/#sec-toindex
var toInteger = __webpack_require__(27);
var toLength = __webpack_require__(9);
module.exports = function (it) {
if (it === undefined) return 0;
var number = toInteger(it);
var length = toLength(number);
if (number !== length) throw RangeError('Wrong length!');
return length;
};
/***/ }),
/* 162 */
/***/ (function(module, exports, __webpack_require__) {
// all object keys, includes non-enumerable and symbols
var gOPN = __webpack_require__(46);
var gOPS = __webpack_require__(71);
var anObject = __webpack_require__(1);
var Reflect = __webpack_require__(2).Reflect;
module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) {
var keys = gOPN.f(anObject(it));
var getSymbols = gOPS.f;
return getSymbols ? keys.concat(getSymbols(it)) : keys;
};
/***/ }),
/* 163 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
var isArray = __webpack_require__(72);
var isObject = __webpack_require__(6);
var toLength = __webpack_require__(9);
var ctx = __webpack_require__(25);
var IS_CONCAT_SPREADABLE = __webpack_require__(8)('isConcatSpreadable');
function flattenIntoArray(target, original, source, sourceLen, start, depth, mapper, thisArg) {
var targetIndex = start;
var sourceIndex = 0;
var mapFn = mapper ? ctx(mapper, thisArg, 3) : false;
var element, spreadable;
while (sourceIndex < sourceLen) {
if (sourceIndex in source) {
element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
spreadable = false;
if (isObject(element)) {
spreadable = element[IS_CONCAT_SPREADABLE];
spreadable = spreadable !== undefined ? !!spreadable : isArray(element);
}
if (spreadable && depth > 0) {
targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1;
} else {
if (targetIndex >= 0x1fffffffffffff) throw TypeError();
target[targetIndex] = element;
}
targetIndex++;
}
sourceIndex++;
}
return targetIndex;
}
module.exports = flattenIntoArray;
/***/ }),
/* 164 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/tc39/proposal-string-pad-start-end
var toLength = __webpack_require__(9);
var repeat = __webpack_require__(97);
var defined = __webpack_require__(31);
module.exports = function (that, maxLength, fillString, left) {
var S = String(defined(that));
var stringLength = S.length;
var fillStr = fillString === undefined ? ' ' : String(fillString);
var intMaxLength = toLength(maxLength);
if (intMaxLength <= stringLength || fillStr == '') return S;
var fillLen = intMaxLength - stringLength;
var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);
return left ? stringFiller + S : S + stringFiller;
};
/***/ }),
/* 165 */
/***/ (function(module, exports, __webpack_require__) {
var getKeys = __webpack_require__(43);
var toIObject = __webpack_require__(20);
var isEnum = __webpack_require__(61).f;
module.exports = function (isEntries) {
return function (it) {
var O = toIObject(it);
var keys = getKeys(O);
var length = keys.length;
var i = 0;
var result = [];
var key;
while (length > i) if (isEnum.call(O, key = keys[i++])) {
result.push(isEntries ? [key, O[key]] : O[key]);
} return result;
};
};
/***/ }),
/* 166 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
var classof = __webpack_require__(55);
var from = __webpack_require__(167);
module.exports = function (NAME) {
return function toJSON() {
if (classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
return from(this);
};
};
/***/ }),
/* 167 */
/***/ (function(module, exports, __webpack_require__) {
var forOf = __webpack_require__(49);
module.exports = function (iter, ITERATOR) {
var result = [];
forOf(iter, false, result.push, result, ITERATOR);
return result;
};
/***/ }),
/* 168 */
/***/ (function(module, exports) {
// https://rwaldron.github.io/proposal-math-extensions/
module.exports = Math.scale || function scale(x, inLow, inHigh, outLow, outHigh) {
if (
arguments.length === 0
// eslint-disable-next-line no-self-compare
|| x != x
// eslint-disable-next-line no-self-compare
|| inLow != inLow
// eslint-disable-next-line no-self-compare
|| inHigh != inHigh
// eslint-disable-next-line no-self-compare
|| outLow != outLow
// eslint-disable-next-line no-self-compare
|| outHigh != outHigh
) return NaN;
if (x === Infinity || x === -Infinity) return x;
return (x - inLow) * (outHigh - outLow) / (inHigh - inLow) + outLow;
};
/***/ }),
/* 169 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: 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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Browser = function () {
function Browser() {
_classCallCheck(this, Browser);
this.isIE = false;
this.isIE8 = false;
this.isIE9 = false;
this.isFirefox = false;
this.isSafari = false;
this.isChrome = false;
this.isMobile = false;
this.isAndroid = false;
this.isiOS = false;
this.isPC = false;
this.init();
}
_createClass(Browser, [{
key: 'init',
value: function init() {
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.match(/msie ([\d\.]+)/) || userAgent.match(/trident/)) {
this.isIE = true;
} else if (userAgent.match('firefox')) {
this.isFirefox = true;
} else if (userAgent.match('chrome')) {
this.isChrome = true;
} else if (userAgent.match('crios')) {
this.isChrome = true;
} else if (userAgent.match('safari') && userAgent.indexOf('chrome') == -1) {
this.isSafari = true;
}
if (userAgent.search(/iphone/) != -1 || userAgent.search(/ipad/) != -1 || userAgent.search(/ipod/) != -1) {
this.isMobile = true;
this.isiOS = true;
} else if (userAgent.search(/android/) != -1) {
this.isMobile = true;
this.isAndroid = true;
}
if (!this.isMobile) {
this.isPC = true;
}
}
}]);
return Browser;
}();
exports.default = Browser;
module.exports = new Browser();
/***/ }),
/* 170 */
/***/ (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; }; }();
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.
* An observable point is a point that triggers a callback when the point's position is changed.
*
* @class
* @memberof PIXI
*/
var ObservablePoint = function () {
/**
* @param {Function} cb - callback when changed
* @param {object} scope - owner of callback
* @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 ObservablePoint(cb, scope) {
var x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
_classCallCheck(this, ObservablePoint);
this._x = x;
this._y = y;
this.cb = cb;
this.scope = scope;
}
/**
* Creates a clone of this point.
* The callback and scope params can be overidden otherwise they will default
* to the clone object's values.
*
* @override
* @param {Function} [cb=null] - callback when changed
* @param {object} [scope=null] - owner of callback
* @return {PIXI.ObservablePoint} a copy of the point
*/
ObservablePoint.prototype.clone = function clone() {
var cb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var _cb = cb || this.cb;
var _scope = scope || this.scope;
return new ObservablePoint(_cb, _scope, this._x, 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
*/
ObservablePoint.prototype.set = function set(x, y) {
var _x = x || 0;
var _y = y || (y !== 0 ? _x : 0);
if (this._x !== _x || this._y !== _y) {
this._x = _x;
this._y = _y;
this.cb.call(this.scope);
}
};
/**
* Copies the data from another point
*
* @param {PIXI.Point|PIXI.ObservablePoint} point - point to copy from
*/
ObservablePoint.prototype.copy = function copy(point) {
if (this._x !== point.x || this._y !== point.y) {
this._x = point.x;
this._y = point.y;
this.cb.call(this.scope);
}
};
/**
* Returns true if the given point is equal to this point
*
* @param {PIXI.Point|PIXI.ObservablePoint} p - The point to check
* @returns {boolean} Whether the given point equal to this point
*/
ObservablePoint.prototype.equals = function equals(p) {
return p.x === this._x && p.y === this._y;
};
/**
* The position of the displayObject on the x axis relative to the local coordinates of the parent.
*
* @member {number}
*/
_createClass(ObservablePoint, [{
key: "x",
get: function get() {
return this._x;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (this._x !== value) {
this._x = value;
this.cb.call(this.scope);
}
}
/**
* The position of the displayObject on the x axis relative to the local coordinates of the parent.
*
* @member {number}
*/
}, {
key: "y",
get: function get() {
return this._y;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (this._y !== value) {
this._y = value;
this.cb.call(this.scope);
}
}
}]);
return ObservablePoint;
}();
exports.default = ObservablePoint;
//# sourceMappingURL=ObservablePoint.js.map
/***/ }),
/* 171 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Matrix = __webpack_require__(118);
var _Matrix2 = _interopRequireDefault(_Matrix);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1]; // Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16
var uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1];
var vx = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1];
var vy = [1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, -1];
var tempMatrices = [];
var mul = [];
function signum(x) {
if (x < 0) {
return -1;
}
if (x > 0) {
return 1;
}
return 0;
}
function init() {
for (var i = 0; i < 16; i++) {
var row = [];
mul.push(row);
for (var j = 0; j < 16; j++) {
var _ux = signum(ux[i] * ux[j] + vx[i] * uy[j]);
var _uy = signum(uy[i] * ux[j] + vy[i] * uy[j]);
var _vx = signum(ux[i] * vx[j] + vx[i] * vy[j]);
var _vy = signum(uy[i] * vx[j] + vy[i] * vy[j]);
for (var k = 0; k < 16; k++) {
if (ux[k] === _ux && uy[k] === _uy && vx[k] === _vx && vy[k] === _vy) {
row.push(k);
break;
}
}
}
}
for (var _i = 0; _i < 16; _i++) {
var mat = new _Matrix2.default();
mat.set(ux[_i], uy[_i], vx[_i], vy[_i], 0, 0);
tempMatrices.push(mat);
}
}
init();
/**
* Implements Dihedral Group D_8, see [group D4]{@link http://mathworld.wolfram.com/DihedralGroupD4.html},
* D8 is the same but with diagonals. Used for texture rotations.
*
* Vector xX(i), xY(i) is U-axis of sprite with rotation i
* Vector yY(i), yY(i) is V-axis of sprite with rotation i
* Rotations: 0 grad (0), 90 grad (2), 180 grad (4), 270 grad (6)
* Mirrors: vertical (8), main diagonal (10), horizontal (12), reverse diagonal (14)
* This is the small part of gameofbombs.com portal system. It works.
*
* @author Ivan @ivanpopelyshev
* @class
* @memberof PIXI
*/
var GroupD8 = {
E: 0,
SE: 1,
S: 2,
SW: 3,
W: 4,
NW: 5,
N: 6,
NE: 7,
MIRROR_VERTICAL: 8,
MIRROR_HORIZONTAL: 12,
uX: function uX(ind) {
return ux[ind];
},
uY: function uY(ind) {
return uy[ind];
},
vX: function vX(ind) {
return vx[ind];
},
vY: function vY(ind) {
return vy[ind];
},
inv: function inv(rotation) {
if (rotation & 8) {
return rotation & 15;
}
return -rotation & 7;
},
add: function add(rotationSecond, rotationFirst) {
return mul[rotationSecond][rotationFirst];
},
sub: function sub(rotationSecond, rotationFirst) {
return mul[rotationSecond][GroupD8.inv(rotationFirst)];
},
/**
* Adds 180 degrees to rotation. Commutative operation.
*
* @memberof PIXI.GroupD8
* @param {number} rotation - The number to rotate.
* @returns {number} rotated number
*/
rotate180: function rotate180(rotation) {
return rotation ^ 4;
},
/**
* Direction of main vector can be horizontal, vertical or diagonal.
* Some objects work with vertical directions different.
*
* @memberof PIXI.GroupD8
* @param {number} rotation - The number to check.
* @returns {boolean} Whether or not the direction is vertical
*/
isVertical: function isVertical(rotation) {
return (rotation & 3) === 2;
},
/**
* @memberof PIXI.GroupD8
* @param {number} dx - TODO
* @param {number} dy - TODO
*
* @return {number} TODO
*/
byDirection: function byDirection(dx, dy) {
if (Math.abs(dx) * 2 <= Math.abs(dy)) {
if (dy >= 0) {
return GroupD8.S;
}
return GroupD8.N;
} else if (Math.abs(dy) * 2 <= Math.abs(dx)) {
if (dx > 0) {
return GroupD8.E;
}
return GroupD8.W;
} else if (dy > 0) {
if (dx > 0) {
return GroupD8.SE;
}
return GroupD8.SW;
} else if (dx > 0) {
return GroupD8.NE;
}
return GroupD8.NW;
},
/**
* Helps sprite to compensate texture packer rotation.
*
* @memberof PIXI.GroupD8
* @param {PIXI.Matrix} matrix - sprite world matrix
* @param {number} rotation - The rotation factor to use.
* @param {number} tx - sprite anchoring
* @param {number} ty - sprite anchoring
*/
matrixAppendRotationInv: function matrixAppendRotationInv(matrix, rotation) {
var tx = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var ty = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
// Packer used "rotation", we use "inv(rotation)"
var mat = tempMatrices[GroupD8.inv(rotation)];
mat.tx = tx;
mat.ty = ty;
matrix.append(mat);
}
};
exports.default = GroupD8;
//# sourceMappingURL=GroupD8.js.map
/***/ }),
/* 172 */
/***/ (function(module, exports) {
// var GL_MAP = {};
/**
* @param gl {WebGLRenderingContext} The current WebGL context
* @param attribs {*}
* @param state {*}
*/
var setVertexAttribArrays = function (gl, attribs, state)
{
var i;
if(state)
{
var tempAttribState = state.tempAttribState,
attribState = state.attribState;
for (i = 0; i < tempAttribState.length; i++)
{
tempAttribState[i] = false;
}
// set the new attribs
for (i = 0; i < attribs.length; i++)
{
tempAttribState[attribs[i].attribute.location] = true;
}
for (i = 0; i < attribState.length; i++)
{
if (attribState[i] !== tempAttribState[i])
{
attribState[i] = tempAttribState[i];
if (state.attribState[i])
{
gl.enableVertexAttribArray(i);
}
else
{
gl.disableVertexAttribArray(i);
}
}
}
}
else
{
for (i = 0; i < attribs.length; i++)
{
var attrib = attribs[i];
gl.enableVertexAttribArray(attrib.attribute.location);
}
}
};
module.exports = setVertexAttribArrays;
/***/ }),
/* 173 */
/***/ (function(module, exports) {
/**
* Helper class to create a WebGL Texture
*
* @class
* @memberof PIXI.glCore
* @param gl {WebGLRenderingContext} The current WebGL context
* @param width {number} the width of the texture
* @param height {number} the height of the texture
* @param format {number} the pixel format of the texture. defaults to gl.RGBA
* @param type {number} the gl type of the texture. defaults to gl.UNSIGNED_BYTE
*/
var Texture = function(gl, width, height, format, type)
{
/**
* The current WebGL rendering context
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
/**
* The WebGL texture
*
* @member {WebGLTexture}
*/
this.texture = gl.createTexture();
/**
* If mipmapping was used for this texture, enable and disable with enableMipmap()
*
* @member {Boolean}
*/
// some settings..
this.mipmap = false;
/**
* Set to true to enable pre-multiplied alpha
*
* @member {Boolean}
*/
this.premultiplyAlpha = false;
/**
* The width of texture
*
* @member {Number}
*/
this.width = width || -1;
/**
* The height of texture
*
* @member {Number}
*/
this.height = height || -1;
/**
* The pixel format of the texture. defaults to gl.RGBA
*
* @member {Number}
*/
this.format = format || gl.RGBA;
/**
* The gl type of the texture. defaults to gl.UNSIGNED_BYTE
*
* @member {Number}
*/
this.type = type || gl.UNSIGNED_BYTE;
};
/**
* Uploads this texture to the GPU
* @param source {HTMLImageElement|ImageData|HTMLVideoElement} the source image of the texture
*/
Texture.prototype.upload = function(source)
{
this.bind();
var gl = this.gl;
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha);
var newWidth = source.videoWidth || source.width;
var newHeight = source.videoHeight || source.height;
if(newHeight !== this.height || newWidth !== this.width)
{
gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, this.type, source);
}
else
{
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.format, this.type, source);
}
// if the source is a video, we need to use the videoWidth / videoHeight properties as width / height will be incorrect.
this.width = newWidth;
this.height = newHeight;
};
var FLOATING_POINT_AVAILABLE = false;
/**
* Use a data source and uploads this texture to the GPU
* @param data {TypedArray} the data to upload to the texture
* @param width {number} the new width of the texture
* @param height {number} the new height of the texture
*/
Texture.prototype.uploadData = function(data, width, height)
{
this.bind();
var gl = this.gl;
if(data instanceof Float32Array)
{
if(!FLOATING_POINT_AVAILABLE)
{
var ext = gl.getExtension("OES_texture_float");
if(ext)
{
FLOATING_POINT_AVAILABLE = true;
}
else
{
throw new Error('floating point textures not available');
}
}
this.type = gl.FLOAT;
}
else
{
// TODO support for other types
this.type = this.type || gl.UNSIGNED_BYTE;
}
// what type of data?
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha);
if(width !== this.width || height !== this.height)
{
gl.texImage2D(gl.TEXTURE_2D, 0, this.format, width, height, 0, this.format, this.type, data || null);
}
else
{
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, width, height, this.format, this.type, data || null);
}
this.width = width;
this.height = height;
// texSubImage2D
};
/**
* Binds the texture
* @param location
*/
Texture.prototype.bind = function(location)
{
var gl = this.gl;
if(location !== undefined)
{
gl.activeTexture(gl.TEXTURE0 + location);
}
gl.bindTexture(gl.TEXTURE_2D, this.texture);
};
/**
* Unbinds the texture
*/
Texture.prototype.unbind = function()
{
var gl = this.gl;
gl.bindTexture(gl.TEXTURE_2D, null);
};
/**
* @param linear {Boolean} if we want to use linear filtering or nearest neighbour interpolation
*/
Texture.prototype.minFilter = function( linear )
{
var gl = this.gl;
this.bind();
if(this.mipmap)
{
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, linear ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST);
}
else
{
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, linear ? gl.LINEAR : gl.NEAREST);
}
};
/**
* @param linear {Boolean} if we want to use linear filtering or nearest neighbour interpolation
*/
Texture.prototype.magFilter = function( linear )
{
var gl = this.gl;
this.bind();
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, linear ? gl.LINEAR : gl.NEAREST);
};
/**
* Enables mipmapping
*/
Texture.prototype.enableMipmap = function()
{
var gl = this.gl;
this.bind();
this.mipmap = true;
gl.generateMipmap(gl.TEXTURE_2D);
};
/**
* Enables linear filtering
*/
Texture.prototype.enableLinearScaling = function()
{
this.minFilter(true);
this.magFilter(true);
};
/**
* Enables nearest neighbour interpolation
*/
Texture.prototype.enableNearestScaling = function()
{
this.minFilter(false);
this.magFilter(false);
};
/**
* Enables clamping on the texture so WebGL will not repeat it
*/
Texture.prototype.enableWrapClamp = function()
{
var gl = this.gl;
this.bind();
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
};
/**
* Enable tiling on the texture
*/
Texture.prototype.enableWrapRepeat = function()
{
var gl = this.gl;
this.bind();
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
};
Texture.prototype.enableWrapMirrorRepeat = function()
{
var gl = this.gl;
this.bind();
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.MIRRORED_REPEAT);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.MIRRORED_REPEAT);
};
/**
* Destroys this texture
*/
Texture.prototype.destroy = function()
{
var gl = this.gl;
//TODO
gl.deleteTexture(this.texture);
};
/**
* @static
* @param gl {WebGLRenderingContext} The current WebGL context
* @param source {HTMLImageElement|ImageData} the source image of the texture
* @param premultiplyAlpha {Boolean} If we want to use pre-multiplied alpha
*/
Texture.fromSource = function(gl, source, premultiplyAlpha)
{
var texture = new Texture(gl);
texture.premultiplyAlpha = premultiplyAlpha || false;
texture.upload(source);
return texture;
};
/**
* @static
* @param gl {WebGLRenderingContext} The current WebGL context
* @param data {TypedArray} the data to upload to the texture
* @param width {number} the new width of the texture
* @param height {number} the new height of the texture
*/
Texture.fromData = function(gl, data, width, height)
{
//console.log(data, width, height);
var texture = new Texture(gl);
texture.uploadData(data, width, height);
return texture;
};
module.exports = Texture;
/***/ }),
/* 174 */
/***/ (function(module, exports) {
/**
* @class
* @memberof PIXI.glCore.shader
* @param gl {WebGLRenderingContext} The current WebGL context {WebGLProgram}
* @param vertexSrc {string|string[]} The vertex shader source as an array of strings.
* @param fragmentSrc {string|string[]} The fragment shader source as an array of strings.
* @param attributeLocations {Object} An attribute location map that lets you manually set the attribute locations
* @return {WebGLProgram} the shader program
*/
var compileProgram = function(gl, vertexSrc, fragmentSrc, attributeLocations)
{
var glVertShader = compileShader(gl, gl.VERTEX_SHADER, vertexSrc);
var glFragShader = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSrc);
var program = gl.createProgram();
gl.attachShader(program, glVertShader);
gl.attachShader(program, glFragShader);
// optionally, set the attributes manually for the program rather than letting WebGL decide..
if(attributeLocations)
{
for(var i in attributeLocations)
{
gl.bindAttribLocation(program, attributeLocations[i], i);
}
}
gl.linkProgram(program);
// if linking fails, then log and cleanup
if (!gl.getProgramParameter(program, gl.LINK_STATUS))
{
console.error('Pixi.js Error: Could not initialize shader.');
console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS));
console.error('gl.getError()', gl.getError());
// if there is a program info log, log it
if (gl.getProgramInfoLog(program) !== '')
{
console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program));
}
gl.deleteProgram(program);
program = null;
}
// clean up some shaders
gl.deleteShader(glVertShader);
gl.deleteShader(glFragShader);
return program;
};
/**
* @private
* @param gl {WebGLRenderingContext} The current WebGL context {WebGLProgram}
* @param type {Number} the type, can be either VERTEX_SHADER or FRAGMENT_SHADER
* @param vertexSrc {string|string[]} The vertex shader source as an array of strings.
* @return {WebGLShader} the shader
*/
var compileShader = function (gl, type, src)
{
var shader = gl.createShader(type);
gl.shaderSource(shader, src);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS))
{
console.log(gl.getShaderInfoLog(shader));
return null;
}
return shader;
};
module.exports = compileProgram;
/***/ }),
/* 175 */
/***/ (function(module, exports, __webpack_require__) {
var mapType = __webpack_require__(120);
var mapSize = __webpack_require__(176);
/**
* Extracts the attributes
* @class
* @memberof PIXI.glCore.shader
* @param gl {WebGLRenderingContext} The current WebGL rendering context
* @param program {WebGLProgram} The shader program to get the attributes from
* @return attributes {Object}
*/
var extractAttributes = function(gl, program)
{
var attributes = {};
var totalAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
for (var i = 0; i < totalAttributes; i++)
{
var attribData = gl.getActiveAttrib(program, i);
var type = mapType(gl, attribData.type);
attributes[attribData.name] = {
type:type,
size:mapSize(type),
location:gl.getAttribLocation(program, attribData.name),
//TODO - make an attribute object
pointer: pointer
};
}
return attributes;
};
var pointer = function(type, normalized, stride, start){
// console.log(this.location)
gl.vertexAttribPointer(this.location,this.size, type || gl.FLOAT, normalized || false, stride || 0, start || 0);
};
module.exports = extractAttributes;
/***/ }),
/* 176 */
/***/ (function(module, exports) {
/**
* @class
* @memberof PIXI.glCore.shader
* @param type {String}
* @return {Number}
*/
var mapSize = function(type)
{
return GLSL_TO_SIZE[type];
};
var GLSL_TO_SIZE = {
'float': 1,
'vec2': 2,
'vec3': 3,
'vec4': 4,
'int': 1,
'ivec2': 2,
'ivec3': 3,
'ivec4': 4,
'bool': 1,
'bvec2': 2,
'bvec3': 3,
'bvec4': 4,
'mat2': 4,
'mat3': 9,
'mat4': 16,
'sampler2D': 1
};
module.exports = mapSize;
/***/ }),
/* 177 */
/***/ (function(module, exports, __webpack_require__) {
var mapType = __webpack_require__(120);
var defaultValue = __webpack_require__(178);
/**
* Extracts the uniforms
* @class
* @memberof PIXI.glCore.shader
* @param gl {WebGLRenderingContext} The current WebGL rendering context
* @param program {WebGLProgram} The shader program to get the uniforms from
* @return uniforms {Object}
*/
var extractUniforms = function(gl, program)
{
var uniforms = {};
var totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
for (var i = 0; i < totalUniforms; i++)
{
var uniformData = gl.getActiveUniform(program, i);
var name = uniformData.name.replace(/\[.*?\]/, "");
var type = mapType(gl, uniformData.type );
uniforms[name] = {
type:type,
size:uniformData.size,
location:gl.getUniformLocation(program, name),
value:defaultValue(type, uniformData.size)
};
}
return uniforms;
};
module.exports = extractUniforms;
/***/ }),
/* 178 */
/***/ (function(module, exports) {
/**
* @class
* @memberof PIXI.glCore.shader
* @param type {String} Type of value
* @param size {Number}
*/
var defaultValue = function(type, size)
{
switch (type)
{
case 'float':
return 0;
case 'vec2':
return new Float32Array(2 * size);
case 'vec3':
return new Float32Array(3 * size);
case 'vec4':
return new Float32Array(4 * size);
case 'int':
case 'sampler2D':
return 0;
case 'ivec2':
return new Int32Array(2 * size);
case 'ivec3':
return new Int32Array(3 * size);
case 'ivec4':
return new Int32Array(4 * size);
case 'bool':
return false;
case 'bvec2':
return booleanArray( 2 * size);
case 'bvec3':
return booleanArray(3 * size);
case 'bvec4':
return booleanArray(4 * size);
case 'mat2':
return new Float32Array([1, 0,
0, 1]);
case 'mat3':
return new Float32Array([1, 0, 0,
0, 1, 0,
0, 0, 1]);
case 'mat4':
return new Float32Array([1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1]);
}
};
var booleanArray = function(size)
{
var array = new Array(size);
for (var i = 0; i < array.length; i++)
{
array[i] = false;
}
return array;
};
module.exports = defaultValue;
/***/ }),
/* 179 */
/***/ (function(module, exports) {
/**
* Sets the float precision on the shader. If the precision is already present this function will do nothing
* @param {string} src the shader source
* @param {string} precision The float precision of the shader. Options are 'lowp', 'mediump' or 'highp'.
*
* @return {string} modified shader source
*/
var setPrecision = function(src, precision)
{
if(src.substring(0, 9) !== 'precision')
{
return 'precision ' + precision + ' float;\n' + src;
}
return src;
};
module.exports = setPrecision;
/***/ }),
/* 180 */
/***/ (function(module, exports) {
/**
* Extracts the attributes
* @class
* @memberof PIXI.glCore.shader
* @param gl {WebGLRenderingContext} The current WebGL rendering context
* @param uniforms {Array} @mat ?
* @return attributes {Object}
*/
var generateUniformAccessObject = function(gl, uniformData)
{
// this is the object we will be sending back.
// an object hierachy will be created for structs
var uniforms = {data:{}};
uniforms.gl = gl;
var uniformKeys= Object.keys(uniformData);
for (var i = 0; i < uniformKeys.length; i++)
{
var fullName = uniformKeys[i];
var nameTokens = fullName.split('.');
var name = nameTokens[nameTokens.length - 1];
var uniformGroup = getUniformGroup(nameTokens, uniforms);
var uniform = uniformData[fullName];
uniformGroup.data[name] = uniform;
uniformGroup.gl = gl;
Object.defineProperty(uniformGroup, name, {
get: generateGetter(name),
set: generateSetter(name, uniform)
});
}
return uniforms;
};
var generateGetter = function(name)
{
return function() {
return this.data[name].value;
};
};
var GLSL_SINGLE_SETTERS = {
float: function setSingleFloat(gl, location, value) { gl.uniform1f(location, value); },
vec2: function setSingleVec2(gl, location, value) { gl.uniform2f(location, value[0], value[1]); },
vec3: function setSingleVec3(gl, location, value) { gl.uniform3f(location, value[0], value[1], value[2]); },
vec4: function setSingleVec4(gl, location, value) { gl.uniform4f(location, value[0], value[1], value[2], value[3]); },
int: function setSingleInt(gl, location, value) { gl.uniform1i(location, value); },
ivec2: function setSingleIvec2(gl, location, value) { gl.uniform2i(location, value[0], value[1]); },
ivec3: function setSingleIvec3(gl, location, value) { gl.uniform3i(location, value[0], value[1], value[2]); },
ivec4: function setSingleIvec4(gl, location, value) { gl.uniform4i(location, value[0], value[1], value[2], value[3]); },
bool: function setSingleBool(gl, location, value) { gl.uniform1i(location, value); },
bvec2: function setSingleBvec2(gl, location, value) { gl.uniform2i(location, value[0], value[1]); },
bvec3: function setSingleBvec3(gl, location, value) { gl.uniform3i(location, value[0], value[1], value[2]); },
bvec4: function setSingleBvec4(gl, location, value) { gl.uniform4i(location, value[0], value[1], value[2], value[3]); },
mat2: function setSingleMat2(gl, location, value) { gl.uniformMatrix2fv(location, false, value); },
mat3: function setSingleMat3(gl, location, value) { gl.uniformMatrix3fv(location, false, value); },
mat4: function setSingleMat4(gl, location, value) { gl.uniformMatrix4fv(location, false, value); },
sampler2D: function setSingleSampler2D(gl, location, value) { gl.uniform1i(location, value); },
};
var GLSL_ARRAY_SETTERS = {
float: function setFloatArray(gl, location, value) { gl.uniform1fv(location, value); },
vec2: function setVec2Array(gl, location, value) { gl.uniform2fv(location, value); },
vec3: function setVec3Array(gl, location, value) { gl.uniform3fv(location, value); },
vec4: function setVec4Array(gl, location, value) { gl.uniform4fv(location, value); },
int: function setIntArray(gl, location, value) { gl.uniform1iv(location, value); },
ivec2: function setIvec2Array(gl, location, value) { gl.uniform2iv(location, value); },
ivec3: function setIvec3Array(gl, location, value) { gl.uniform3iv(location, value); },
ivec4: function setIvec4Array(gl, location, value) { gl.uniform4iv(location, value); },
bool: function setBoolArray(gl, location, value) { gl.uniform1iv(location, value); },
bvec2: function setBvec2Array(gl, location, value) { gl.uniform2iv(location, value); },
bvec3: function setBvec3Array(gl, location, value) { gl.uniform3iv(location, value); },
bvec4: function setBvec4Array(gl, location, value) { gl.uniform4iv(location, value); },
sampler2D: function setSampler2DArray(gl, location, value) { gl.uniform1iv(location, value); },
};
function generateSetter(name, uniform)
{
return function(value) {
this.data[name].value = value;
var location = this.data[name].location;
if (uniform.size === 1)
{
GLSL_SINGLE_SETTERS[uniform.type](this.gl, location, value);
}
else
{
// glslSetArray(gl, location, type, value) {
GLSL_ARRAY_SETTERS[uniform.type](this.gl, location, value);
}
};
}
function getUniformGroup(nameTokens, uniform)
{
var cur = uniform;
for (var i = 0; i < nameTokens.length - 1; i++)
{
var o = cur[nameTokens[i]] || {data:{}};
cur[nameTokens[i]] = o;
cur = o;
}
return cur;
}
module.exports = generateUniformAccessObject;
/***/ }),
/* 181 */
/***/ (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 _eventemitter = __webpack_require__(52);
var _eventemitter2 = _interopRequireDefault(_eventemitter);
var _const = __webpack_require__(3);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
var _TransformStatic = __webpack_require__(182);
var _TransformStatic2 = _interopRequireDefault(_TransformStatic);
var _Transform = __webpack_require__(183);
var _Transform2 = _interopRequireDefault(_Transform);
var _Bounds = __webpack_require__(121);
var _Bounds2 = _interopRequireDefault(_Bounds);
var _math = __webpack_require__(14);
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; }
// _tempDisplayObjectParent = new DisplayObject();
/**
* The base class for all objects that are rendered on the screen.
* This is an abstract class and should not be used on its own rather it should be extended.
*
* @class
* @extends EventEmitter
* @memberof PIXI
*/
var DisplayObject = function (_EventEmitter) {
_inherits(DisplayObject, _EventEmitter);
/**
*
*/
function DisplayObject() {
_classCallCheck(this, DisplayObject);
var _this = _possibleConstructorReturn(this, _EventEmitter.call(this));
var TransformClass = _settings2.default.TRANSFORM_MODE === _const.TRANSFORM_MODE.STATIC ? _TransformStatic2.default : _Transform2.default;
_this.tempDisplayObjectParent = null;
// TODO: need to create Transform from factory
/**
* World transform and local transform of this object.
* This will become read-only later, please do not assign anything there unless you know what are you doing
*
* @member {PIXI.TransformBase}
*/
_this.transform = new TransformClass();
/**
* The opacity of the object.
*
* @member {number}
*/
_this.alpha = 1;
/**
* The visibility of the object. If false the object will not be drawn, and
* the updateTransform function will not be called.
*
* Only affects recursive calls from parent. You can ask for bounds or call updateTransform manually
*
* @member {boolean}
*/
_this.visible = true;
/**
* Can this object be rendered, if false the object will not be drawn but the updateTransform
* methods will still be called.
*
* Only affects recursive calls from parent. You can ask for bounds manually
*
* @member {boolean}
*/
_this.renderable = true;
/**
* The display object container that contains this display object.
*
* @member {PIXI.Container}
* @readonly
*/
_this.parent = null;
/**
* The multiplied alpha of the displayObject
*
* @member {number}
* @readonly
*/
_this.worldAlpha = 1;
/**
* The area the filter is applied to. This is used as more of an optimisation
* rather than figuring out the dimensions of the displayObject each frame you can set this rectangle
*
* Also works as an interaction mask
*
* @member {PIXI.Rectangle}
*/
_this.filterArea = null;
_this._filters = null;
_this._enabledFilters = null;
/**
* The bounds object, this is used to calculate and store the bounds of the displayObject
*
* @member {PIXI.Rectangle}
* @private
*/
_this._bounds = new _Bounds2.default();
_this._boundsID = 0;
_this._lastBoundsID = -1;
_this._boundsRect = null;
_this._localBoundsRect = null;
/**
* The original, cached mask of the object
*
* @member {PIXI.Graphics|PIXI.Sprite}
* @private
*/
_this._mask = null;
/**
* If the object has been destroyed via destroy(). If true, it should not be used.
*
* @member {boolean}
* @private
* @readonly
*/
_this._destroyed = false;
/**
* Fired when this DisplayObject is added to a Container.
*
* @event PIXI.DisplayObject#added
* @param {PIXI.Container} container - The container added to.
*/
/**
* Fired when this DisplayObject is removed from a Container.
*
* @event PIXI.DisplayObject#removed
* @param {PIXI.Container} container - The container removed from.
*/
return _this;
}
/**
* @private
* @member {PIXI.DisplayObject}
*/
/**
* Updates the object transform for rendering
*
* TODO - Optimization pass!
*/
DisplayObject.prototype.updateTransform = function updateTransform() {
this.transform.updateTransform(this.parent.transform);
// multiply the alphas..
this.worldAlpha = this.alpha * this.parent.worldAlpha;
this._bounds.updateID++;
};
/**
* recursively updates transform of all objects from the root to this one
* internal function for toLocal()
*/
DisplayObject.prototype._recursivePostUpdateTransform = function _recursivePostUpdateTransform() {
if (this.parent) {
this.parent._recursivePostUpdateTransform();
this.transform.updateTransform(this.parent.transform);
} else {
this.transform.updateTransform(this._tempDisplayObjectParent.transform);
}
};
/**
* Retrieves the bounds of the displayObject as a rectangle object.
*
* @param {boolean} skipUpdate - setting to true will stop the transforms of the scene graph from
* being updated. This means the calculation returned MAY be out of date BUT will give you a
* nice performance boost
* @param {PIXI.Rectangle} rect - Optional rectangle to store the result of the bounds calculation
* @return {PIXI.Rectangle} the rectangular bounding area
*/
DisplayObject.prototype.getBounds = function getBounds(skipUpdate, rect) {
if (!skipUpdate) {
if (!this.parent) {
this.parent = this._tempDisplayObjectParent;
this.updateTransform();
this.parent = null;
} else {
this._recursivePostUpdateTransform();
this.updateTransform();
}
}
if (this._boundsID !== this._lastBoundsID) {
this.calculateBounds();
}
if (!rect) {
if (!this._boundsRect) {
this._boundsRect = new _math.Rectangle();
}
rect = this._boundsRect;
}
return this._bounds.getRectangle(rect);
};
/**
* Retrieves the local bounds of the displayObject as a rectangle object
*
* @param {PIXI.Rectangle} [rect] - Optional rectangle to store the result of the bounds calculation
* @return {PIXI.Rectangle} the rectangular bounding area
*/
DisplayObject.prototype.getLocalBounds = function getLocalBounds(rect) {
var transformRef = this.transform;
var parentRef = this.parent;
this.parent = null;
this.transform = this._tempDisplayObjectParent.transform;
if (!rect) {
if (!this._localBoundsRect) {
this._localBoundsRect = new _math.Rectangle();
}
rect = this._localBoundsRect;
}
var bounds = this.getBounds(false, rect);
this.parent = parentRef;
this.transform = transformRef;
return bounds;
};
/**
* Calculates the global position of the display object
*
* @param {PIXI.Point} position - The world origin to calculate from
* @param {PIXI.Point} [point] - A Point object in which to store the value, optional
* (otherwise will create a new Point)
* @param {boolean} [skipUpdate=false] - Should we skip the update transform.
* @return {PIXI.Point} A point object representing the position of this object
*/
DisplayObject.prototype.toGlobal = function toGlobal(position, point) {
var skipUpdate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (!skipUpdate) {
this._recursivePostUpdateTransform();
// this parent check is for just in case the item is a root object.
// If it is we need to give it a temporary parent so that displayObjectUpdateTransform works correctly
// this is mainly to avoid a parent check in the main loop. Every little helps for performance :)
if (!this.parent) {
this.parent = this._tempDisplayObjectParent;
this.displayObjectUpdateTransform();
this.parent = null;
} else {
this.displayObjectUpdateTransform();
}
}
// don't need to update the lot
return this.worldTransform.apply(position, point);
};
/**
* Calculates the local position of the display object relative to another point
*
* @param {PIXI.Point} position - The world origin to calculate from
* @param {PIXI.DisplayObject} [from] - The DisplayObject to calculate the global position from
* @param {PIXI.Point} [point] - A Point object in which to store the value, optional
* (otherwise will create a new Point)
* @param {boolean} [skipUpdate=false] - Should we skip the update transform
* @return {PIXI.Point} A point object representing the position of this object
*/
DisplayObject.prototype.toLocal = function toLocal(position, from, point, skipUpdate) {
if (from) {
position = from.toGlobal(position, point, skipUpdate);
}
if (!skipUpdate) {
this._recursivePostUpdateTransform();
// this parent check is for just in case the item is a root object.
// If it is we need to give it a temporary parent so that displayObjectUpdateTransform works correctly
// this is mainly to avoid a parent check in the main loop. Every little helps for performance :)
if (!this.parent) {
this.parent = this._tempDisplayObjectParent;
this.displayObjectUpdateTransform();
this.parent = null;
} else {
this.displayObjectUpdateTransform();
}
}
// simply apply the matrix..
return this.worldTransform.applyInverse(position, point);
};
/**
* Renders the object using the WebGL renderer
*
* @param {PIXI.WebGLRenderer} renderer - The renderer
*/
DisplayObject.prototype.renderWebGL = function renderWebGL(renderer) // eslint-disable-line no-unused-vars
{}
// OVERWRITE;
/**
* Renders the object using the Canvas renderer
*
* @param {PIXI.CanvasRenderer} renderer - The renderer
*/
;
DisplayObject.prototype.renderCanvas = function renderCanvas(renderer) // eslint-disable-line no-unused-vars
{}
// OVERWRITE;
/**
* Set the parent Container of this DisplayObject
*
* @param {PIXI.Container} container - The Container to add this DisplayObject to
* @return {PIXI.Container} The Container that this DisplayObject was added to
*/
;
DisplayObject.prototype.setParent = function setParent(container) {
if (!container || !container.addChild) {
throw new Error('setParent: Argument must be a Container');
}
container.addChild(this);
return container;
};
/**
* Convenience function to set the position, scale, skew and pivot at once.
*
* @param {number} [x=0] - The X position
* @param {number} [y=0] - The Y position
* @param {number} [scaleX=1] - The X scale value
* @param {number} [scaleY=1] - The Y scale value
* @param {number} [rotation=0] - The rotation
* @param {number} [skewX=0] - The X skew value
* @param {number} [skewY=0] - The Y skew value
* @param {number} [pivotX=0] - The X pivot value
* @param {number} [pivotY=0] - The Y pivot value
* @return {PIXI.DisplayObject} The DisplayObject instance
*/
DisplayObject.prototype.setTransform = function setTransform() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var scaleX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
var scaleY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
var rotation = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
var skewX = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
var skewY = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
var pivotX = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
var pivotY = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 0;
this.position.x = x;
this.position.y = y;
this.scale.x = !scaleX ? 1 : scaleX;
this.scale.y = !scaleY ? 1 : scaleY;
this.rotation = rotation;
this.skew.x = skewX;
this.skew.y = skewY;
this.pivot.x = pivotX;
this.pivot.y = pivotY;
return this;
};
/**
* Base destroy method for generic display objects. This will automatically
* remove the display object from its parent Container as well as remove
* all current event listeners and internal references. Do not use a DisplayObject
* after calling `destroy`.
*
*/
DisplayObject.prototype.destroy = function destroy() {
this.removeAllListeners();
if (this.parent) {
this.parent.removeChild(this);
}
this.transform = null;
this.parent = null;
this._bounds = null;
this._currentBounds = null;
this._mask = null;
this.filterArea = null;
this.interactive = false;
this.interactiveChildren = false;
this._destroyed = true;
};
/**
* The position of the displayObject on the x axis relative to the local coordinates of the parent.
* An alias to position.x
*
* @member {number}
*/
_createClass(DisplayObject, [{
key: '_tempDisplayObjectParent',
get: function get() {
if (this.tempDisplayObjectParent === null) {
this.tempDisplayObjectParent = new DisplayObject();
}
return this.tempDisplayObjectParent;
}
}, {
key: 'x',
get: function get() {
return this.position.x;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.transform.position.x = value;
}
/**
* The position of the displayObject on the y axis relative to the local coordinates of the parent.
* An alias to position.y
*
* @member {number}
*/
}, {
key: 'y',
get: function get() {
return this.position.y;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.transform.position.y = value;
}
/**
* Current transform of the object based on world (parent) factors
*
* @member {PIXI.Matrix}
* @readonly
*/
}, {
key: 'worldTransform',
get: function get() {
return this.transform.worldTransform;
}
/**
* Current transform of the object based on local factors: position, scale, other stuff
*
* @member {PIXI.Matrix}
* @readonly
*/
}, {
key: 'localTransform',
get: function get() {
return this.transform.localTransform;
}
/**
* The coordinate of the object relative to the local coordinates of the parent.
* Assignment by value since pixi-v4.
*
* @member {PIXI.Point|PIXI.ObservablePoint}
*/
}, {
key: 'position',
get: function get() {
return this.transform.position;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.transform.position.copy(value);
}
/**
* The scale factor of the object.
* Assignment by value since pixi-v4.
*
* @member {PIXI.Point|PIXI.ObservablePoint}
*/
}, {
key: 'scale',
get: function get() {
return this.transform.scale;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.transform.scale.copy(value);
}
/**
* The pivot point of the displayObject that it rotates around.
* Assignment by value since pixi-v4.
*
* @member {PIXI.Point|PIXI.ObservablePoint}
*/
}, {
key: 'pivot',
get: function get() {
return this.transform.pivot;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.transform.pivot.copy(value);
}
/**
* The skew factor for the object in radians.
* Assignment by value since pixi-v4.
*
* @member {PIXI.ObservablePoint}
*/
}, {
key: 'skew',
get: function get() {
return this.transform.skew;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.transform.skew.copy(value);
}
/**
* The rotation of the object in radians.
*
* @member {number}
*/
}, {
key: 'rotation',
get: function get() {
return this.transform.rotation;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.transform.rotation = value;
}
/**
* Indicates if the object is globally visible.
*
* @member {boolean}
* @readonly
*/
}, {
key: 'worldVisible',
get: function get() {
var item = this;
do {
if (!item.visible) {
return false;
}
item = item.parent;
} while (item);
return true;
}
/**
* Sets a mask for the displayObject. A mask is an object that limits the visibility of an
* object to the shape of the mask applied to it. In PIXI a regular mask must be a
* PIXI.Graphics or a PIXI.Sprite object. This allows for much faster masking in canvas as it
* utilises shape clipping. To remove a mask, set this property to null.
*
* @todo For the moment, PIXI.CanvasRenderer doesn't support PIXI.Sprite as mask.
*
* @member {PIXI.Graphics|PIXI.Sprite}
*/
}, {
key: 'mask',
get: function get() {
return this._mask;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (this._mask) {
this._mask.renderable = true;
this._mask.isMask = false;
}
this._mask = value;
if (this._mask) {
this._mask.renderable = false;
this._mask.isMask = true;
}
}
/**
* Sets the filters for the displayObject.
* * IMPORTANT: This is a webGL only feature and will be ignored by the canvas renderer.
* To remove filters simply set this property to 'null'
*
* @member {PIXI.Filter[]}
*/
}, {
key: 'filters',
get: function get() {
return this._filters && this._filters.slice();
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._filters = value && value.slice();
}
}]);
return DisplayObject;
}(_eventemitter2.default);
// performance increase to avoid using call.. (10x faster)
exports.default = DisplayObject;
DisplayObject.prototype.displayObjectUpdateTransform = DisplayObject.prototype.updateTransform;
//# sourceMappingURL=DisplayObject.js.map
/***/ }),
/* 182 */
/***/ (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 _TransformBase2 = __webpack_require__(123);
var _TransformBase3 = _interopRequireDefault(_TransformBase2);
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; }
/**
* Transform that takes care about its versions
*
* @class
* @extends PIXI.TransformBase
* @memberof PIXI
*/
var TransformStatic = function (_TransformBase) {
_inherits(TransformStatic, _TransformBase);
/**
*
*/
function TransformStatic() {
_classCallCheck(this, TransformStatic);
/**
* The coordinate of the object relative to the local coordinates of the parent.
*
* @member {PIXI.ObservablePoint}
*/
var _this = _possibleConstructorReturn(this, _TransformBase.call(this));
_this.position = new _math.ObservablePoint(_this.onChange, _this, 0, 0);
/**
* The scale factor of the object.
*
* @member {PIXI.ObservablePoint}
*/
_this.scale = new _math.ObservablePoint(_this.onChange, _this, 1, 1);
/**
* The pivot point of the displayObject that it rotates around.
*
* @member {PIXI.ObservablePoint}
*/
_this.pivot = new _math.ObservablePoint(_this.onChange, _this, 0, 0);
/**
* The skew amount, on the x and y axis.
*
* @member {PIXI.ObservablePoint}
*/
_this.skew = new _math.ObservablePoint(_this.updateSkew, _this, 0, 0);
_this._rotation = 0;
_this._cx = 1; // cos rotation + skewY;
_this._sx = 0; // sin rotation + skewY;
_this._cy = 0; // cos rotation + Math.PI/2 - skewX;
_this._sy = 1; // sin rotation + Math.PI/2 - skewX;
_this._localID = 0;
_this._currentLocalID = 0;
return _this;
}
/**
* Called when a value changes.
*
* @private
*/
TransformStatic.prototype.onChange = function onChange() {
this._localID++;
};
/**
* Called when skew or rotation changes
*
* @private
*/
TransformStatic.prototype.updateSkew = function updateSkew() {
this._cx = Math.cos(this._rotation + this.skew._y);
this._sx = Math.sin(this._rotation + this.skew._y);
this._cy = -Math.sin(this._rotation - this.skew._x); // cos, added PI/2
this._sy = Math.cos(this._rotation - this.skew._x); // sin, added PI/2
this._localID++;
};
/**
* Updates only local matrix
*/
TransformStatic.prototype.updateLocalTransform = function updateLocalTransform() {
var lt = this.localTransform;
if (this._localID !== this._currentLocalID) {
// get the matrix values of the displayobject based on its transform properties..
lt.a = this._cx * this.scale._x;
lt.b = this._sx * this.scale._x;
lt.c = this._cy * this.scale._y;
lt.d = this._sy * this.scale._y;
lt.tx = this.position._x - (this.pivot._x * lt.a + this.pivot._y * lt.c);
lt.ty = this.position._y - (this.pivot._x * lt.b + this.pivot._y * lt.d);
this._currentLocalID = this._localID;
// force an update..
this._parentID = -1;
}
};
/**
* Updates the values of the object and applies the parent's transform.
*
* @param {PIXI.Transform} parentTransform - The transform of the parent of this object
*/
TransformStatic.prototype.updateTransform = function updateTransform(parentTransform) {
var lt = this.localTransform;
if (this._localID !== this._currentLocalID) {
// get the matrix values of the displayobject based on its transform properties..
lt.a = this._cx * this.scale._x;
lt.b = this._sx * this.scale._x;
lt.c = this._cy * this.scale._y;
lt.d = this._sy * this.scale._y;
lt.tx = this.position._x - (this.pivot._x * lt.a + this.pivot._y * lt.c);
lt.ty = this.position._y - (this.pivot._x * lt.b + this.pivot._y * lt.d);
this._currentLocalID = this._localID;
// force an update..
this._parentID = -1;
}
if (this._parentID !== parentTransform._worldID) {
// concat the parent matrix with the objects transform.
var pt = parentTransform.worldTransform;
var wt = this.worldTransform;
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._parentID = parentTransform._worldID;
// update the id of the transform..
this._worldID++;
}
};
/**
* Decomposes a matrix and sets the transforms properties based on it.
*
* @param {PIXI.Matrix} matrix - The matrix to decompose
*/
TransformStatic.prototype.setFromMatrix = function setFromMatrix(matrix) {
matrix.decompose(this);
this._localID++;
};
/**
* The rotation of the object in radians.
*
* @member {number}
*/
_createClass(TransformStatic, [{
key: 'rotation',
get: function get() {
return this._rotation;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (this._rotation !== value) {
this._rotation = value;
this.updateSkew();
}
}
}]);
return TransformStatic;
}(_TransformBase3.default);
exports.default = TransformStatic;
//# sourceMappingURL=TransformStatic.js.map
/***/ }),
/* 183 */
/***/ (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 _TransformBase2 = __webpack_require__(123);
var _TransformBase3 = _interopRequireDefault(_TransformBase2);
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; }
/**
* Generic class to deal with traditional 2D matrix transforms
* local transformation is calculated from position,scale,skew and rotation
*
* @class
* @extends PIXI.TransformBase
* @memberof PIXI
*/
var Transform = function (_TransformBase) {
_inherits(Transform, _TransformBase);
/**
*
*/
function Transform() {
_classCallCheck(this, Transform);
/**
* The coordinate of the object relative to the local coordinates of the parent.
*
* @member {PIXI.Point}
*/
var _this = _possibleConstructorReturn(this, _TransformBase.call(this));
_this.position = new _math.Point(0, 0);
/**
* The scale factor of the object.
*
* @member {PIXI.Point}
*/
_this.scale = new _math.Point(1, 1);
/**
* The skew amount, on the x and y axis.
*
* @member {PIXI.ObservablePoint}
*/
_this.skew = new _math.ObservablePoint(_this.updateSkew, _this, 0, 0);
/**
* The pivot point of the displayObject that it rotates around.
*
* @member {PIXI.Point}
*/
_this.pivot = new _math.Point(0, 0);
/**
* The rotation value of the object, in radians
*
* @member {Number}
* @private
*/
_this._rotation = 0;
_this._cx = 1; // cos rotation + skewY;
_this._sx = 0; // sin rotation + skewY;
_this._cy = 0; // cos rotation + Math.PI/2 - skewX;
_this._sy = 1; // sin rotation + Math.PI/2 - skewX;
return _this;
}
/**
* Updates the skew values when the skew or rotation changes.
*
* @private
*/
Transform.prototype.updateSkew = function updateSkew() {
this._cx = Math.cos(this._rotation + this.skew._y);
this._sx = Math.sin(this._rotation + this.skew._y);
this._cy = -Math.sin(this._rotation - this.skew._x); // cos, added PI/2
this._sy = Math.cos(this._rotation - this.skew._x); // sin, added PI/2
};
/**
* Updates only local matrix
*/
Transform.prototype.updateLocalTransform = function updateLocalTransform() {
var lt = this.localTransform;
lt.a = this._cx * this.scale.x;
lt.b = this._sx * this.scale.x;
lt.c = this._cy * this.scale.y;
lt.d = this._sy * this.scale.y;
lt.tx = this.position.x - (this.pivot.x * lt.a + this.pivot.y * lt.c);
lt.ty = this.position.y - (this.pivot.x * lt.b + this.pivot.y * lt.d);
};
/**
* Updates the values of the object and applies the parent's transform.
*
* @param {PIXI.Transform} parentTransform - The transform of the parent of this object
*/
Transform.prototype.updateTransform = function updateTransform(parentTransform) {
var lt = this.localTransform;
lt.a = this._cx * this.scale.x;
lt.b = this._sx * this.scale.x;
lt.c = this._cy * this.scale.y;
lt.d = this._sy * this.scale.y;
lt.tx = this.position.x - (this.pivot.x * lt.a + this.pivot.y * lt.c);
lt.ty = this.position.y - (this.pivot.x * lt.b + this.pivot.y * lt.d);
// concat the parent matrix with the objects transform.
var pt = parentTransform.worldTransform;
var wt = this.worldTransform;
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++;
};
/**
* Decomposes a matrix and sets the transforms properties based on it.
*
* @param {PIXI.Matrix} matrix - The matrix to decompose
*/
Transform.prototype.setFromMatrix = function setFromMatrix(matrix) {
matrix.decompose(this);
};
/**
* The rotation of the object in radians.
*
* @member {number}
*/
_createClass(Transform, [{
key: 'rotation',
get: function get() {
return this._rotation;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._rotation = value;
this.updateSkew();
}
}]);
return Transform;
}(_TransformBase3.default);
exports.default = Transform;
//# sourceMappingURL=Transform.js.map
/***/ }),
/* 184 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = determineCrossOrigin;
var _url2 = __webpack_require__(185);
var _url3 = _interopRequireDefault(_url2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var tempAnchor = void 0;
/**
* Sets the `crossOrigin` property for this resource based on if the url
* for this resource is cross-origin. If crossOrigin was manually set, this
* function does nothing.
* Nipped from the resource loader!
*
* @ignore
* @param {string} url - The url to test.
* @param {object} [loc=window.location] - The location object to test against.
* @return {string} The crossOrigin value to use (or empty string for none).
*/
function determineCrossOrigin(url) {
var loc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location;
// data: and javascript: urls are considered same-origin
if (url.indexOf('data:') === 0) {
return '';
}
// default is window.location
loc = loc || window.location;
if (!tempAnchor) {
tempAnchor = document.createElement('a');
}
// let the browser determine the full href for the url of this resource and then
// parse with the node url lib, we can't use the properties of the anchor element
// because they don't work in IE9 :(
tempAnchor.href = url;
url = _url3.default.parse(tempAnchor.href);
var samePort = !url.port && loc.port === '' || url.port === loc.port;
// if cross origin
if (url.hostname !== loc.hostname || !samePort || url.protocol !== loc.protocol) {
return 'anonymous';
}
return '';
}
//# sourceMappingURL=determineCrossOrigin.js.map
/***/ }),
/* 185 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 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.
var punycode = __webpack_require__(457);
var util = __webpack_require__(459);
exports.parse = urlParse;
exports.resolve = urlResolve;
exports.resolveObject = urlResolveObject;
exports.format = urlFormat;
exports.Url = Url;
function Url() {
this.protocol = null;
this.slashes = null;
this.auth = null;
this.host = null;
this.port = null;
this.hostname = null;
this.hash = null;
this.search = null;
this.query = null;
this.pathname = null;
this.path = null;
this.href = null;
}
// Reference: RFC 3986, RFC 1808, RFC 2396
// define these here so at least they only have to be
// compiled once on the first module load.
var protocolPattern = /^([a-z0-9.+-]+:)/i,
portPattern = /:[0-9]*$/,
// Special case for a simple path URL
simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
// RFC 2396: characters reserved for delimiting URLs.
// We actually just auto-escape these.
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
// RFC 2396: characters not allowed for various reasons.
unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
// Allowed by RFCs, but cause of XSS attacks. Always escape these.
autoEscape = ['\''].concat(unwise),
// Characters that are never ever allowed in a hostname.
// Note that any invalid chars are also handled, but these
// are the ones that are *expected* to be seen, so we fast-path
// them.
nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
hostEndingChars = ['/', '?', '#'],
hostnameMaxLen = 255,
hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
// protocols that can allow "unsafe" and "unwise" chars.
unsafeProtocol = {
'javascript': true,
'javascript:': true
},
// protocols that never have a hostname.
hostlessProtocol = {
'javascript': true,
'javascript:': true
},
// protocols that always contain a // bit.
slashedProtocol = {
'http': true,
'https': true,
'ftp': true,
'gopher': true,
'file': true,
'http:': true,
'https:': true,
'ftp:': true,
'gopher:': true,
'file:': true
},
querystring = __webpack_require__(460);
function urlParse(url, parseQueryString, slashesDenoteHost) {
if (url && util.isObject(url) && url instanceof Url) return url;
var u = new Url;
u.parse(url, parseQueryString, slashesDenoteHost);
return u;
}
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
if (!util.isString(url)) {
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
}
// Copy chrome, IE, opera backslash-handling behavior.
// Back slashes before the query string get converted to forward slashes
// See: https://code.google.com/p/chromium/issues/detail?id=25916
var queryIndex = url.indexOf('?'),
splitter =
(queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
uSplit = url.split(splitter),
slashRegex = /\\/g;
uSplit[0] = uSplit[0].replace(slashRegex, '/');
url = uSplit.join(splitter);
var rest = url;
// trim before proceeding.
// This is to support parse stuff like " http://foo.com \n"
rest = rest.trim();
if (!slashesDenoteHost && url.split('#').length === 1) {
// Try fast path regexp
var simplePath = simplePathPattern.exec(rest);
if (simplePath) {
this.path = rest;
this.href = rest;
this.pathname = simplePath[1];
if (simplePath[2]) {
this.search = simplePath[2];
if (parseQueryString) {
this.query = querystring.parse(this.search.substr(1));
} else {
this.query = this.search.substr(1);
}
} else if (parseQueryString) {
this.search = '';
this.query = {};
}
return this;
}
}
var proto = protocolPattern.exec(rest);
if (proto) {
proto = proto[0];
var lowerProto = proto.toLowerCase();
this.protocol = lowerProto;
rest = rest.substr(proto.length);
}
// figure out if it's got a host
// user@server is *always* interpreted as a hostname, and url
// resolution will treat //foo/bar as host=foo,path=bar because that's
// how the browser resolves relative URLs.
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
var slashes = rest.substr(0, 2) === '//';
if (slashes && !(proto && hostlessProtocol[proto])) {
rest = rest.substr(2);
this.slashes = true;
}
}
if (!hostlessProtocol[proto] &&
(slashes || (proto && !slashedProtocol[proto]))) {
// there's a hostname.
// the first instance of /, ?, ;, or # ends the host.
//
// If there is an @ in the hostname, then non-host chars *are* allowed
// to the left of the last @ sign, unless some host-ending character
// comes *before* the @-sign.
// URLs are obnoxious.
//
// ex:
// http://a@b@c/ => user:a@b host:c
// http://a@b?@c => user:a host:c path:/?@c
// v0.12 TODO(isaacs): This is not quite how Chrome does things.
// Review our test case against browsers more comprehensively.
// find the first instance of any hostEndingChars
var hostEnd = -1;
for (var i = 0; i < hostEndingChars.length; i++) {
var hec = rest.indexOf(hostEndingChars[i]);
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
hostEnd = hec;
}
// at this point, either we have an explicit point where the
// auth portion cannot go past, or the last @ char is the decider.
var auth, atSign;
if (hostEnd === -1) {
// atSign can be anywhere.
atSign = rest.lastIndexOf('@');
} else {
// atSign must be in auth portion.
// http://a@b/c@d => host:b auth:a path:/c@d
atSign = rest.lastIndexOf('@', hostEnd);
}
// Now we have a portion which is definitely the auth.
// Pull that off.
if (atSign !== -1) {
auth = rest.slice(0, atSign);
rest = rest.slice(atSign + 1);
this.auth = decodeURIComponent(auth);
}
// the host is the remaining to the left of the first non-host char
hostEnd = -1;
for (var i = 0; i < nonHostChars.length; i++) {
var hec = rest.indexOf(nonHostChars[i]);
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
hostEnd = hec;
}
// if we still have not hit it, then the entire thing is a host.
if (hostEnd === -1)
hostEnd = rest.length;
this.host = rest.slice(0, hostEnd);
rest = rest.slice(hostEnd);
// pull out port.
this.parseHost();
// we've indicated that there is a hostname,
// so even if it's empty, it has to be present.
this.hostname = this.hostname || '';
// if hostname begins with [ and ends with ]
// assume that it's an IPv6 address.
var ipv6Hostname = this.hostname[0] === '[' &&
this.hostname[this.hostname.length - 1] === ']';
// validate a little.
if (!ipv6Hostname) {
var hostparts = this.hostname.split(/\./);
for (var i = 0, l = hostparts.length; i < l; i++) {
var part = hostparts[i];
if (!part) continue;
if (!part.match(hostnamePartPattern)) {
var newpart = '';
for (var j = 0, k = part.length; j < k; j++) {
if (part.charCodeAt(j) > 127) {
// we replace non-ASCII char with a temporary placeholder
// we need this to make sure size of hostname is not
// broken by replacing non-ASCII by nothing
newpart += 'x';
} else {
newpart += part[j];
}
}
// we test again with ASCII char only
if (!newpart.match(hostnamePartPattern)) {
var validParts = hostparts.slice(0, i);
var notHost = hostparts.slice(i + 1);
var bit = part.match(hostnamePartStart);
if (bit) {
validParts.push(bit[1]);
notHost.unshift(bit[2]);
}
if (notHost.length) {
rest = '/' + notHost.join('.') + rest;
}
this.hostname = validParts.join('.');
break;
}
}
}
}
if (this.hostname.length > hostnameMaxLen) {
this.hostname = '';
} else {
// hostnames are always lower case.
this.hostname = this.hostname.toLowerCase();
}
if (!ipv6Hostname) {
// IDNA Support: Returns a punycoded representation of "domain".
// It only converts parts of the domain name that
// have non-ASCII characters, i.e. it doesn't matter if
// you call it with a domain that already is ASCII-only.
this.hostname = punycode.toASCII(this.hostname);
}
var p = this.port ? ':' + this.port : '';
var h = this.hostname || '';
this.host = h + p;
this.href += this.host;
// strip [ and ] from the hostname
// the host field still retains them, though
if (ipv6Hostname) {
this.hostname = this.hostname.substr(1, this.hostname.length - 2);
if (rest[0] !== '/') {
rest = '/' + rest;
}
}
}
// now rest is set to the post-host stuff.
// chop off any delim chars.
if (!unsafeProtocol[lowerProto]) {
// First, make 100% sure that any "autoEscape" chars get
// escaped, even if encodeURIComponent doesn't think they
// need to be.
for (var i = 0, l = autoEscape.length; i < l; i++) {
var ae = autoEscape[i];
if (rest.indexOf(ae) === -1)
continue;
var esc = encodeURIComponent(ae);
if (esc === ae) {
esc = escape(ae);
}
rest = rest.split(ae).join(esc);
}
}
// chop off from the tail first.
var hash = rest.indexOf('#');
if (hash !== -1) {
// got a fragment string.
this.hash = rest.substr(hash);
rest = rest.slice(0, hash);
}
var qm = rest.indexOf('?');
if (qm !== -1) {
this.search = rest.substr(qm);
this.query = rest.substr(qm + 1);
if (parseQueryString) {
this.query = querystring.parse(this.query);
}
rest = rest.slice(0, qm);
} else if (parseQueryString) {
// no query string, but parseQueryString still requested
this.search = '';
this.query = {};
}
if (rest) this.pathname = rest;
if (slashedProtocol[lowerProto] &&
this.hostname && !this.pathname) {
this.pathname = '/';
}
//to support http.request
if (this.pathname || this.search) {
var p = this.pathname || '';
var s = this.search || '';
this.path = p + s;
}
// finally, reconstruct the href based on what has been validated.
this.href = this.format();
return this;
};
// format a parsed object into a url string
function urlFormat(obj) {
// ensure it's an object, and not a string url.
// If it's an obj, this is a no-op.
// this way, you can call url_format() on strings
// to clean up potentially wonky urls.
if (util.isString(obj)) obj = urlParse(obj);
if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
return obj.format();
}
Url.prototype.format = function() {
var auth = this.auth || '';
if (auth) {
auth = encodeURIComponent(auth);
auth = auth.replace(/%3A/i, ':');
auth += '@';
}
var protocol = this.protocol || '',
pathname = this.pathname || '',
hash = this.hash || '',
host = false,
query = '';
if (this.host) {
host = auth + this.host;
} else if (this.hostname) {
host = auth + (this.hostname.indexOf(':') === -1 ?
this.hostname :
'[' + this.hostname + ']');
if (this.port) {
host += ':' + this.port;
}
}
if (this.query &&
util.isObject(this.query) &&
Object.keys(this.query).length) {
query = querystring.stringify(this.query);
}
var search = this.search || (query && ('?' + query)) || '';
if (protocol && protocol.substr(-1) !== ':') protocol += ':';
// only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
// unless they had them to begin with.
if (this.slashes ||
(!protocol || slashedProtocol[protocol]) && host !== false) {
host = '//' + (host || '');
if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
} else if (!host) {
host = '';
}
if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
if (search && search.charAt(0) !== '?') search = '?' + search;
pathname = pathname.replace(/[?#]/g, function(match) {
return encodeURIComponent(match);
});
search = search.replace('#', '%23');
return protocol + host + pathname + search + hash;
};
function urlResolve(source, relative) {
return urlParse(source, false, true).resolve(relative);
}
Url.prototype.resolve = function(relative) {
return this.resolveObject(urlParse(relative, false, true)).format();
};
function urlResolveObject(source, relative) {
if (!source) return relative;
return urlParse(source, false, true).resolveObject(relative);
}
Url.prototype.resolveObject = function(relative) {
if (util.isString(relative)) {
var rel = new Url();
rel.parse(relative, false, true);
relative = rel;
}
var result = new Url();
var tkeys = Object.keys(this);
for (var tk = 0; tk < tkeys.length; tk++) {
var tkey = tkeys[tk];
result[tkey] = this[tkey];
}
// hash is always overridden, no matter what.
// even href="" will remove it.
result.hash = relative.hash;
// if the relative url is empty, then there's nothing left to do here.
if (relative.href === '') {
result.href = result.format();
return result;
}
// hrefs like //foo/bar always cut to the protocol.
if (relative.slashes && !relative.protocol) {
// take everything except the protocol from relative
var rkeys = Object.keys(relative);
for (var rk = 0; rk < rkeys.length; rk++) {
var rkey = rkeys[rk];
if (rkey !== 'protocol')
result[rkey] = relative[rkey];
}
//urlParse appends trailing / to urls like http://www.example.com
if (slashedProtocol[result.protocol] &&
result.hostname && !result.pathname) {
result.path = result.pathname = '/';
}
result.href = result.format();
return result;
}
if (relative.protocol && relative.protocol !== result.protocol) {
// if it's a known url protocol, then changing
// the protocol does weird things
// first, if it's not file:, then we MUST have a host,
// and if there was a path
// to begin with, then we MUST have a path.
// if it is file:, then the host is dropped,
// because that's known to be hostless.
// anything else is assumed to be absolute.
if (!slashedProtocol[relative.protocol]) {
var keys = Object.keys(relative);
for (var v = 0; v < keys.length; v++) {
var k = keys[v];
result[k] = relative[k];
}
result.href = result.format();
return result;
}
result.protocol = relative.protocol;
if (!relative.host && !hostlessProtocol[relative.protocol]) {
var relPath = (relative.pathname || '').split('/');
while (relPath.length && !(relative.host = relPath.shift()));
if (!relative.host) relative.host = '';
if (!relative.hostname) relative.hostname = '';
if (relPath[0] !== '') relPath.unshift('');
if (relPath.length < 2) relPath.unshift('');
result.pathname = relPath.join('/');
} else {
result.pathname = relative.pathname;
}
result.search = relative.search;
result.query = relative.query;
result.host = relative.host || '';
result.auth = relative.auth;
result.hostname = relative.hostname || relative.host;
result.port = relative.port;
// to support http.request
if (result.pathname || result.search) {
var p = result.pathname || '';
var s = result.search || '';
result.path = p + s;
}
result.slashes = result.slashes || relative.slashes;
result.href = result.format();
return result;
}
var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
isRelAbs = (
relative.host ||
relative.pathname && relative.pathname.charAt(0) === '/'
),
mustEndAbs = (isRelAbs || isSourceAbs ||
(result.host && relative.pathname)),
removeAllDots = mustEndAbs,
srcPath = result.pathname && result.pathname.split('/') || [],
relPath = relative.pathname && relative.pathname.split('/') || [],
psychotic = result.protocol && !slashedProtocol[result.protocol];
// if the url is a non-slashed url, then relative
// links like ../.. should be able
// to crawl up to the hostname, as well. This is strange.
// result.protocol has already been set by now.
// Later on, put the first path part into the host field.
if (psychotic) {
result.hostname = '';
result.port = null;
if (result.host) {
if (srcPath[0] === '') srcPath[0] = result.host;
else srcPath.unshift(result.host);
}
result.host = '';
if (relative.protocol) {
relative.hostname = null;
relative.port = null;
if (relative.host) {
if (relPath[0] === '') relPath[0] = relative.host;
else relPath.unshift(relative.host);
}
relative.host = null;
}
mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
}
if (isRelAbs) {
// it's absolute.
result.host = (relative.host || relative.host === '') ?
relative.host : result.host;
result.hostname = (relative.hostname || relative.hostname === '') ?
relative.hostname : result.hostname;
result.search = relative.search;
result.query = relative.query;
srcPath = relPath;
// fall through to the dot-handling below.
} else if (relPath.length) {
// it's relative
// throw away the existing file, and take the new path instead.
if (!srcPath) srcPath = [];
srcPath.pop();
srcPath = srcPath.concat(relPath);
result.search = relative.search;
result.query = relative.query;
} else if (!util.isNullOrUndefined(relative.search)) {
// just pull out the search.
// like href='?foo'.
// Put this after the other two cases because it simplifies the booleans
if (psychotic) {
result.hostname = result.host = srcPath.shift();
//occationaly the auth can get stuck only in host
//this especially happens in cases like
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
var authInHost = result.host && result.host.indexOf('@') > 0 ?
result.host.split('@') : false;
if (authInHost) {
result.auth = authInHost.shift();
result.host = result.hostname = authInHost.shift();
}
}
result.search = relative.search;
result.query = relative.query;
//to support http.request
if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
result.path = (result.pathname ? result.pathname : '') +
(result.search ? result.search : '');
}
result.href = result.format();
return result;
}
if (!srcPath.length) {
// no path at all. easy.
// we've already handled the other stuff above.
result.pathname = null;
//to support http.request
if (result.search) {
result.path = '/' + result.search;
} else {
result.path = null;
}
result.href = result.format();
return result;
}
// if a url ENDs in . or .., then it must get a trailing slash.
// however, if it ends in anything else non-slashy,
// then it must NOT get a trailing slash.
var last = srcPath.slice(-1)[0];
var hasTrailingSlash = (
(result.host || relative.host || srcPath.length > 1) &&
(last === '.' || last === '..') || last === '');
// strip single dots, resolve double dots to parent dir
// if the path tries to go above the root, `up` ends up > 0
var up = 0;
for (var i = srcPath.length; i >= 0; i--) {
last = srcPath[i];
if (last === '.') {
srcPath.splice(i, 1);
} else if (last === '..') {
srcPath.splice(i, 1);
up++;
} else if (up) {
srcPath.splice(i, 1);
up--;
}
}
// if the path is allowed to go above the root, restore leading ..s
if (!mustEndAbs && !removeAllDots) {
for (; up--; up) {
srcPath.unshift('..');
}
}
if (mustEndAbs && srcPath[0] !== '' &&
(!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
srcPath.unshift('');
}
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
srcPath.push('');
}
var isAbsolute = srcPath[0] === '' ||
(srcPath[0] && srcPath[0].charAt(0) === '/');
// put the host back
if (psychotic) {
result.hostname = result.host = isAbsolute ? '' :
srcPath.length ? srcPath.shift() : '';
//occationaly the auth can get stuck only in host
//this especially happens in cases like
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
var authInHost = result.host && result.host.indexOf('@') > 0 ?
result.host.split('@') : false;
if (authInHost) {
result.auth = authInHost.shift();
result.host = result.hostname = authInHost.shift();
}
}
mustEndAbs = mustEndAbs || (result.host && srcPath.length);
if (mustEndAbs && !isAbsolute) {
srcPath.unshift('');
}
if (!srcPath.length) {
result.pathname = null;
result.path = null;
} else {
result.pathname = srcPath.join('/');
}
//to support request.http
if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
result.path = (result.pathname ? result.pathname : '') +
(result.search ? result.search : '');
}
result.auth = relative.auth || result.auth;
result.slashes = result.slashes || relative.slashes;
result.href = result.format();
return result;
};
Url.prototype.parseHost = function() {
var host = this.host;
var port = portPattern.exec(host);
if (port) {
port = port[0];
if (port !== ':') {
this.port = port.substr(1);
}
host = host.substr(0, host.length - port.length);
}
if (host) this.hostname = host;
};
/***/ }),
/* 186 */
/***/ (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 _BaseTexture2 = __webpack_require__(58);
var _BaseTexture3 = _interopRequireDefault(_BaseTexture2);
var _utils = __webpack_require__(7);
var _ticker = __webpack_require__(127);
var _const = __webpack_require__(3);
var _determineCrossOrigin = __webpack_require__(184);
var _determineCrossOrigin2 = _interopRequireDefault(_determineCrossOrigin);
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 of a [playing] Video.
*
* Video base textures mimic PixiJS BaseTexture.from.... method in their creation process.
*
* This can be used in several ways, such as:
*
* ```js
* let texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4');
*
* let texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' });
*
* let texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']);
*
* let texture = PIXI.VideoBaseTexture.fromUrls([
* { src: '/video.webm', mime: 'video/webm' },
* { src: '/video.mp4', mime: 'video/mp4' }
* ]);
* ```
*
* See the ["deus" demo](http://www.goodboydigital.com/pixijs/examples/deus/).
*
* @class
* @extends PIXI.BaseTexture
* @memberof PIXI
*/
var VideoBaseTexture = function (_BaseTexture) {
_inherits(VideoBaseTexture, _BaseTexture);
/**
* @param {HTMLVideoElement} source - Video source
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values
* @param {boolean} [autoPlay=true] - Start playing video as soon as it is loaded
*/
function VideoBaseTexture(source, scaleMode) {
var autoPlay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
_classCallCheck(this, VideoBaseTexture);
if (!source) {
throw new Error('No video source element specified.');
}
// hook in here to check if video is already available.
// BaseTexture looks for a source.complete boolean, plus width & height.
if ((source.readyState === source.HAVE_ENOUGH_DATA || source.readyState === source.HAVE_FUTURE_DATA) && source.width && source.height) {
source.complete = true;
}
var _this = _possibleConstructorReturn(this, _BaseTexture.call(this, source, scaleMode));
_this.width = source.videoWidth;
_this.height = source.videoHeight;
_this._autoUpdate = true;
_this._isAutoUpdating = false;
/**
* When set to true will automatically play videos used by this texture once
* they are loaded. If false, it will not modify the playing state.
*
* @member {boolean}
* @default true
*/
_this.autoPlay = autoPlay;
_this.update = _this.update.bind(_this);
_this._onCanPlay = _this._onCanPlay.bind(_this);
source.addEventListener('play', _this._onPlayStart.bind(_this));
source.addEventListener('pause', _this._onPlayStop.bind(_this));
_this.hasLoaded = false;
_this.__loaded = false;
if (!_this._isSourceReady()) {
source.addEventListener('canplay', _this._onCanPlay);
source.addEventListener('canplaythrough', _this._onCanPlay);
} else {
_this._onCanPlay();
}
return _this;
}
/**
* Returns true if the underlying source is playing.
*
* @private
* @return {boolean} True if playing.
*/
VideoBaseTexture.prototype._isSourcePlaying = function _isSourcePlaying() {
var source = this.source;
return source.currentTime > 0 && source.paused === false && source.ended === false && source.readyState > 2;
};
/**
* Returns true if the underlying source is ready for playing.
*
* @private
* @return {boolean} True if ready.
*/
VideoBaseTexture.prototype._isSourceReady = function _isSourceReady() {
return this.source.readyState === 3 || this.source.readyState === 4;
};
/**
* Runs the update loop when the video is ready to play
*
* @private
*/
VideoBaseTexture.prototype._onPlayStart = function _onPlayStart() {
// Just in case the video has not received its can play even yet..
if (!this.hasLoaded) {
this._onCanPlay();
}
if (!this._isAutoUpdating && this.autoUpdate) {
_ticker.shared.add(this.update, this, _const.UPDATE_PRIORITY.HIGH);
this._isAutoUpdating = true;
}
};
/**
* Fired when a pause event is triggered, stops the update loop
*
* @private
*/
VideoBaseTexture.prototype._onPlayStop = function _onPlayStop() {
if (this._isAutoUpdating) {
_ticker.shared.remove(this.update, this);
this._isAutoUpdating = false;
}
};
/**
* Fired when the video is loaded and ready to play
*
* @private
*/
VideoBaseTexture.prototype._onCanPlay = function _onCanPlay() {
this.hasLoaded = true;
if (this.source) {
this.source.removeEventListener('canplay', this._onCanPlay);
this.source.removeEventListener('canplaythrough', this._onCanPlay);
this.width = this.source.videoWidth;
this.height = this.source.videoHeight;
// prevent multiple loaded dispatches..
if (!this.__loaded) {
this.__loaded = true;
this.emit('loaded', this);
}
if (this._isSourcePlaying()) {
this._onPlayStart();
} else if (this.autoPlay) {
this.source.play();
}
}
};
/**
* Destroys this texture
*
*/
VideoBaseTexture.prototype.destroy = function destroy() {
if (this._isAutoUpdating) {
_ticker.shared.remove(this.update, this);
}
if (this.source && this.source._pixiId) {
_BaseTexture3.default.removeFromCache(this.source._pixiId);
delete this.source._pixiId;
this.source.pause();
this.source.src = '';
this.source.load();
}
_BaseTexture.prototype.destroy.call(this);
};
/**
* Mimic PixiJS BaseTexture.from.... method.
*
* @static
* @param {HTMLVideoElement} video - Video to create texture from
* @param {number} [scaleMode=PIXI.settings.SCALE_MODE] - See {@link PIXI.SCALE_MODES} for possible values
* @param {boolean} [autoPlay=true] - Start playing video as soon as it is loaded
* @return {PIXI.VideoBaseTexture} Newly created VideoBaseTexture
*/
VideoBaseTexture.fromVideo = function fromVideo(video, scaleMode, autoPlay) {
if (!video._pixiId) {
video._pixiId = 'video_' + (0, _utils.uid)();
}
var baseTexture = _utils.BaseTextureCache[video._pixiId];
if (!baseTexture) {
baseTexture = new VideoBaseTexture(video, scaleMode, autoPlay);
_BaseTexture3.default.addToCache(baseTexture, video._pixiId);
}
return baseTexture;
};
/**
* Helper function that creates a new BaseTexture based on the given video element.
* This BaseTexture can then be used to create a texture
*
* @static
* @param {string|object|string[]|object[]} videoSrc - The URL(s) for the video.
* @param {string} [videoSrc.src] - One of the source urls for the video
* @param {string} [videoSrc.mime] - The mimetype of the video (e.g. 'video/mp4'). If not specified
* the url's extension will be used as the second part of the mime type.
* @param {number} scaleMode - 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.VideoBaseTexture} Newly created VideoBaseTexture
*/
VideoBaseTexture.fromUrl = function fromUrl(videoSrc, scaleMode, crossorigin, autoPlay) {
var video = document.createElement('video');
video.setAttribute('webkit-playsinline', '');
video.setAttribute('playsinline', '');
var url = Array.isArray(videoSrc) ? videoSrc[0].src || videoSrc[0] : videoSrc.src || videoSrc;
if (crossorigin === undefined && url.indexOf('data:') !== 0) {
video.crossOrigin = (0, _determineCrossOrigin2.default)(url);
} else if (crossorigin) {
video.crossOrigin = typeof crossorigin === 'string' ? crossorigin : 'anonymous';
}
// array of objects or strings
if (Array.isArray(videoSrc)) {
for (var i = 0; i < videoSrc.length; ++i) {
video.appendChild(createSource(videoSrc[i].src || videoSrc[i], videoSrc[i].mime));
}
}
// single object or string
else {
video.appendChild(createSource(url, videoSrc.mime));
}
video.load();
return VideoBaseTexture.fromVideo(video, scaleMode, autoPlay);
};
/**
* Should the base texture automatically update itself, set to true by default
*
* @member {boolean}
*/
_createClass(VideoBaseTexture, [{
key: 'autoUpdate',
get: function get() {
return this._autoUpdate;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (value !== this._autoUpdate) {
this._autoUpdate = value;
if (!this._autoUpdate && this._isAutoUpdating) {
_ticker.shared.remove(this.update, this);
this._isAutoUpdating = false;
} else if (this._autoUpdate && !this._isAutoUpdating) {
_ticker.shared.add(this.update, this, _const.UPDATE_PRIORITY.HIGH);
this._isAutoUpdating = true;
}
}
}
}]);
return VideoBaseTexture;
}(_BaseTexture3.default);
exports.default = VideoBaseTexture;
VideoBaseTexture.fromUrls = VideoBaseTexture.fromUrl;
function createSource(path, type) {
if (!type) {
var purePath = path.split('?').shift().toLowerCase();
type = 'video/' + purePath.substr(purePath.lastIndexOf('.') + 1);
}
var source = document.createElement('source');
source.src = path;
source.type = type;
return source;
}
//# sourceMappingURL=VideoBaseTexture.js.map
/***/ }),
/* 187 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _GroupD = __webpack_require__(171);
var _GroupD2 = _interopRequireDefault(_GroupD);
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"); } }
/**
* A standard object to store the Uvs of a texture
*
* @class
* @private
* @memberof PIXI
*/
var TextureUvs = function () {
/**
*
*/
function TextureUvs() {
_classCallCheck(this, TextureUvs);
this.x0 = 0;
this.y0 = 0;
this.x1 = 1;
this.y1 = 0;
this.x2 = 1;
this.y2 = 1;
this.x3 = 0;
this.y3 = 1;
this.uvsUint32 = new Uint32Array(4);
}
/**
* Sets the texture Uvs based on the given frame information.
*
* @private
* @param {PIXI.Rectangle} frame - The frame of the texture
* @param {PIXI.Rectangle} baseFrame - The base frame of the texture
* @param {number} rotate - Rotation of frame, see {@link PIXI.GroupD8}
*/
TextureUvs.prototype.set = function set(frame, baseFrame, rotate) {
var tw = baseFrame.width;
var th = baseFrame.height;
if (rotate) {
// width and height div 2 div baseFrame size
var w2 = frame.width / 2 / tw;
var h2 = frame.height / 2 / th;
// coordinates of center
var cX = frame.x / tw + w2;
var cY = frame.y / th + h2;
rotate = _GroupD2.default.add(rotate, _GroupD2.default.NW); // NW is top-left corner
this.x0 = cX + w2 * _GroupD2.default.uX(rotate);
this.y0 = cY + h2 * _GroupD2.default.uY(rotate);
rotate = _GroupD2.default.add(rotate, 2); // rotate 90 degrees clockwise
this.x1 = cX + w2 * _GroupD2.default.uX(rotate);
this.y1 = cY + h2 * _GroupD2.default.uY(rotate);
rotate = _GroupD2.default.add(rotate, 2);
this.x2 = cX + w2 * _GroupD2.default.uX(rotate);
this.y2 = cY + h2 * _GroupD2.default.uY(rotate);
rotate = _GroupD2.default.add(rotate, 2);
this.x3 = cX + w2 * _GroupD2.default.uX(rotate);
this.y3 = cY + h2 * _GroupD2.default.uY(rotate);
} else {
this.x0 = frame.x / tw;
this.y0 = frame.y / th;
this.x1 = (frame.x + frame.width) / tw;
this.y1 = frame.y / th;
this.x2 = (frame.x + frame.width) / tw;
this.y2 = (frame.y + frame.height) / th;
this.x3 = frame.x / tw;
this.y3 = (frame.y + frame.height) / th;
}
this.uvsUint32[0] = (Math.round(this.y0 * 65535) & 0xFFFF) << 16 | Math.round(this.x0 * 65535) & 0xFFFF;
this.uvsUint32[1] = (Math.round(this.y1 * 65535) & 0xFFFF) << 16 | Math.round(this.x1 * 65535) & 0xFFFF;
this.uvsUint32[2] = (Math.round(this.y2 * 65535) & 0xFFFF) << 16 | Math.round(this.x2 * 65535) & 0xFFFF;
this.uvsUint32[3] = (Math.round(this.y3 * 65535) & 0xFFFF) << 16 | Math.round(this.x3 * 65535) & 0xFFFF;
};
return TextureUvs;
}();
exports.default = TextureUvs;
//# sourceMappingURL=TextureUvs.js.map
/***/ }),
/* 188 */
/***/ (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 _math = __webpack_require__(14);
var _const = __webpack_require__(3);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
var _Container = __webpack_require__(64);
var _Container2 = _interopRequireDefault(_Container);
var _RenderTexture = __webpack_require__(128);
var _RenderTexture2 = _interopRequireDefault(_RenderTexture);
var _eventemitter = __webpack_require__(52);
var _eventemitter2 = _interopRequireDefault(_eventemitter);
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 tempMatrix = new _math.Matrix();
/**
* The SystemRenderer is the base for a PixiJS Renderer. It is extended by the {@link PIXI.CanvasRenderer}
* and {@link PIXI.WebGLRenderer} which can be used for rendering a PixiJS scene.
*
* @abstract
* @class
* @extends EventEmitter
* @memberof PIXI
*/
var SystemRenderer = function (_EventEmitter) {
_inherits(SystemRenderer, _EventEmitter);
// eslint-disable-next-line valid-jsdoc
/**
* @param {string} system - The name of the system this renderer is for.
* @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 SystemRenderer(system, options, arg2, arg3) {
_classCallCheck(this, SystemRenderer);
var _this = _possibleConstructorReturn(this, _EventEmitter.call(this));
(0, _utils.sayHello)(system);
// Support for constructor(system, screenWidth, screenHeight, options)
if (typeof options === 'number') {
options = Object.assign({
width: options,
height: arg2 || _settings2.default.RENDER_OPTIONS.height
}, arg3);
}
// Add the default render options
options = Object.assign({}, _settings2.default.RENDER_OPTIONS, options);
/**
* The supplied constructor options.
*
* @member {Object}
* @readOnly
*/
_this.options = options;
/**
* The type of the renderer.
*
* @member {number}
* @default PIXI.RENDERER_TYPE.UNKNOWN
* @see PIXI.RENDERER_TYPE
*/
_this.type = _const.RENDERER_TYPE.UNKNOWN;
/**
* Measurements of the screen. (0, 0, screenWidth, screenHeight)
*
* Its safe to use as filterArea or hitArea for whole stage
*
* @member {PIXI.Rectangle}
*/
_this.screen = new _math.Rectangle(0, 0, options.width, options.height);
/**
* The canvas element that everything is drawn to
*
* @member {HTMLCanvasElement}
*/
_this.view = options.view || document.createElement('canvas');
/**
* The resolution / device pixel ratio of the renderer
*
* @member {number}
* @default 1
*/
_this.resolution = options.resolution || _settings2.default.RESOLUTION;
/**
* Whether the render view is transparent
*
* @member {boolean}
*/
_this.transparent = options.transparent;
/**
* Whether css dimensions of canvas view should be resized to screen dimensions automatically
*
* @member {boolean}
*/
_this.autoResize = options.autoResize || false;
/**
* Tracks the blend modes useful for this renderer.
*
* @member {object<string, mixed>}
*/
_this.blendModes = null;
/**
* The value of the preserveDrawingBuffer flag affects whether or not the contents of
* the stencil buffer is retained after rendering.
*
* @member {boolean}
*/
_this.preserveDrawingBuffer = options.preserveDrawingBuffer;
/**
* This sets if the CanvasRenderer will clear the canvas or not before the new render pass.
* If the scene is NOT transparent PixiJS will use a canvas sized fillRect operation every
* frame to set the canvas background color. If the scene is transparent PixiJS will use clearRect
* to clear the canvas every frame. Disable this by setting this to false. For example if
* your game has a canvas filling background image you often don't need this set.
*
* @member {boolean}
* @default
*/
_this.clearBeforeRender = options.clearBeforeRender;
/**
* If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.
* Handy for crisp pixel art and speed on legacy devices.
*
* @member {boolean}
*/
_this.roundPixels = options.roundPixels;
/**
* The background color as a number.
*
* @member {number}
* @private
*/
_this._backgroundColor = 0x000000;
/**
* The background color as an [R, G, B] array.
*
* @member {number[]}
* @private
*/
_this._backgroundColorRgba = [0, 0, 0, 0];
/**
* The background color as a string.
*
* @member {string}
* @private
*/
_this._backgroundColorString = '#000000';
_this.backgroundColor = options.backgroundColor || _this._backgroundColor; // run bg color setter
/**
* This temporary display object used as the parent of the currently being rendered item
*
* @member {PIXI.DisplayObject}
* @private
*/
_this._tempDisplayObjectParent = new _Container2.default();
/**
* The last root object that the renderer tried to render.
*
* @member {PIXI.DisplayObject}
* @private
*/
_this._lastObjectRendered = _this._tempDisplayObjectParent;
return _this;
}
/**
* Same as view.width, actual number of pixels in the canvas by horizontal
*
* @member {number}
* @readonly
* @default 800
*/
/**
* Resizes the screen and canvas to the specified width and height
* Canvas dimensions are multiplied by resolution
*
* @param {number} screenWidth - the new width of the screen
* @param {number} screenHeight - the new height of the screen
*/
SystemRenderer.prototype.resize = function resize(screenWidth, screenHeight) {
this.screen.width = screenWidth;
this.screen.height = screenHeight;
this.view.width = screenWidth * this.resolution;
this.view.height = screenHeight * this.resolution;
if (this.autoResize) {
this.view.style.width = screenWidth + 'px';
this.view.style.height = screenHeight + 'px';
}
};
/**
* Useful function that returns a texture of the display object that can then be used to create sprites
* This can be quite useful if your displayObject is complicated and needs to be reused multiple times.
*
* @param {PIXI.DisplayObject} displayObject - The displayObject the object will be generated from
* @param {number} scaleMode - Should be one of the scaleMode consts
* @param {number} resolution - The resolution / device pixel ratio of the texture being generated
* @param {PIXI.Rectangle} [region] - The region of the displayObject, that shall be rendered,
* if no region is specified, defaults to the local bounds of the displayObject.
* @return {PIXI.Texture} a texture of the graphics object
*/
SystemRenderer.prototype.generateTexture = function generateTexture(displayObject, scaleMode, resolution, region) {
region = region || displayObject.getLocalBounds();
var renderTexture = _RenderTexture2.default.create(region.width | 0, region.height | 0, scaleMode, resolution);
tempMatrix.tx = -region.x;
tempMatrix.ty = -region.y;
this.render(displayObject, renderTexture, false, tempMatrix, !!displayObject.parent);
return renderTexture;
};
/**
* Removes everything from the renderer and optionally removes the Canvas DOM element.
*
* @param {boolean} [removeView=false] - Removes the Canvas element from the DOM.
*/
SystemRenderer.prototype.destroy = function destroy(removeView) {
if (removeView && this.view.parentNode) {
this.view.parentNode.removeChild(this.view);
}
this.type = _const.RENDERER_TYPE.UNKNOWN;
this.view = null;
this.screen = null;
this.resolution = 0;
this.transparent = false;
this.autoResize = false;
this.blendModes = null;
this.options = null;
this.preserveDrawingBuffer = false;
this.clearBeforeRender = false;
this.roundPixels = false;
this._backgroundColor = 0;
this._backgroundColorRgba = null;
this._backgroundColorString = null;
this._tempDisplayObjectParent = null;
this._lastObjectRendered = null;
};
/**
* The background color to fill if not transparent
*
* @member {number}
*/
_createClass(SystemRenderer, [{
key: 'width',
get: function get() {
return this.view.width;
}
/**
* Same as view.height, actual number of pixels in the canvas by vertical
*
* @member {number}
* @readonly
* @default 600
*/
}, {
key: 'height',
get: function get() {
return this.view.height;
}
}, {
key: 'backgroundColor',
get: function get() {
return this._backgroundColor;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._backgroundColor = value;
this._backgroundColorString = (0, _utils.hex2string)(value);
(0, _utils.hex2rgb)(value, this._backgroundColorRgba);
}
}]);
return SystemRenderer;
}(_eventemitter2.default);
exports.default = SystemRenderer;
//# sourceMappingURL=SystemRenderer.js.map
/***/ }),
/* 189 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _BaseTexture2 = __webpack_require__(58);
var _BaseTexture3 = _interopRequireDefault(_BaseTexture2);
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 BaseRenderTexture is a special texture that allows any PixiJS display object to be rendered to it.
*
* __Hint__: All DisplayObjects (i.e. Sprites) that render to a BaseRenderTexture should be preloaded
* otherwise black rectangles will be drawn instead.
*
* A BaseRenderTexture takes a snapshot of any Display Object given to its render method. The position
* and rotation of the given Display Objects is ignored. For example:
*
* ```js
* let renderer = PIXI.autoDetectRenderer(1024, 1024);
* let baseRenderTexture = new PIXI.BaseRenderTexture(800, 600);
* let renderTexture = new PIXI.RenderTexture(baseRenderTexture);
* let sprite = PIXI.Sprite.fromImage("spinObj_01.png");
*
* sprite.position.x = 800/2;
* sprite.position.y = 600/2;
* sprite.anchor.x = 0.5;
* sprite.anchor.y = 0.5;
*
* renderer.render(sprite, renderTexture);
* ```
*
* The Sprite in this case will be rendered using its local transform. To render this sprite at 0,0
* you can clear the transform
*
* ```js
*
* sprite.setTransform()
*
* let baseRenderTexture = new PIXI.BaseRenderTexture(100, 100);
* let renderTexture = new PIXI.RenderTexture(baseRenderTexture);
*
* renderer.render(sprite, renderTexture); // Renders to center of RenderTexture
* ```
*
* @class
* @extends PIXI.BaseTexture
* @memberof PIXI
*/
var BaseRenderTexture = function (_BaseTexture) {
_inherits(BaseRenderTexture, _BaseTexture);
/**
* @param {number} [width=100] - The width of the base render texture
* @param {number} [height=100] - The height of the base render 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 being generated
*/
function BaseRenderTexture() {
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
var scaleMode = arguments[2];
var resolution = arguments[3];
_classCallCheck(this, BaseRenderTexture);
var _this = _possibleConstructorReturn(this, _BaseTexture.call(this, null, scaleMode));
_this.resolution = resolution || _settings2.default.RESOLUTION;
_this.width = Math.ceil(width);
_this.height = Math.ceil(height);
_this.realWidth = _this.width * _this.resolution;
_this.realHeight = _this.height * _this.resolution;
_this.scaleMode = scaleMode !== undefined ? scaleMode : _settings2.default.SCALE_MODE;
_this.hasLoaded = true;
/**
* A map of renderer IDs to webgl renderTargets
*
* @private
* @member {object<number, WebGLTexture>}
*/
_this._glRenderTargets = {};
/**
* A reference to the canvas render target (we only need one as this can be shared across renderers)
*
* @private
* @member {object<number, WebGLTexture>}
*/
_this._canvasRenderTarget = null;
/**
* 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;
return _this;
}
/**
* Resizes the BaseRenderTexture.
*
* @param {number} width - The width to resize to.
* @param {number} height - The height to resize to.
*/
BaseRenderTexture.prototype.resize = function resize(width, height) {
width = Math.ceil(width);
height = Math.ceil(height);
if (width === this.width && height === this.height) {
return;
}
this.valid = width > 0 && height > 0;
this.width = width;
this.height = height;
this.realWidth = this.width * this.resolution;
this.realHeight = this.height * this.resolution;
if (!this.valid) {
return;
}
this.emit('update', this);
};
/**
* Destroys this texture
*
*/
BaseRenderTexture.prototype.destroy = function destroy() {
_BaseTexture.prototype.destroy.call(this, true);
this.renderer = null;
};
return BaseRenderTexture;
}(_BaseTexture3.default);
exports.default = BaseRenderTexture;
//# sourceMappingURL=BaseRenderTexture.js.map
/***/ }),
/* 190 */
/***/ (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 _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"); } }
/**
* Creates a Canvas element of the given size.
*
* @class
* @memberof PIXI
*/
var CanvasRenderTarget = function () {
/**
* @param {number} width - the width for the newly created canvas
* @param {number} height - the height for the newly created canvas
* @param {number} [resolution=1] - The resolution / device pixel ratio of the canvas
*/
function CanvasRenderTarget(width, height, resolution) {
_classCallCheck(this, CanvasRenderTarget);
/**
* The Canvas object that belongs to this CanvasRenderTarget.
*
* @member {HTMLCanvasElement}
*/
this.canvas = document.createElement('canvas');
/**
* A CanvasRenderingContext2D object representing a two-dimensional rendering context.
*
* @member {CanvasRenderingContext2D}
*/
this.context = this.canvas.getContext('2d');
this.resolution = resolution || _settings2.default.RESOLUTION;
this.resize(width, height);
}
/**
* Clears the canvas that was created by the CanvasRenderTarget class.
*
* @private
*/
CanvasRenderTarget.prototype.clear = function clear() {
this.context.setTransform(1, 0, 0, 1, 0, 0);
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
};
/**
* Resizes the canvas to the specified width and height.
*
* @param {number} width - the new width of the canvas
* @param {number} height - the new height of the canvas
*/
CanvasRenderTarget.prototype.resize = function resize(width, height) {
this.canvas.width = width * this.resolution;
this.canvas.height = height * this.resolution;
};
/**
* Destroys this canvas.
*
*/
CanvasRenderTarget.prototype.destroy = function destroy() {
this.context = null;
this.canvas = null;
};
/**
* The width of the canvas buffer in pixels.
*
* @member {number}
*/
_createClass(CanvasRenderTarget, [{
key: 'width',
get: function get() {
return this.canvas.width;
},
set: function set(val) // eslint-disable-line require-jsdoc
{
this.canvas.width = val;
}
/**
* The height of the canvas buffer in pixels.
*
* @member {number}
*/
}, {
key: 'height',
get: function get() {
return this.canvas.height;
},
set: function set(val) // eslint-disable-line require-jsdoc
{
this.canvas.height = val;
}
}]);
return CanvasRenderTarget;
}();
exports.default = CanvasRenderTarget;
//# sourceMappingURL=CanvasRenderTarget.js.map
/***/ }),
/* 191 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = canUseNewCanvasBlendModes;
/**
* Creates a little colored canvas
*
* @ignore
* @param {string} color - The color to make the canvas
* @return {canvas} a small canvas element
*/
function createColoredCanvas(color) {
var canvas = document.createElement('canvas');
canvas.width = 6;
canvas.height = 1;
var context = canvas.getContext('2d');
context.fillStyle = color;
context.fillRect(0, 0, 6, 1);
return canvas;
}
/**
* Checks whether the Canvas BlendModes are supported by the current browser
*
* @return {boolean} whether they are supported
*/
function canUseNewCanvasBlendModes() {
if (typeof document === 'undefined') {
return false;
}
var magenta = createColoredCanvas('#ff00ff');
var yellow = createColoredCanvas('#ffff00');
var canvas = document.createElement('canvas');
canvas.width = 6;
canvas.height = 1;
var context = canvas.getContext('2d');
context.globalCompositeOperation = 'multiply';
context.drawImage(magenta, 0, 0);
context.drawImage(yellow, 2, 0);
var imageData = context.getImageData(2, 0, 1, 1);
if (!imageData) {
return false;
}
var data = imageData.data;
return data[0] === 255 && data[1] === 0 && data[2] === 0;
}
//# sourceMappingURL=canUseNewCanvasBlendModes.js.map
/***/ }),
/* 192 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Filter2 = __webpack_require__(193);
var _Filter3 = _interopRequireDefault(_Filter2);
var _math = __webpack_require__(14);
var _path = __webpack_require__(34);
var _TextureMatrix = __webpack_require__(194);
var _TextureMatrix2 = _interopRequireDefault(_TextureMatrix);
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 SpriteMaskFilter class
*
* @class
* @extends PIXI.Filter
* @memberof PIXI
*/
var SpriteMaskFilter = function (_Filter) {
_inherits(SpriteMaskFilter, _Filter);
/**
* @param {PIXI.Sprite} sprite - the target sprite
*/
function SpriteMaskFilter(sprite) {
_classCallCheck(this, SpriteMaskFilter);
var maskMatrix = new _math.Matrix();
var _this = _possibleConstructorReturn(this, _Filter.call(this, 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n}\n', 'varying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(maskClamp.x, vMaskCoord.x) +\n step(maskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, maskClamp.z) +\n step(vMaskCoord.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n\n original *= (masky.r * masky.a * alpha * clip);\n\n gl_FragColor = original;\n}\n'));
sprite.renderable = false;
_this.maskSprite = sprite;
_this.maskMatrix = maskMatrix;
return _this;
}
/**
* Applies the filter
*
* @param {PIXI.FilterManager} filterManager - The renderer to retrieve the filter from
* @param {PIXI.RenderTarget} input - The input render target.
* @param {PIXI.RenderTarget} output - The target to output to.
* @param {boolean} clear - Should the output be cleared before rendering to it
*/
SpriteMaskFilter.prototype.apply = function apply(filterManager, input, output, clear) {
var maskSprite = this.maskSprite;
var tex = this.maskSprite.texture;
if (!tex.valid) {
return;
}
if (!tex.transform) {
// margin = 0.0, let it bleed a bit, shader code becomes easier
// assuming that atlas textures were made with 1-pixel padding
tex.transform = new _TextureMatrix2.default(tex, 0.0);
}
tex.transform.update();
this.uniforms.mask = tex;
this.uniforms.otherMatrix = filterManager.calculateSpriteMatrix(this.maskMatrix, maskSprite).prepend(tex.transform.mapCoord);
this.uniforms.alpha = maskSprite.worldAlpha;
this.uniforms.maskClamp = tex.transform.uClampFrame;
filterManager.applyFilter(this, input, output, clear);
};
return SpriteMaskFilter;
}(_Filter3.default);
exports.default = SpriteMaskFilter;
//# sourceMappingURL=SpriteMaskFilter.js.map
/***/ }),
/* 193 */
/***/ (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 _extractUniformsFromSrc = __webpack_require__(470);
var _extractUniformsFromSrc2 = _interopRequireDefault(_extractUniformsFromSrc);
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"); } }
var SOURCE_KEY_MAP = {};
// let math = require('../../../math');
/**
* @class
* @memberof PIXI
* @extends PIXI.Shader
*/
var Filter = function () {
/**
* @param {string} [vertexSrc] - The source of the vertex shader.
* @param {string} [fragmentSrc] - The source of the fragment shader.
* @param {object} [uniformData] - Custom uniforms to use to augment the built-in ones.
*/
function Filter(vertexSrc, fragmentSrc, uniformData) {
_classCallCheck(this, Filter);
/**
* The vertex shader.
*
* @member {string}
*/
this.vertexSrc = vertexSrc || Filter.defaultVertexSrc;
/**
* The fragment shader.
*
* @member {string}
*/
this.fragmentSrc = fragmentSrc || Filter.defaultFragmentSrc;
this._blendMode = _const.BLEND_MODES.NORMAL;
this.uniformData = uniformData || (0, _extractUniformsFromSrc2.default)(this.vertexSrc, this.fragmentSrc, 'projectionMatrix|uSampler');
/**
* An object containing the current values of custom uniforms.
* @example <caption>Updating the value of a custom uniform</caption>
* filter.uniforms.time = performance.now();
*
* @member {object}
*/
this.uniforms = {};
for (var i in this.uniformData) {
this.uniforms[i] = this.uniformData[i].value;
if (this.uniformData[i].type) {
this.uniformData[i].type = this.uniformData[i].type.toLowerCase();
}
}
// this is where we store shader references..
// TODO we could cache this!
this.glShaders = {};
// used for caching.. sure there is a better way!
if (!SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc]) {
SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc] = (0, _utils.uid)();
}
this.glShaderKey = SOURCE_KEY_MAP[this.vertexSrc + this.fragmentSrc];
/**
* The padding of the filter. Some filters require extra space to breath such as a blur.
* Increasing this will add extra width and height to the bounds of the object that the
* filter is applied to.
*
* @member {number}
*/
this.padding = 4;
/**
* The resolution of the filter. Setting this to be lower will lower the quality but
* increase the performance of the filter.
*
* @member {number}
*/
this.resolution = _settings2.default.FILTER_RESOLUTION;
/**
* If enabled is true the filter is applied, if false it will not.
*
* @member {boolean}
*/
this.enabled = true;
/**
* If enabled, PixiJS will fit the filter area into boundaries for better performance.
* Switch it off if it does not work for specific shader.
*
* @member {boolean}
*/
this.autoFit = true;
}
/**
* Applies the filter
*
* @param {PIXI.FilterManager} filterManager - The renderer to retrieve the filter from
* @param {PIXI.RenderTarget} input - The input render target.
* @param {PIXI.RenderTarget} output - The target to output to.
* @param {boolean} clear - Should the output be cleared before rendering to it
* @param {object} [currentState] - It's current state of filter.
* There are some useful properties in the currentState :
* target, filters, sourceFrame, destinationFrame, renderTarget, resolution
*/
Filter.prototype.apply = function apply(filterManager, input, output, clear, currentState) // eslint-disable-line no-unused-vars
{
// --- //
// this.uniforms.filterMatrix = filterManager.calculateSpriteMatrix(tempMatrix, window.panda );
// do as you please!
filterManager.applyFilter(this, input, output, clear);
// or just do a regular render..
};
/**
* Sets the blendmode of the filter
*
* @member {number}
* @default PIXI.BLEND_MODES.NORMAL
*/
_createClass(Filter, [{
key: 'blendMode',
get: function get() {
return this._blendMode;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._blendMode = value;
}
/**
* The default vertex shader source
*
* @static
* @constant
*/
}], [{
key: 'defaultVertexSrc',
get: function get() {
return ['attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', 'uniform mat3 projectionMatrix;', 'uniform mat3 filterMatrix;', 'varying vec2 vTextureCoord;', 'varying vec2 vFilterCoord;', 'void main(void){', ' gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);', ' vFilterCoord = ( filterMatrix * vec3( aTextureCoord, 1.0) ).xy;', ' vTextureCoord = aTextureCoord ;', '}'].join('\n');
}
/**
* The default fragment shader source
*
* @static
* @constant
*/
}, {
key: 'defaultFragmentSrc',
get: function get() {
return ['varying vec2 vTextureCoord;', 'varying vec2 vFilterCoord;', 'uniform sampler2D uSampler;', 'uniform sampler2D filterSampler;', 'void main(void){', ' vec4 masky = texture2D(filterSampler, vFilterCoord);', ' vec4 sample = texture2D(uSampler, vTextureCoord);', ' vec4 color;', ' if(mod(vFilterCoord.x, 1.0) > 0.5)', ' {', ' color = vec4(1.0, 0.0, 0.0, 1.0);', ' }', ' else', ' {', ' color = vec4(0.0, 1.0, 0.0, 1.0);', ' }',
// ' gl_FragColor = vec4(mod(vFilterCoord.x, 1.5), vFilterCoord.y,0.0,1.0);',
' gl_FragColor = mix(sample, masky, 0.5);', ' gl_FragColor *= sample.a;', '}'].join('\n');
}
}]);
return Filter;
}();
exports.default = Filter;
//# sourceMappingURL=Filter.js.map
/***/ }),
/* 194 */
/***/ (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 _Matrix = __webpack_require__(118);
var _Matrix2 = _interopRequireDefault(_Matrix);
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"); } }
var tempMat = new _Matrix2.default();
/**
* Class controls uv transform and frame clamp for texture
* Can be used in Texture "transform" field, or separately, you can use different clamp settings on the same texture.
* If you want to add support for texture region of certain feature or filter, that's what you're looking for.
*
* @see PIXI.Texture
* @see PIXI.mesh.Mesh
* @see PIXI.extras.TilingSprite
* @class
* @memberof PIXI
*/
var TextureMatrix = function () {
/**
*
* @param {PIXI.Texture} texture observed texture
* @param {number} [clampMargin] Changes frame clamping, 0.5 by default. Use -0.5 for extra border.
* @constructor
*/
function TextureMatrix(texture, clampMargin) {
_classCallCheck(this, TextureMatrix);
this._texture = texture;
this.mapCoord = new _Matrix2.default();
this.uClampFrame = new Float32Array(4);
this.uClampOffset = new Float32Array(2);
this._lastTextureID = -1;
/**
* Changes frame clamping
* Works with TilingSprite and Mesh
* Change to 1.5 if you texture has repeated right and bottom lines, that leads to smoother borders
*
* @default 0
* @member {number}
*/
this.clampOffset = 0;
/**
* Changes frame clamping
* Works with TilingSprite and Mesh
* Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas
*
* @default 0.5
* @member {number}
*/
this.clampMargin = typeof clampMargin === 'undefined' ? 0.5 : clampMargin;
}
/**
* texture property
* @member {PIXI.Texture}
*/
/**
* Multiplies uvs array to transform
* @param {Float32Array} uvs mesh uvs
* @param {Float32Array} [out=uvs] output
* @returns {Float32Array} output
*/
TextureMatrix.prototype.multiplyUvs = function multiplyUvs(uvs, out) {
if (out === undefined) {
out = uvs;
}
var mat = this.mapCoord;
for (var i = 0; i < uvs.length; i += 2) {
var x = uvs[i];
var y = uvs[i + 1];
out[i] = x * mat.a + y * mat.c + mat.tx;
out[i + 1] = x * mat.b + y * mat.d + mat.ty;
}
return out;
};
/**
* updates matrices if texture was changed
* @param {boolean} forceUpdate if true, matrices will be updated any case
* @returns {boolean} whether or not it was updated
*/
TextureMatrix.prototype.update = function update(forceUpdate) {
var tex = this._texture;
if (!tex || !tex.valid) {
return false;
}
if (!forceUpdate && this._lastTextureID === tex._updateID) {
return false;
}
this._lastTextureID = tex._updateID;
var uvs = tex._uvs;
this.mapCoord.set(uvs.x1 - uvs.x0, uvs.y1 - uvs.y0, uvs.x3 - uvs.x0, uvs.y3 - uvs.y0, uvs.x0, uvs.y0);
var orig = tex.orig;
var trim = tex.trim;
if (trim) {
tempMat.set(orig.width / trim.width, 0, 0, orig.height / trim.height, -trim.x / trim.width, -trim.y / trim.height);
this.mapCoord.append(tempMat);
}
var texBase = tex.baseTexture;
var frame = this.uClampFrame;
var margin = this.clampMargin / texBase.resolution;
var offset = this.clampOffset;
frame[0] = (tex._frame.x + margin + offset) / texBase.width;
frame[1] = (tex._frame.y + margin + offset) / texBase.height;
frame[2] = (tex._frame.x + tex._frame.width - margin + offset) / texBase.width;
frame[3] = (tex._frame.y + tex._frame.height - margin + offset) / texBase.height;
this.uClampOffset[0] = offset / texBase.realWidth;
this.uClampOffset[1] = offset / texBase.realHeight;
return true;
};
_createClass(TextureMatrix, [{
key: 'texture',
get: function get() {
return this._texture;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._texture = value;
this._lastTextureID = -1;
}
}]);
return TextureMatrix;
}();
exports.default = TextureMatrix;
//# sourceMappingURL=TextureMatrix.js.map
/***/ }),
/* 195 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _pixiGlCore = __webpack_require__(23);
var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore);
var _createIndicesForQuads = __webpack_require__(129);
var _createIndicesForQuads2 = _interopRequireDefault(_createIndicesForQuads);
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"); } }
/**
* Helper class to create a quad
*
* @class
* @memberof PIXI
*/
var Quad = function () {
/**
* @param {WebGLRenderingContext} gl - The gl context for this quad to use.
* @param {object} state - TODO: Description
*/
function Quad(gl, state) {
_classCallCheck(this, Quad);
/**
* the current WebGL drawing context
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
/**
* An array of vertices
*
* @member {Float32Array}
*/
this.vertices = new Float32Array([-1, -1, 1, -1, 1, 1, -1, 1]);
/**
* The Uvs of the quad
*
* @member {Float32Array}
*/
this.uvs = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
this.interleaved = new Float32Array(8 * 2);
for (var i = 0; i < 4; i++) {
this.interleaved[i * 4] = this.vertices[i * 2];
this.interleaved[i * 4 + 1] = this.vertices[i * 2 + 1];
this.interleaved[i * 4 + 2] = this.uvs[i * 2];
this.interleaved[i * 4 + 3] = this.uvs[i * 2 + 1];
}
/**
* An array containing the indices of the vertices
*
* @member {Uint16Array}
*/
this.indices = (0, _createIndicesForQuads2.default)(1);
/**
* The vertex buffer
*
* @member {glCore.GLBuffer}
*/
this.vertexBuffer = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, this.interleaved, gl.STATIC_DRAW);
/**
* The index buffer
*
* @member {glCore.GLBuffer}
*/
this.indexBuffer = _pixiGlCore2.default.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW);
/**
* The vertex array object
*
* @member {glCore.VertexArrayObject}
*/
this.vao = new _pixiGlCore2.default.VertexArrayObject(gl, state);
}
/**
* Initialises the vaos and uses the shader.
*
* @param {PIXI.Shader} shader - the shader to use
*/
Quad.prototype.initVao = function initVao(shader) {
this.vao.clear().addIndex(this.indexBuffer).addAttribute(this.vertexBuffer, shader.attributes.aVertexPosition, this.gl.FLOAT, false, 4 * 4, 0).addAttribute(this.vertexBuffer, shader.attributes.aTextureCoord, this.gl.FLOAT, false, 4 * 4, 2 * 4);
};
/**
* Maps two Rectangle to the quad.
*
* @param {PIXI.Rectangle} targetTextureFrame - the first rectangle
* @param {PIXI.Rectangle} destinationFrame - the second rectangle
* @return {PIXI.Quad} Returns itself.
*/
Quad.prototype.map = function map(targetTextureFrame, destinationFrame) {
var x = 0; // destinationFrame.x / targetTextureFrame.width;
var y = 0; // destinationFrame.y / targetTextureFrame.height;
this.uvs[0] = x;
this.uvs[1] = y;
this.uvs[2] = x + destinationFrame.width / targetTextureFrame.width;
this.uvs[3] = y;
this.uvs[4] = x + destinationFrame.width / targetTextureFrame.width;
this.uvs[5] = y + destinationFrame.height / targetTextureFrame.height;
this.uvs[6] = x;
this.uvs[7] = y + destinationFrame.height / targetTextureFrame.height;
x = destinationFrame.x;
y = destinationFrame.y;
this.vertices[0] = x;
this.vertices[1] = y;
this.vertices[2] = x + destinationFrame.width;
this.vertices[3] = y;
this.vertices[4] = x + destinationFrame.width;
this.vertices[5] = y + destinationFrame.height;
this.vertices[6] = x;
this.vertices[7] = y + destinationFrame.height;
return this;
};
/**
* Binds the buffer and uploads the data
*
* @return {PIXI.Quad} Returns itself.
*/
Quad.prototype.upload = function upload() {
for (var i = 0; i < 4; i++) {
this.interleaved[i * 4] = this.vertices[i * 2];
this.interleaved[i * 4 + 1] = this.vertices[i * 2 + 1];
this.interleaved[i * 4 + 2] = this.uvs[i * 2];
this.interleaved[i * 4 + 3] = this.uvs[i * 2 + 1];
}
this.vertexBuffer.upload(this.interleaved);
return this;
};
/**
* Removes this quad from WebGL
*/
Quad.prototype.destroy = function destroy() {
var gl = this.gl;
gl.deleteBuffer(this.vertexBuffer);
gl.deleteBuffer(this.indexBuffer);
};
return Quad;
}();
exports.default = Quad;
//# sourceMappingURL=Quad.js.map
/***/ }),
/* 196 */
/***/ (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; }; }(); // disabling eslint for now, going to rewrite this in v5
/* eslint-disable */
var _const = __webpack_require__(3);
var _utils = __webpack_require__(7);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var defaultStyle = {
align: 'left',
breakWords: false,
dropShadow: false,
dropShadowAlpha: 1,
dropShadowAngle: Math.PI / 6,
dropShadowBlur: 0,
dropShadowColor: 'black',
dropShadowDistance: 5,
fill: 'black',
fillGradientType: _const.TEXT_GRADIENT.LINEAR_VERTICAL,
fillGradientStops: [],
fontFamily: 'Arial',
fontSize: 26,
fontStyle: 'normal',
fontVariant: 'normal',
fontWeight: 'normal',
letterSpacing: 0,
lineHeight: 0,
lineJoin: 'miter',
miterLimit: 10,
padding: 0,
stroke: 'black',
strokeThickness: 0,
textBaseline: 'alphabetic',
trim: false,
whiteSpace: 'pre',
wordWrap: false,
wordWrapWidth: 100,
leading: 0
};
var genericFontFamilies = ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui'];
/**
* A TextStyle Object decorates a Text Object. It can be shared between
* multiple Text objects. Changing the style will update all text objects using it.
* It can be generated [here](https://pixijs.io/pixi-text-style).
*
* @class
* @memberof PIXI
*/
var TextStyle = function () {
/**
* @param {object} [style] - The style parameters
* @param {string} [style.align='left'] - Alignment for multiline text ('left', 'center' or 'right'),
* does not affect single line text
* @param {boolean} [style.breakWords=false] - Indicates if lines can be wrapped within words, it
* needs wordWrap to be set to true
* @param {boolean} [style.dropShadow=false] - Set a drop shadow for the text
* @param {number} [style.dropShadowAlpha=1] - Set alpha for the drop shadow
* @param {number} [style.dropShadowAngle=Math.PI/6] - Set a angle of the drop shadow
* @param {number} [style.dropShadowBlur=0] - Set a shadow blur radius
* @param {string|number} [style.dropShadowColor='black'] - A fill style to be used on the dropshadow e.g 'red', '#00FF00'
* @param {number} [style.dropShadowDistance=5] - Set a distance of the drop shadow
* @param {string|string[]|number|number[]|CanvasGradient|CanvasPattern} [style.fill='black'] - A canvas
* fillstyle that will be used on the text e.g 'red', '#00FF00'. Can be an array to create a gradient
* eg ['#000000','#FFFFFF']
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle|MDN}
* @param {number} [style.fillGradientType=PIXI.TEXT_GRADIENT.LINEAR_VERTICAL] - If fill is an array of colours
* to create a gradient, this can change the type/direction of the gradient. See {@link PIXI.TEXT_GRADIENT}
* @param {number[]} [style.fillGradientStops] - If fill is an array of colours to create a gradient, this array can set
* the stop points (numbers between 0 and 1) for the color, overriding the default behaviour of evenly spacing them.
* @param {string|string[]} [style.fontFamily='Arial'] - The font family
* @param {number|string} [style.fontSize=26] - The font size (as a number it converts to px, but as a string,
* equivalents are '26px','20pt','160%' or '1.6em')
* @param {string} [style.fontStyle='normal'] - The font style ('normal', 'italic' or 'oblique')
* @param {string} [style.fontVariant='normal'] - The font variant ('normal' or 'small-caps')
* @param {string} [style.fontWeight='normal'] - The font weight ('normal', 'bold', 'bolder', 'lighter' and '100',
* '200', '300', '400', '500', '600', '700', 800' or '900')
* @param {number} [style.leading=0] - The space between lines
* @param {number} [style.letterSpacing=0] - The amount of spacing between letters, default is 0
* @param {number} [style.lineHeight] - The line height, a number that represents the vertical space that a letter uses
* @param {string} [style.lineJoin='miter'] - The lineJoin property sets the type of corner created, it can resolve
* spiked text issues. Possible values "miter" (creates a sharp corner), "round" (creates a round corner) or "bevel"
* (creates a squared corner).
* @param {number} [style.miterLimit=10] - The miter limit to use when using the 'miter' lineJoin mode. This can reduce
* or increase the spikiness of rendered text.
* @param {number} [style.padding=0] - Occasionally some fonts are cropped. Adding some padding will prevent this from
* happening by adding padding to all sides of the text.
* @param {string|number} [style.stroke='black'] - A canvas fillstyle that will be used on the text stroke
* e.g 'blue', '#FCFF00'
* @param {number} [style.strokeThickness=0] - A number that represents the thickness of the stroke.
* Default is 0 (no stroke)
* @param {boolean} [style.trim=false] - Trim transparent borders
* @param {string} [style.textBaseline='alphabetic'] - The baseline of the text that is rendered.
* @param {boolean} [style.whiteSpace='pre'] - Determines whether newlines & spaces are collapsed or preserved "normal"
* (collapse, collapse), "pre" (preserve, preserve) | "pre-line" (preserve, collapse). It needs wordWrap to be set to true
* @param {boolean} [style.wordWrap=false] - Indicates if word wrap should be used
* @param {number} [style.wordWrapWidth=100] - The width at which text will wrap, it needs wordWrap to be set to true
*/
function TextStyle(style) {
_classCallCheck(this, TextStyle);
this.styleID = 0;
this.reset();
deepCopyProperties(this, style, style);
}
/**
* Creates a new TextStyle object with the same values as this one.
* Note that the only the properties of the object are cloned.
*
* @return {PIXI.TextStyle} New cloned TextStyle object
*/
TextStyle.prototype.clone = function clone() {
var clonedProperties = {};
deepCopyProperties(clonedProperties, this, defaultStyle);
return new TextStyle(clonedProperties);
};
/**
* Resets all properties to the defaults specified in TextStyle.prototype._default
*/
TextStyle.prototype.reset = function reset() {
deepCopyProperties(this, defaultStyle, defaultStyle);
};
/**
* Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text
*
* @member {string}
*/
/**
* Generates a font style string to use for `TextMetrics.measureFont()`.
*
* @return {string} Font style string, for passing to `TextMetrics.measureFont()`
*/
TextStyle.prototype.toFontString = function toFontString() {
// build canvas api font setting from individual components. Convert a numeric this.fontSize to px
var fontSizeString = typeof this.fontSize === 'number' ? this.fontSize + 'px' : this.fontSize;
// Clean-up fontFamily property by quoting each font name
// this will support font names with spaces
var fontFamilies = this.fontFamily;
if (!Array.isArray(this.fontFamily)) {
fontFamilies = this.fontFamily.split(',');
}
for (var i = fontFamilies.length - 1; i >= 0; i--) {
// Trim any extra white-space
var fontFamily = fontFamilies[i].trim();
// Check if font is already escaped in quotes except for CSS generic fonts
if (!/([\"\'])[^\'\"]+\1/.test(fontFamily) && genericFontFamilies.indexOf(fontFamily) < 0) {
fontFamily = '"' + fontFamily + '"';
}
fontFamilies[i] = fontFamily;
}
return this.fontStyle + ' ' + this.fontVariant + ' ' + this.fontWeight + ' ' + fontSizeString + ' ' + fontFamilies.join(',');
};
_createClass(TextStyle, [{
key: 'align',
get: function get() {
return this._align;
},
set: function set(align) // eslint-disable-line require-jsdoc
{
if (this._align !== align) {
this._align = align;
this.styleID++;
}
}
/**
* Indicates if lines can be wrapped within words, it needs wordWrap to be set to true
*
* @member {boolean}
*/
}, {
key: 'breakWords',
get: function get() {
return this._breakWords;
},
set: function set(breakWords) // eslint-disable-line require-jsdoc
{
if (this._breakWords !== breakWords) {
this._breakWords = breakWords;
this.styleID++;
}
}
/**
* Set a drop shadow for the text
*
* @member {boolean}
*/
}, {
key: 'dropShadow',
get: function get() {
return this._dropShadow;
},
set: function set(dropShadow) // eslint-disable-line require-jsdoc
{
if (this._dropShadow !== dropShadow) {
this._dropShadow = dropShadow;
this.styleID++;
}
}
/**
* Set alpha for the drop shadow
*
* @member {number}
*/
}, {
key: 'dropShadowAlpha',
get: function get() {
return this._dropShadowAlpha;
},
set: function set(dropShadowAlpha) // eslint-disable-line require-jsdoc
{
if (this._dropShadowAlpha !== dropShadowAlpha) {
this._dropShadowAlpha = dropShadowAlpha;
this.styleID++;
}
}
/**
* Set a angle of the drop shadow
*
* @member {number}
*/
}, {
key: 'dropShadowAngle',
get: function get() {
return this._dropShadowAngle;
},
set: function set(dropShadowAngle) // eslint-disable-line require-jsdoc
{
if (this._dropShadowAngle !== dropShadowAngle) {
this._dropShadowAngle = dropShadowAngle;
this.styleID++;
}
}
/**
* Set a shadow blur radius
*
* @member {number}
*/
}, {
key: 'dropShadowBlur',
get: function get() {
return this._dropShadowBlur;
},
set: function set(dropShadowBlur) // eslint-disable-line require-jsdoc
{
if (this._dropShadowBlur !== dropShadowBlur) {
this._dropShadowBlur = dropShadowBlur;
this.styleID++;
}
}
/**
* A fill style to be used on the dropshadow e.g 'red', '#00FF00'
*
* @member {string|number}
*/
}, {
key: 'dropShadowColor',
get: function get() {
return this._dropShadowColor;
},
set: function set(dropShadowColor) // eslint-disable-line require-jsdoc
{
var outputColor = getColor(dropShadowColor);
if (this._dropShadowColor !== outputColor) {
this._dropShadowColor = outputColor;
this.styleID++;
}
}
/**
* Set a distance of the drop shadow
*
* @member {number}
*/
}, {
key: 'dropShadowDistance',
get: function get() {
return this._dropShadowDistance;
},
set: function set(dropShadowDistance) // eslint-disable-line require-jsdoc
{
if (this._dropShadowDistance !== dropShadowDistance) {
this._dropShadowDistance = dropShadowDistance;
this.styleID++;
}
}
/**
* A canvas fillstyle that will be used on the text e.g 'red', '#00FF00'.
* Can be an array to create a gradient eg ['#000000','#FFFFFF']
* {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle|MDN}
*
* @member {string|string[]|number|number[]|CanvasGradient|CanvasPattern}
*/
}, {
key: 'fill',
get: function get() {
return this._fill;
},
set: function set(fill) // eslint-disable-line require-jsdoc
{
var outputColor = getColor(fill);
if (this._fill !== outputColor) {
this._fill = outputColor;
this.styleID++;
}
}
/**
* If fill is an array of colours to create a gradient, this can change the type/direction of the gradient.
* See {@link PIXI.TEXT_GRADIENT}
*
* @member {number}
*/
}, {
key: 'fillGradientType',
get: function get() {
return this._fillGradientType;
},
set: function set(fillGradientType) // eslint-disable-line require-jsdoc
{
if (this._fillGradientType !== fillGradientType) {
this._fillGradientType = fillGradientType;
this.styleID++;
}
}
/**
* If fill is an array of colours to create a gradient, this array can set the stop points
* (numbers between 0 and 1) for the color, overriding the default behaviour of evenly spacing them.
*
* @member {number[]}
*/
}, {
key: 'fillGradientStops',
get: function get() {
return this._fillGradientStops;
},
set: function set(fillGradientStops) // eslint-disable-line require-jsdoc
{
if (!areArraysEqual(this._fillGradientStops, fillGradientStops)) {
this._fillGradientStops = fillGradientStops;
this.styleID++;
}
}
/**
* The font family
*
* @member {string|string[]}
*/
}, {
key: 'fontFamily',
get: function get() {
return this._fontFamily;
},
set: function set(fontFamily) // eslint-disable-line require-jsdoc
{
if (this.fontFamily !== fontFamily) {
this._fontFamily = fontFamily;
this.styleID++;
}
}
/**
* The font size
* (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em')
*
* @member {number|string}
*/
}, {
key: 'fontSize',
get: function get() {
return this._fontSize;
},
set: function set(fontSize) // eslint-disable-line require-jsdoc
{
if (this._fontSize !== fontSize) {
this._fontSize = fontSize;
this.styleID++;
}
}
/**
* The font style
* ('normal', 'italic' or 'oblique')
*
* @member {string}
*/
}, {
key: 'fontStyle',
get: function get() {
return this._fontStyle;
},
set: function set(fontStyle) // eslint-disable-line require-jsdoc
{
if (this._fontStyle !== fontStyle) {
this._fontStyle = fontStyle;
this.styleID++;
}
}
/**
* The font variant
* ('normal' or 'small-caps')
*
* @member {string}
*/
}, {
key: 'fontVariant',
get: function get() {
return this._fontVariant;
},
set: function set(fontVariant) // eslint-disable-line require-jsdoc
{
if (this._fontVariant !== fontVariant) {
this._fontVariant = fontVariant;
this.styleID++;
}
}
/**
* The font weight
* ('normal', 'bold', 'bolder', 'lighter' and '100', '200', '300', '400', '500', '600', '700', 800' or '900')
*
* @member {string}
*/
}, {
key: 'fontWeight',
get: function get() {
return this._fontWeight;
},
set: function set(fontWeight) // eslint-disable-line require-jsdoc
{
if (this._fontWeight !== fontWeight) {
this._fontWeight = fontWeight;
this.styleID++;
}
}
/**
* The amount of spacing between letters, default is 0
*
* @member {number}
*/
}, {
key: 'letterSpacing',
get: function get() {
return this._letterSpacing;
},
set: function set(letterSpacing) // eslint-disable-line require-jsdoc
{
if (this._letterSpacing !== letterSpacing) {
this._letterSpacing = letterSpacing;
this.styleID++;
}
}
/**
* The line height, a number that represents the vertical space that a letter uses
*
* @member {number}
*/
}, {
key: 'lineHeight',
get: function get() {
return this._lineHeight;
},
set: function set(lineHeight) // eslint-disable-line require-jsdoc
{
if (this._lineHeight !== lineHeight) {
this._lineHeight = lineHeight;
this.styleID++;
}
}
/**
* The space between lines
*
* @member {number}
*/
}, {
key: 'leading',
get: function get() {
return this._leading;
},
set: function set(leading) // eslint-disable-line require-jsdoc
{
if (this._leading !== leading) {
this._leading = leading;
this.styleID++;
}
}
/**
* The lineJoin property sets the type of corner created, it can resolve spiked text issues.
* Default is 'miter' (creates a sharp corner).
*
* @member {string}
*/
}, {
key: 'lineJoin',
get: function get() {
return this._lineJoin;
},
set: function set(lineJoin) // eslint-disable-line require-jsdoc
{
if (this._lineJoin !== lineJoin) {
this._lineJoin = lineJoin;
this.styleID++;
}
}
/**
* The miter limit to use when using the 'miter' lineJoin mode
* This can reduce or increase the spikiness of rendered text.
*
* @member {number}
*/
}, {
key: 'miterLimit',
get: function get() {
return this._miterLimit;
},
set: function set(miterLimit) // eslint-disable-line require-jsdoc
{
if (this._miterLimit !== miterLimit) {
this._miterLimit = miterLimit;
this.styleID++;
}
}
/**
* Occasionally some fonts are cropped. Adding some padding will prevent this from happening
* by adding padding to all sides of the text.
*
* @member {number}
*/
}, {
key: 'padding',
get: function get() {
return this._padding;
},
set: function set(padding) // eslint-disable-line require-jsdoc
{
if (this._padding !== padding) {
this._padding = padding;
this.styleID++;
}
}
/**
* A canvas fillstyle that will be used on the text stroke
* e.g 'blue', '#FCFF00'
*
* @member {string|number}
*/
}, {
key: 'stroke',
get: function get() {
return this._stroke;
},
set: function set(stroke) // eslint-disable-line require-jsdoc
{
var outputColor = getColor(stroke);
if (this._stroke !== outputColor) {
this._stroke = outputColor;
this.styleID++;
}
}
/**
* A number that represents the thickness of the stroke.
* Default is 0 (no stroke)
*
* @member {number}
*/
}, {
key: 'strokeThickness',
get: function get() {
return this._strokeThickness;
},
set: function set(strokeThickness) // eslint-disable-line require-jsdoc
{
if (this._strokeThickness !== strokeThickness) {
this._strokeThickness = strokeThickness;
this.styleID++;
}
}
/**
* The baseline of the text that is rendered.
*
* @member {string}
*/
}, {
key: 'textBaseline',
get: function get() {
return this._textBaseline;
},
set: function set(textBaseline) // eslint-disable-line require-jsdoc
{
if (this._textBaseline !== textBaseline) {
this._textBaseline = textBaseline;
this.styleID++;
}
}
/**
* Trim transparent borders
*
* @member {boolean}
*/
}, {
key: 'trim',
get: function get() {
return this._trim;
},
set: function set(trim) // eslint-disable-line require-jsdoc
{
if (this._trim !== trim) {
this._trim = trim;
this.styleID++;
}
}
/**
* How newlines and spaces should be handled.
* Default is 'pre' (preserve, preserve).
*
* value | New lines | Spaces
* --- | --- | ---
* 'normal' | Collapse | Collapse
* 'pre' | Preserve | Preserve
* 'pre-line' | Preserve | Collapse
*
* @member {string}
*/
}, {
key: 'whiteSpace',
get: function get() {
return this._whiteSpace;
},
set: function set(whiteSpace) // eslint-disable-line require-jsdoc
{
if (this._whiteSpace !== whiteSpace) {
this._whiteSpace = whiteSpace;
this.styleID++;
}
}
/**
* Indicates if word wrap should be used
*
* @member {boolean}
*/
}, {
key: 'wordWrap',
get: function get() {
return this._wordWrap;
},
set: function set(wordWrap) // eslint-disable-line require-jsdoc
{
if (this._wordWrap !== wordWrap) {
this._wordWrap = wordWrap;
this.styleID++;
}
}
/**
* The width at which text will wrap, it needs wordWrap to be set to true
*
* @member {number}
*/
}, {
key: 'wordWrapWidth',
get: function get() {
return this._wordWrapWidth;
},
set: function set(wordWrapWidth) // eslint-disable-line require-jsdoc
{
if (this._wordWrapWidth !== wordWrapWidth) {
this._wordWrapWidth = wordWrapWidth;
this.styleID++;
}
}
}]);
return TextStyle;
}();
/**
* Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string.
* @private
* @param {number|number[]} color
* @return {string} The color as a string.
*/
exports.default = TextStyle;
function getSingleColor(color) {
if (typeof color === 'number') {
return (0, _utils.hex2string)(color);
} else if (typeof color === 'string') {
if (color.indexOf('0x') === 0) {
color = color.replace('0x', '#');
}
}
return color;
}
/**
* Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string.
* This version can also convert array of colors
* @private
* @param {number|number[]} color
* @return {string} The color as a string.
*/
function getColor(color) {
if (!Array.isArray(color)) {
return getSingleColor(color);
} else {
for (var i = 0; i < color.length; ++i) {
color[i] = getSingleColor(color[i]);
}
return color;
}
}
/**
* Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string.
* This version can also convert array of colors
* @private
* @param {Array} array1 First array to compare
* @param {Array} array2 Second array to compare
* @return {boolean} Do the arrays contain the same values in the same order
*/
function areArraysEqual(array1, array2) {
if (!Array.isArray(array1) || !Array.isArray(array2)) {
return false;
}
if (array1.length !== array2.length) {
return false;
}
for (var i = 0; i < array1.length; ++i) {
if (array1[i] !== array2[i]) {
return false;
}
}
return true;
}
/**
* Utility function to ensure that object properties are copied by value, and not by reference
* @private
* @param {Object} target Target object to copy properties into
* @param {Object} source Source object for the proporties to copy
* @param {string} propertyObj Object containing properties names we want to loop over
*/
function deepCopyProperties(target, source, propertyObj) {
for (var prop in propertyObj) {
if (Array.isArray(source[prop])) {
target[prop] = source[prop].slice();
} else {
target[prop] = source[prop];
}
}
}
//# sourceMappingURL=TextStyle.js.map
/***/ }),
/* 197 */
/***/ (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 TextMetrics object represents the measurement of a block of text with a specified style.
*
* ```js
* let style = new PIXI.TextStyle({fontFamily : 'Arial', fontSize: 24, fill : 0xff1010, align : 'center'})
* let textMetrics = PIXI.TextMetrics.measureText('Your text', style)
* ```
*
* @class
* @memberOf PIXI
*/
var TextMetrics = function () {
/**
* @param {string} text - the text that was measured
* @param {PIXI.TextStyle} style - the style that was measured
* @param {number} width - the measured width of the text
* @param {number} height - the measured height of the text
* @param {array} lines - an array of the lines of text broken by new lines and wrapping if specified in style
* @param {array} lineWidths - an array of the line widths for each line matched to `lines`
* @param {number} lineHeight - the measured line height for this style
* @param {number} maxLineWidth - the maximum line width for all measured lines
* @param {Object} fontProperties - the font properties object from TextMetrics.measureFont
*/
function TextMetrics(text, style, width, height, lines, lineWidths, lineHeight, maxLineWidth, fontProperties) {
_classCallCheck(this, TextMetrics);
this.text = text;
this.style = style;
this.width = width;
this.height = height;
this.lines = lines;
this.lineWidths = lineWidths;
this.lineHeight = lineHeight;
this.maxLineWidth = maxLineWidth;
this.fontProperties = fontProperties;
}
/**
* Measures the supplied string of text and returns a Rectangle.
*
* @param {string} text - the text to measure.
* @param {PIXI.TextStyle} style - the text style to use for measuring
* @param {boolean} [wordWrap] - optional override for if word-wrap should be applied to the text.
* @param {HTMLCanvasElement} [canvas] - optional specification of the canvas to use for measuring.
* @return {PIXI.TextMetrics} measured width and height of the text.
*/
TextMetrics.measureText = function measureText(text, style, wordWrap) {
var canvas = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : TextMetrics._canvas;
wordWrap = wordWrap === undefined || wordWrap === null ? style.wordWrap : wordWrap;
var font = style.toFontString();
var fontProperties = TextMetrics.measureFont(font);
var context = canvas.getContext('2d');
context.font = font;
var outputText = wordWrap ? TextMetrics.wordWrap(text, style, canvas) : text;
var lines = outputText.split(/(?:\r\n|\r|\n)/);
var lineWidths = new Array(lines.length);
var maxLineWidth = 0;
for (var i = 0; i < lines.length; i++) {
var lineWidth = context.measureText(lines[i]).width + (lines[i].length - 1) * style.letterSpacing;
lineWidths[i] = lineWidth;
maxLineWidth = Math.max(maxLineWidth, lineWidth);
}
var width = maxLineWidth + style.strokeThickness;
if (style.dropShadow) {
width += style.dropShadowDistance;
}
var lineHeight = style.lineHeight || fontProperties.fontSize + style.strokeThickness;
var height = Math.max(lineHeight, fontProperties.fontSize + style.strokeThickness) + (lines.length - 1) * (lineHeight + style.leading);
if (style.dropShadow) {
height += style.dropShadowDistance;
}
return new TextMetrics(text, style, width, height, lines, lineWidths, lineHeight + style.leading, maxLineWidth, fontProperties);
};
/**
* Applies newlines to a string to have it optimally fit into the horizontal
* bounds set by the Text object's wordWrapWidth property.
*
* @private
* @param {string} text - String to apply word wrapping to
* @param {PIXI.TextStyle} style - the style to use when wrapping
* @param {HTMLCanvasElement} [canvas] - optional specification of the canvas to use for measuring.
* @return {string} New string with new lines applied where required
*/
TextMetrics.wordWrap = function wordWrap(text, style) {
var canvas = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : TextMetrics._canvas;
var context = canvas.getContext('2d');
var width = 0;
var line = '';
var lines = '';
var cache = {};
var letterSpacing = style.letterSpacing,
whiteSpace = style.whiteSpace;
// How to handle whitespaces
var collapseSpaces = TextMetrics.collapseSpaces(whiteSpace);
var collapseNewlines = TextMetrics.collapseNewlines(whiteSpace);
// whether or not spaces may be added to the beginning of lines
var canPrependSpaces = !collapseSpaces;
// There is letterSpacing after every char except the last one
// t_h_i_s_' '_i_s_' '_a_n_' '_e_x_a_m_p_l_e_' '_!
// so for convenience the above needs to be compared to width + 1 extra letterSpace
// t_h_i_s_' '_i_s_' '_a_n_' '_e_x_a_m_p_l_e_' '_!_
// ________________________________________________
// And then the final space is simply no appended to each line
var wordWrapWidth = style.wordWrapWidth + letterSpacing;
// break text into words, spaces and newline chars
var tokens = TextMetrics.tokenize(text);
for (var i = 0; i < tokens.length; i++) {
// get the word, space or newlineChar
var token = tokens[i];
// if word is a new line
if (TextMetrics.isNewline(token)) {
// keep the new line
if (!collapseNewlines) {
lines += TextMetrics.addLine(line);
canPrependSpaces = !collapseSpaces;
line = '';
width = 0;
continue;
}
// if we should collapse new lines
// we simply convert it into a space
token = ' ';
}
// if we should collapse repeated whitespaces
if (collapseSpaces) {
// check both this and the last tokens for spaces
var currIsBreakingSpace = TextMetrics.isBreakingSpace(token);
var lastIsBreakingSpace = TextMetrics.isBreakingSpace(line[line.length - 1]);
if (currIsBreakingSpace && lastIsBreakingSpace) {
continue;
}
}
// get word width from cache if possible
var tokenWidth = TextMetrics.getFromCache(token, letterSpacing, cache, context);
// word is longer than desired bounds
if (tokenWidth > wordWrapWidth) {
// if we are not already at the beginning of a line
if (line !== '') {
// start newlines for overflow words
lines += TextMetrics.addLine(line);
line = '';
width = 0;
}
// break large word over multiple lines
if (TextMetrics.canBreakWords(token, style.breakWords)) {
// break word into characters
var characters = token.split('');
// loop the characters
for (var j = 0; j < characters.length; j++) {
var char = characters[j];
var k = 1;
// we are not at the end of the token
while (characters[j + k]) {
var nextChar = characters[j + k];
var lastChar = char[char.length - 1];
// should not split chars
if (!TextMetrics.canBreakChars(lastChar, nextChar, token, j, style.breakWords)) {
// combine chars & move forward one
char += nextChar;
} else {
break;
}
k++;
}
j += char.length - 1;
var characterWidth = TextMetrics.getFromCache(char, letterSpacing, cache, context);
if (characterWidth + width > wordWrapWidth) {
lines += TextMetrics.addLine(line);
canPrependSpaces = false;
line = '';
width = 0;
}
line += char;
width += characterWidth;
}
}
// run word out of the bounds
else {
// if there are words in this line already
// finish that line and start a new one
if (line.length > 0) {
lines += TextMetrics.addLine(line);
line = '';
width = 0;
}
var isLastToken = i === tokens.length - 1;
// give it its own line if it's not the end
lines += TextMetrics.addLine(token, !isLastToken);
canPrependSpaces = false;
line = '';
width = 0;
}
}
// word could fit
else {
// word won't fit because of existing words
// start a new line
if (tokenWidth + width > wordWrapWidth) {
// if its a space we don't want it
canPrependSpaces = false;
// add a new line
lines += TextMetrics.addLine(line);
// start a new line
line = '';
width = 0;
}
// don't add spaces to the beginning of lines
if (line.length > 0 || !TextMetrics.isBreakingSpace(token) || canPrependSpaces) {
// add the word to the current line
line += token;
// update width counter
width += tokenWidth;
}
}
}
lines += TextMetrics.addLine(line, false);
return lines;
};
/**
* Convienience function for logging each line added during the wordWrap
* method
*
* @private
* @param {string} line - The line of text to add
* @param {boolean} newLine - Add new line character to end
* @return {string} A formatted line
*/
TextMetrics.addLine = function addLine(line) {
var newLine = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
line = TextMetrics.trimRight(line);
line = newLine ? line + '\n' : line;
return line;
};
/**
* Gets & sets the widths of calculated characters in a cache object
*
* @private
* @param {string} key The key
* @param {number} letterSpacing The letter spacing
* @param {object} cache The cache
* @param {CanvasRenderingContext2D} context The canvas context
* @return {number} The from cache.
*/
TextMetrics.getFromCache = function getFromCache(key, letterSpacing, cache, context) {
var width = cache[key];
if (width === undefined) {
var spacing = key.length * letterSpacing;
width = context.measureText(key).width + spacing;
cache[key] = width;
}
return width;
};
/**
* Determines whether we should collapse breaking spaces
*
* @private
* @param {string} whiteSpace The TextStyle property whiteSpace
* @return {boolean} should collapse
*/
TextMetrics.collapseSpaces = function collapseSpaces(whiteSpace) {
return whiteSpace === 'normal' || whiteSpace === 'pre-line';
};
/**
* Determines whether we should collapse newLine chars
*
* @private
* @param {string} whiteSpace The white space
* @return {boolean} should collapse
*/
TextMetrics.collapseNewlines = function collapseNewlines(whiteSpace) {
return whiteSpace === 'normal';
};
/**
* trims breaking whitespaces from string
*
* @private
* @param {string} text The text
* @return {string} trimmed string
*/
TextMetrics.trimRight = function trimRight(text) {
if (typeof text !== 'string') {
return '';
}
for (var i = text.length - 1; i >= 0; i--) {
var char = text[i];
if (!TextMetrics.isBreakingSpace(char)) {
break;
}
text = text.slice(0, -1);
}
return text;
};
/**
* Determines if char is a newline.
*
* @private
* @param {string} char The character
* @return {boolean} True if newline, False otherwise.
*/
TextMetrics.isNewline = function isNewline(char) {
if (typeof char !== 'string') {
return false;
}
return TextMetrics._newlines.indexOf(char.charCodeAt(0)) >= 0;
};
/**
* Determines if char is a breaking whitespace.
*
* @private
* @param {string} char The character
* @return {boolean} True if whitespace, False otherwise.
*/
TextMetrics.isBreakingSpace = function isBreakingSpace(char) {
if (typeof char !== 'string') {
return false;
}
return TextMetrics._breakingSpaces.indexOf(char.charCodeAt(0)) >= 0;
};
/**
* Splits a string into words, breaking-spaces and newLine characters
*
* @private
* @param {string} text The text
* @return {array} A tokenized array
*/
TextMetrics.tokenize = function tokenize(text) {
var tokens = [];
var token = '';
if (typeof text !== 'string') {
return tokens;
}
for (var i = 0; i < text.length; i++) {
var char = text[i];
if (TextMetrics.isBreakingSpace(char) || TextMetrics.isNewline(char)) {
if (token !== '') {
tokens.push(token);
token = '';
}
tokens.push(char);
continue;
}
token += char;
}
if (token !== '') {
tokens.push(token);
}
return tokens;
};
/**
* This method exists to be easily overridden
* It allows one to customise which words should break
* Examples are if the token is CJK or numbers.
* It must return a boolean.
*
* @private
* @param {string} token The token
* @param {boolean} breakWords The style attr break words
* @return {boolean} whether to break word or not
*/
TextMetrics.canBreakWords = function canBreakWords(token, breakWords) {
return breakWords;
};
/**
* This method exists to be easily overridden
* It allows one to determine whether a pair of characters
* should be broken by newlines
* For example certain characters in CJK langs or numbers.
* It must return a boolean.
*
* @private
* @param {string} char The character
* @param {string} nextChar The next character
* @param {string} token The token/word the characters are from
* @param {number} index The index in the token of the char
* @param {boolean} breakWords The style attr break words
* @return {boolean} whether to break word or not
*/
TextMetrics.canBreakChars = function canBreakChars(char, nextChar, token, index, breakWords) // eslint-disable-line no-unused-vars
{
return true;
};
/**
* Calculates the ascent, descent and fontSize of a given font-style
*
* @static
* @param {string} font - String representing the style of the font
* @return {PIXI.TextMetrics~FontMetrics} Font properties object
*/
TextMetrics.measureFont = function measureFont(font) {
// as this method is used for preparing assets, don't recalculate things if we don't need to
if (TextMetrics._fonts[font]) {
return TextMetrics._fonts[font];
}
var properties = {};
var canvas = TextMetrics._canvas;
var context = TextMetrics._context;
context.font = font;
var metricsString = TextMetrics.METRICS_STRING + TextMetrics.BASELINE_SYMBOL;
var width = Math.ceil(context.measureText(metricsString).width);
var baseline = Math.ceil(context.measureText(TextMetrics.BASELINE_SYMBOL).width);
var height = 2 * baseline;
baseline = baseline * TextMetrics.BASELINE_MULTIPLIER | 0;
canvas.width = width;
canvas.height = height;
context.fillStyle = '#f00';
context.fillRect(0, 0, width, height);
context.font = font;
context.textBaseline = 'alphabetic';
context.fillStyle = '#000';
context.fillText(metricsString, 0, baseline);
var imagedata = context.getImageData(0, 0, width, height).data;
var pixels = imagedata.length;
var line = width * 4;
var i = 0;
var idx = 0;
var stop = false;
// ascent. scan from top to bottom until we find a non red pixel
for (i = 0; i < baseline; ++i) {
for (var j = 0; j < line; j += 4) {
if (imagedata[idx + j] !== 255) {
stop = true;
break;
}
}
if (!stop) {
idx += line;
} else {
break;
}
}
properties.ascent = baseline - i;
idx = pixels - line;
stop = false;
// descent. scan from bottom to top until we find a non red pixel
for (i = height; i > baseline; --i) {
for (var _j = 0; _j < line; _j += 4) {
if (imagedata[idx + _j] !== 255) {
stop = true;
break;
}
}
if (!stop) {
idx -= line;
} else {
break;
}
}
properties.descent = i - baseline;
properties.fontSize = properties.ascent + properties.descent;
TextMetrics._fonts[font] = properties;
return properties;
};
/**
* Clear font metrics in metrics cache.
*
* @static
* @param {string} [font] - font name. If font name not set then clear cache for all fonts.
*/
TextMetrics.clearMetrics = function clearMetrics() {
var font = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
if (font) {
delete TextMetrics._fonts[font];
} else {
TextMetrics._fonts = {};
}
};
return TextMetrics;
}();
/**
* Internal return object for {@link PIXI.TextMetrics.measureFont `TextMetrics.measureFont`}.
* @class FontMetrics
* @memberof PIXI.TextMetrics~
* @property {number} ascent - The ascent distance
* @property {number} descent - The descent distance
* @property {number} fontSize - Font size from ascent to descent
*/
exports.default = TextMetrics;
var canvas = document.createElement('canvas');
canvas.width = canvas.height = 10;
/**
* Cached canvas element for measuring text
* @memberof PIXI.TextMetrics
* @type {HTMLCanvasElement}
* @private
*/
TextMetrics._canvas = canvas;
/**
* Cache for context to use.
* @memberof PIXI.TextMetrics
* @type {CanvasRenderingContext2D}
* @private
*/
TextMetrics._context = canvas.getContext('2d');
/**
* Cache of PIXI.TextMetrics~FontMetrics objects.
* @memberof PIXI.TextMetrics
* @type {Object}
* @private
*/
TextMetrics._fonts = {};
/**
* String used for calculate font metrics.
* @static
* @memberof PIXI.TextMetrics
* @name METRICS_STRING
* @type {string}
* @default |Éq
*/
TextMetrics.METRICS_STRING = '|Éq';
/**
* Baseline symbol for calculate font metrics.
* @static
* @memberof PIXI.TextMetrics
* @name BASELINE_SYMBOL
* @type {string}
* @default M
*/
TextMetrics.BASELINE_SYMBOL = 'M';
/**
* Baseline multiplier for calculate font metrics.
* @static
* @memberof PIXI.TextMetrics
* @name BASELINE_MULTIPLIER
* @type {number}
* @default 1.4
*/
TextMetrics.BASELINE_MULTIPLIER = 1.4;
/**
* Cache of new line chars.
* @memberof PIXI.TextMetrics
* @type {number[]}
* @private
*/
TextMetrics._newlines = [0x000A, // line feed
0x000D];
/**
* Cache of breaking spaces.
* @memberof PIXI.TextMetrics
* @type {number[]}
* @private
*/
TextMetrics._breakingSpaces = [0x0009, // character tabulation
0x0020, // space
0x2000, // en quad
0x2001, // em quad
0x2002, // en space
0x2003, // em space
0x2004, // three-per-em space
0x2005, // four-per-em space
0x2006, // six-per-em space
0x2008, // punctuation space
0x2009, // thin space
0x200A, // hair space
0x205F, // medium mathematical space
0x3000];
//# sourceMappingURL=TextMetrics.js.map
/***/ }),
/* 198 */
/***/ (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"); } }
/**
* A GraphicsData object.
*
* @class
* @memberof PIXI
*/
var GraphicsData = function () {
/**
*
* @param {number} lineWidth - the width of the line to draw
* @param {number} lineColor - the color of the line to draw
* @param {number} lineAlpha - the alpha of the line to draw
* @param {number} fillColor - the color of the fill
* @param {number} fillAlpha - the alpha of the fill
* @param {boolean} fill - whether or not the shape is filled with a colour
* @param {boolean} nativeLines - the method for drawing lines
* @param {PIXI.Circle|PIXI.Rectangle|PIXI.Ellipse|PIXI.Polygon} shape - The shape object to draw.
* @param {number} lineAlignment - the alignment of the line.
*/
function GraphicsData(lineWidth, lineColor, lineAlpha, fillColor, fillAlpha, fill, nativeLines, shape, lineAlignment) {
_classCallCheck(this, GraphicsData);
/**
* the width of the line to draw
* @member {number}
*/
this.lineWidth = lineWidth;
/**
* The alignment of any lines drawn (0.5 = middle, 1 = outter, 0 = inner).
*
* @member {number}
* @default 0
*/
this.lineAlignment = lineAlignment;
/**
* if true the liens will be draw using LINES instead of TRIANGLE_STRIP
* @member {boolean}
*/
this.nativeLines = nativeLines;
/**
* the color of the line to draw
* @member {number}
*/
this.lineColor = lineColor;
/**
* the alpha of the line to draw
* @member {number}
*/
this.lineAlpha = lineAlpha;
/**
* cached tint of the line to draw
* @member {number}
* @private
*/
this._lineTint = lineColor;
/**
* the color of the fill
* @member {number}
*/
this.fillColor = fillColor;
/**
* the alpha of the fill
* @member {number}
*/
this.fillAlpha = fillAlpha;
/**
* cached tint of the fill
* @member {number}
* @private
*/
this._fillTint = fillColor;
/**
* whether or not the shape is filled with a colour
* @member {boolean}
*/
this.fill = fill;
this.holes = [];
/**
* The shape object to draw.
* @member {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle}
*/
this.shape = shape;
/**
* The type of the shape, see the Const.Shapes file for all the existing types,
* @member {number}
*/
this.type = shape.type;
}
/**
* Creates a new GraphicsData object with the same values as this one.
*
* @return {PIXI.GraphicsData} Cloned GraphicsData object
*/
GraphicsData.prototype.clone = function clone() {
return new GraphicsData(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.fill, this.nativeLines, this.shape, this.lineAlignment);
};
/**
* Adds a hole to the shape.
*
* @param {PIXI.Rectangle|PIXI.Circle} shape - The shape of the hole.
*/
GraphicsData.prototype.addHole = function addHole(shape) {
this.holes.push(shape);
};
/**
* Destroys the Graphics data.
*/
GraphicsData.prototype.destroy = function destroy() {
this.shape = null;
this.holes = null;
};
return GraphicsData;
}();
exports.default = GraphicsData;
//# sourceMappingURL=GraphicsData.js.map
/***/ }),
/* 199 */
/***/ (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 _autoDetectRenderer = __webpack_require__(200);
var _Container = __webpack_require__(64);
var _Container2 = _interopRequireDefault(_Container);
var _ticker = __webpack_require__(127);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
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"); } }
/**
* Convenience class to create a new PIXI application.
* This class automatically creates the renderer, ticker
* and root container.
*
* @example
* // Create the application
* const app = new PIXI.Application();
*
* // Add the view to the DOM
* document.body.appendChild(app.view);
*
* // ex, add display objects
* app.stage.addChild(PIXI.Sprite.fromImage('something.png'));
*
* @class
* @memberof PIXI
*/
var Application = function () {
// eslint-disable-next-line valid-jsdoc
/**
* @param {object} [options] - The optional renderer parameters
* @param {boolean} [options.autoStart=true] - automatically starts the rendering after the construction.
* Note that setting this parameter to false does NOT stop the shared ticker even if you set
* options.sharedTicker to true in case that it is already started. Stop it by your own.
* @param {number} [options.width=800] - the width of the renderers view
* @param {number} [options.height=600] - the height of the renderers view
* @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.antialias=false] - sets antialias (only applicable in chrome at the moment)
* @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation, enable this if you
* need to call toDataUrl on the webgl context
* @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer, retina would be 2
* @param {boolean} [options.forceCanvas=false] - prevents selection of WebGL renderer, even if such is present
* @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area
* (shown if not transparent).
* @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or
* not before the new render pass.
* @param {boolean} [options.roundPixels=false] - If true PixiJS will Math.floor() x/y values when rendering,
* stopping pixel interpolation.
* @param {boolean} [options.forceFXAA=false] - forces FXAA antialiasing to be used over native.
* FXAA is faster, but may not always look as great **webgl only**
* @param {boolean} [options.legacy=false] - `true` to ensure compatibility with older / less advanced devices.
* If you experience unexplained flickering try setting this to true. **webgl only**
* @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance"
* for devices with dual graphics card **webgl only**
* @param {boolean} [options.sharedTicker=false] - `true` to use PIXI.ticker.shared, `false` to create new ticker.
* @param {boolean} [options.sharedLoader=false] - `true` to use PIXI.loaders.shared, `false` to create new Loader.
*/
function Application(options, arg2, arg3, arg4, arg5) {
_classCallCheck(this, Application);
// Support for constructor(width, height, options, noWebGL, useSharedTicker)
if (typeof options === 'number') {
options = Object.assign({
width: options,
height: arg2 || _settings2.default.RENDER_OPTIONS.height,
forceCanvas: !!arg4,
sharedTicker: !!arg5
}, arg3);
}
/**
* The default options, so we mixin functionality later.
* @member {object}
* @protected
*/
this._options = options = Object.assign({
autoStart: true,
sharedTicker: false,
forceCanvas: false,
sharedLoader: false
}, options);
/**
* WebGL renderer if available, otherwise CanvasRenderer
* @member {PIXI.WebGLRenderer|PIXI.CanvasRenderer}
*/
this.renderer = (0, _autoDetectRenderer.autoDetectRenderer)(options);
/**
* The root display container that's rendered.
* @member {PIXI.Container}
*/
this.stage = new _Container2.default();
/**
* Internal reference to the ticker
* @member {PIXI.ticker.Ticker}
* @private
*/
this._ticker = null;
/**
* Ticker for doing render updates.
* @member {PIXI.ticker.Ticker}
* @default PIXI.ticker.shared
*/
this.ticker = options.sharedTicker ? _ticker.shared : new _ticker.Ticker();
// Start the rendering
if (options.autoStart) {
this.start();
}
}
/**
* Render the current stage.
*/
Application.prototype.render = function render() {
this.renderer.render(this.stage);
};
/**
* Convenience method for stopping the render.
*/
Application.prototype.stop = function stop() {
this._ticker.stop();
};
/**
* Convenience method for starting the render.
*/
Application.prototype.start = function start() {
this._ticker.start();
};
/**
* Reference to the renderer's canvas element.
* @member {HTMLCanvasElement}
* @readonly
*/
/**
* Destroy and don't use after this.
* @param {Boolean} [removeView=false] Automatically remove canvas from DOM.
* @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy
* method called as well. 'stageOptions' will be passed on to those calls.
* @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the texture of the child sprite
* @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set
* to true. Should it destroy the base texture of the child sprite
*/
Application.prototype.destroy = function destroy(removeView, stageOptions) {
if (this._ticker) {
var oldTicker = this._ticker;
this.ticker = null;
oldTicker.destroy();
}
this.stage.destroy(stageOptions);
this.stage = null;
this.renderer.destroy(removeView);
this.renderer = null;
this._options = null;
};
_createClass(Application, [{
key: 'ticker',
set: function set(ticker) // eslint-disable-line require-jsdoc
{
if (this._ticker) {
this._ticker.remove(this.render, this);
}
this._ticker = ticker;
if (ticker) {
ticker.add(this.render, this, _const.UPDATE_PRIORITY.LOW);
}
},
get: function get() // eslint-disable-line require-jsdoc
{
return this._ticker;
}
}, {
key: 'view',
get: function get() {
return this.renderer.view;
}
/**
* Reference to the renderer's screen rectangle. Its safe to use as filterArea or hitArea for whole screen
* @member {PIXI.Rectangle}
* @readonly
*/
}, {
key: 'screen',
get: function get() {
return this.renderer.screen;
}
}]);
return Application;
}();
exports.default = Application;
//# sourceMappingURL=Application.js.map
/***/ }),
/* 200 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.autoDetectRenderer = autoDetectRenderer;
var _utils = __webpack_require__(7);
var utils = _interopRequireWildcard(_utils);
var _CanvasRenderer = __webpack_require__(65);
var _CanvasRenderer2 = _interopRequireDefault(_CanvasRenderer);
var _WebGLRenderer = __webpack_require__(86);
var _WebGLRenderer2 = _interopRequireDefault(_WebGLRenderer);
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; } }
// eslint-disable-next-line valid-jsdoc
/**
* This helper function will automatically detect which renderer you should be using.
* WebGL is the preferred renderer as it is a lot faster. If webGL is not supported by
* the browser then this function will return a canvas renderer
*
* @memberof PIXI
* @function autoDetectRenderer
* @param {object} [options] - The optional renderer parameters
* @param {number} [options.width=800] - the width of the renderers view
* @param {number} [options.height=600] - the height of the renderers view
* @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.antialias=false] - sets antialias (only applicable in chrome at the moment)
* @param {boolean} [options.preserveDrawingBuffer=false] - enables drawing buffer preservation, enable this if you
* need to call toDataUrl on the webgl context
* @param {number} [options.backgroundColor=0x000000] - The background color of the rendered area
* (shown if not transparent).
* @param {boolean} [options.clearBeforeRender=true] - This sets if the renderer will clear the canvas or
* not before the new render pass.
* @param {number} [options.resolution=1] - The resolution / device pixel ratio of the renderer, retina would be 2
* @param {boolean} [options.forceCanvas=false] - prevents selection of WebGL renderer, even if such is present
* @param {boolean} [options.roundPixels=false] - If true PixiJS will Math.floor() x/y values when rendering,
* stopping pixel interpolation.
* @param {boolean} [options.forceFXAA=false] - forces FXAA antialiasing to be used over native.
* FXAA is faster, but may not always look as great **webgl only**
* @param {boolean} [options.legacy=false] - `true` to ensure compatibility with older / less advanced devices.
* If you experience unexplained flickering try setting this to true. **webgl only**
* @param {string} [options.powerPreference] - Parameter passed to webgl context, set to "high-performance"
* for devices with dual graphics card **webgl only**
* @return {PIXI.WebGLRenderer|PIXI.CanvasRenderer} Returns WebGL renderer if available, otherwise CanvasRenderer
*/
function autoDetectRenderer(options, arg1, arg2, arg3) {
// Backward-compatible support for noWebGL option
var forceCanvas = options && options.forceCanvas;
if (arg3 !== undefined) {
forceCanvas = arg3;
}
if (!forceCanvas && utils.isWebGLSupported()) {
return new _WebGLRenderer2.default(options, arg1, arg2);
}
return new _CanvasRenderer2.default(options, arg1, arg2);
}
//# sourceMappingURL=autoDetectRenderer.js.map
/***/ }),
/* 201 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
/**
* Default property values of accessible objects
* used by {@link PIXI.accessibility.AccessibilityManager}.
*
* @function accessibleTarget
* @memberof PIXI.accessibility
* @example
* function MyObject() {}
*
* Object.assign(
* MyObject.prototype,
* PIXI.accessibility.accessibleTarget
* );
*/
exports.default = {
/**
* Flag for if the object is accessible. If true AccessibilityManager will overlay a
* shadow div with attributes set
*
* @member {boolean}
*/
accessible: false,
/**
* Sets the title attribute of the shadow div
* If accessibleTitle AND accessibleHint has not been this will default to 'displayObject [tabIndex]'
*
* @member {string}
*/
accessibleTitle: null,
/**
* Sets the aria-label attribute of the shadow div
*
* @member {string}
*/
accessibleHint: null,
/**
* @todo Needs docs.
*/
tabIndex: 0,
/**
* @todo Needs docs.
*/
_accessibleActive: false,
/**
* @todo Needs docs.
*/
_accessibleDiv: false
};
//# sourceMappingURL=accessibleTarget.js.map
/***/ }),
/* 202 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.BitmapText = exports.TilingSpriteRenderer = exports.TilingSprite = exports.AnimatedSprite = undefined;
var _AnimatedSprite = __webpack_require__(503);
Object.defineProperty(exports, 'AnimatedSprite', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_AnimatedSprite).default;
}
});
var _TilingSprite = __webpack_require__(504);
Object.defineProperty(exports, 'TilingSprite', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_TilingSprite).default;
}
});
var _TilingSpriteRenderer = __webpack_require__(505);
Object.defineProperty(exports, 'TilingSpriteRenderer', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_TilingSpriteRenderer).default;
}
});
var _BitmapText = __webpack_require__(506);
Object.defineProperty(exports, 'BitmapText', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_BitmapText).default;
}
});
__webpack_require__(507);
__webpack_require__(508);
__webpack_require__(509);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// imported for side effect of extending the prototype only, contains no exports
//# sourceMappingURL=index.js.map
/***/ }),
/* 203 */
/***/ (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 _generateBlurVertSource = __webpack_require__(204);
var _generateBlurVertSource2 = _interopRequireDefault(_generateBlurVertSource);
var _generateBlurFragSource = __webpack_require__(205);
var _generateBlurFragSource2 = _interopRequireDefault(_generateBlurFragSource);
var _getMaxBlurKernelSize = __webpack_require__(206);
var _getMaxBlurKernelSize2 = _interopRequireDefault(_getMaxBlurKernelSize);
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; }
/**
* The BlurXFilter applies a horizontal Gaussian blur to an object.
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
*/
var BlurXFilter = function (_core$Filter) {
_inherits(BlurXFilter, _core$Filter);
/**
* @param {number} strength - The strength of the blur filter.
* @param {number} quality - The quality of the blur filter.
* @param {number} resolution - The resolution of the blur filter.
* @param {number} [kernelSize=5] - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15.
*/
function BlurXFilter(strength, quality, resolution, kernelSize) {
_classCallCheck(this, BlurXFilter);
kernelSize = kernelSize || 5;
var vertSrc = (0, _generateBlurVertSource2.default)(kernelSize, true);
var fragSrc = (0, _generateBlurFragSource2.default)(kernelSize);
var _this = _possibleConstructorReturn(this, _core$Filter.call(this,
// vertex shader
vertSrc,
// fragment shader
fragSrc));
_this.resolution = resolution || core.settings.RESOLUTION;
_this._quality = 0;
_this.quality = quality || 4;
_this.strength = strength || 8;
_this.firstRun = true;
return _this;
}
/**
* Applies the filter.
*
* @param {PIXI.FilterManager} filterManager - The manager.
* @param {PIXI.RenderTarget} input - The input target.
* @param {PIXI.RenderTarget} output - The output target.
* @param {boolean} clear - Should the output be cleared before rendering?
*/
BlurXFilter.prototype.apply = function apply(filterManager, input, output, clear) {
if (this.firstRun) {
var gl = filterManager.renderer.gl;
var kernelSize = (0, _getMaxBlurKernelSize2.default)(gl);
this.vertexSrc = (0, _generateBlurVertSource2.default)(kernelSize, true);
this.fragmentSrc = (0, _generateBlurFragSource2.default)(kernelSize);
this.firstRun = false;
}
this.uniforms.strength = 1 / output.size.width * (output.size.width / input.size.width);
// screen space!
this.uniforms.strength *= this.strength;
this.uniforms.strength /= this.passes; // / this.passes//Math.pow(1, this.passes);
if (this.passes === 1) {
filterManager.applyFilter(this, input, output, clear);
} else {
var renderTarget = filterManager.getRenderTarget(true);
var flip = input;
var flop = renderTarget;
for (var i = 0; i < this.passes - 1; i++) {
filterManager.applyFilter(this, flip, flop, true);
var temp = flop;
flop = flip;
flip = temp;
}
filterManager.applyFilter(this, flip, output, clear);
filterManager.returnRenderTarget(renderTarget);
}
};
/**
* Sets the strength of both the blur.
*
* @member {number}
* @default 16
*/
_createClass(BlurXFilter, [{
key: 'blur',
get: function get() {
return this.strength;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.padding = Math.abs(value) * 2;
this.strength = value;
}
/**
* Sets the quality of the blur by modifying the number of passes. More passes means higher
* quaility bluring but the lower the performance.
*
* @member {number}
* @default 4
*/
}, {
key: 'quality',
get: function get() {
return this._quality;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._quality = value;
this.passes = value;
}
}]);
return BlurXFilter;
}(core.Filter);
exports.default = BlurXFilter;
//# sourceMappingURL=BlurXFilter.js.map
/***/ }),
/* 204 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = generateVertBlurSource;
var vertTemplate = ['attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', 'uniform float strength;', 'uniform mat3 projectionMatrix;', 'varying vec2 vBlurTexCoords[%size%];', 'void main(void)', '{', 'gl_Position = vec4((projectionMatrix * vec3((aVertexPosition), 1.0)).xy, 0.0, 1.0);', '%blur%', '}'].join('\n');
function generateVertBlurSource(kernelSize, x) {
var halfLength = Math.ceil(kernelSize / 2);
var vertSource = vertTemplate;
var blurLoop = '';
var template = void 0;
// let value;
if (x) {
template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(%sampleIndex% * strength, 0.0);';
} else {
template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(0.0, %sampleIndex% * strength);';
}
for (var i = 0; i < kernelSize; i++) {
var blur = template.replace('%index%', i);
// value = i;
// if(i >= halfLength)
// {
// value = kernelSize - i - 1;
// }
blur = blur.replace('%sampleIndex%', i - (halfLength - 1) + '.0');
blurLoop += blur;
blurLoop += '\n';
}
vertSource = vertSource.replace('%blur%', blurLoop);
vertSource = vertSource.replace('%size%', kernelSize);
return vertSource;
}
//# sourceMappingURL=generateBlurVertSource.js.map
/***/ }),
/* 205 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = generateFragBlurSource;
var GAUSSIAN_VALUES = {
5: [0.153388, 0.221461, 0.250301],
7: [0.071303, 0.131514, 0.189879, 0.214607],
9: [0.028532, 0.067234, 0.124009, 0.179044, 0.20236],
11: [0.0093, 0.028002, 0.065984, 0.121703, 0.175713, 0.198596],
13: [0.002406, 0.009255, 0.027867, 0.065666, 0.121117, 0.174868, 0.197641],
15: [0.000489, 0.002403, 0.009246, 0.02784, 0.065602, 0.120999, 0.174697, 0.197448]
};
var fragTemplate = ['varying vec2 vBlurTexCoords[%size%];', 'uniform sampler2D uSampler;', 'void main(void)', '{', ' gl_FragColor = vec4(0.0);', ' %blur%', '}'].join('\n');
function generateFragBlurSource(kernelSize) {
var kernel = GAUSSIAN_VALUES[kernelSize];
var halfLength = kernel.length;
var fragSource = fragTemplate;
var blurLoop = '';
var template = 'gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;';
var value = void 0;
for (var i = 0; i < kernelSize; i++) {
var blur = template.replace('%index%', i);
value = i;
if (i >= halfLength) {
value = kernelSize - i - 1;
}
blur = blur.replace('%value%', kernel[value]);
blurLoop += blur;
blurLoop += '\n';
}
fragSource = fragSource.replace('%blur%', blurLoop);
fragSource = fragSource.replace('%size%', kernelSize);
return fragSource;
}
//# sourceMappingURL=generateBlurFragSource.js.map
/***/ }),
/* 206 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = getMaxKernelSize;
function getMaxKernelSize(gl) {
var maxVaryings = gl.getParameter(gl.MAX_VARYING_VECTORS);
var kernelSize = 15;
while (kernelSize > maxVaryings) {
kernelSize -= 2;
}
return kernelSize;
}
//# sourceMappingURL=getMaxBlurKernelSize.js.map
/***/ }),
/* 207 */
/***/ (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 _generateBlurVertSource = __webpack_require__(204);
var _generateBlurVertSource2 = _interopRequireDefault(_generateBlurVertSource);
var _generateBlurFragSource = __webpack_require__(205);
var _generateBlurFragSource2 = _interopRequireDefault(_generateBlurFragSource);
var _getMaxBlurKernelSize = __webpack_require__(206);
var _getMaxBlurKernelSize2 = _interopRequireDefault(_getMaxBlurKernelSize);
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; }
/**
* The BlurYFilter applies a horizontal Gaussian blur to an object.
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
*/
var BlurYFilter = function (_core$Filter) {
_inherits(BlurYFilter, _core$Filter);
/**
* @param {number} strength - The strength of the blur filter.
* @param {number} quality - The quality of the blur filter.
* @param {number} resolution - The resolution of the blur filter.
* @param {number} [kernelSize=5] - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15.
*/
function BlurYFilter(strength, quality, resolution, kernelSize) {
_classCallCheck(this, BlurYFilter);
kernelSize = kernelSize || 5;
var vertSrc = (0, _generateBlurVertSource2.default)(kernelSize, false);
var fragSrc = (0, _generateBlurFragSource2.default)(kernelSize);
var _this = _possibleConstructorReturn(this, _core$Filter.call(this,
// vertex shader
vertSrc,
// fragment shader
fragSrc));
_this.resolution = resolution || core.settings.RESOLUTION;
_this._quality = 0;
_this.quality = quality || 4;
_this.strength = strength || 8;
_this.firstRun = true;
return _this;
}
/**
* Applies the filter.
*
* @param {PIXI.FilterManager} filterManager - The manager.
* @param {PIXI.RenderTarget} input - The input target.
* @param {PIXI.RenderTarget} output - The output target.
* @param {boolean} clear - Should the output be cleared before rendering?
*/
BlurYFilter.prototype.apply = function apply(filterManager, input, output, clear) {
if (this.firstRun) {
var gl = filterManager.renderer.gl;
var kernelSize = (0, _getMaxBlurKernelSize2.default)(gl);
this.vertexSrc = (0, _generateBlurVertSource2.default)(kernelSize, false);
this.fragmentSrc = (0, _generateBlurFragSource2.default)(kernelSize);
this.firstRun = false;
}
this.uniforms.strength = 1 / output.size.height * (output.size.height / input.size.height);
this.uniforms.strength *= this.strength;
this.uniforms.strength /= this.passes;
if (this.passes === 1) {
filterManager.applyFilter(this, input, output, clear);
} else {
var renderTarget = filterManager.getRenderTarget(true);
var flip = input;
var flop = renderTarget;
for (var i = 0; i < this.passes - 1; i++) {
filterManager.applyFilter(this, flip, flop, true);
var temp = flop;
flop = flip;
flip = temp;
}
filterManager.applyFilter(this, flip, output, clear);
filterManager.returnRenderTarget(renderTarget);
}
};
/**
* Sets the strength of both the blur.
*
* @member {number}
* @default 2
*/
_createClass(BlurYFilter, [{
key: 'blur',
get: function get() {
return this.strength;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.padding = Math.abs(value) * 2;
this.strength = value;
}
/**
* Sets the quality of the blur by modifying the number of passes. More passes means higher
* quaility bluring but the lower the performance.
*
* @member {number}
* @default 4
*/
}, {
key: 'quality',
get: function get() {
return this._quality;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._quality = value;
this.passes = value;
}
}]);
return BlurYFilter;
}(core.Filter);
exports.default = BlurYFilter;
//# sourceMappingURL=BlurYFilter.js.map
/***/ }),
/* 208 */
/***/ (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);
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"); } }
/**
* Holds all information related to an Interaction event
*
* @class
* @memberof PIXI.interaction
*/
var InteractionData = function () {
/**
*
*/
function InteractionData() {
_classCallCheck(this, InteractionData);
/**
* This point stores the global coords of where the touch/mouse event happened
*
* @member {PIXI.Point}
*/
this.global = new core.Point();
/**
* The target DisplayObject that was interacted with
*
* @member {PIXI.DisplayObject}
*/
this.target = null;
/**
* When passed to an event handler, this will be the original DOM Event that was captured
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
* @see https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent
* @member {MouseEvent|TouchEvent|PointerEvent}
*/
this.originalEvent = null;
/**
* Unique identifier for this interaction
*
* @member {number}
*/
this.identifier = null;
/**
* Indicates whether or not the pointer device that created the event is the primary pointer.
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary
* @type {Boolean}
*/
this.isPrimary = false;
/**
* Indicates which button was pressed on the mouse or pointer device to trigger the event.
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
* @type {number}
*/
this.button = 0;
/**
* Indicates which buttons are pressed on the mouse or pointer device when the event is triggered.
* @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
* @type {number}
*/
this.buttons = 0;
/**
* The width of the pointer's contact along the x-axis, measured in CSS pixels.
* radiusX of TouchEvents will be represented by this value.
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width
* @type {number}
*/
this.width = 0;
/**
* The height of the pointer's contact along the y-axis, measured in CSS pixels.
* radiusY of TouchEvents will be represented by this value.
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height
* @type {number}
*/
this.height = 0;
/**
* The angle, in degrees, between the pointer device and the screen.
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX
* @type {number}
*/
this.tiltX = 0;
/**
* The angle, in degrees, between the pointer device and the screen.
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY
* @type {number}
*/
this.tiltY = 0;
/**
* The type of pointer that triggered the event.
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType
* @type {string}
*/
this.pointerType = null;
/**
* Pressure applied by the pointing device during the event. A Touch's force property
* will be represented by this value.
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure
* @type {number}
*/
this.pressure = 0;
/**
* From TouchEvents (not PointerEvents triggered by touches), the rotationAngle of the Touch.
* @see https://developer.mozilla.org/en-US/docs/Web/API/Touch/rotationAngle
* @type {number}
*/
this.rotationAngle = 0;
/**
* Twist of a stylus pointer.
* @see https://w3c.github.io/pointerevents/#pointerevent-interface
* @type {number}
*/
this.twist = 0;
/**
* Barrel pressure on a stylus pointer.
* @see https://w3c.github.io/pointerevents/#pointerevent-interface
* @type {number}
*/
this.tangentialPressure = 0;
}
/**
* The unique identifier of the pointer. It will be the same as `identifier`.
* @readonly
* @member {number}
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId
*/
/**
* This will return the local coordinates of the specified displayObject for this InteractionData
*
* @param {PIXI.DisplayObject} displayObject - The DisplayObject that you would like the local
* coords off
* @param {PIXI.Point} [point] - A Point object in which to store the value, optional (otherwise
* will create a new point)
* @param {PIXI.Point} [globalPos] - A Point object containing your custom global coords, optional
* (otherwise will use the current global coords)
* @return {PIXI.Point} A point containing the coordinates of the InteractionData position relative
* to the DisplayObject
*/
InteractionData.prototype.getLocalPosition = function getLocalPosition(displayObject, point, globalPos) {
return displayObject.worldTransform.applyInverse(globalPos || this.global, point);
};
/**
* Copies properties from normalized event data.
*
* @param {Touch|MouseEvent|PointerEvent} event The normalized event data
*/
InteractionData.prototype.copyEvent = function copyEvent(event) {
// isPrimary should only change on touchstart/pointerdown, so we don't want to overwrite
// it with "false" on later events when our shim for it on touch events might not be
// accurate
if (event.isPrimary) {
this.isPrimary = true;
}
this.button = event.button;
// event.buttons is not available in all browsers (ie. Safari), but it does have a non-standard
// event.which property instead, which conveys the same information.
this.buttons = Number.isInteger(event.buttons) ? event.buttons : event.which;
this.width = event.width;
this.height = event.height;
this.tiltX = event.tiltX;
this.tiltY = event.tiltY;
this.pointerType = event.pointerType;
this.pressure = event.pressure;
this.rotationAngle = event.rotationAngle;
this.twist = event.twist || 0;
this.tangentialPressure = event.tangentialPressure || 0;
};
/**
* Resets the data for pooling.
*/
InteractionData.prototype.reset = function reset() {
// isPrimary is the only property that we really need to reset - everything else is
// guaranteed to be overwritten
this.isPrimary = false;
};
_createClass(InteractionData, [{
key: 'pointerId',
get: function get() {
return this.identifier;
}
}]);
return InteractionData;
}();
exports.default = InteractionData;
//# sourceMappingURL=InteractionData.js.map
/***/ }),
/* 209 */
/***/ (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"); } }
/**
* Event class that mimics native DOM events.
*
* @class
* @memberof PIXI.interaction
*/
var InteractionEvent = function () {
/**
*
*/
function InteractionEvent() {
_classCallCheck(this, InteractionEvent);
/**
* Whether this event will continue propagating in the tree
*
* @member {boolean}
*/
this.stopped = false;
/**
* The object which caused this event to be dispatched.
* For listener callback see {@link PIXI.interaction.InteractionEvent.currentTarget}.
*
* @member {PIXI.DisplayObject}
*/
this.target = null;
/**
* The object whose event listener’s callback is currently being invoked.
*
* @member {PIXI.DisplayObject}
*/
this.currentTarget = null;
/**
* Type of the event
*
* @member {string}
*/
this.type = null;
/**
* InteractionData related to this event
*
* @member {PIXI.interaction.InteractionData}
*/
this.data = null;
}
/**
* Prevents event from reaching any objects other than the current object.
*
*/
InteractionEvent.prototype.stopPropagation = function stopPropagation() {
this.stopped = true;
};
/**
* Resets the event.
*/
InteractionEvent.prototype.reset = function reset() {
this.stopped = false;
this.currentTarget = null;
this.target = null;
};
return InteractionEvent;
}();
exports.default = InteractionEvent;
//# sourceMappingURL=InteractionEvent.js.map
/***/ }),
/* 210 */
/***/ (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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* DisplayObjects with the {@link PIXI.interaction.interactiveTarget} mixin use this class to track interactions
*
* @class
* @private
* @memberof PIXI.interaction
*/
var InteractionTrackingData = function () {
/**
* @param {number} pointerId - Unique pointer id of the event
*/
function InteractionTrackingData(pointerId) {
_classCallCheck(this, InteractionTrackingData);
this._pointerId = pointerId;
this._flags = InteractionTrackingData.FLAGS.NONE;
}
/**
*
* @private
* @param {number} flag - The interaction flag to set
* @param {boolean} yn - Should the flag be set or unset
*/
InteractionTrackingData.prototype._doSet = function _doSet(flag, yn) {
if (yn) {
this._flags = this._flags | flag;
} else {
this._flags = this._flags & ~flag;
}
};
/**
* Unique pointer id of the event
*
* @readonly
* @member {number}
*/
_createClass(InteractionTrackingData, [{
key: "pointerId",
get: function get() {
return this._pointerId;
}
/**
* State of the tracking data, expressed as bit flags
*
* @member {number}
* @memberof PIXI.interaction.InteractionTrackingData#
*/
}, {
key: "flags",
get: function get() {
return this._flags;
}
/**
* Set the flags for the tracking data
*
* @param {number} flags - Flags to set
*/
,
set: function set(flags) {
this._flags = flags;
}
/**
* Is the tracked event inactive (not over or down)?
*
* @member {number}
* @memberof PIXI.interaction.InteractionTrackingData#
*/
}, {
key: "none",
get: function get() {
return this._flags === this.constructor.FLAGS.NONE;
}
/**
* Is the tracked event over the DisplayObject?
*
* @member {boolean}
* @memberof PIXI.interaction.InteractionTrackingData#
*/
}, {
key: "over",
get: function get() {
return (this._flags & this.constructor.FLAGS.OVER) !== 0;
}
/**
* Set the over flag
*
* @param {boolean} yn - Is the event over?
*/
,
set: function set(yn) {
this._doSet(this.constructor.FLAGS.OVER, yn);
}
/**
* Did the right mouse button come down in the DisplayObject?
*
* @member {boolean}
* @memberof PIXI.interaction.InteractionTrackingData#
*/
}, {
key: "rightDown",
get: function get() {
return (this._flags & this.constructor.FLAGS.RIGHT_DOWN) !== 0;
}
/**
* Set the right down flag
*
* @param {boolean} yn - Is the right mouse button down?
*/
,
set: function set(yn) {
this._doSet(this.constructor.FLAGS.RIGHT_DOWN, yn);
}
/**
* Did the left mouse button come down in the DisplayObject?
*
* @member {boolean}
* @memberof PIXI.interaction.InteractionTrackingData#
*/
}, {
key: "leftDown",
get: function get() {
return (this._flags & this.constructor.FLAGS.LEFT_DOWN) !== 0;
}
/**
* Set the left down flag
*
* @param {boolean} yn - Is the left mouse button down?
*/
,
set: function set(yn) {
this._doSet(this.constructor.FLAGS.LEFT_DOWN, yn);
}
}]);
return InteractionTrackingData;
}();
exports.default = InteractionTrackingData;
InteractionTrackingData.FLAGS = Object.freeze({
NONE: 0,
OVER: 1 << 0,
LEFT_DOWN: 1 << 1,
RIGHT_DOWN: 1 << 2
});
//# sourceMappingURL=InteractionTrackingData.js.map
/***/ }),
/* 211 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
/**
* Default property values of interactive objects
* Used by {@link PIXI.interaction.InteractionManager} to automatically give all DisplayObjects these properties
*
* @private
* @name interactiveTarget
* @memberof PIXI.interaction
* @example
* function MyObject() {}
*
* Object.assign(
* core.DisplayObject.prototype,
* PIXI.interaction.interactiveTarget
* );
*/
exports.default = {
/**
* Enable interaction events for the DisplayObject. Touch, pointer and mouse
* events will not be emitted unless `interactive` is set to `true`.
*
* @example
* const sprite = new PIXI.Sprite(texture);
* sprite.interactive = true;
* sprite.on('tap', (event) => {
* //handle event
* });
* @member {boolean}
* @memberof PIXI.DisplayObject#
*/
interactive: false,
/**
* Determines if the children to the displayObject can be clicked/touched
* Setting this to false allows PixiJS to bypass a recursive `hitTest` function
*
* @member {boolean}
* @memberof PIXI.Container#
*/
interactiveChildren: true,
/**
* Interaction shape. Children will be hit first, then this shape will be checked.
* Setting this will cause this shape to be checked in hit tests rather than the displayObject's bounds.
*
* @example
* const sprite = new PIXI.Sprite(texture);
* sprite.interactive = true;
* sprite.hitArea = new PIXI.Rectangle(0, 0, 100, 100);
* @member {PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle}
* @memberof PIXI.DisplayObject#
*/
hitArea: null,
/**
* If enabled, the mouse cursor use the pointer behavior when hovered over the displayObject if it is interactive
* Setting this changes the 'cursor' property to `'pointer'`.
*
* @example
* const sprite = new PIXI.Sprite(texture);
* sprite.interactive = true;
* sprite.buttonMode = true;
* @member {boolean}
* @memberof PIXI.DisplayObject#
*/
get buttonMode() {
return this.cursor === 'pointer';
},
set buttonMode(value) {
if (value) {
this.cursor = 'pointer';
} else if (this.cursor === 'pointer') {
this.cursor = null;
}
},
/**
* This defines what cursor mode is used when the mouse cursor
* is hovered over the displayObject.
*
* @example
* const sprite = new PIXI.Sprite(texture);
* sprite.interactive = true;
* sprite.cursor = 'wait';
* @see https://developer.mozilla.org/en/docs/Web/CSS/cursor
*
* @member {string}
* @memberof PIXI.DisplayObject#
*/
cursor: null,
/**
* Internal set of all active pointers, by identifier
*
* @member {Map<number, InteractionTrackingData>}
* @memberof PIXI.DisplayObject#
* @private
*/
get trackedPointers() {
if (this._trackedPointers === undefined) this._trackedPointers = {};
return this._trackedPointers;
},
/**
* Map of all tracked pointers, by identifier. Use trackedPointers to access.
*
* @private
* @type {Map<number, InteractionTrackingData>}
*/
_trackedPointers: undefined
};
//# sourceMappingURL=interactiveTarget.js.map
/***/ }),
/* 212 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.parse = parse;
exports.default = function () {
return function bitmapFontParser(resource, next) {
// skip if no data or not xml data
if (!resource.data || resource.type !== _resourceLoader.Resource.TYPE.XML) {
next();
return;
}
// skip if not bitmap font data, using some silly duck-typing
if (resource.data.getElementsByTagName('page').length === 0 || resource.data.getElementsByTagName('info').length === 0 || resource.data.getElementsByTagName('info')[0].getAttribute('face') === null) {
next();
return;
}
var xmlUrl = !resource.isDataUrl ? path.dirname(resource.url) : '';
if (resource.isDataUrl) {
if (xmlUrl === '.') {
xmlUrl = '';
}
if (this.baseUrl && xmlUrl) {
// if baseurl has a trailing slash then add one to xmlUrl so the replace works below
if (this.baseUrl.charAt(this.baseUrl.length - 1) === '/') {
xmlUrl += '/';
}
}
}
// remove baseUrl from xmlUrl
xmlUrl = xmlUrl.replace(this.baseUrl, '');
// if there is an xmlUrl now, it needs a trailing slash. Ensure that it does if the string isn't empty.
if (xmlUrl && xmlUrl.charAt(xmlUrl.length - 1) !== '/') {
xmlUrl += '/';
}
var pages = resource.data.getElementsByTagName('page');
var textures = {};
// Handle completed, when the number of textures
// load is the same number as references in the fnt file
var completed = function completed(page) {
textures[page.metadata.pageFile] = page.texture;
if (Object.keys(textures).length === pages.length) {
parse(resource, textures);
next();
}
};
for (var i = 0; i < pages.length; ++i) {
var pageFile = pages[i].getAttribute('file');
var url = xmlUrl + pageFile;
var exists = false;
// incase the image is loaded outside
// using the same loader, resource will be available
for (var name in this.resources) {
var bitmapResource = this.resources[name];
if (bitmapResource.url === url) {
bitmapResource.metadata.pageFile = pageFile;
if (bitmapResource.texture) {
completed(bitmapResource);
} else {
bitmapResource.onAfterMiddleware.add(completed);
}
exists = true;
break;
}
}
// texture is not loaded, we'll attempt to add
// it to the load and add the texture to the list
if (!exists) {
// Standard loading options for images
var options = {
crossOrigin: resource.crossOrigin,
loadType: _resourceLoader.Resource.LOAD_TYPE.IMAGE,
metadata: Object.assign({ pageFile: pageFile }, resource.metadata.imageMetadata),
parentResource: resource
};
this.add(url, options, completed);
}
}
};
};
var _path = __webpack_require__(34);
var path = _interopRequireWildcard(_path);
var _resourceLoader = __webpack_require__(68);
var _extras = __webpack_require__(202);
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; } }
/**
* Register a BitmapText font from loader resource.
*
* @function parseBitmapFontData
* @memberof PIXI.loaders
* @param {PIXI.loaders.Resource} resource - Loader resource.
* @param {PIXI.Texture|PIXI.Texture[]} textures - List of textures for each page.
*/
function parse(resource, textures) {
resource.bitmapFont = _extras.BitmapText.registerFont(resource.data, textures);
}
//# sourceMappingURL=bitmapFontParser.js.map
/***/ }),
/* 213 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, '__esModule', {
value: 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; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var MiniSignalBinding = (function () {
function MiniSignalBinding(fn, once, thisArg) {
if (once === undefined) once = false;
_classCallCheck(this, MiniSignalBinding);
this._fn = fn;
this._once = once;
this._thisArg = thisArg;
this._next = this._prev = this._owner = null;
}
_createClass(MiniSignalBinding, [{
key: 'detach',
value: function detach() {
if (this._owner === null) return false;
this._owner.detach(this);
return true;
}
}]);
return MiniSignalBinding;
})();
function _addMiniSignalBinding(self, node) {
if (!self._head) {
self._head = node;
self._tail = node;
} else {
self._tail._next = node;
node._prev = self._tail;
self._tail = node;
}
node._owner = self;
return node;
}
var MiniSignal = (function () {
function MiniSignal() {
_classCallCheck(this, MiniSignal);
this._head = this._tail = undefined;
}
_createClass(MiniSignal, [{
key: 'handlers',
value: function handlers() {
var exists = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
var node = this._head;
if (exists) return !!node;
var ee = [];
while (node) {
ee.push(node);
node = node._next;
}
return ee;
}
}, {
key: 'has',
value: function has(node) {
if (!(node instanceof MiniSignalBinding)) {
throw new Error('MiniSignal#has(): First arg must be a MiniSignalBinding object.');
}
return node._owner === this;
}
}, {
key: 'dispatch',
value: function dispatch() {
var node = this._head;
if (!node) return false;
while (node) {
if (node._once) this.detach(node);
node._fn.apply(node._thisArg, arguments);
node = node._next;
}
return true;
}
}, {
key: 'add',
value: function add(fn) {
var thisArg = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
if (typeof fn !== 'function') {
throw new Error('MiniSignal#add(): First arg must be a Function.');
}
return _addMiniSignalBinding(this, new MiniSignalBinding(fn, false, thisArg));
}
}, {
key: 'once',
value: function once(fn) {
var thisArg = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
if (typeof fn !== 'function') {
throw new Error('MiniSignal#once(): First arg must be a Function.');
}
return _addMiniSignalBinding(this, new MiniSignalBinding(fn, true, thisArg));
}
}, {
key: 'detach',
value: function detach(node) {
if (!(node instanceof MiniSignalBinding)) {
throw new Error('MiniSignal#detach(): First arg must be a MiniSignalBinding object.');
}
if (node._owner !== this) return this;
if (node._prev) node._prev._next = node._next;
if (node._next) node._next._prev = node._prev;
if (node === this._head) {
this._head = node._next;
if (node._next === null) {
this._tail = null;
}
} else if (node === this._tail) {
this._tail = node._prev;
this._tail._next = null;
}
node._owner = null;
return this;
}
}, {
key: 'detachAll',
value: function detachAll() {
var node = this._head;
if (!node) return this;
this._head = this._tail = null;
while (node) {
node._owner = null;
node = node._next;
}
return this;
}
}]);
return MiniSignal;
})();
MiniSignal.MiniSignalBinding = MiniSignalBinding;
exports['default'] = MiniSignal;
module.exports = exports['default'];
/***/ }),
/* 214 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = function parseURI (str, opts) {
opts = opts || {}
var o = {
key: ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'],
q: {
name: 'queryKey',
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
},
parser: {
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
}
}
var m = o.parser[opts.strictMode ? 'strict' : 'loose'].exec(str)
var uri = {}
var i = 14
while (i--) uri[o.key[i]] = m[i] || ''
uri[o.q.name] = {}
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
if ($1) uri[o.q.name][$1] = $2
})
return uri
}
/***/ }),
/* 215 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.eachSeries = eachSeries;
exports.queue = queue;
/**
* Smaller version of the async library constructs.
*
* @namespace async
*/
/**
* Noop function
*
* @ignore
* @function
* @memberof async
*/
function _noop() {} /* empty */
/**
* Iterates an array in series.
*
* @memberof async
* @param {Array.<*>} array - Array to iterate.
* @param {function} iterator - Function to call for each element.
* @param {function} callback - Function to call when done, or on error.
* @param {boolean} [deferNext=false] - Break synchronous each loop by calling next with a setTimeout of 1.
*/
function eachSeries(array, iterator, callback, deferNext) {
var i = 0;
var len = array.length;
(function next(err) {
if (err || i === len) {
if (callback) {
callback(err);
}
return;
}
if (deferNext) {
setTimeout(function () {
iterator(array[i++], next);
}, 1);
} else {
iterator(array[i++], next);
}
})();
}
/**
* Ensures a function is only called once.
*
* @ignore
* @memberof async
* @param {function} fn - The function to wrap.
* @return {function} The wrapping function.
*/
function onlyOnce(fn) {
return function onceWrapper() {
if (fn === null) {
throw new Error('Callback was already called.');
}
var callFn = fn;
fn = null;
callFn.apply(this, arguments);
};
}
/**
* Async queue implementation,
*
* @memberof async
* @param {function} worker - The worker function to call for each task.
* @param {number} concurrency - How many workers to run in parrallel.
* @return {*} The async queue object.
*/
function queue(worker, concurrency) {
if (concurrency == null) {
// eslint-disable-line no-eq-null,eqeqeq
concurrency = 1;
} else if (concurrency === 0) {
throw new Error('Concurrency must not be zero');
}
var workers = 0;
var q = {
_tasks: [],
concurrency: concurrency,
saturated: _noop,
unsaturated: _noop,
buffer: concurrency / 4,
empty: _noop,
drain: _noop,
error: _noop,
started: false,
paused: false,
push: function push(data, callback) {
_insert(data, false, callback);
},
kill: function kill() {
workers = 0;
q.drain = _noop;
q.started = false;
q._tasks = [];
},
unshift: function unshift(data, callback) {
_insert(data, true, callback);
},
process: function process() {
while (!q.paused && workers < q.concurrency && q._tasks.length) {
var task = q._tasks.shift();
if (q._tasks.length === 0) {
q.empty();
}
workers += 1;
if (workers === q.concurrency) {
q.saturated();
}
worker(task.data, onlyOnce(_next(task)));
}
},
length: function length() {
return q._tasks.length;
},
running: function running() {
return workers;
},
idle: function idle() {
return q._tasks.length + workers === 0;
},
pause: function pause() {
if (q.paused === true) {
return;
}
q.paused = true;
},
resume: function resume() {
if (q.paused === false) {
return;
}
q.paused = false;
// Need to call q.process once per concurrent
// worker to preserve full concurrency after pause
for (var w = 1; w <= q.concurrency; w++) {
q.process();
}
}
};
function _insert(data, insertAtFront, callback) {
if (callback != null && typeof callback !== 'function') {
// eslint-disable-line no-eq-null,eqeqeq
throw new Error('task callback must be a function');
}
q.started = true;
if (data == null && q.idle()) {
// eslint-disable-line no-eq-null,eqeqeq
// call drain immediately if there are no tasks
setTimeout(function () {
return q.drain();
}, 1);
return;
}
var item = {
data: data,
callback: typeof callback === 'function' ? callback : _noop
};
if (insertAtFront) {
q._tasks.unshift(item);
} else {
q._tasks.push(item);
}
setTimeout(function () {
return q.process();
}, 1);
}
function _next(task) {
return function next() {
workers -= 1;
task.callback.apply(task, arguments);
if (arguments[0] != null) {
// eslint-disable-line no-eq-null,eqeqeq
q.error(arguments[0], task.data);
}
if (workers <= q.concurrency - q.buffer) {
q.unsaturated();
}
if (q.idle()) {
q.drain();
}
q.process();
};
}
return q;
}
//# sourceMappingURL=async.js.map
/***/ }),
/* 216 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.encodeBinary = encodeBinary;
var _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
/**
* Encodes binary into base64.
*
* @param {string} input The input data to encode.
* @returns {string} The encoded base64 string
*/
function encodeBinary(input) {
var output = '';
var inx = 0;
while (inx < input.length) {
// Fill byte buffer array
var bytebuffer = [0, 0, 0];
var encodedCharIndexes = [0, 0, 0, 0];
for (var jnx = 0; jnx < bytebuffer.length; ++jnx) {
if (inx < input.length) {
// throw away high-order byte, as documented at:
// https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data
bytebuffer[jnx] = input.charCodeAt(inx++) & 0xff;
} else {
bytebuffer[jnx] = 0;
}
}
// Get each encoded character, 6 bits at a time
// index 1: first 6 bits
encodedCharIndexes[0] = bytebuffer[0] >> 2;
// index 2: second 6 bits (2 least significant bits from input byte 1 + 4 most significant bits from byte 2)
encodedCharIndexes[1] = (bytebuffer[0] & 0x3) << 4 | bytebuffer[1] >> 4;
// index 3: third 6 bits (4 least significant bits from input byte 2 + 2 most significant bits from byte 3)
encodedCharIndexes[2] = (bytebuffer[1] & 0x0f) << 2 | bytebuffer[2] >> 6;
// index 3: forth 6 bits (6 least significant bits from input byte 3)
encodedCharIndexes[3] = bytebuffer[2] & 0x3f;
// Determine whether padding happened, and adjust accordingly
var paddingBytes = inx - (input.length - 1);
switch (paddingBytes) {
case 2:
// Set last 2 characters to padding char
encodedCharIndexes[3] = 64;
encodedCharIndexes[2] = 64;
break;
case 1:
// Set last character to padding char
encodedCharIndexes[3] = 64;
break;
default:
break; // No padding - proceed
}
// Now we will grab each appropriate character out of our keystring
// based on our index array and append it to the output string
for (var _jnx = 0; _jnx < encodedCharIndexes.length; ++_jnx) {
output += _keyStr.charAt(encodedCharIndexes[_jnx]);
}
}
return output;
}
// Backwards compat
if (true) {
module.exports.default = encodeBinary; // eslint-disable-line no-undef
}
//# sourceMappingURL=b64.js.map
/***/ }),
/* 217 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = function () {
return function spritesheetParser(resource, next) {
var imageResourceName = resource.name + '_image';
// skip if no data, its not json, it isn't spritesheet data, or the image resource already exists
if (!resource.data || resource.type !== _resourceLoader.Resource.TYPE.JSON || !resource.data.frames || this.resources[imageResourceName]) {
next();
return;
}
var loadOptions = {
crossOrigin: resource.crossOrigin,
metadata: resource.metadata.imageMetadata,
parentResource: resource
};
var resourcePath = getResourcePath(resource, this.baseUrl);
// load the image for this sheet
this.add(imageResourceName, resourcePath, loadOptions, function onImageLoad(res) {
if (res.error) {
next(res.error);
return;
}
var spritesheet = new _core.Spritesheet(res.texture.baseTexture, resource.data, resource.url);
spritesheet.parse(function () {
resource.spritesheet = spritesheet;
resource.textures = spritesheet.textures;
next();
});
});
};
};
exports.getResourcePath = getResourcePath;
var _resourceLoader = __webpack_require__(68);
var _url = __webpack_require__(185);
var _url2 = _interopRequireDefault(_url);
var _core = __webpack_require__(5);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getResourcePath(resource, baseUrl) {
// Prepend url path unless the resource image is a data url
if (resource.isDataUrl) {
return resource.data.meta.image;
}
return _url2.default.resolve(resource.url.replace(baseUrl, ''), resource.data.meta.image);
}
//# sourceMappingURL=spritesheetParser.js.map
/***/ }),
/* 218 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = function () {
return function textureParser(resource, next) {
// create a new texture if the data is an Image object
if (resource.data && resource.type === _resourceLoader.Resource.TYPE.IMAGE) {
resource.texture = _Texture2.default.fromLoader(resource.data, resource.url, resource.name);
}
next();
};
};
var _resourceLoader = __webpack_require__(68);
var _Texture = __webpack_require__(40);
var _Texture2 = _interopRequireDefault(_Texture);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=textureParser.js.map
/***/ }),
/* 219 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Mesh2 = __webpack_require__(69);
var _Mesh3 = _interopRequireDefault(_Mesh2);
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 Plane allows you to draw a texture across several points and them manipulate these points
*
*```js
* for (let i = 0; i < 20; i++) {
* points.push(new PIXI.Point(i * 50, 0));
* };
* let Plane = new PIXI.Plane(PIXI.Texture.fromImage("snake.png"), points);
* ```
*
* @class
* @extends PIXI.mesh.Mesh
* @memberof PIXI.mesh
*
*/
var Plane = function (_Mesh) {
_inherits(Plane, _Mesh);
/**
* @param {PIXI.Texture} texture - The texture to use on the Plane.
* @param {number} [verticesX=10] - The number of vertices in the x-axis
* @param {number} [verticesY=10] - The number of vertices in the y-axis
*/
function Plane(texture, verticesX, verticesY) {
_classCallCheck(this, Plane);
/**
* Tracker for if the Plane is ready to be drawn. Needed because Mesh ctor can
* call _onTextureUpdated which could call refresh too early.
*
* @member {boolean}
* @private
*/
var _this = _possibleConstructorReturn(this, _Mesh.call(this, texture));
_this._ready = true;
_this.verticesX = verticesX || 10;
_this.verticesY = verticesY || 10;
_this.drawMode = _Mesh3.default.DRAW_MODES.TRIANGLES;
_this.refresh();
return _this;
}
/**
* Refreshes plane coordinates
*
*/
Plane.prototype._refresh = function _refresh() {
var texture = this._texture;
var total = this.verticesX * this.verticesY;
var verts = [];
var colors = [];
var uvs = [];
var indices = [];
var segmentsX = this.verticesX - 1;
var segmentsY = this.verticesY - 1;
var sizeX = texture.width / segmentsX;
var sizeY = texture.height / segmentsY;
for (var i = 0; i < total; i++) {
var x = i % this.verticesX;
var y = i / this.verticesX | 0;
verts.push(x * sizeX, y * sizeY);
uvs.push(x / segmentsX, y / segmentsY);
}
// cons
var totalSub = segmentsX * segmentsY;
for (var _i = 0; _i < totalSub; _i++) {
var xpos = _i % segmentsX;
var ypos = _i / segmentsX | 0;
var value = ypos * this.verticesX + xpos;
var value2 = ypos * this.verticesX + xpos + 1;
var value3 = (ypos + 1) * this.verticesX + xpos;
var value4 = (ypos + 1) * this.verticesX + xpos + 1;
indices.push(value, value2, value3);
indices.push(value2, value4, value3);
}
// console.log(indices)
this.vertices = new Float32Array(verts);
this.uvs = new Float32Array(uvs);
this.colors = new Float32Array(colors);
this.indices = new Uint16Array(indices);
this.dirty++;
this.indexDirty++;
this.multiplyUvs();
};
/**
* Clear texture UVs when new texture is set
*
* @private
*/
Plane.prototype._onTextureUpdate = function _onTextureUpdate() {
_Mesh3.default.prototype._onTextureUpdate.call(this);
// wait for the Plane ctor to finish before calling refresh
if (this._ready) {
this.refresh();
}
};
return Plane;
}(_Mesh3.default);
exports.default = Plane;
//# sourceMappingURL=Plane.js.map
/***/ }),
/* 220 */
/***/ (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"); } }
/**
* CountLimiter limits the number of items handled by a {@link PIXI.prepare.BasePrepare} to a specified
* number of items per frame.
*
* @class
* @memberof PIXI
*/
var CountLimiter = function () {
/**
* @param {number} maxItemsPerFrame - The maximum number of items that can be prepared each frame.
*/
function CountLimiter(maxItemsPerFrame) {
_classCallCheck(this, CountLimiter);
/**
* The maximum number of items that can be prepared each frame.
* @private
*/
this.maxItemsPerFrame = maxItemsPerFrame;
/**
* The number of items that can be prepared in the current frame.
* @type {number}
* @private
*/
this.itemsLeft = 0;
}
/**
* Resets any counting properties to start fresh on a new frame.
*/
CountLimiter.prototype.beginFrame = function beginFrame() {
this.itemsLeft = this.maxItemsPerFrame;
};
/**
* Checks to see if another item can be uploaded. This should only be called once per item.
* @return {boolean} If the item is allowed to be uploaded.
*/
CountLimiter.prototype.allowedToUpload = function allowedToUpload() {
return this.itemsLeft-- > 0;
};
return CountLimiter;
}();
exports.default = CountLimiter;
//# sourceMappingURL=CountLimiter.js.map
/***/ }),
/* 221 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export TimelineMax */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return TimelineMax; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TimelineLite_js__ = __webpack_require__(132);
/* unused harmony reexport TimelineLite */
/*!
* 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 */
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine("TimelineMax", ["TimelineLite","TweenLite","easing.Ease"], function() {
var TimelineMax = function(vars) {
__WEBPACK_IMPORTED_MODULE_1__TimelineLite_js__["a" /* default */].call(this, vars);
this._repeat = this.vars.repeat || 0;
this._repeatDelay = this.vars.repeatDelay || 0;
this._cycle = 0;
this._yoyo = !!this.vars.yoyo;
this._dirty = true;
},
_tinyNum = 0.00000001,
TweenLiteInternals = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */]._internals,
_lazyTweens = TweenLiteInternals.lazyTweens,
_lazyRender = TweenLiteInternals.lazyRender,
_globals = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine.globals,
_easeNone = new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */](null, null, 1, 0),
p = TimelineMax.prototype = new __WEBPACK_IMPORTED_MODULE_1__TimelineLite_js__["a" /* default */]();
p.constructor = TimelineMax;
p.kill()._gc = false;
TimelineMax.version = "2.1.2";
p.invalidate = function() {
this._yoyo = !!this.vars.yoyo;
this._repeat = this.vars.repeat || 0;
this._repeatDelay = this.vars.repeatDelay || 0;
this._uncache(true);
return __WEBPACK_IMPORTED_MODULE_1__TimelineLite_js__["a" /* default */].prototype.invalidate.call(this);
};
p.addCallback = function(callback, position, params, scope) {
return this.add( __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].delayedCall(0, callback, params, scope), position);
};
p.removeCallback = function(callback, position) {
if (callback) {
if (position == null) {
this._kill(null, callback);
} else {
var a = this.getTweensOf(callback, false),
i = a.length,
time = this._parseTimeOrLabel(position);
while (--i > -1) {
if (a[i]._startTime === time) {
a[i]._enabled(false, false);
}
}
}
}
return this;
};
p.removePause = function(position) {
return this.removeCallback(__WEBPACK_IMPORTED_MODULE_1__TimelineLite_js__["a" /* default */]._internals.pauseCallback, position);
};
p.tweenTo = function(position, vars) {
vars = vars || {};
var copy = {ease:_easeNone, useFrames:this.usesFrames(), immediateRender:false, lazy:false},
Engine = (vars.repeat && _globals.TweenMax) || __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */],
duration, p, t;
for (p in vars) {
copy[p] = vars[p];
}
copy.time = this._parseTimeOrLabel(position);
duration = (Math.abs(Number(copy.time) - this._time) / this._timeScale) || 0.001;
t = new Engine(this, duration, copy);
copy.onStart = function() {
t.target.paused(true);
if (t.vars.time !== t.target.time() && duration === t.duration() && !t.isFromTo) { //don't make the duration zero - if it's supposed to be zero, don't worry because it's already initting the tween and will complete immediately, effectively making the duration zero anyway. If we make duration zero, the tween won't run at all.
t.duration( Math.abs( t.vars.time - t.target.time()) / t.target._timeScale ).render(t.time(), true, true); //render() right away to ensure that things look right, especially in the case of .tweenTo(0).
}
if (vars.onStart) { //in case the user had an onStart in the vars - we don't want to overwrite it.
vars.onStart.apply(vars.onStartScope || vars.callbackScope || t, vars.onStartParams || []); //don't use t._callback("onStart") or it'll point to the copy.onStart and we'll get a recursion error.
}
};
return t;
};
p.tweenFromTo = function(fromPosition, toPosition, vars) {
vars = vars || {};
fromPosition = this._parseTimeOrLabel(fromPosition);
vars.startAt = {onComplete:this.seek, onCompleteParams:[fromPosition], callbackScope:this};
vars.immediateRender = (vars.immediateRender !== false);
var t = this.tweenTo(toPosition, vars);
t.isFromTo = 1; //to ensure we don't mess with the duration in the onStart (we've got the start and end values here, so lock it in)
return t.duration((Math.abs( t.vars.time - fromPosition) / this._timeScale) || 0.001);
};
p.render = function(time, suppressEvents, force) {
if (this._gc) {
this._enabled(true, false);
}
var self = this,
prevTime = self._time,
totalDur = (!self._dirty) ? self._totalDuration : self.totalDuration(),
dur = self._duration,
prevTotalTime = self._totalTime,
prevStart = self._startTime,
prevTimeScale = self._timeScale,
prevRawPrevTime = self._rawPrevTime,
prevPaused = self._paused,
prevCycle = self._cycle,
tween, isComplete, next, callback, internalForce, cycleDuration, pauseTween, curTime, pauseTime;
if (prevTime !== self._time) { //if totalDuration() finds a child with a negative startTime and smoothChildTiming is true, things get shifted around internally so we need to adjust the time accordingly. For example, if a tween starts at -30 we must shift EVERYTHING forward 30 seconds and move this timeline's startTime backward by 30 seconds so that things align with the playhead (no jump).
time += self._time - prevTime;
}
if (time >= totalDur - _tinyNum && time >= 0) { //to work around occasional floating point math artifacts.
if (!self._locked) {
self._totalTime = totalDur;
self._cycle = self._repeat;
}
if (!self._reversed) if (!self._hasPausedChild()) {
isComplete = true;
callback = "onComplete";
internalForce = !!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 (self._duration === 0) if ((time <= 0 && time >= -_tinyNum) || prevRawPrevTime < 0 || prevRawPrevTime === _tinyNum) if (prevRawPrevTime !== time && self._first) {
internalForce = true;
if (prevRawPrevTime > _tinyNum) {
callback = "onReverseComplete";
}
}
}
self._rawPrevTime = (self._duration || !suppressEvents || time || self._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or 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._yoyo && (self._cycle & 1)) {
self._time = time = 0;
} else {
self._time = dur;
time = dur + 0.0001; //to avoid occasional floating point rounding errors - sometimes child tweens/timelines were not being fully completed (their progress might be 0.999999999999998 instead of 1 because when _time - tween._startTime is performed, floating point errors would return a value that was SLIGHTLY off). Try (999999999999.7 - 999999999999) * 1 = 0.699951171875 instead of 0.7. We cannot do less then 0.0001 because the same issue can occur when the duration is extremely large like 999999999999 in which case adding 0.00000001, for example, causes it to act like nothing was added.
}
} else if (time < _tinyNum) { //to work around occasional floating point math artifacts, round super small values to 0.
if (!self._locked) {
self._totalTime = self._cycle = 0;
}
self._time = 0;
if (time > -_tinyNum) {
time = 0;
}
if (prevTime !== 0 || (dur === 0 && prevRawPrevTime !== _tinyNum && (prevRawPrevTime > 0 || (time < 0 && prevRawPrevTime >= 0)) && !self._locked)) { //edge case for checking time < 0 && prevRawPrevTime >= 0: a zero-duration fromTo() tween inside a zero-duration timeline (yeah, very rare)
callback = "onReverseComplete";
isComplete = self._reversed;
}
if (time < 0) {
self._active = false;
if (self._timeline.autoRemoveChildren && self._reversed) {
internalForce = isComplete = true;
callback = "onReverseComplete";
} else if (prevRawPrevTime >= 0 && self._first) { //when going back beyond the start, force a render so that zero-duration tweens that sit at the very beginning render their start values properly. Otherwise, if the parent timeline's playhead lands exactly at this timeline's startTime, and then moves backwards, the zero-duration tweens at the beginning would still be at their end state.
internalForce = true;
}
self._rawPrevTime = time;
} else {
self._rawPrevTime = (dur || !suppressEvents || time || self._rawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline or 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 (time === 0 && isComplete) { //if there's a zero-duration tween at the very beginning of a timeline and the playhead lands EXACTLY at time 0, that tween will correctly render its end values, but we need to keep the timeline alive for one more render so that the beginning values render properly as the parent's playhead keeps moving beyond the begining. Imagine obj.x starts at 0 and then we do tl.set(obj, {x:100}).to(obj, 1, {x:200}) and then later we tl.reverse()...the goal is to have obj.x revert to 0. If the playhead happens to land on exactly 0, without this chunk of code, it'd complete the timeline and remove it from the rendering queue (not good).
tween = self._first;
while (tween && tween._startTime === 0) {
if (!tween._duration) {
isComplete = false;
}
tween = tween._next;
}
}
time = 0; //to avoid occasional floating point rounding errors (could cause problems especially with zero-duration tweens at the very beginning of the timeline)
if (!self._initted) {
internalForce = true;
}
}
} else {
if (dur === 0 && prevRawPrevTime < 0) { //without this, zero-duration repeating timelines (like with a simple callback nested at the very beginning and a repeatDelay) wouldn't render the first time through.
internalForce = true;
}
self._time = self._rawPrevTime = time;
if (!self._locked) {
self._totalTime = time;
if (self._repeat !== 0) {
cycleDuration = dur + self._repeatDelay;
self._cycle = (self._totalTime / cycleDuration) >> 0; //originally _totalTime % cycleDuration but floating point errors caused problems, so I normalized it. (4 % 0.8 should be 0 but it gets reported as 0.79999999!)
if (self._cycle) if (self._cycle === self._totalTime / cycleDuration && prevTotalTime <= time) {
self._cycle--; //otherwise when rendered exactly at the end time, it will act as though it is repeating (at the beginning)
}
self._time = self._totalTime - (self._cycle * cycleDuration);
if (self._yoyo) if (self._cycle & 1) {
self._time = dur - self._time;
}
if (self._time > dur) {
self._time = dur;
time = dur + 0.0001; //to avoid occasional floating point rounding error
} else if (self._time < 0) {
self._time = time = 0;
} else {
time = self._time;
}
}
}
if (self._hasPause && !self._forcingPlayhead && !suppressEvents) {
time = self._time;
if (time >= prevTime || (self._repeat && prevCycle !== self._cycle)) {
tween = self._first;
while (tween && tween._startTime <= time && !pauseTween) {
if (!tween._duration) if (tween.data === "isPause" && !tween.ratio && !(tween._startTime === 0 && self._rawPrevTime === 0)) {
pauseTween = tween;
}
tween = tween._next;
}
} else {
tween = self._last;
while (tween && tween._startTime >= time && !pauseTween) {
if (!tween._duration) if (tween.data === "isPause" && tween._rawPrevTime > 0) {
pauseTween = tween;
}
tween = tween._prev;
}
}
if (pauseTween) {
pauseTime = self._startTime + (pauseTween._startTime / self._timeScale);
if (pauseTween._startTime < dur) {
self._time = self._rawPrevTime = time = pauseTween._startTime;
self._totalTime = time + (self._cycle * (self._totalDuration + self._repeatDelay));
}
}
}
}
if (self._cycle !== prevCycle) if (!self._locked) {
/*
make sure children at the end/beginning of the timeline are rendered properly. If, for example,
a 3-second long timeline rendered at 2.9 seconds previously, and now renders at 3.2 seconds (which
would get translated to 2.8 seconds if the timeline yoyos or 0.2 seconds if it just repeats), there
could be a callback or a short tween that's at 2.95 or 3 seconds in which wouldn't render. So
we need to push the timeline to the end (and/or beginning depending on its yoyo value). Also we must
ensure that zero-duration tweens at the very beginning or end of the TimelineMax work.
*/
var backwards = (self._yoyo && (prevCycle & 1) !== 0),
wrap = (backwards === (self._yoyo && (self._cycle & 1) !== 0)),
recTotalTime = self._totalTime,
recCycle = self._cycle,
recRawPrevTime = self._rawPrevTime,
recTime = self._time;
self._totalTime = prevCycle * dur;
if (self._cycle < prevCycle) {
backwards = !backwards;
} else {
self._totalTime += dur;
}
self._time = prevTime; //temporarily revert _time so that render() renders the children in the correct order. Without this, tweens won't rewind correctly. We could arhictect things in a "cleaner" way by splitting out the rendering queue into a separate method but for performance reasons, we kept it all inside this method.
self._rawPrevTime = (dur === 0) ? prevRawPrevTime - 0.0001 : prevRawPrevTime;
self._cycle = prevCycle;
self._locked = true; //prevents changes to totalTime and skips repeat/yoyo behavior when we recursively call render()
prevTime = (backwards) ? 0 : dur;
self.render(prevTime, suppressEvents, (dur === 0));
if (!suppressEvents) if (!self._gc) {
if (self.vars.onRepeat) {
self._cycle = recCycle; //in case the onRepeat alters the playhead or invalidates(), we shouldn't stay locked or use the previous cycle.
self._locked = false;
self._callback("onRepeat");
}
}
if (prevTime !== self._time) { //in case there's a callback like onComplete in a nested tween/timeline that changes the playhead position, like via seek(), we should just abort.
return;
}
if (wrap) {
self._cycle = prevCycle; //if there's an onRepeat, we reverted this above, so make sure it's set properly again. We also unlocked in that scenario, so reset that too.
self._locked = true;
prevTime = (backwards) ? dur + 0.0001 : -0.0001;
self.render(prevTime, true, false);
}
self._locked = false;
if (self._paused && !prevPaused) { //if the render() triggered callback that paused this timeline, we should abort (very rare, but possible)
return;
}
self._time = recTime;
self._totalTime = recTotalTime;
self._cycle = recCycle;
self._rawPrevTime = recRawPrevTime;
}
if ((self._time === prevTime || !self._first) && !force && !internalForce && !pauseTween) {
if (prevTotalTime !== self._totalTime) if (self._onUpdate) if (!suppressEvents) { //so that onUpdate fires even during the repeatDelay - as long as the totalTime changed, we should trigger onUpdate.
self._callback("onUpdate");
}
return;
} else if (!self._initted) {
self._initted = true;
}
if (!self._active) if (!self._paused && self._totalTime !== prevTotalTime && time > 0) {
self._active = true; //so that if the user renders the timeline (as opposed to the parent timeline rendering it), it is forced to re-render and align it with the proper time/frame on the next rendering cycle. Maybe the timeline already finished but the user manually re-renders it as halfway done, for example.
}
if (prevTotalTime === 0) if (self.vars.onStart) if (self._totalTime !== 0 || !self._totalDuration) if (!suppressEvents) {
self._callback("onStart");
}
curTime = self._time;
if (curTime >= prevTime) {
tween = self._first;
while (tween) {
next = tween._next; //record it here because the value could change after rendering...
if (curTime !== self._time || (self._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete
break;
} else if (tween._active || (tween._startTime <= self._time && !tween._paused && !tween._gc)) {
if (pauseTween === tween) {
self.pause();
self._pauseTime = pauseTime; //so that when we resume(), it's starting from exactly the right spot (the pause() method uses the rawTime for the parent, but that may be a bit too far ahead)
}
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;
}
} else {
tween = self._last;
while (tween) {
next = tween._prev; //record it here because the value could change after rendering...
if (curTime !== self._time || (self._paused && !prevPaused)) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete
break;
} else if (tween._active || (tween._startTime <= prevTime && !tween._paused && !tween._gc)) {
if (pauseTween === tween) {
pauseTween = tween._prev; //the linked list is organized by _startTime, thus it's possible that a tween could start BEFORE the pause and end after it, in which case it would be positioned before the pause tween in the linked list, but we should render it before we pause() the timeline and cease rendering. This is only a concern when going in reverse.
while (pauseTween && pauseTween.endTime() > self._time) {
pauseTween.render( (pauseTween._reversed ? pauseTween.totalDuration() - ((time - pauseTween._startTime) * pauseTween._timeScale) : (time - pauseTween._startTime) * pauseTween._timeScale), suppressEvents, force);
pauseTween = pauseTween._prev;
}
pauseTween = null;
self.pause();
self._pauseTime = pauseTime; //so that when we resume(), it's starting from exactly the right spot (the pause() method uses the rawTime for the parent, but that may be a bit too far ahead)
}
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;
}
}
if (self._onUpdate) if (!suppressEvents) {
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onUpdate on a timeline that reports/checks tweened values.
_lazyRender();
}
self._callback("onUpdate");
}
if (callback) if (!self._locked) if (!self._gc) if (prevStart === self._startTime || prevTimeScale !== self._timeScale) if (self._time === 0 || totalDur >= self.totalDuration()) { //if one of the tweens that was rendered altered this timeline's startTime (like if an onComplete reversed the timeline), it probably isn't complete. If it is, don't worry, because whatever call altered the startTime would complete if it was necessary at the new time. The only exception is the timeScale property. Also check _gc because there's a chance that kill() could be called in an onUpdate
if (isComplete) {
if (_lazyTweens.length) { //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onComplete on a timeline that reports/checks tweened values.
_lazyRender();
}
if (self._timeline.autoRemoveChildren) {
self._enabled(false, false);
}
self._active = false;
}
if (!suppressEvents && self.vars[callback]) {
self._callback(callback);
}
}
};
p.getActive = function(nested, tweens, timelines) {
var a = [],
all = this.getChildren(nested || (nested == null), tweens || (nested == null), !!timelines),
cnt = 0,
l = all.length,
i, tween;
for (i = 0; i < l; i++) {
tween = all[i];
if (tween.isActive()) {
a[cnt++] = tween;
}
}
return a;
};
p.getLabelAfter = function(time) {
if (!time) if (time !== 0) { //faster than isNan()
time = this._time;
}
var labels = this.getLabelsArray(),
l = labels.length,
i;
for (i = 0; i < l; i++) {
if (labels[i].time > time) {
return labels[i].name;
}
}
return null;
};
p.getLabelBefore = function(time) {
if (time == null) {
time = this._time;
}
var labels = this.getLabelsArray(),
i = labels.length;
while (--i > -1) {
if (labels[i].time < time) {
return labels[i].name;
}
}
return null;
};
p.getLabelsArray = function() {
var a = [],
cnt = 0,
p;
for (p in this._labels) {
a[cnt++] = {time:this._labels[p], name:p};
}
a.sort(function(a,b) {
return a.time - b.time;
});
return a;
};
p.invalidate = function() {
this._locked = false; //unlock and set cycle in case invalidate() is called from inside an onRepeat
return __WEBPACK_IMPORTED_MODULE_1__TimelineLite_js__["a" /* default */].prototype.invalidate.call(this);
};
//---- GETTERS / SETTERS -------------------------------------------------------------------------------------------------------
p.progress = function(value, suppressEvents) {
return (!arguments.length) ? (this._time / this.duration()) || 0 : this.totalTime( this.duration() * ((this._yoyo && (this._cycle & 1) !== 0) ? 1 - value : value) + (this._cycle * (this._duration + this._repeatDelay)), suppressEvents);
};
p.totalProgress = function(value, suppressEvents) {
return (!arguments.length) ? (this._totalTime / this.totalDuration()) || 0 : this.totalTime( this.totalDuration() * value, suppressEvents);
};
p.totalDuration = function(value) {
if (!arguments.length) {
if (this._dirty) {
__WEBPACK_IMPORTED_MODULE_1__TimelineLite_js__["a" /* default */].prototype.totalDuration.call(this); //just forces refresh
//Instead of Infinity, we use 999999999999 so that we can accommodate reverses.
this._totalDuration = (this._repeat === -1) ? 999999999999 : this._duration * (this._repeat + 1) + (this._repeatDelay * this._repeat);
}
return this._totalDuration;
}
return (this._repeat === -1 || !value) ? this : this.timeScale( this.totalDuration() / value );
};
p.time = function(value, suppressEvents) {
if (!arguments.length) {
return this._time;
}
if (this._dirty) {
this.totalDuration();
}
var duration = this._duration,
cycle = this._cycle,
cycleDur = cycle * (duration + this._repeatDelay);
if (value > duration) {
value = duration;
}
return this.totalTime((this._yoyo && (cycle & 1)) ? duration - value + cycleDur : this._repeat ? value + cycleDur : value, suppressEvents);
};
p.repeat = function(value) {
if (!arguments.length) {
return this._repeat;
}
this._repeat = value;
return this._uncache(true);
};
p.repeatDelay = function(value) {
if (!arguments.length) {
return this._repeatDelay;
}
this._repeatDelay = value;
return this._uncache(true);
};
p.yoyo = function(value) {
if (!arguments.length) {
return this._yoyo;
}
this._yoyo = value;
return this;
};
p.currentLabel = function(value) {
if (!arguments.length) {
return this.getLabelBefore(this._time + _tinyNum);
}
return this.seek(value, true);
};
return TimelineMax;
}, true);
var TimelineMax = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].TimelineMax;
/***/ }),
/* 222 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export CSSPlugin */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CSSPlugin; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/*!
* VERSION: 2.1.0
* DATE: 2019-02-15
* 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 */
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine("plugins.CSSPlugin", ["plugins.TweenPlugin","TweenLite"], function() {
/** @constructor **/
var CSSPlugin = function() {
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["j" /* TweenPlugin */].call(this, "css");
this._overwriteProps.length = 0;
this.setRatio = CSSPlugin.prototype.setRatio; //speed optimization (avoid prototype lookup on this "hot" method)
},
_globals = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine.globals,
_hasPriority, //turns true whenever a CSSPropTween instance is created that has a priority other than 0. This helps us discern whether or not we should spend the time organizing the linked list or not after a CSSPlugin's _onInitTween() method is called.
_suffixMap, //we set this in _onInitTween() each time as a way to have a persistent variable we can use in other methods like _parse() without having to pass it around as a parameter and we keep _parse() decoupled from a particular CSSPlugin instance
_cs, //computed style (we store this in a shared variable to conserve memory and make minification tighter
_overwriteProps, //alias to the currently instantiating CSSPlugin's _overwriteProps array. We use this closure in order to avoid having to pass a reference around from method to method and aid in minification.
_specialProps = {},
p = CSSPlugin.prototype = new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["j" /* TweenPlugin */]("css");
p.constructor = CSSPlugin;
CSSPlugin.version = "2.1.0";
CSSPlugin.API = 2;
CSSPlugin.defaultTransformPerspective = 0;
CSSPlugin.defaultSkewType = "compensated";
CSSPlugin.defaultSmoothOrigin = true;
p = "px"; //we'll reuse the "p" variable to keep file size down
CSSPlugin.suffixMap = {top:p, right:p, bottom:p, left:p, width:p, height:p, fontSize:p, padding:p, margin:p, perspective:p, lineHeight:""};
var _numExp = /(?:\-|\.|\b)(\d|\.|e\-)+/g,
_relNumExp = /(?:\d|\-\d|\.\d|\-\.\d|\+=\d|\-=\d|\+=.\d|\-=\.\d)+/g,
_valuesExp = /(?:\+=|\-=|\-|\b)[\d\-\.]+[a-zA-Z0-9]*(?:%|\b)/gi, //finds all the values that begin with numbers or += or -= and then a number. Includes suffixes. We use this to split complex values apart like "1px 5px 20px rgb(255,102,51)"
_NaNExp = /(?![+-]?\d*\.?\d+|[+-]|e[+-]\d+)[^0-9]/g, //also allows scientific notation and doesn't kill the leading -/+ in -= and +=
_suffixExp = /(?:\d|\-|\+|=|#|\.)*/g,
_opacityExp = /opacity *= *([^)]*)/i,
_opacityValExp = /opacity:([^;]*)/i,
_alphaFilterExp = /alpha\(opacity *=.+?\)/i,
_rgbhslExp = /^(rgb|hsl)/,
_capsExp = /([A-Z])/g,
_camelExp = /-([a-z])/gi,
_urlExp = /(^(?:url\(\"|url\())|(?:(\"\))$|\)$)/gi, //for pulling out urls from url(...) or url("...") strings (some browsers wrap urls in quotes, some don't when reporting things like backgroundImage)
_camelFunc = function(s, g) { return g.toUpperCase(); },
_horizExp = /(?:Left|Right|Width)/i,
_ieGetMatrixExp = /(M11|M12|M21|M22)=[\d\-\.e]+/gi,
_ieSetMatrixExp = /progid\:DXImageTransform\.Microsoft\.Matrix\(.+?\)/i,
_commasOutsideParenExp = /,(?=[^\)]*(?:\(|$))/gi, //finds any commas that are not within parenthesis
_complexExp = /[\s,\(]/i, //for testing a string to find if it has a space, comma, or open parenthesis (clues that it's a complex value)
_DEG2RAD = Math.PI / 180,
_RAD2DEG = 180 / Math.PI,
_forcePT = {},
_dummyElement = {style:{}},
_doc = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */].document || {createElement: function() {return _dummyElement;}},
_createElement = function(type, ns) {
return (ns && _doc.createElementNS) ? _doc.createElementNS(ns, type) : _doc.createElement(type);
},
_tempDiv = _createElement("div"),
_tempImg = _createElement("img"),
_internals = CSSPlugin._internals = {_specialProps:_specialProps}, //provides a hook to a few internal methods that we need to access from inside other plugins
_agent = (__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */].navigator || {}).userAgent || "",
_autoRound,
_reqSafariFix, //we won't apply the Safari transform fix until we actually come across a tween that affects a transform property (to maintain best performance).
_isSafari,
_isFirefox, //Firefox has a bug that causes 3D transformed elements to randomly disappear unless a repaint is forced after each update on each element.
_isSafariLT6, //Safari (and Android 4 which uses a flavor of Safari) has a bug that prevents changes to "top" and "left" properties from rendering properly if changed on the same frame as a transform UNLESS we set the element's WebkitBackfaceVisibility to hidden (weird, I know). Doing this for Android 3 and earlier seems to actually cause other problems, though (fun!)
_ieVers,
_supportsOpacity = (function() { //we set _isSafari, _ieVers, _isFirefox, and _supportsOpacity all in one function here to reduce file size slightly, especially in the minified version.
var i = _agent.indexOf("Android"),
a = _createElement("a");
_isSafari = (_agent.indexOf("Safari") !== -1 && _agent.indexOf("Chrome") === -1 && (i === -1 || parseFloat(_agent.substr(i+8, 2)) > 3));
_isSafariLT6 = (_isSafari && (parseFloat(_agent.substr(_agent.indexOf("Version/")+8, 2)) < 6));
_isFirefox = (_agent.indexOf("Firefox") !== -1);
if ((/MSIE ([0-9]{1,}[\.0-9]{0,})/).exec(_agent) || (/Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/).exec(_agent)) {
_ieVers = parseFloat( RegExp.$1 );
}
if (!a) {
return false;
}
a.style.cssText = "top:1px;opacity:.55;";
return /^0.55/.test(a.style.opacity);
}()),
_getIEOpacity = function(v) {
return (_opacityExp.test( ((typeof(v) === "string") ? v : (v.currentStyle ? v.currentStyle.filter : v.style.filter) || "") ) ? ( parseFloat( RegExp.$1 ) / 100 ) : 1);
},
_log = function(s) {//for logging messages, but in a way that won't throw errors in old versions of IE.
if (__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */].console) {
console.log(s);
}
},
_target, //when initting a CSSPlugin, we set this variable so that we can access it from within many other functions without having to pass it around as params
_index, //when initting a CSSPlugin, we set this variable so that we can access it from within many other functions without having to pass it around as params
_prefixCSS = "", //the non-camelCase vendor prefix like "-o-", "-moz-", "-ms-", or "-webkit-"
_prefix = "", //camelCase vendor prefix like "O", "ms", "Webkit", or "Moz".
// @private feed in a camelCase property name like "transform" and it will check to see if it is valid as-is or if it needs a vendor prefix. It returns the corrected camelCase property name (i.e. "WebkitTransform" or "MozTransform" or "transform" or null if no such property is found, like if the browser is IE8 or before, "transform" won't be found at all)
_checkPropPrefix = function(p, e) {
e = e || _tempDiv;
var s = e.style,
a, i;
if (s[p] !== undefined) {
return p;
}
p = p.charAt(0).toUpperCase() + p.substr(1);
a = ["O","Moz","ms","Ms","Webkit"];
i = 5;
while (--i > -1 && s[a[i]+p] === undefined) { }
if (i >= 0) {
_prefix = (i === 3) ? "ms" : a[i];
_prefixCSS = "-" + _prefix.toLowerCase() + "-";
return _prefix + p;
}
return null;
},
_computedStyleScope = (typeof(window) !== "undefined" ? window : _doc.defaultView || {getComputedStyle:function() {}}),
_getComputedStyle = function(e) {
return _computedStyleScope.getComputedStyle(e); //to avoid errors in Microsoft Edge, we need to call getComputedStyle() from a specific scope, typically window.
},
/**
* @private Returns the css style for a particular property of an element. For example, to get whatever the current "left" css value for an element with an ID of "myElement", you could do:
* var currentLeft = CSSPlugin.getStyle( document.getElementById("myElement"), "left");
*
* @param {!Object} t Target element whose style property you want to query
* @param {!string} p Property name (like "left" or "top" or "marginTop", etc.)
* @param {Object=} cs Computed style object. This just provides a way to speed processing if you're going to get several properties on the same element in quick succession - you can reuse the result of the getComputedStyle() call.
* @param {boolean=} calc If true, the value will not be read directly from the element's "style" property (if it exists there), but instead the getComputedStyle() result will be used. This can be useful when you want to ensure that the browser itself is interpreting the value.
* @param {string=} dflt Default value that should be returned in the place of null, "none", "auto" or "auto auto".
* @return {?string} The current property value
*/
_getStyle = CSSPlugin.getStyle = function(t, p, cs, calc, dflt) {
var rv;
if (!_supportsOpacity) if (p === "opacity") { //several versions of IE don't use the standard "opacity" property - they use things like filter:alpha(opacity=50), so we parse that here.
return _getIEOpacity(t);
}
if (!calc && t.style[p]) {
rv = t.style[p];
} else if ((cs = cs || _getComputedStyle(t))) {
rv = cs[p] || cs.getPropertyValue(p) || cs.getPropertyValue(p.replace(_capsExp, "-$1").toLowerCase());
} else if (t.currentStyle) {
rv = t.currentStyle[p];
}
return (dflt != null && (!rv || rv === "none" || rv === "auto" || rv === "auto auto")) ? dflt : rv;
},
/**
* @private Pass the target element, the property name, the numeric value, and the suffix (like "%", "em", "px", etc.) and it will spit back the equivalent pixel number.
* @param {!Object} t Target element
* @param {!string} p Property name (like "left", "top", "marginLeft", etc.)
* @param {!number} v Value
* @param {string=} sfx Suffix (like "px" or "%" or "em")
* @param {boolean=} recurse If true, the call is a recursive one. In some browsers (like IE7/8), occasionally the value isn't accurately reported initially, but if we run the function again it will take effect.
* @return {number} value in pixels
*/
_convertToPixels = _internals.convertToPixels = function(t, p, v, sfx, recurse) {
if (sfx === "px" || (!sfx && p !== "lineHeight")) { return v; }
if (sfx === "auto" || !v) { return 0; }
var horiz = _horizExp.test(p),
node = t,
style = _tempDiv.style,
neg = (v < 0),
precise = (v === 1),
pix, cache, time;
if (neg) {
v = -v;
}
if (precise) {
v *= 100;
}
if (p === "lineHeight" && !sfx) { //special case of when a simple lineHeight (without a unit) is used. Set it to the value, read back the computed value, and then revert.
cache = _getComputedStyle(t).lineHeight;
t.style.lineHeight = v;
pix = parseFloat(_getComputedStyle(t).lineHeight);
t.style.lineHeight = cache;
} else if (sfx === "%" && p.indexOf("border") !== -1) {
pix = (v / 100) * (horiz ? t.clientWidth : t.clientHeight);
} else {
style.cssText = "border:0 solid red;position:" + _getStyle(t, "position") + ";line-height:0;";
if (sfx === "%" || !node.appendChild || sfx.charAt(0) === "v" || sfx === "rem") {
node = t.parentNode || _doc.body;
if (_getStyle(node, "display").indexOf("flex") !== -1) { //Edge and IE11 have a bug that causes offsetWidth to report as 0 if the container has display:flex and the child is position:relative. Switching to position: absolute solves it.
style.position = "absolute";
}
cache = node._gsCache;
time = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].ticker.frame;
if (cache && horiz && cache.time === time) { //performance optimization: we record the width of elements along with the ticker frame so that we can quickly get it again on the same tick (seems relatively safe to assume it wouldn't change on the same tick)
return cache.width * v / 100;
}
style[(horiz ? "width" : "height")] = v + sfx;
} else {
style[(horiz ? "borderLeftWidth" : "borderTopWidth")] = v + sfx;
}
node.appendChild(_tempDiv);
pix = parseFloat(_tempDiv[(horiz ? "offsetWidth" : "offsetHeight")]);
node.removeChild(_tempDiv);
if (horiz && sfx === "%" && CSSPlugin.cacheWidths !== false) {
cache = node._gsCache = node._gsCache || {};
cache.time = time;
cache.width = pix / v * 100;
}
if (pix === 0 && !recurse) {
pix = _convertToPixels(t, p, v, sfx, true);
}
}
if (precise) {
pix /= 100;
}
return neg ? -pix : pix;
},
_calculateOffset = _internals.calculateOffset = function(t, p, cs) { //for figuring out "top" or "left" in px when it's "auto". We need to factor in margin with the offsetLeft/offsetTop
if (_getStyle(t, "position", cs) !== "absolute") { return 0; }
var dim = ((p === "left") ? "Left" : "Top"),
v = _getStyle(t, "margin" + dim, cs);
return t["offset" + dim] - (_convertToPixels(t, p, parseFloat(v), v.replace(_suffixExp, "")) || 0);
},
// @private returns at object containing ALL of the style properties in camelCase and their associated values.
_getAllStyles = function(t, cs) {
var s = {},
i, tr, p;
if ((cs = cs || _getComputedStyle(t, null))) {
if ((i = cs.length)) {
while (--i > -1) {
p = cs[i];
if (p.indexOf("-transform") === -1 || _transformPropCSS === p) { //Some webkit browsers duplicate transform values, one non-prefixed and one prefixed ("transform" and "WebkitTransform"), so we must weed out the extra one here.
s[p.replace(_camelExp, _camelFunc)] = cs.getPropertyValue(p);
}
}
} else { //some browsers behave differently - cs.length is always 0, so we must do a for...in loop.
for (i in cs) {
if (i.indexOf("Transform") === -1 || _transformProp === i) { //Some webkit browsers duplicate transform values, one non-prefixed and one prefixed ("transform" and "WebkitTransform"), so we must weed out the extra one here.
s[i] = cs[i];
}
}
}
} else if ((cs = t.currentStyle || t.style)) {
for (i in cs) {
if (typeof(i) === "string" && s[i] === undefined) {
s[i.replace(_camelExp, _camelFunc)] = cs[i];
}
}
}
if (!_supportsOpacity) {
s.opacity = _getIEOpacity(t);
}
tr = _getTransform(t, cs, false);
s.rotation = tr.rotation;
s.skewX = tr.skewX;
s.scaleX = tr.scaleX;
s.scaleY = tr.scaleY;
s.x = tr.x;
s.y = tr.y;
if (_supports3D) {
s.z = tr.z;
s.rotationX = tr.rotationX;
s.rotationY = tr.rotationY;
s.scaleZ = tr.scaleZ;
}
if (s.filters) {
delete s.filters;
}
return s;
},
// @private analyzes two style objects (as returned by _getAllStyles()) and only looks for differences between them that contain tweenable values (like a number or color). It returns an object with a "difs" property which refers to an object containing only those isolated properties and values for tweening, and a "firstMPT" property which refers to the first MiniPropTween instance in a linked list that recorded all the starting values of the different properties so that we can revert to them at the end or beginning of the tween - we don't want the cascading to get messed up. The forceLookup parameter is an optional generic object with properties that should be forced into the results - this is necessary for className tweens that are overwriting others because imagine a scenario where a rollover/rollout adds/removes a class and the user swipes the mouse over the target SUPER fast, thus nothing actually changed yet and the subsequent comparison of the properties would indicate they match (especially when px rounding is taken into consideration), thus no tweening is necessary even though it SHOULD tween and remove those properties after the tween (otherwise the inline styles will contaminate things). See the className SpecialProp code for details.
_cssDif = function(t, s1, s2, vars, forceLookup) {
var difs = {},
style = t.style,
val, p, mpt;
for (p in s2) {
if (p !== "cssText") if (p !== "length") if (isNaN(p)) if (s1[p] !== (val = s2[p]) || (forceLookup && forceLookup[p])) if (p.indexOf("Origin") === -1) if (typeof(val) === "number" || typeof(val) === "string") {
difs[p] = (val === "auto" && (p === "left" || p === "top")) ? _calculateOffset(t, p) : ((val === "" || val === "auto" || val === "none") && typeof(s1[p]) === "string" && s1[p].replace(_NaNExp, "") !== "") ? 0 : val; //if the ending value is defaulting ("" or "auto"), we check the starting value and if it can be parsed into a number (a string which could have a suffix too, like 700px), then we swap in 0 for "" or "auto" so that things actually tween.
if (style[p] !== undefined) { //for className tweens, we must remember which properties already existed inline - the ones that didn't should be removed when the tween isn't in progress because they were only introduced to facilitate the transition between classes.
mpt = new MiniPropTween(style, p, style[p], mpt);
}
}
}
if (vars) {
for (p in vars) { //copy properties (except className)
if (p !== "className") {
difs[p] = vars[p];
}
}
}
return {difs:difs, firstMPT:mpt};
},
_dimensions = {width:["Left","Right"], height:["Top","Bottom"]},
_margins = ["marginLeft","marginRight","marginTop","marginBottom"],
/**
* @private Gets the width or height of an element
* @param {!Object} t Target element
* @param {!string} p Property name ("width" or "height")
* @param {Object=} cs Computed style object (if one exists). Just a speed optimization.
* @return {number} Dimension (in pixels)
*/
_getDimension = function(t, p, cs) {
if ((t.nodeName + "").toLowerCase() === "svg") { //Chrome no longer supports offsetWidth/offsetHeight on SVG elements.
return (cs || _getComputedStyle(t))[p] || 0;
} else if (t.getCTM && _isSVG(t)) {
return t.getBBox()[p] || 0;
}
var v = parseFloat((p === "width") ? t.offsetWidth : t.offsetHeight),
a = _dimensions[p],
i = a.length;
cs = cs || _getComputedStyle(t, null);
while (--i > -1) {
v -= parseFloat( _getStyle(t, "padding" + a[i], cs, true) ) || 0;
v -= parseFloat( _getStyle(t, "border" + a[i] + "Width", cs, true) ) || 0;
}
return v;
},
// @private Parses position-related complex strings like "top left" or "50px 10px" or "70% 20%", etc. which are used for things like transformOrigin or backgroundPosition. Optionally decorates a supplied object (recObj) with the following properties: "ox" (offsetX), "oy" (offsetY), "oxp" (if true, "ox" is a percentage not a pixel value), and "oxy" (if true, "oy" is a percentage not a pixel value)
_parsePosition = function(v, recObj) {
if (v === "contain" || v === "auto" || v === "auto auto") { //note: Firefox uses "auto auto" as default whereas Chrome uses "auto".
return v + " ";
}
if (v == null || v === "") {
v = "0 0";
}
var a = v.split(" "),
x = (v.indexOf("left") !== -1) ? "0%" : (v.indexOf("right") !== -1) ? "100%" : a[0],
y = (v.indexOf("top") !== -1) ? "0%" : (v.indexOf("bottom") !== -1) ? "100%" : a[1],
i;
if (a.length > 3 && !recObj) { //multiple positions
a = v.split(", ").join(",").split(",");
v = [];
for (i = 0; i < a.length; i++) {
v.push(_parsePosition(a[i]));
}
return v.join(",");
}
if (y == null) {
y = (x === "center") ? "50%" : "0";
} else if (y === "center") {
y = "50%";
}
if (x === "center" || (isNaN(parseFloat(x)) && (x + "").indexOf("=") === -1)) { //remember, the user could flip-flop the values and say "bottom center" or "center bottom", etc. "center" is ambiguous because it could be used to describe horizontal or vertical, hence the isNaN(). If there's an "=" sign in the value, it's relative.
x = "50%";
}
v = x + " " + y + ((a.length > 2) ? " " + a[2] : "");
if (recObj) {
recObj.oxp = (x.indexOf("%") !== -1);
recObj.oyp = (y.indexOf("%") !== -1);
recObj.oxr = (x.charAt(1) === "=");
recObj.oyr = (y.charAt(1) === "=");
recObj.ox = parseFloat(x.replace(_NaNExp, ""));
recObj.oy = parseFloat(y.replace(_NaNExp, ""));
recObj.v = v;
}
return recObj || v;
},
/**
* @private Takes an ending value (typically a string, but can be a number) and a starting value and returns the change between the two, looking for relative value indicators like += and -= and it also ignores suffixes (but make sure the ending value starts with a number or +=/-= and that the starting value is a NUMBER!)
* @param {(number|string)} e End value which is typically a string, but could be a number
* @param {(number|string)} b Beginning value which is typically a string but could be a number
* @return {number} Amount of change between the beginning and ending values (relative values that have a "+=" or "-=" are recognized)
*/
_parseChange = function(e, b) {
if (typeof(e) === "function") {
e = e(_index, _target);
}
return (typeof(e) === "string" && e.charAt(1) === "=") ? parseInt(e.charAt(0) + "1", 10) * parseFloat(e.substr(2)) : (parseFloat(e) - parseFloat(b)) || 0;
},
/**
* @private Takes a value and a default number, checks if the value is relative, null, or numeric and spits back a normalized number accordingly. Primarily used in the _parseTransform() function.
* @param {Object} v Value to be parsed
* @param {!number} d Default value (which is also used for relative calculations if "+=" or "-=" is found in the first parameter)
* @return {number} Parsed value
*/
_parseVal = function(v, d) {
if (typeof(v) === "function") {
v = v(_index, _target);
}
var isRelative = (typeof(v) === "string" && v.charAt(1) === "=");
if (typeof(v) === "string" && v.charAt(v.length - 2) === "v") { //convert vw and vh into px-equivalents.
v = (isRelative ? v.substr(0, 2) : 0) + (window["inner" + ((v.substr(-2) === "vh") ? "Height" : "Width")] * (parseFloat(isRelative ? v.substr(2) : v) / 100));
}
return (v == null) ? d : isRelative ? parseInt(v.charAt(0) + "1", 10) * parseFloat(v.substr(2)) + d : parseFloat(v) || 0;
},
/**
* @private Translates strings like "40deg" or "40" or 40rad" or "+=40deg" or "270_short" or "-90_cw" or "+=45_ccw" to a numeric radian angle. Of course a starting/default value must be fed in too so that relative values can be calculated properly.
* @param {Object} v Value to be parsed
* @param {!number} d Default value (which is also used for relative calculations if "+=" or "-=" is found in the first parameter)
* @param {string=} p property name for directionalEnd (optional - only used when the parsed value is directional ("_short", "_cw", or "_ccw" suffix). We need a way to store the uncompensated value so that at the end of the tween, we set it to exactly what was requested with no directional compensation). Property name would be "rotation", "rotationX", or "rotationY"
* @param {Object=} directionalEnd An object that will store the raw end values for directional angles ("_short", "_cw", or "_ccw" suffix). We need a way to store the uncompensated value so that at the end of the tween, we set it to exactly what was requested with no directional compensation.
* @return {number} parsed angle in radians
*/
_parseAngle = function(v, d, p, directionalEnd) {
var min = 0.000001,
cap, split, dif, result, isRelative;
if (typeof(v) === "function") {
v = v(_index, _target);
}
if (v == null) {
result = d;
} else if (typeof(v) === "number") {
result = v;
} else {
cap = 360;
split = v.split("_");
isRelative = (v.charAt(1) === "=");
dif = (isRelative ? parseInt(v.charAt(0) + "1", 10) * parseFloat(split[0].substr(2)) : parseFloat(split[0])) * ((v.indexOf("rad") === -1) ? 1 : _RAD2DEG) - (isRelative ? 0 : d);
if (split.length) {
if (directionalEnd) {
directionalEnd[p] = d + dif;
}
if (v.indexOf("short") !== -1) {
dif = dif % cap;
if (dif !== dif % (cap / 2)) {
dif = (dif < 0) ? dif + cap : dif - cap;
}
}
if (v.indexOf("_cw") !== -1 && dif < 0) {
dif = ((dif + cap * 9999999999) % cap) - ((dif / cap) | 0) * cap;
} else if (v.indexOf("ccw") !== -1 && dif > 0) {
dif = ((dif - cap * 9999999999) % cap) - ((dif / cap) | 0) * cap;
}
}
result = d + dif;
}
if (result < min && result > -min) {
result = 0;
}
return result;
},
_colorLookup = {aqua:[0,255,255],
lime:[0,255,0],
silver:[192,192,192],
black:[0,0,0],
maroon:[128,0,0],
teal:[0,128,128],
blue:[0,0,255],
navy:[0,0,128],
white:[255,255,255],
fuchsia:[255,0,255],
olive:[128,128,0],
yellow:[255,255,0],
orange:[255,165,0],
gray:[128,128,128],
purple:[128,0,128],
green:[0,128,0],
red:[255,0,0],
pink:[255,192,203],
cyan:[0,255,255],
transparent:[255,255,255,0]},
_hue = function(h, m1, m2) {
h = (h < 0) ? h + 1 : (h > 1) ? h - 1 : h;
return ((((h * 6 < 1) ? m1 + (m2 - m1) * h * 6 : (h < 0.5) ? m2 : (h * 3 < 2) ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * 255) + 0.5) | 0;
},
/**
* @private Parses a color (like #9F0, #FF9900, rgb(255,51,153) or hsl(108, 50%, 10%)) into an array with 3 elements for red, green, and blue or if toHSL parameter is true, it will populate the array with hue, saturation, and lightness values. If a relative value is found in an hsl() or hsla() string, it will preserve those relative prefixes and all the values in the array will be strings instead of numbers (in all other cases it will be populated with numbers).
* @param {(string|number)} v The value the should be parsed which could be a string like #9F0 or rgb(255,102,51) or rgba(255,0,0,0.5) or it could be a number like 0xFF00CC or even a named color like red, blue, purple, etc.
* @param {(boolean)} toHSL If true, an hsl() or hsla() value will be returned instead of rgb() or rgba()
* @return {Array.<number>} An array containing red, green, and blue (and optionally alpha) in that order, or if the toHSL parameter was true, the array will contain hue, saturation and lightness (and optionally alpha) in that order. Always numbers unless there's a relative prefix found in an hsl() or hsla() string and toHSL is true.
*/
_parseColor = CSSPlugin.parseColor = function(v, toHSL) {
var a, r, g, b, h, s, l, max, min, d, wasHSL;
if (!v) {
a = _colorLookup.black;
} else if (typeof(v) === "number") {
a = [v >> 16, (v >> 8) & 255, v & 255];
} else {
if (v.charAt(v.length - 1) === ",") { //sometimes a trailing comma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)" - in this example "blue," has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value.
v = v.substr(0, v.length - 1);
}
if (_colorLookup[v]) {
a = _colorLookup[v];
} else if (v.charAt(0) === "#") {
if (v.length === 4) { //for shorthand like #9F0
r = v.charAt(1);
g = v.charAt(2);
b = v.charAt(3);
v = "#" + r + r + g + g + b + b;
}
v = parseInt(v.substr(1), 16);
a = [v >> 16, (v >> 8) & 255, v & 255];
} else if (v.substr(0, 3) === "hsl") {
a = wasHSL = v.match(_numExp);
if (!toHSL) {
h = (Number(a[0]) % 360) / 360;
s = Number(a[1]) / 100;
l = Number(a[2]) / 100;
g = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
r = l * 2 - g;
if (a.length > 3) {
a[3] = Number(a[3]);
}
a[0] = _hue(h + 1 / 3, r, g);
a[1] = _hue(h, r, g);
a[2] = _hue(h - 1 / 3, r, g);
} else if (v.indexOf("=") !== -1) { //if relative values are found, just return the raw strings with the relative prefixes in place.
return v.match(_relNumExp);
}
} else {
a = v.match(_numExp) || _colorLookup.transparent;
}
a[0] = Number(a[0]);
a[1] = Number(a[1]);
a[2] = Number(a[2]);
if (a.length > 3) {
a[3] = Number(a[3]);
}
}
if (toHSL && !wasHSL) {
r = a[0] / 255;
g = a[1] / 255;
b = a[2] / 255;
max = Math.max(r, g, b);
min = Math.min(r, g, b);
l = (max + min) / 2;
if (max === min) {
h = s = 0;
} else {
d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
h = (max === r) ? (g - b) / d + (g < b ? 6 : 0) : (max === g) ? (b - r) / d + 2 : (r - g) / d + 4;
h *= 60;
}
a[0] = (h + 0.5) | 0;
a[1] = (s * 100 + 0.5) | 0;
a[2] = (l * 100 + 0.5) | 0;
}
return a;
},
_formatColors = function(s, toHSL) {
var colors = s.match(_colorExp) || [],
charIndex = 0,
parsed = "",
i, color, temp;
if (!colors.length) {
return s;
}
for (i = 0; i < colors.length; i++) {
color = colors[i];
temp = s.substr(charIndex, s.indexOf(color, charIndex)-charIndex);
charIndex += temp.length + color.length;
color = _parseColor(color, toHSL);
if (color.length === 3) {
color.push(1);
}
parsed += temp + (toHSL ? "hsla(" + color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : "rgba(" + color.join(",")) + ")";
}
return parsed + s.substr(charIndex);
},
_colorExp = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3}){1,2}\\b"; //we'll dynamically build this Regular Expression to conserve file size. After building it, it will be able to find rgb(), rgba(), # (hexadecimal), and named color values like red, blue, purple, etc.
for (p in _colorLookup) {
_colorExp += "|" + p + "\\b";
}
_colorExp = new RegExp(_colorExp+")", "gi");
CSSPlugin.colorStringFilter = function(a) {
var combined = a[0] + " " + a[1],
toHSL;
if (_colorExp.test(combined)) {
toHSL = (combined.indexOf("hsl(") !== -1 || combined.indexOf("hsla(") !== -1);
a[0] = _formatColors(a[0], toHSL);
a[1] = _formatColors(a[1], toHSL);
}
_colorExp.lastIndex = 0;
};
if (!__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].defaultStringFilter) {
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].defaultStringFilter = CSSPlugin.colorStringFilter;
}
/**
* @private Returns a formatter function that handles taking a string (or number in some cases) and returning a consistently formatted one in terms of delimiters, quantity of values, etc. For example, we may get boxShadow values defined as "0px red" or "0px 0px 10px rgb(255,0,0)" or "0px 0px 20px 20px #F00" and we need to ensure that what we get back is described with 4 numbers and a color. This allows us to feed it into the _parseComplex() method and split the values up appropriately. The neat thing about this _getFormatter() function is that the dflt defines a pattern as well as a default, so for example, _getFormatter("0px 0px 0px 0px #777", true) not only sets the default as 0px for all distances and #777 for the color, but also sets the pattern such that 4 numbers and a color will always get returned.
* @param {!string} dflt The default value and pattern to follow. So "0px 0px 0px 0px #777" will ensure that 4 numbers and a color will always get returned.
* @param {boolean=} clr If true, the values should be searched for color-related data. For example, boxShadow values typically contain a color whereas borderRadius don't.
* @param {boolean=} collapsible If true, the value is a top/left/right/bottom style one that acts like margin or padding, where if only one value is received, it's used for all 4; if 2 are received, the first is duplicated for 3rd (bottom) and the 2nd is duplicated for the 4th spot (left), etc.
* @return {Function} formatter function
*/
var _getFormatter = function(dflt, clr, collapsible, multi) {
if (dflt == null) {
return function(v) {return v;};
}
var dColor = clr ? (dflt.match(_colorExp) || [""])[0] : "",
dVals = dflt.split(dColor).join("").match(_valuesExp) || [],
pfx = dflt.substr(0, dflt.indexOf(dVals[0])),
sfx = (dflt.charAt(dflt.length - 1) === ")") ? ")" : "",
delim = (dflt.indexOf(" ") !== -1) ? " " : ",",
numVals = dVals.length,
dSfx = (numVals > 0) ? dVals[0].replace(_numExp, "") : "",
formatter;
if (!numVals) {
return function(v) {return v;};
}
if (clr) {
formatter = function(v) {
var color, vals, i, a;
if (typeof(v) === "number") {
v += dSfx;
} else if (multi && _commasOutsideParenExp.test(v)) {
a = v.replace(_commasOutsideParenExp, "|").split("|");
for (i = 0; i < a.length; i++) {
a[i] = formatter(a[i]);
}
return a.join(",");
}
color = (v.match(_colorExp) || [dColor])[0];
vals = v.split(color).join("").match(_valuesExp) || [];
i = vals.length;
if (numVals > i--) {
while (++i < numVals) {
vals[i] = collapsible ? vals[(((i - 1) / 2) | 0)] : dVals[i];
}
}
return pfx + vals.join(delim) + delim + color + sfx + (v.indexOf("inset") !== -1 ? " inset" : "");
};
return formatter;
}
formatter = function(v) {
var vals, a, i;
if (typeof(v) === "number") {
v += dSfx;
} else if (multi && _commasOutsideParenExp.test(v)) {
a = v.replace(_commasOutsideParenExp, "|").split("|");
for (i = 0; i < a.length; i++) {
a[i] = formatter(a[i]);
}
return a.join(",");
}
vals = v.match(_valuesExp) || [];
i = vals.length;
if (numVals > i--) {
while (++i < numVals) {
vals[i] = collapsible ? vals[(((i - 1) / 2) | 0)] : dVals[i];
}
}
return pfx + vals.join(delim) + sfx;
};
return formatter;
},
/**
* @private returns a formatter function that's used for edge-related values like marginTop, marginLeft, paddingBottom, paddingRight, etc. Just pass a comma-delimited list of property names related to the edges.
* @param {!string} props a comma-delimited list of property names in order from top to left, like "marginTop,marginRight,marginBottom,marginLeft"
* @return {Function} a formatter function
*/
_getEdgeParser = function(props) {
props = props.split(",");
return function(t, e, p, cssp, pt, plugin, vars) {
var a = (e + "").split(" "),
i;
vars = {};
for (i = 0; i < 4; i++) {
vars[props[i]] = a[i] = a[i] || a[(((i - 1) / 2) >> 0)];
}
return cssp.parse(t, vars, pt, plugin);
};
},
// @private used when other plugins must tween values first, like BezierPlugin or ThrowPropsPlugin, etc. That plugin's setRatio() gets called first so that the values are updated, and then we loop through the MiniPropTweens which handle copying the values into their appropriate slots so that they can then be applied correctly in the main CSSPlugin setRatio() method. Remember, we typically create a proxy object that has a bunch of uniquely-named properties that we feed to the sub-plugin and it does its magic normally, and then we must interpret those values and apply them to the css because often numbers must get combined/concatenated, suffixes added, etc. to work with css, like boxShadow could have 4 values plus a color.
_setPluginRatio = _internals._setPluginRatio = function(v) {
this.plugin.setRatio(v);
var d = this.data,
proxy = d.proxy,
mpt = d.firstMPT,
min = 0.000001,
val, pt, i, str, p;
while (mpt) {
val = proxy[mpt.v];
if (mpt.r) {
val = mpt.r(val);
} else if (val < min && val > -min) {
val = 0;
}
mpt.t[mpt.p] = val;
mpt = mpt._next;
}
if (d.autoRotate) {
d.autoRotate.rotation = d.mod ? d.mod.call(this._tween, proxy.rotation, this.t, this._tween) : proxy.rotation; //special case for ModifyPlugin to hook into an auto-rotating bezier
}
//at the end, we must set the CSSPropTween's "e" (end) value dynamically here because that's what is used in the final setRatio() method. Same for "b" at the beginning.
if (v === 1 || v === 0) {
mpt = d.firstMPT;
p = (v === 1) ? "e" : "b";
while (mpt) {
pt = mpt.t;
if (!pt.type) {
pt[p] = pt.s + pt.xs0;
} else if (pt.type === 1) {
str = pt.xs0 + pt.s + pt.xs1;
for (i = 1; i < pt.l; i++) {
str += pt["xn"+i] + pt["xs"+(i+1)];
}
pt[p] = str;
}
mpt = mpt._next;
}
}
},
/**
* @private @constructor Used by a few SpecialProps to hold important values for proxies. For example, _parseToProxy() creates a MiniPropTween instance for each property that must get tweened on the proxy, and we record the original property name as well as the unique one we create for the proxy, plus whether or not the value needs to be rounded plus the original value.
* @param {!Object} t target object whose property we're tweening (often a CSSPropTween)
* @param {!string} p property name
* @param {(number|string|object)} v value
* @param {MiniPropTween=} next next MiniPropTween in the linked list
* @param {boolean=} r if true, the tweened value should be rounded to the nearest integer
*/
MiniPropTween = function(t, p, v, next, r) {
this.t = t;
this.p = p;
this.v = v;
this.r = r;
if (next) {
next._prev = this;
this._next = next;
}
},
/**
* @private Most other plugins (like BezierPlugin and ThrowPropsPlugin and others) can only tween numeric values, but CSSPlugin must accommodate special values that have a bunch of extra data (like a suffix or strings between numeric values, etc.). For example, boxShadow has values like "10px 10px 20px 30px rgb(255,0,0)" which would utterly confuse other plugins. This method allows us to split that data apart and grab only the numeric data and attach it to uniquely-named properties of a generic proxy object ({}) so that we can feed that to virtually any plugin to have the numbers tweened. However, we must also keep track of which properties from the proxy go with which CSSPropTween values and instances. So we create a linked list of MiniPropTweens. Each one records a target (the original CSSPropTween), property (like "s" or "xn1" or "xn2") that we're tweening and the unique property name that was used for the proxy (like "boxShadow_xn1" and "boxShadow_xn2") and whether or not they need to be rounded. That way, in the _setPluginRatio() method we can simply copy the values over from the proxy to the CSSPropTween instance(s). Then, when the main CSSPlugin setRatio() method runs and applies the CSSPropTween values accordingly, they're updated nicely. So the external plugin tweens the numbers, _setPluginRatio() copies them over, and setRatio() acts normally, applying css-specific values to the element.
* This method returns an object that has the following properties:
* - proxy: a generic object containing the starting values for all the properties that will be tweened by the external plugin. This is what we feed to the external _onInitTween() as the target
* - end: a generic object containing the ending values for all the properties that will be tweened by the external plugin. This is what we feed to the external plugin's _onInitTween() as the destination values
* - firstMPT: the first MiniPropTween in the linked list
* - pt: the first CSSPropTween in the linked list that was created when parsing. If shallow is true, this linked list will NOT attach to the one passed into the _parseToProxy() as the "pt" (4th) parameter.
* @param {!Object} t target object to be tweened
* @param {!(Object|string)} vars the object containing the information about the tweening values (typically the end/destination values) that should be parsed
* @param {!CSSPlugin} cssp The CSSPlugin instance
* @param {CSSPropTween=} pt the next CSSPropTween in the linked list
* @param {TweenPlugin=} plugin the external TweenPlugin instance that will be handling tweening the numeric values
* @param {boolean=} shallow if true, the resulting linked list from the parse will NOT be attached to the CSSPropTween that was passed in as the "pt" (4th) parameter.
* @return An object containing the following properties: proxy, end, firstMPT, and pt (see above for descriptions)
*/
_parseToProxy = _internals._parseToProxy = function(t, vars, cssp, pt, plugin, shallow) {
var bpt = pt,
start = {},
end = {},
transform = cssp._transform,
oldForce = _forcePT,
i, p, xp, mpt, firstPT;
cssp._transform = null;
_forcePT = vars;
pt = firstPT = cssp.parse(t, vars, pt, plugin);
_forcePT = oldForce;
//break off from the linked list so the new ones are isolated.
if (shallow) {
cssp._transform = transform;
if (bpt) {
bpt._prev = null;
if (bpt._prev) {
bpt._prev._next = null;
}
}
}
while (pt && pt !== bpt) {
if (pt.type <= 1) {
p = pt.p;
end[p] = pt.s + pt.c;
start[p] = pt.s;
if (!shallow) {
mpt = new MiniPropTween(pt, "s", p, mpt, pt.r);
pt.c = 0;
}
if (pt.type === 1) {
i = pt.l;
while (--i > 0) {
xp = "xn" + i;
p = pt.p + "_" + xp;
end[p] = pt.data[xp];
start[p] = pt[xp];
if (!shallow) {
mpt = new MiniPropTween(pt, xp, p, mpt, pt.rxp[xp]);
}
}
}
}
pt = pt._next;
}
return {proxy:start, end:end, firstMPT:mpt, pt:firstPT};
},
/**
* @constructor Each property that is tweened has at least one CSSPropTween associated with it. These instances store important information like the target, property, starting value, amount of change, etc. They can also optionally have a number of "extra" strings and numeric values named xs1, xn1, xs2, xn2, xs3, xn3, etc. where "s" indicates string and "n" indicates number. These can be pieced together in a complex-value tween (type:1) that has alternating types of data like a string, number, string, number, etc. For example, boxShadow could be "5px 5px 8px rgb(102, 102, 51)". In that value, there are 6 numbers that may need to tween and then pieced back together into a string again with spaces, suffixes, etc. xs0 is special in that it stores the suffix for standard (type:0) tweens, -OR- the first string (prefix) in a complex-value (type:1) CSSPropTween -OR- it can be the non-tweening value in a type:-1 CSSPropTween. We do this to conserve memory.
* CSSPropTweens have the following optional properties as well (not defined through the constructor):
* - l: Length in terms of the number of extra properties that the CSSPropTween has (default: 0). For example, for a boxShadow we may need to tween 5 numbers in which case l would be 5; Keep in mind that the start/end values for the first number that's tweened are always stored in the s and c properties to conserve memory. All additional values thereafter are stored in xn1, xn2, etc.
* - xfirst: The first instance of any sub-CSSPropTweens that are tweening properties of this instance. For example, we may split up a boxShadow tween so that there's a main CSSPropTween of type:1 that has various xs* and xn* values associated with the h-shadow, v-shadow, blur, color, etc. Then we spawn a CSSPropTween for each of those that has a higher priority and runs BEFORE the main CSSPropTween so that the values are all set by the time it needs to re-assemble them. The xfirst gives us an easy way to identify the first one in that chain which typically ends at the main one (because they're all prepende to the linked list)
* - plugin: The TweenPlugin instance that will handle the tweening of any complex values. For example, sometimes we don't want to use normal subtweens (like xfirst refers to) to tween the values - we might want ThrowPropsPlugin or BezierPlugin some other plugin to do the actual tweening, so we create a plugin instance and store a reference here. We need this reference so that if we get a request to round values or disable a tween, we can pass along that request.
* - data: Arbitrary data that needs to be stored with the CSSPropTween. Typically if we're going to have a plugin handle the tweening of a complex-value tween, we create a generic object that stores the END values that we're tweening to and the CSSPropTween's xs1, xs2, etc. have the starting values. We store that object as data. That way, we can simply pass that object to the plugin and use the CSSPropTween as the target.
* - setRatio: Only used for type:2 tweens that require custom functionality. In this case, we call the CSSPropTween's setRatio() method and pass the ratio each time the tween updates. This isn't quite as efficient as doing things directly in the CSSPlugin's setRatio() method, but it's very convenient and flexible.
* @param {!Object} t Target object whose property will be tweened. Often a DOM element, but not always. It could be anything.
* @param {string} p Property to tween (name). For example, to tween element.width, p would be "width".
* @param {number} s Starting numeric value
* @param {number} c Change in numeric value over the course of the entire tween. For example, if element.width starts at 5 and should end at 100, c would be 95.
* @param {CSSPropTween=} next The next CSSPropTween in the linked list. If one is defined, we will define its _prev as the new instance, and the new instance's _next will be pointed at it.
* @param {number=} type The type of CSSPropTween where -1 = a non-tweening value, 0 = a standard simple tween, 1 = a complex value (like one that has multiple numbers in a comma- or space-delimited string like border:"1px solid red"), and 2 = one that uses a custom setRatio function that does all of the work of applying the values on each update.
* @param {string=} n Name of the property that should be used for overwriting purposes which is typically the same as p but not always. For example, we may need to create a subtween for the 2nd part of a "clip:rect(...)" tween in which case "p" might be xs1 but "n" is still "clip"
* @param {boolean=} r If true, the value(s) should be rounded
* @param {number=} pr Priority in the linked list order. Higher priority CSSPropTweens will be updated before lower priority ones. The default priority is 0.
* @param {string=} b Beginning value. We store this to ensure that it is EXACTLY what it was when the tween began without any risk of interpretation issues.
* @param {string=} e Ending value. We store this to ensure that it is EXACTLY what the user defined at the end of the tween without any risk of interpretation issues.
*/
CSSPropTween = _internals.CSSPropTween = function(t, p, s, c, next, type, n, r, pr, b, e) {
this.t = t; //target
this.p = p; //property
this.s = s; //starting value
this.c = c; //change value
this.n = n || p; //name that this CSSPropTween should be associated to (usually the same as p, but not always - n is what overwriting looks at)
if (!(t instanceof CSSPropTween)) {
_overwriteProps.push(this.n);
}
this.r = !r ? r : (typeof(r) === "function") ? r : Math.round; //round (boolean)
this.type = type || 0; //0 = normal tween, -1 = non-tweening (in which case xs0 will be applied to the target's property, like tp.t[tp.p] = tp.xs0), 1 = complex-value SpecialProp, 2 = custom setRatio() that does all the work
if (pr) {
this.pr = pr;
_hasPriority = true;
}
this.b = (b === undefined) ? s : b;
this.e = (e === undefined) ? s + c : e;
if (next) {
this._next = next;
next._prev = this;
}
},
_addNonTweeningNumericPT = function(target, prop, start, end, next, overwriteProp) { //cleans up some code redundancies and helps minification. Just a fast way to add a NUMERIC non-tweening CSSPropTween
var pt = new CSSPropTween(target, prop, start, end - start, next, -1, overwriteProp);
pt.b = start;
pt.e = pt.xs0 = end;
return pt;
},
/**
* Takes a target, the beginning value and ending value (as strings) and parses them into a CSSPropTween (possibly with child CSSPropTweens) that accommodates multiple numbers, colors, comma-delimited values, etc. For example:
* sp.parseComplex(element, "boxShadow", "5px 10px 20px rgb(255,102,51)", "0px 0px 0px red", true, "0px 0px 0px rgb(0,0,0,0)", pt);
* It will walk through the beginning and ending values (which should be in the same format with the same number and type of values) and figure out which parts are numbers, what strings separate the numeric/tweenable values, and then create the CSSPropTweens accordingly. If a plugin is defined, no child CSSPropTweens will be created. Instead, the ending values will be stored in the "data" property of the returned CSSPropTween like: {s:-5, xn1:-10, xn2:-20, xn3:255, xn4:0, xn5:0} so that it can be fed to any other plugin and it'll be plain numeric tweens but the recomposition of the complex value will be handled inside CSSPlugin's setRatio().
* If a setRatio is defined, the type of the CSSPropTween will be set to 2 and recomposition of the values will be the responsibility of that method.
*
* @param {!Object} t Target whose property will be tweened
* @param {!string} p Property that will be tweened (its name, like "left" or "backgroundColor" or "boxShadow")
* @param {string} b Beginning value
* @param {string} e Ending value
* @param {boolean} clrs If true, the value could contain a color value like "rgb(255,0,0)" or "#F00" or "red". The default is false, so no colors will be recognized (a performance optimization)
* @param {(string|number|Object)} dflt The default beginning value that should be used if no valid beginning value is defined or if the number of values inside the complex beginning and ending values don't match
* @param {?CSSPropTween} pt CSSPropTween instance that is the current head of the linked list (we'll prepend to this).
* @param {number=} pr Priority in the linked list order. Higher priority properties will be updated before lower priority ones. The default priority is 0.
* @param {TweenPlugin=} plugin If a plugin should handle the tweening of extra properties, pass the plugin instance here. If one is defined, then NO subtweens will be created for any extra properties (the properties will be created - just not additional CSSPropTween instances to tween them) because the plugin is expected to do so. However, the end values WILL be populated in the "data" property, like {s:100, xn1:50, xn2:300}
* @param {function(number)=} setRatio If values should be set in a custom function instead of being pieced together in a type:1 (complex-value) CSSPropTween, define that custom function here.
* @return {CSSPropTween} The first CSSPropTween in the linked list which includes the new one(s) added by the parseComplex() call.
*/
_parseComplex = CSSPlugin.parseComplex = function(t, p, b, e, clrs, dflt, pt, pr, plugin, setRatio) {
//DEBUG: _log("parseComplex: "+p+", b: "+b+", e: "+e);
b = b || dflt || "";
if (typeof(e) === "function") {
e = e(_index, _target);
}
pt = new CSSPropTween(t, p, 0, 0, pt, (setRatio ? 2 : 1), null, false, pr, b, e);
e += ""; //ensures it's a string
if (clrs && _colorExp.test(e + b)) { //if colors are found, normalize the formatting to rgba() or hsla().
e = [b, e];
CSSPlugin.colorStringFilter(e);
b = e[0];
e = e[1];
}
var ba = b.split(", ").join(",").split(" "), //beginning array
ea = e.split(", ").join(",").split(" "), //ending array
l = ba.length,
autoRound = (_autoRound !== false),
i, xi, ni, bv, ev, bnums, enums, bn, hasAlpha, temp, cv, str, useHSL;
if (e.indexOf(",") !== -1 || b.indexOf(",") !== -1) {
if ((e + b).indexOf("rgb") !== -1 || (e + b).indexOf("hsl") !== -1) { //keep rgb(), rgba(), hsl(), and hsla() values together! (remember, we're splitting on spaces)
ba = ba.join(" ").replace(_commasOutsideParenExp, ", ").split(" ");
ea = ea.join(" ").replace(_commasOutsideParenExp, ", ").split(" ");
} else {
ba = ba.join(" ").split(",").join(", ").split(" ");
ea = ea.join(" ").split(",").join(", ").split(" ");
}
l = ba.length;
}
if (l !== ea.length) {
//DEBUG: _log("mismatched formatting detected on " + p + " (" + b + " vs " + e + ")");
ba = (dflt || "").split(" ");
l = ba.length;
}
pt.plugin = plugin;
pt.setRatio = setRatio;
_colorExp.lastIndex = 0;
for (i = 0; i < l; i++) {
bv = ba[i];
ev = ea[i] + "";
bn = parseFloat(bv);
//if the value begins with a number (most common). It's fine if it has a suffix like px
if (bn || bn === 0) {
pt.appendXtra("", bn, _parseChange(ev, bn), ev.replace(_relNumExp, ""), (autoRound && ev.indexOf("px") !== -1) ? Math.round : false, true);
//if the value is a color
} else if (clrs && _colorExp.test(bv)) {
str = ev.indexOf(")") + 1;
str = ")" + (str ? ev.substr(str) : ""); //if there's a comma or ) at the end, retain it.
useHSL = (ev.indexOf("hsl") !== -1 && _supportsOpacity);
temp = ev; //original string value so we can look for any prefix later.
bv = _parseColor(bv, useHSL);
ev = _parseColor(ev, useHSL);
hasAlpha = (bv.length + ev.length > 6);
if (hasAlpha && !_supportsOpacity && ev[3] === 0) { //older versions of IE don't support rgba(), so if the destination alpha is 0, just use "transparent" for the end color
pt["xs" + pt.l] += pt.l ? " transparent" : "transparent";
pt.e = pt.e.split(ea[i]).join("transparent");
} else {
if (!_supportsOpacity) { //old versions of IE don't support rgba().
hasAlpha = false;
}
if (useHSL) {
pt.appendXtra(temp.substr(0, temp.indexOf("hsl")) + (hasAlpha ? "hsla(" : "hsl("), bv[0], _parseChange(ev[0], bv[0]), ",", false, true)
.appendXtra("", bv[1], _parseChange(ev[1], bv[1]), "%,", false)
.appendXtra("", bv[2], _parseChange(ev[2], bv[2]), (hasAlpha ? "%," : "%" + str), false);
} else {
pt.appendXtra(temp.substr(0, temp.indexOf("rgb")) + (hasAlpha ? "rgba(" : "rgb("), bv[0], ev[0] - bv[0], ",", Math.round, true)
.appendXtra("", bv[1], ev[1] - bv[1], ",", Math.round)
.appendXtra("", bv[2], ev[2] - bv[2], (hasAlpha ? "," : str), Math.round);
}
if (hasAlpha) {
bv = (bv.length < 4) ? 1 : bv[3];
pt.appendXtra("", bv, ((ev.length < 4) ? 1 : ev[3]) - bv, str, false);
}
}
_colorExp.lastIndex = 0; //otherwise the test() on the RegExp could move the lastIndex and taint future results.
} else {
bnums = bv.match(_numExp); //gets each group of numbers in the beginning value string and drops them into an array
//if no number is found, treat it as a non-tweening value and just append the string to the current xs.
if (!bnums) {
pt["xs" + pt.l] += (pt.l || pt["xs" + pt.l]) ? " " + ev : ev;
//loop through all the numbers that are found and construct the extra values on the pt.
} else {
enums = ev.match(_relNumExp); //get each group of numbers in the end value string and drop them into an array. We allow relative values too, like +=50 or -=.5
if (!enums || enums.length !== bnums.length) {
//DEBUG: _log("mismatched formatting detected on " + p + " (" + b + " vs " + e + ")");
return pt;
}
ni = 0;
for (xi = 0; xi < bnums.length; xi++) {
cv = bnums[xi];
temp = bv.indexOf(cv, ni);
pt.appendXtra(bv.substr(ni, temp - ni), Number(cv), _parseChange(enums[xi], cv), "", (autoRound && bv.substr(temp + cv.length, 2) === "px") ? Math.round : false, (xi === 0));
ni = temp + cv.length;
}
pt["xs" + pt.l] += bv.substr(ni);
}
}
}
//if there are relative values ("+=" or "-=" prefix), we need to adjust the ending value to eliminate the prefixes and combine the values properly.
if (e.indexOf("=") !== -1) if (pt.data) {
str = pt.xs0 + pt.data.s;
for (i = 1; i < pt.l; i++) {
str += pt["xs" + i] + pt.data["xn" + i];
}
pt.e = str + pt["xs" + i];
}
if (!pt.l) {
pt.type = -1;
pt.xs0 = pt.e;
}
return pt.xfirst || pt;
},
i = 9;
p = CSSPropTween.prototype;
p.l = p.pr = 0; //length (number of extra properties like xn1, xn2, xn3, etc.
while (--i > 0) {
p["xn" + i] = 0;
p["xs" + i] = "";
}
p.xs0 = "";
p._next = p._prev = p.xfirst = p.data = p.plugin = p.setRatio = p.rxp = null;
/**
* Appends and extra tweening value to a CSSPropTween and automatically manages any prefix and suffix strings. The first extra value is stored in the s and c of the main CSSPropTween instance, but thereafter any extras are stored in the xn1, xn2, xn3, etc. The prefixes and suffixes are stored in the xs0, xs1, xs2, etc. properties. For example, if I walk through a clip value like "rect(10px, 5px, 0px, 20px)", the values would be stored like this:
* xs0:"rect(", s:10, xs1:"px, ", xn1:5, xs2:"px, ", xn2:0, xs3:"px, ", xn3:20, xn4:"px)"
* And they'd all get joined together when the CSSPlugin renders (in the setRatio() method).
* @param {string=} pfx Prefix (if any)
* @param {!number} s Starting value
* @param {!number} c Change in numeric value over the course of the entire tween. For example, if the start is 5 and the end is 100, the change would be 95.
* @param {string=} sfx Suffix (if any)
* @param {boolean=} r Round (if true).
* @param {boolean=} pad If true, this extra value should be separated by the previous one by a space. If there is no previous extra and pad is true, it will automatically drop the space.
* @return {CSSPropTween} returns itself so that multiple methods can be chained together.
*/
p.appendXtra = function(pfx, s, c, sfx, r, pad) {
var pt = this,
l = pt.l;
pt["xs" + l] += (pad && (l || pt["xs" + l])) ? " " + pfx : pfx || "";
if (!c) if (l !== 0 && !pt.plugin) { //typically we'll combine non-changing values right into the xs to optimize performance, but we don't combine them when there's a plugin that will be tweening the values because it may depend on the values being split apart, like for a bezier, if a value doesn't change between the first and second iteration but then it does on the 3rd, we'll run into trouble because there's no xn slot for that value!
pt["xs" + l] += s + (sfx || "");
return pt;
}
pt.l++;
pt.type = pt.setRatio ? 2 : 1;
pt["xs" + pt.l] = sfx || "";
if (l > 0) {
pt.data["xn" + l] = s + c;
pt.rxp["xn" + l] = r; //round extra property (we need to tap into this in the _parseToProxy() method)
pt["xn" + l] = s;
if (!pt.plugin) {
pt.xfirst = new CSSPropTween(pt, "xn" + l, s, c, pt.xfirst || pt, 0, pt.n, r, pt.pr);
pt.xfirst.xs0 = 0; //just to ensure that the property stays numeric which helps modern browsers speed up processing. Remember, in the setRatio() method, we do pt.t[pt.p] = val + pt.xs0 so if pt.xs0 is "" (the default), it'll cast the end value as a string. When a property is a number sometimes and a string sometimes, it prevents the compiler from locking in the data type, slowing things down slightly.
}
return pt;
}
pt.data = {s:s + c};
pt.rxp = {};
pt.s = s;
pt.c = c;
pt.r = r;
return pt;
};
/**
* @constructor A SpecialProp is basically a css property that needs to be treated in a non-standard way, like if it may contain a complex value like boxShadow:"5px 10px 15px rgb(255, 102, 51)" or if it is associated with another plugin like ThrowPropsPlugin or BezierPlugin. Every SpecialProp is associated with a particular property name like "boxShadow" or "throwProps" or "bezier" and it will intercept those values in the vars object that's passed to the CSSPlugin and handle them accordingly.
* @param {!string} p Property name (like "boxShadow" or "throwProps")
* @param {Object=} options An object containing any of the following configuration options:
* - defaultValue: the default value
* - parser: A function that should be called when the associated property name is found in the vars. This function should return a CSSPropTween instance and it should ensure that it is properly inserted into the linked list. It will receive 4 paramters: 1) The target, 2) The value defined in the vars, 3) The CSSPlugin instance (whose _firstPT should be used for the linked list), and 4) A computed style object if one was calculated (this is a speed optimization that allows retrieval of starting values quicker)
* - formatter: a function that formats any value received for this special property (for example, boxShadow could take "5px 5px red" and format it to "5px 5px 0px 0px red" so that both the beginning and ending values have a common order and quantity of values.)
* - prefix: if true, we'll determine whether or not this property requires a vendor prefix (like Webkit or Moz or ms or O)
* - color: set this to true if the value for this SpecialProp may contain color-related values like rgb(), rgba(), etc.
* - priority: priority in the linked list order. Higher priority SpecialProps will be updated before lower priority ones. The default priority is 0.
* - multi: if true, the formatter should accommodate a comma-delimited list of values, like boxShadow could have multiple boxShadows listed out.
* - collapsible: if true, the formatter should treat the value like it's a top/right/bottom/left value that could be collapsed, like "5px" would apply to all, "5px, 10px" would use 5px for top/bottom and 10px for right/left, etc.
* - keyword: a special keyword that can [optionally] be found inside the value (like "inset" for boxShadow). This allows us to validate beginning/ending values to make sure they match (if the keyword is found in one, it'll be added to the other for consistency by default).
*/
var SpecialProp = function(p, options) {
options = options || {};
this.p = options.prefix ? _checkPropPrefix(p) || p : p;
_specialProps[p] = _specialProps[this.p] = this;
this.format = options.formatter || _getFormatter(options.defaultValue, options.color, options.collapsible, options.multi);
if (options.parser) {
this.parse = options.parser;
}
this.clrs = options.color;
this.multi = options.multi;
this.keyword = options.keyword;
this.dflt = options.defaultValue;
this.allowFunc = options.allowFunc;
this.pr = options.priority || 0;
},
//shortcut for creating a new SpecialProp that can accept multiple properties as a comma-delimited list (helps minification). dflt can be an array for multiple values (we don't do a comma-delimited list because the default value may contain commas, like rect(0px,0px,0px,0px)). We attach this method to the SpecialProp class/object instead of using a private _createSpecialProp() method so that we can tap into it externally if necessary, like from another plugin.
_registerComplexSpecialProp = _internals._registerComplexSpecialProp = function(p, options, defaults) {
if (typeof(options) !== "object") {
options = {parser:defaults}; //to make backwards compatible with older versions of BezierPlugin and ThrowPropsPlugin
}
var a = p.split(","),
d = options.defaultValue,
i, temp;
defaults = defaults || [d];
for (i = 0; i < a.length; i++) {
options.prefix = (i === 0 && options.prefix);
options.defaultValue = defaults[i] || d;
temp = new SpecialProp(a[i], options);
}
},
//creates a placeholder special prop for a plugin so that the property gets caught the first time a tween of it is attempted, and at that time it makes the plugin register itself, thus taking over for all future tweens of that property. This allows us to not mandate that things load in a particular order and it also allows us to log() an error that informs the user when they attempt to tween an external plugin-related property without loading its .js file.
_registerPluginProp = _internals._registerPluginProp = function(p) {
if (!_specialProps[p]) {
var pluginName = p.charAt(0).toUpperCase() + p.substr(1) + "Plugin";
_registerComplexSpecialProp(p, {parser:function(t, e, p, cssp, pt, plugin, vars) {
var pluginClass = _globals.com.greensock.plugins[pluginName];
if (!pluginClass) {
_log("Error: " + pluginName + " js file not loaded.");
return pt;
}
pluginClass._cssRegister();
return _specialProps[p].parse(t, e, p, cssp, pt, plugin, vars);
}});
}
};
p = SpecialProp.prototype;
/**
* Alias for _parseComplex() that automatically plugs in certain values for this SpecialProp, like its property name, whether or not colors should be sensed, the default value, and priority. It also looks for any keyword that the SpecialProp defines (like "inset" for boxShadow) and ensures that the beginning and ending values have the same number of values for SpecialProps where multi is true (like boxShadow and textShadow can have a comma-delimited list)
* @param {!Object} t target element
* @param {(string|number|object)} b beginning value
* @param {(string|number|object)} e ending (destination) value
* @param {CSSPropTween=} pt next CSSPropTween in the linked list
* @param {TweenPlugin=} plugin If another plugin will be tweening the complex value, that TweenPlugin instance goes here.
* @param {function=} setRatio If a custom setRatio() method should be used to handle this complex value, that goes here.
* @return {CSSPropTween=} First CSSPropTween in the linked list
*/
p.parseComplex = function(t, b, e, pt, plugin, setRatio) {
var kwd = this.keyword,
i, ba, ea, l, bi, ei;
//if this SpecialProp's value can contain a comma-delimited list of values (like boxShadow or textShadow), we must parse them in a special way, and look for a keyword (like "inset" for boxShadow) and ensure that the beginning and ending BOTH have it if the end defines it as such. We also must ensure that there are an equal number of values specified (we can't tween 1 boxShadow to 3 for example)
if (this.multi) if (_commasOutsideParenExp.test(e) || _commasOutsideParenExp.test(b)) {
ba = b.replace(_commasOutsideParenExp, "|").split("|");
ea = e.replace(_commasOutsideParenExp, "|").split("|");
} else if (kwd) {
ba = [b];
ea = [e];
}
if (ea) {
l = (ea.length > ba.length) ? ea.length : ba.length;
for (i = 0; i < l; i++) {
b = ba[i] = ba[i] || this.dflt;
e = ea[i] = ea[i] || this.dflt;
if (kwd) {
bi = b.indexOf(kwd);
ei = e.indexOf(kwd);
if (bi !== ei) {
if (ei === -1) { //if the keyword isn't in the end value, remove it from the beginning one.
ba[i] = ba[i].split(kwd).join("");
} else if (bi === -1) { //if the keyword isn't in the beginning, add it.
ba[i] += " " + kwd;
}
}
}
}
b = ba.join(", ");
e = ea.join(", ");
}
return _parseComplex(t, this.p, b, e, this.clrs, this.dflt, pt, this.pr, plugin, setRatio);
};
/**
* Accepts a target and end value and spits back a CSSPropTween that has been inserted into the CSSPlugin's linked list and conforms with all the conventions we use internally, like type:-1, 0, 1, or 2, setting up any extra property tweens, priority, etc. For example, if we have a boxShadow SpecialProp and call:
* this._firstPT = sp.parse(element, "5px 10px 20px rgb(2550,102,51)", "boxShadow", this);
* It should figure out the starting value of the element's boxShadow, compare it to the provided end value and create all the necessary CSSPropTweens of the appropriate types to tween the boxShadow. The CSSPropTween that gets spit back should already be inserted into the linked list (the 4th parameter is the current head, so prepend to that).
* @param {!Object} t Target object whose property is being tweened
* @param {Object} e End value as provided in the vars object (typically a string, but not always - like a throwProps would be an object).
* @param {!string} p Property name
* @param {!CSSPlugin} cssp The CSSPlugin instance that should be associated with this tween.
* @param {?CSSPropTween} pt The CSSPropTween that is the current head of the linked list (we'll prepend to it)
* @param {TweenPlugin=} plugin If a plugin will be used to tween the parsed value, this is the plugin instance.
* @param {Object=} vars Original vars object that contains the data for parsing.
* @return {CSSPropTween} The first CSSPropTween in the linked list which includes the new one(s) added by the parse() call.
*/
p.parse = function(t, e, p, cssp, pt, plugin, vars) {
return this.parseComplex(t.style, this.format(_getStyle(t, this.p, _cs, false, this.dflt)), this.format(e), pt, plugin);
};
/**
* Registers a special property that should be intercepted from any "css" objects defined in tweens. This allows you to handle them however you want without CSSPlugin doing it for you. The 2nd parameter should be a function that accepts 3 parameters:
* 1) Target object whose property should be tweened (typically a DOM element)
* 2) The end/destination value (could be a string, number, object, or whatever you want)
* 3) The tween instance (you probably don't need to worry about this, but it can be useful for looking up information like the duration)
*
* Then, your function should return a function which will be called each time the tween gets rendered, passing a numeric "ratio" parameter to your function that indicates the change factor (usually between 0 and 1). For example:
*
* CSSPlugin.registerSpecialProp("myCustomProp", function(target, value, tween) {
* var start = target.style.width;
* return function(ratio) {
* target.style.width = (start + value * ratio) + "px";
* console.log("set width to " + target.style.width);
* }
* }, 0);
*
* Then, when I do this tween, it will trigger my special property:
*
* TweenLite.to(element, 1, {css:{myCustomProp:100}});
*
* In the example, of course, we're just changing the width, but you can do anything you want.
*
* @param {!string} name Property name (or comma-delimited list of property names) that should be intercepted and handled by your function. For example, if I define "myCustomProp", then it would handle that portion of the following tween: TweenLite.to(element, 1, {css:{myCustomProp:100}})
* @param {!function(Object, Object, Object, string):function(number)} onInitTween The function that will be called when a tween of this special property is performed. The function will receive 4 parameters: 1) Target object that should be tweened, 2) Value that was passed to the tween, 3) The tween instance itself (rarely used), and 4) The property name that's being tweened. Your function should return a function that should be called on every update of the tween. That function will receive a single parameter that is a "change factor" value (typically between 0 and 1) indicating the amount of change as a ratio. You can use this to determine how to set the values appropriately in your function.
* @param {number=} priority Priority that helps the engine determine the order in which to set the properties (default: 0). Higher priority properties will be updated before lower priority ones.
*/
CSSPlugin.registerSpecialProp = function(name, onInitTween, priority) {
_registerComplexSpecialProp(name, {parser:function(t, e, p, cssp, pt, plugin, vars) {
var rv = new CSSPropTween(t, p, 0, 0, pt, 2, p, false, priority);
rv.plugin = plugin;
rv.setRatio = onInitTween(t, e, cssp._tween, p);
return rv;
}, priority:priority});
};
//transform-related methods and properties
CSSPlugin.useSVGTransformAttr = true; //Safari and Firefox both have some rendering bugs when applying CSS transforms to SVG elements, so default to using the "transform" attribute instead (users can override this).
var _transformProps = ("scaleX,scaleY,scaleZ,x,y,z,skewX,skewY,rotation,rotationX,rotationY,perspective,xPercent,yPercent").split(","),
_transformProp = _checkPropPrefix("transform"), //the Javascript (camelCase) transform property, like msTransform, WebkitTransform, MozTransform, or OTransform.
_transformPropCSS = _prefixCSS + "transform",
_transformOriginProp = _checkPropPrefix("transformOrigin"),
_supports3D = (_checkPropPrefix("perspective") !== null),
Transform = _internals.Transform = function() {
this.perspective = parseFloat(CSSPlugin.defaultTransformPerspective) || 0;
this.force3D = (CSSPlugin.defaultForce3D === false || !_supports3D) ? false : CSSPlugin.defaultForce3D || "auto";
},
_SVGElement = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */].SVGElement,
_useSVGTransformAttr,
//Some browsers (like Firefox and IE) don't honor transform-origin properly in SVG elements, so we need to manually adjust the matrix accordingly. We feature detect here rather than always doing the conversion for certain browsers because they may fix the problem at some point in the future.
_createSVG = function(type, container, attributes) {
var element = _doc.createElementNS("http://www.w3.org/2000/svg", type),
reg = /([a-z])([A-Z])/g,
p;
for (p in attributes) {
element.setAttributeNS(null, p.replace(reg, "$1-$2").toLowerCase(), attributes[p]);
}
container.appendChild(element);
return element;
},
_docElement = _doc.documentElement || {},
_forceSVGTransformAttr = (function() {
//IE and Android stock don't support CSS transforms on SVG elements, so we must write them to the "transform" attribute. We populate this variable in the _parseTransform() method, and only if/when we come across an SVG element
var force = _ieVers || (/Android/i.test(_agent) && !__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */].chrome),
svg, rect, width;
if (_doc.createElementNS && !force) { //IE8 and earlier doesn't support SVG anyway
svg = _createSVG("svg", _docElement);
rect = _createSVG("rect", svg, {width:100, height:50, x:100});
width = rect.getBoundingClientRect().width;
rect.style[_transformOriginProp] = "50% 50%";
rect.style[_transformProp] = "scaleX(0.5)";
force = (width === rect.getBoundingClientRect().width && !(_isFirefox && _supports3D)); //note: Firefox fails the test even though it does support CSS transforms in 3D. Since we can't push 3D stuff into the transform attribute, we force Firefox to pass the test here (as long as it does truly support 3D).
_docElement.removeChild(svg);
}
return force;
})(),
_parseSVGOrigin = function(e, local, decoratee, absolute, smoothOrigin, skipRecord) {
var tm = e._gsTransform,
m = _getMatrix(e, true),
v, x, y, xOrigin, yOrigin, a, b, c, d, tx, ty, determinant, xOriginOld, yOriginOld;
if (tm) {
xOriginOld = tm.xOrigin; //record the original values before we alter them.
yOriginOld = tm.yOrigin;
}
if (!absolute || (v = absolute.split(" ")).length < 2) {
b = e.getBBox();
if (b.x === 0 && b.y === 0 && b.width + b.height === 0) { //some browsers (like Firefox) misreport the bounds if the element has zero width and height (it just assumes it's at x:0, y:0), thus we need to manually grab the position in that case.
b = {x: parseFloat(e.hasAttribute("x") ? e.getAttribute("x") : e.hasAttribute("cx") ? e.getAttribute("cx") : 0) || 0, y: parseFloat(e.hasAttribute("y") ? e.getAttribute("y") : e.hasAttribute("cy") ? e.getAttribute("cy") : 0) || 0, width:0, height:0};
}
local = _parsePosition(local).split(" ");
v = [(local[0].indexOf("%") !== -1 ? parseFloat(local[0]) / 100 * b.width : parseFloat(local[0])) + b.x,
(local[1].indexOf("%") !== -1 ? parseFloat(local[1]) / 100 * b.height : parseFloat(local[1])) + b.y];
}
decoratee.xOrigin = xOrigin = parseFloat(v[0]);
decoratee.yOrigin = yOrigin = parseFloat(v[1]);
if (absolute && m !== _identity2DMatrix) { //if svgOrigin is being set, we must invert the matrix and determine where the absolute point is, factoring in the current transforms. Otherwise, the svgOrigin would be based on the element's non-transformed position on the canvas.
a = m[0];
b = m[1];
c = m[2];
d = m[3];
tx = m[4];
ty = m[5];
determinant = (a * d - b * c);
if (determinant) { //if it's zero (like if scaleX and scaleY are zero), skip it to avoid errors with dividing by zero.
x = xOrigin * (d / determinant) + yOrigin * (-c / determinant) + ((c * ty - d * tx) / determinant);
y = xOrigin * (-b / determinant) + yOrigin * (a / determinant) - ((a * ty - b * tx) / determinant);
xOrigin = decoratee.xOrigin = v[0] = x;
yOrigin = decoratee.yOrigin = v[1] = y;
}
}
if (tm) { //avoid jump when transformOrigin is changed - adjust the x/y values accordingly
if (skipRecord) {
decoratee.xOffset = tm.xOffset;
decoratee.yOffset = tm.yOffset;
tm = decoratee;
}
if (smoothOrigin || (smoothOrigin !== false && CSSPlugin.defaultSmoothOrigin !== false)) {
x = xOrigin - xOriginOld;
y = yOrigin - yOriginOld;
//originally, we simply adjusted the x and y values, but that would cause problems if, for example, you created a rotational tween part-way through an x/y tween. Managing the offset in a separate variable gives us ultimate flexibility.
//tm.x -= x - (x * m[0] + y * m[2]);
//tm.y -= y - (x * m[1] + y * m[3]);
tm.xOffset += (x * m[0] + y * m[2]) - x;
tm.yOffset += (x * m[1] + y * m[3]) - y;
} else {
tm.xOffset = tm.yOffset = 0;
}
}
if (!skipRecord) {
e.setAttribute("data-svg-origin", v.join(" "));
}
},
_getBBoxHack = function(swapIfPossible) { //works around issues in some browsers (like Firefox) that don't correctly report getBBox() on SVG elements inside a <defs> element and/or <mask>. We try creating an SVG, adding it to the documentElement and toss the element in there so that it's definitely part of the rendering tree, then grab the bbox and if it works, we actually swap out the original getBBox() method for our own that does these extra steps whenever getBBox is needed. This helps ensure that performance is optimal (only do all these extra steps when absolutely necessary...most elements don't need it).
var svg = _createElement("svg", (this.ownerSVGElement && this.ownerSVGElement.getAttribute("xmlns")) || "http://www.w3.org/2000/svg"),
oldParent = this.parentNode,
oldSibling = this.nextSibling,
oldCSS = this.style.cssText,
bbox;
_docElement.appendChild(svg);
svg.appendChild(this);
this.style.display = "block";
if (swapIfPossible) {
try {
bbox = this.getBBox();
this._originalGetBBox = this.getBBox;
this.getBBox = _getBBoxHack;
} catch (e) { }
} else if (this._originalGetBBox) {
bbox = this._originalGetBBox();
}
if (oldSibling) {
oldParent.insertBefore(this, oldSibling);
} else {
oldParent.appendChild(this);
}
_docElement.removeChild(svg);
this.style.cssText = oldCSS;
return bbox;
},
_getBBox = function(e) {
try {
return e.getBBox(); //Firefox throws errors if you try calling getBBox() on an SVG element that's not rendered (like in a <symbol> or <defs>). https://bugzilla.mozilla.org/show_bug.cgi?id=612118
} catch (error) {
return _getBBoxHack.call(e, true);
}
},
_isSVG = function(e) { //reports if the element is an SVG on which getBBox() actually works
return !!(_SVGElement && e.getCTM && (!e.parentNode || e.ownerSVGElement) && _getBBox(e));
},
_identity2DMatrix = [1,0,0,1,0,0],
_getMatrix = function(e, force2D) {
var tm = e._gsTransform || new Transform(),
rnd = 100000,
style = e.style,
isDefault, s, m, n, dec, nextSibling, parent;
if (_transformProp) {
s = _getStyle(e, _transformPropCSS, null, true);
} else if (e.currentStyle) {
//for older versions of IE, we need to interpret the filter portion that is in the format: progid:DXImageTransform.Microsoft.Matrix(M11=6.123233995736766e-17, M12=-1, M21=1, M22=6.123233995736766e-17, sizingMethod='auto expand') Notice that we need to swap b and c compared to a normal matrix.
s = e.currentStyle.filter.match(_ieGetMatrixExp);
s = (s && s.length === 4) ? [s[0].substr(4), Number(s[2].substr(4)), Number(s[1].substr(4)), s[3].substr(4), (tm.x || 0), (tm.y || 0)].join(",") : "";
}
isDefault = (!s || s === "none" || s === "matrix(1, 0, 0, 1, 0, 0)");
if (_transformProp && isDefault && !e.offsetParent) { //note: if offsetParent is null, that means the element isn't in the normal document flow, like if it has display:none or one of its ancestors has display:none). Firefox returns null for getComputedStyle() if the element is in an iframe that has display:none. https://bugzilla.mozilla.org/show_bug.cgi?id=548397
//browsers don't report transforms accurately unless the element is in the DOM and has a display value that's not "none". Firefox and Microsoft browsers have a partial bug where they'll report transforms even if display:none BUT not any percentage-based values like translate(-50%, 8px) will be reported as if it's translate(0, 8px).
n = style.display;
style.display = "block";
parent = e.parentNode;
if (!parent || !e.offsetParent) {
dec = 1; //flag
nextSibling = e.nextSibling;
_docElement.appendChild(e); //we must add it to the DOM in order to get values properly
}
s = _getStyle(e, _transformPropCSS, null, true);
isDefault = (!s || s === "none" || s === "matrix(1, 0, 0, 1, 0, 0)");
if (n) {
style.display = n;
} else {
_removeProp(style, "display");
}
if (dec) {
if (nextSibling) {
parent.insertBefore(e, nextSibling);
} else if (parent) {
parent.appendChild(e);
} else {
_docElement.removeChild(e);
}
}
}
if (tm.svg || (e.getCTM && _isSVG(e))) {
if (isDefault && (style[_transformProp] + "").indexOf("matrix") !== -1) { //some browsers (like Chrome 40) don't correctly report transforms that are applied inline on an SVG element (they don't get included in the computed style), so we double-check here and accept matrix values
s = style[_transformProp];
isDefault = 0;
}
m = e.getAttribute("transform");
if (isDefault && m) {
m = e.transform.baseVal.consolidate().matrix; //ensures that even complex values like "translate(50,60) rotate(135,0,0)" are parsed because it mashes it into a matrix.
s = "matrix(" + m.a + "," + m.b + "," + m.c + "," + m.d + "," + m.e + "," + m.f + ")";
isDefault = 0;
}
}
if (isDefault) {
return _identity2DMatrix;
}
//split the matrix values out into an array (m for matrix)
m = (s || "").match(_numExp) || [];
i = m.length;
while (--i > -1) {
n = Number(m[i]);
m[i] = (dec = n - (n |= 0)) ? ((dec * rnd + (dec < 0 ? -0.5 : 0.5)) | 0) / rnd + n : n; //convert strings to Numbers and round to 5 decimal places to avoid issues with tiny numbers. Roughly 20x faster than Number.toFixed(). We also must make sure to round before dividing so that values like 0.9999999999 become 1 to avoid glitches in browser rendering and interpretation of flipped/rotated 3D matrices. And don't just multiply the number by rnd, floor it, and then divide by rnd because the bitwise operations max out at a 32-bit signed integer, thus it could get clipped at a relatively low value (like 22,000.00000 for example).
}
return (force2D && m.length > 6) ? [m[0], m[1], m[4], m[5], m[12], m[13]] : m;
},
/**
* Parses the transform values for an element, returning an object with x, y, z, scaleX, scaleY, scaleZ, rotation, rotationX, rotationY, skewX, and skewY properties. Note: by default (for performance reasons), all skewing is combined into skewX and rotation but skewY still has a place in the transform object so that we can record how much of the skew is attributed to skewX vs skewY. Remember, a skewY of 10 looks the same as a rotation of 10 and skewX of -10.
* @param {!Object} t target element
* @param {Object=} cs computed style object (optional)
* @param {boolean=} rec if true, the transform values will be recorded to the target element's _gsTransform object, like target._gsTransform = {x:0, y:0, z:0, scaleX:1...}
* @param {boolean=} parse if true, we'll ignore any _gsTransform values that already exist on the element, and force a reparsing of the css (calculated style)
* @return {object} object containing all of the transform properties/values like {x:0, y:0, z:0, scaleX:1...}
*/
_getTransform = _internals.getTransform = function(t, cs, rec, parse) {
if (t._gsTransform && rec && !parse) {
return t._gsTransform; //if the element already has a _gsTransform, use that. Note: some browsers don't accurately return the calculated style for the transform (particularly for SVG), so it's almost always safest to just use the values we've already applied rather than re-parsing things.
}
var tm = rec ? t._gsTransform || new Transform() : new Transform(),
invX = (tm.scaleX < 0), //in order to interpret things properly, we need to know if the user applied a negative scaleX previously so that we can adjust the rotation and skewX accordingly. Otherwise, if we always interpret a flipped matrix as affecting scaleY and the user only wants to tween the scaleX on multiple sequential tweens, it would keep the negative scaleY without that being the user's intent.
min = 0.00002,
rnd = 100000,
zOrigin = _supports3D ? parseFloat(_getStyle(t, _transformOriginProp, cs, false, "0 0 0").split(" ")[2]) || tm.zOrigin || 0 : 0,
defaultTransformPerspective = parseFloat(CSSPlugin.defaultTransformPerspective) || 0,
m, i, scaleX, scaleY, rotation, skewX;
tm.svg = !!(t.getCTM && _isSVG(t));
if (tm.svg) {
_parseSVGOrigin(t, _getStyle(t, _transformOriginProp, cs, false, "50% 50%") + "", tm, t.getAttribute("data-svg-origin"));
_useSVGTransformAttr = CSSPlugin.useSVGTransformAttr || _forceSVGTransformAttr;
}
m = _getMatrix(t);
if (m !== _identity2DMatrix) {
if (m.length === 16) {
//we'll only look at these position-related 6 variables first because if x/y/z all match, it's relatively safe to assume we don't need to re-parse everything which risks losing important rotational information (like rotationX:180 plus rotationY:180 would look the same as rotation:180 - there's no way to know for sure which direction was taken based solely on the matrix3d() values)
var a11 = m[0], a21 = m[1], a31 = m[2], a41 = m[3],
a12 = m[4], a22 = m[5], a32 = m[6], a42 = m[7],
a13 = m[8], a23 = m[9], a33 = m[10],
a14 = m[12], a24 = m[13], a34 = m[14],
a43 = m[11],
angle = Math.atan2(a32, a33),
t1, t2, t3, t4, cos, sin;
//we manually compensate for non-zero z component of transformOrigin to work around bugs in Safari
if (tm.zOrigin) {
a34 = -tm.zOrigin;
a14 = a13*a34-m[12];
a24 = a23*a34-m[13];
a34 = a33*a34+tm.zOrigin-m[14];
}
//note for possible future consolidation: rotationX: Math.atan2(a32, a33), rotationY: Math.atan2(-a31, Math.sqrt(a33 * a33 + a32 * a32)), rotation: Math.atan2(a21, a11), skew: Math.atan2(a12, a22). However, it doesn't seem to be quite as reliable as the full-on backwards rotation procedure.
tm.rotationX = angle * _RAD2DEG;
//rotationX
if (angle) {
cos = Math.cos(-angle);
sin = Math.sin(-angle);
t1 = a12*cos+a13*sin;
t2 = a22*cos+a23*sin;
t3 = a32*cos+a33*sin;
a13 = a12*-sin+a13*cos;
a23 = a22*-sin+a23*cos;
a33 = a32*-sin+a33*cos;
a43 = a42*-sin+a43*cos;
a12 = t1;
a22 = t2;
a32 = t3;
}
//rotationY
angle = Math.atan2(-a31, a33);
tm.rotationY = angle * _RAD2DEG;
if (angle) {
cos = Math.cos(-angle);
sin = Math.sin(-angle);
t1 = a11*cos-a13*sin;
t2 = a21*cos-a23*sin;
t3 = a31*cos-a33*sin;
a23 = a21*sin+a23*cos;
a33 = a31*sin+a33*cos;
a43 = a41*sin+a43*cos;
a11 = t1;
a21 = t2;
a31 = t3;
}
//rotationZ
angle = Math.atan2(a21, a11);
tm.rotation = angle * _RAD2DEG;
if (angle) {
cos = Math.cos(angle);
sin = Math.sin(angle);
t1 = a11*cos+a21*sin;
t2 = a12*cos+a22*sin;
t3 = a13*cos+a23*sin;
a21 = a21*cos-a11*sin;
a22 = a22*cos-a12*sin;
a23 = a23*cos-a13*sin;
a11 = t1;
a12 = t2;
a13 = t3;
}
if (tm.rotationX && Math.abs(tm.rotationX) + Math.abs(tm.rotation) > 359.9) { //when rotationY is set, it will often be parsed as 180 degrees different than it should be, and rotationX and rotation both being 180 (it looks the same), so we adjust for that here.
tm.rotationX = tm.rotation = 0;
tm.rotationY = 180 - tm.rotationY;
}
//skewX
angle = Math.atan2(a12, a22);
//scales
tm.scaleX = ((Math.sqrt(a11 * a11 + a21 * a21 + a31 * a31) * rnd + 0.5) | 0) / rnd;
tm.scaleY = ((Math.sqrt(a22 * a22 + a32 * a32) * rnd + 0.5) | 0) / rnd;
tm.scaleZ = ((Math.sqrt(a13 * a13 + a23 * a23 + a33 * a33) * rnd + 0.5) | 0) / rnd;
a11 /= tm.scaleX;
a12 /= tm.scaleY;
a21 /= tm.scaleX;
a22 /= tm.scaleY;
if (Math.abs(angle) > min) {
tm.skewX = angle * _RAD2DEG;
a12 = 0; //unskews
if (tm.skewType !== "simple") {
tm.scaleY *= 1 / Math.cos(angle); //by default, we compensate the scale based on the skew so that the element maintains a similar proportion when skewed, so we have to alter the scaleY here accordingly to match the default (non-adjusted) skewing that CSS does (stretching more and more as it skews).
}
} else {
tm.skewX = 0;
}
/* //for testing purposes
var transform = "matrix3d(",
comma = ",",
zero = "0";
a13 /= tm.scaleZ;
a23 /= tm.scaleZ;
a31 /= tm.scaleX;
a32 /= tm.scaleY;
a33 /= tm.scaleZ;
transform += ((a11 < min && a11 > -min) ? zero : a11) + comma + ((a21 < min && a21 > -min) ? zero : a21) + comma + ((a31 < min && a31 > -min) ? zero : a31);
transform += comma + ((a41 < min && a41 > -min) ? zero : a41) + comma + ((a12 < min && a12 > -min) ? zero : a12) + comma + ((a22 < min && a22 > -min) ? zero : a22);
transform += comma + ((a32 < min && a32 > -min) ? zero : a32) + comma + ((a42 < min && a42 > -min) ? zero : a42) + comma + ((a13 < min && a13 > -min) ? zero : a13);
transform += comma + ((a23 < min && a23 > -min) ? zero : a23) + comma + ((a33 < min && a33 > -min) ? zero : a33) + comma + ((a43 < min && a43 > -min) ? zero : a43) + comma;
transform += a14 + comma + a24 + comma + a34 + comma + (tm.perspective ? (1 + (-a34 / tm.perspective)) : 1) + ")";
console.log(transform);
document.querySelector(".test").style[_transformProp] = transform;
*/
tm.perspective = a43 ? 1 / ((a43 < 0) ? -a43 : a43) : 0;
tm.x = a14;
tm.y = a24;
tm.z = a34;
if (tm.svg) {
tm.x -= tm.xOrigin - (tm.xOrigin * a11 - tm.yOrigin * a12);
tm.y -= tm.yOrigin - (tm.yOrigin * a21 - tm.xOrigin * a22);
}
} else if ((!_supports3D || parse || !m.length || tm.x !== m[4] || tm.y !== m[5] || (!tm.rotationX && !tm.rotationY))) { //sometimes a 6-element matrix is returned even when we performed 3D transforms, like if rotationX and rotationY are 180. In cases like this, we still need to honor the 3D transforms. If we just rely on the 2D info, it could affect how the data is interpreted, like scaleY might get set to -1 or rotation could get offset by 180 degrees. For example, do a TweenLite.to(element, 1, {css:{rotationX:180, rotationY:180}}) and then later, TweenLite.to(element, 1, {css:{rotationX:0}}) and without this conditional logic in place, it'd jump to a state of being unrotated when the 2nd tween starts. Then again, we need to honor the fact that the user COULD alter the transforms outside of CSSPlugin, like by manually applying new css, so we try to sense that by looking at x and y because if those changed, we know the changes were made outside CSSPlugin and we force a reinterpretation of the matrix values. Also, in Webkit browsers, if the element's "display" is "none", its calculated style value will always return empty, so if we've already recorded the values in the _gsTransform object, we'll just rely on those.
var k = (m.length >= 6),
a = k ? m[0] : 1,
b = m[1] || 0,
c = m[2] || 0,
d = k ? m[3] : 1;
tm.x = m[4] || 0;
tm.y = m[5] || 0;
scaleX = Math.sqrt(a * a + b * b);
scaleY = Math.sqrt(d * d + c * c);
rotation = (a || b) ? Math.atan2(b, a) * _RAD2DEG : tm.rotation || 0; //note: if scaleX is 0, we cannot accurately measure rotation. Same for skewX with a scaleY of 0. Therefore, we default to the previously recorded value (or zero if that doesn't exist).
skewX = (c || d) ? Math.atan2(c, d) * _RAD2DEG + rotation : tm.skewX || 0;
tm.scaleX = scaleX;
tm.scaleY = scaleY;
tm.rotation = rotation;
tm.skewX = skewX;
if (_supports3D) {
tm.rotationX = tm.rotationY = tm.z = 0;
tm.perspective = defaultTransformPerspective;
tm.scaleZ = 1;
}
if (tm.svg) {
tm.x -= tm.xOrigin - (tm.xOrigin * a + tm.yOrigin * c);
tm.y -= tm.yOrigin - (tm.xOrigin * b + tm.yOrigin * d);
}
}
if (Math.abs(tm.skewX) > 90 && Math.abs(tm.skewX) < 270) {
if (invX) {
tm.scaleX *= -1;
tm.skewX += (tm.rotation <= 0) ? 180 : -180;
tm.rotation += (tm.rotation <= 0) ? 180 : -180;
} else {
tm.scaleY *= -1;
tm.skewX += (tm.skewX <= 0) ? 180 : -180;
}
}
tm.zOrigin = zOrigin;
//some browsers have a hard time with very small values like 2.4492935982947064e-16 (notice the "e-" towards the end) and would render the object slightly off. So we round to 0 in these cases. The conditional logic here is faster than calling Math.abs(). Also, browsers tend to render a SLIGHTLY rotated object in a fuzzy way, so we need to snap to exactly 0 when appropriate.
for (i in tm) {
if (tm[i] < min) if (tm[i] > -min) {
tm[i] = 0;
}
}
}
//DEBUG: _log("parsed rotation of " + t.getAttribute("id")+": "+(tm.rotationX)+", "+(tm.rotationY)+", "+(tm.rotation)+", scale: "+tm.scaleX+", "+tm.scaleY+", "+tm.scaleZ+", position: "+tm.x+", "+tm.y+", "+tm.z+", perspective: "+tm.perspective+ ", origin: "+ tm.xOrigin+ ","+ tm.yOrigin);
if (rec) {
t._gsTransform = tm; //record to the object's _gsTransform which we use so that tweens can control individual properties independently (we need all the properties to accurately recompose the matrix in the setRatio() method)
if (tm.svg) { //if we're supposed to apply transforms to the SVG element's "transform" attribute, make sure there aren't any CSS transforms applied or they'll override the attribute ones. Also clear the transform attribute if we're using CSS, just to be clean.
if (_useSVGTransformAttr && t.style[_transformProp]) {
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].delayedCall(0.001, function(){ //if we apply this right away (before anything has rendered), we risk there being no transforms for a brief moment and it also interferes with adjusting the transformOrigin in a tween with immediateRender:true (it'd try reading the matrix and it wouldn't have the appropriate data in place because we just removed it).
_removeProp(t.style, _transformProp);
});
} else if (!_useSVGTransformAttr && t.getAttribute("transform")) {
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].delayedCall(0.001, function(){
t.removeAttribute("transform");
});
}
}
}
return tm;
},
//for setting 2D transforms in IE6, IE7, and IE8 (must use a "filter" to emulate the behavior of modern day browser transforms)
_setIETransformRatio = function(v) {
var t = this.data, //refers to the element's _gsTransform object
ang = -t.rotation * _DEG2RAD,
skew = ang + t.skewX * _DEG2RAD,
rnd = 100000,
a = ((Math.cos(ang) * t.scaleX * rnd) | 0) / rnd,
b = ((Math.sin(ang) * t.scaleX * rnd) | 0) / rnd,
c = ((Math.sin(skew) * -t.scaleY * rnd) | 0) / rnd,
d = ((Math.cos(skew) * t.scaleY * rnd) | 0) / rnd,
style = this.t.style,
cs = this.t.currentStyle,
filters, val;
if (!cs) {
return;
}
val = b; //just for swapping the variables an inverting them (reused "val" to avoid creating another variable in memory). IE's filter matrix uses a non-standard matrix configuration (angle goes the opposite way, and b and c are reversed and inverted)
b = -c;
c = -val;
filters = cs.filter;
style.filter = ""; //remove filters so that we can accurately measure offsetWidth/offsetHeight
var w = this.t.offsetWidth,
h = this.t.offsetHeight,
clip = (cs.position !== "absolute"),
m = "progid:DXImageTransform.Microsoft.Matrix(M11=" + a + ", M12=" + b + ", M21=" + c + ", M22=" + d,
ox = t.x + (w * t.xPercent / 100),
oy = t.y + (h * t.yPercent / 100),
dx, dy;
//if transformOrigin is being used, adjust the offset x and y
if (t.ox != null) {
dx = ((t.oxp) ? w * t.ox * 0.01 : t.ox) - w / 2;
dy = ((t.oyp) ? h * t.oy * 0.01 : t.oy) - h / 2;
ox += dx - (dx * a + dy * b);
oy += dy - (dx * c + dy * d);
}
if (!clip) {
m += ", sizingMethod='auto expand')";
} else {
dx = (w / 2);
dy = (h / 2);
//translate to ensure that transformations occur around the correct origin (default is center).
m += ", Dx=" + (dx - (dx * a + dy * b) + ox) + ", Dy=" + (dy - (dx * c + dy * d) + oy) + ")";
}
if (filters.indexOf("DXImageTransform.Microsoft.Matrix(") !== -1) {
style.filter = filters.replace(_ieSetMatrixExp, m);
} else {
style.filter = m + " " + filters; //we must always put the transform/matrix FIRST (before alpha(opacity=xx)) to avoid an IE bug that slices part of the object when rotation is applied with alpha.
}
//at the end or beginning of the tween, if the matrix is normal (1, 0, 0, 1) and opacity is 100 (or doesn't exist), remove the filter to improve browser performance.
if (v === 0 || v === 1) if (a === 1) if (b === 0) if (c === 0) if (d === 1) if (!clip || m.indexOf("Dx=0, Dy=0") !== -1) if (!_opacityExp.test(filters) || parseFloat(RegExp.$1) === 100) if (filters.indexOf("gradient(" && filters.indexOf("Alpha")) === -1) {
style.removeAttribute("filter");
}
//we must set the margins AFTER applying the filter in order to avoid some bugs in IE8 that could (in rare scenarios) cause them to be ignored intermittently (vibration).
if (!clip) {
var mult = (_ieVers < 8) ? 1 : -1, //in Internet Explorer 7 and before, the box model is broken, causing the browser to treat the width/height of the actual rotated filtered image as the width/height of the box itself, but Microsoft corrected that in IE8. We must use a negative offset in IE8 on the right/bottom
marg, prop, dif;
dx = t.ieOffsetX || 0;
dy = t.ieOffsetY || 0;
t.ieOffsetX = Math.round((w - ((a < 0 ? -a : a) * w + (b < 0 ? -b : b) * h)) / 2 + ox);
t.ieOffsetY = Math.round((h - ((d < 0 ? -d : d) * h + (c < 0 ? -c : c) * w)) / 2 + oy);
for (i = 0; i < 4; i++) {
prop = _margins[i];
marg = cs[prop];
//we need to get the current margin in case it is being tweened separately (we want to respect that tween's changes)
val = (marg.indexOf("px") !== -1) ? parseFloat(marg) : _convertToPixels(this.t, prop, parseFloat(marg), marg.replace(_suffixExp, "")) || 0;
if (val !== t[prop]) {
dif = (i < 2) ? -t.ieOffsetX : -t.ieOffsetY; //if another tween is controlling a margin, we cannot only apply the difference in the ieOffsets, so we essentially zero-out the dx and dy here in that case. We record the margin(s) later so that we can keep comparing them, making this code very flexible.
} else {
dif = (i < 2) ? dx - t.ieOffsetX : dy - t.ieOffsetY;
}
style[prop] = (t[prop] = Math.round( val - dif * ((i === 0 || i === 2) ? 1 : mult) )) + "px";
}
}
},
/* translates a super small decimal to a string WITHOUT scientific notation
_safeDecimal = function(n) {
var s = (n < 0 ? -n : n) + "",
a = s.split("e-");
return (n < 0 ? "-0." : "0.") + new Array(parseInt(a[1], 10) || 0).join("0") + a[0].split(".").join("");
},
*/
_setTransformRatio = _internals.set3DTransformRatio = _internals.setTransformRatio = function(v) {
var t = this.data, //refers to the element's _gsTransform object
style = this.t.style,
angle = t.rotation,
rotationX = t.rotationX,
rotationY = t.rotationY,
sx = t.scaleX,
sy = t.scaleY,
sz = t.scaleZ,
x = t.x,
y = t.y,
z = t.z,
isSVG = t.svg,
perspective = t.perspective,
force3D = t.force3D,
skewY = t.skewY,
skewX = t.skewX,
t1, a11, a12, a13, a21, a22, a23, a31, a32, a33, a41, a42, a43,
zOrigin, min, cos, sin, t2, transform, comma, zero, skew, rnd;
if (skewY) { //for performance reasons, we combine all skewing into the skewX and rotation values. Remember, a skewY of 10 degrees looks the same as a rotation of 10 degrees plus a skewX of 10 degrees.
skewX += skewY;
angle += skewY;
}
//check to see if we should render as 2D (and SVGs must use 2D when _useSVGTransformAttr is true)
if (((((v === 1 || v === 0) && force3D === "auto" && (this.tween._totalTime === this.tween._totalDuration || !this.tween._totalTime)) || !force3D) && !z && !perspective && !rotationY && !rotationX && sz === 1) || (_useSVGTransformAttr && isSVG) || !_supports3D) { //on the final render (which could be 0 for a from tween), if there are no 3D aspects, render in 2D to free up memory and improve performance especially on mobile devices. Check the tween's totalTime/totalDuration too in order to make sure it doesn't happen between repeats if it's a repeating tween.
//2D
if (angle || skewX || isSVG) {
angle *= _DEG2RAD;
skew = skewX * _DEG2RAD;
rnd = 100000;
a11 = Math.cos(angle) * sx;
a21 = Math.sin(angle) * sx;
a12 = Math.sin(angle - skew) * -sy;
a22 = Math.cos(angle - skew) * sy;
if (skew && t.skewType === "simple") { //by default, we compensate skewing on the other axis to make it look more natural, but you can set the skewType to "simple" to use the uncompensated skewing that CSS does
t1 = Math.tan(skew - skewY * _DEG2RAD);
t1 = Math.sqrt(1 + t1 * t1);
a12 *= t1;
a22 *= t1;
if (skewY) {
t1 = Math.tan(skewY * _DEG2RAD);
t1 = Math.sqrt(1 + t1 * t1);
a11 *= t1;
a21 *= t1;
}
}
if (isSVG) {
x += t.xOrigin - (t.xOrigin * a11 + t.yOrigin * a12) + t.xOffset;
y += t.yOrigin - (t.xOrigin * a21 + t.yOrigin * a22) + t.yOffset;
if (_useSVGTransformAttr && (t.xPercent || t.yPercent)) { //The SVG spec doesn't support percentage-based translation in the "transform" attribute, so we merge it into the matrix to simulate it.
min = this.t.getBBox();
x += t.xPercent * 0.01 * min.width;
y += t.yPercent * 0.01 * min.height;
}
min = 0.000001;
if (x < min) if (x > -min) {
x = 0;
}
if (y < min) if (y > -min) {
y = 0;
}
}
transform = (((a11 * rnd) | 0) / rnd) + "," + (((a21 * rnd) | 0) / rnd) + "," + (((a12 * rnd) | 0) / rnd) + "," + (((a22 * rnd) | 0) / rnd) + "," + x + "," + y + ")";
if (isSVG && _useSVGTransformAttr) {
this.t.setAttribute("transform", "matrix(" + transform);
} else {
//some browsers have a hard time with very small values like 2.4492935982947064e-16 (notice the "e-" towards the end) and would render the object slightly off. So we round to 5 decimal places.
style[_transformProp] = ((t.xPercent || t.yPercent) ? "translate(" + t.xPercent + "%," + t.yPercent + "%) matrix(" : "matrix(") + transform;
}
} else {
style[_transformProp] = ((t.xPercent || t.yPercent) ? "translate(" + t.xPercent + "%," + t.yPercent + "%) matrix(" : "matrix(") + sx + ",0,0," + sy + "," + x + "," + y + ")";
}
return;
}
if (_isFirefox) { //Firefox has a bug (at least in v25) that causes it to render the transparent part of 32-bit PNG images as black when displayed inside an iframe and the 3D scale is very small and doesn't change sufficiently enough between renders (like if you use a Power4.easeInOut to scale from 0 to 1 where the beginning values only change a tiny amount to begin the tween before accelerating). In this case, we force the scale to be 0.00002 instead which is visually the same but works around the Firefox issue.
min = 0.0001;
if (sx < min && sx > -min) {
sx = sz = 0.00002;
}
if (sy < min && sy > -min) {
sy = sz = 0.00002;
}
if (perspective && !t.z && !t.rotationX && !t.rotationY) { //Firefox has a bug that causes elements to have an odd super-thin, broken/dotted black border on elements that have a perspective set but aren't utilizing 3D space (no rotationX, rotationY, or z).
perspective = 0;
}
}
if (angle || skewX) {
angle *= _DEG2RAD;
cos = a11 = Math.cos(angle);
sin = a21 = Math.sin(angle);
if (skewX) {
angle -= skewX * _DEG2RAD;
cos = Math.cos(angle);
sin = Math.sin(angle);
if (t.skewType === "simple") { //by default, we compensate skewing on the other axis to make it look more natural, but you can set the skewType to "simple" to use the uncompensated skewing that CSS does
t1 = Math.tan((skewX - skewY) * _DEG2RAD);
t1 = Math.sqrt(1 + t1 * t1);
cos *= t1;
sin *= t1;
if (t.skewY) {
t1 = Math.tan(skewY * _DEG2RAD);
t1 = Math.sqrt(1 + t1 * t1);
a11 *= t1;
a21 *= t1;
}
}
}
a12 = -sin;
a22 = cos;
} else if (!rotationY && !rotationX && sz === 1 && !perspective && !isSVG) { //if we're only translating and/or 2D scaling, this is faster...
style[_transformProp] = ((t.xPercent || t.yPercent) ? "translate(" + t.xPercent + "%," + t.yPercent + "%) translate3d(" : "translate3d(") + x + "px," + y + "px," + z +"px)" + ((sx !== 1 || sy !== 1) ? " scale(" + sx + "," + sy + ")" : "");
return;
} else {
a11 = a22 = 1;
a12 = a21 = 0;
}
// KEY INDEX AFFECTS a[row][column]
// a11 0 rotation, rotationY, scaleX
// a21 1 rotation, rotationY, scaleX
// a31 2 rotationY, scaleX
// a41 3 rotationY, scaleX
// a12 4 rotation, skewX, rotationX, scaleY
// a22 5 rotation, skewX, rotationX, scaleY
// a32 6 rotationX, scaleY
// a42 7 rotationX, scaleY
// a13 8 rotationY, rotationX, scaleZ
// a23 9 rotationY, rotationX, scaleZ
// a33 10 rotationY, rotationX, scaleZ
// a43 11 rotationY, rotationX, perspective, scaleZ
// a14 12 x, zOrigin, svgOrigin
// a24 13 y, zOrigin, svgOrigin
// a34 14 z, zOrigin
// a44 15
// rotation: Math.atan2(a21, a11)
// rotationY: Math.atan2(a13, a33) (or Math.atan2(a13, a11))
// rotationX: Math.atan2(a32, a33)
a33 = 1;
a13 = a23 = a31 = a32 = a41 = a42 = 0;
a43 = (perspective) ? -1 / perspective : 0;
zOrigin = t.zOrigin;
min = 0.000001; //threshold below which browsers use scientific notation which won't work.
comma = ",";
zero = "0";
angle = rotationY * _DEG2RAD;
if (angle) {
cos = Math.cos(angle);
sin = Math.sin(angle);
a31 = -sin;
a41 = a43*-sin;
a13 = a11*sin;
a23 = a21*sin;
a33 = cos;
a43 *= cos;
a11 *= cos;
a21 *= cos;
}
angle = rotationX * _DEG2RAD;
if (angle) {
cos = Math.cos(angle);
sin = Math.sin(angle);
t1 = a12*cos+a13*sin;
t2 = a22*cos+a23*sin;
a32 = a33*sin;
a42 = a43*sin;
a13 = a12*-sin+a13*cos;
a23 = a22*-sin+a23*cos;
a33 = a33*cos;
a43 = a43*cos;
a12 = t1;
a22 = t2;
}
if (sz !== 1) {
a13*=sz;
a23*=sz;
a33*=sz;
a43*=sz;
}
if (sy !== 1) {
a12*=sy;
a22*=sy;
a32*=sy;
a42*=sy;
}
if (sx !== 1) {
a11*=sx;
a21*=sx;
a31*=sx;
a41*=sx;
}
if (zOrigin || isSVG) {
if (zOrigin) {
x += a13*-zOrigin;
y += a23*-zOrigin;
z += a33*-zOrigin+zOrigin;
}
if (isSVG) { //due to bugs in some browsers, we need to manage the transform-origin of SVG manually
x += t.xOrigin - (t.xOrigin * a11 + t.yOrigin * a12) + t.xOffset;
y += t.yOrigin - (t.xOrigin * a21 + t.yOrigin * a22) + t.yOffset;
}
if (x < min && x > -min) {
x = zero;
}
if (y < min && y > -min) {
y = zero;
}
if (z < min && z > -min) {
z = 0; //don't use string because we calculate perspective later and need the number.
}
}
//optimized way of concatenating all the values into a string. If we do it all in one shot, it's slower because of the way browsers have to create temp strings and the way it affects memory. If we do it piece-by-piece with +=, it's a bit slower too. We found that doing it in these sized chunks works best overall:
transform = ((t.xPercent || t.yPercent) ? "translate(" + t.xPercent + "%," + t.yPercent + "%) matrix3d(" : "matrix3d(");
transform += ((a11 < min && a11 > -min) ? zero : a11) + comma + ((a21 < min && a21 > -min) ? zero : a21) + comma + ((a31 < min && a31 > -min) ? zero : a31);
transform += comma + ((a41 < min && a41 > -min) ? zero : a41) + comma + ((a12 < min && a12 > -min) ? zero : a12) + comma + ((a22 < min && a22 > -min) ? zero : a22);
if (rotationX || rotationY || sz !== 1) { //performance optimization (often there's no rotationX or rotationY, so we can skip these calculations)
transform += comma + ((a32 < min && a32 > -min) ? zero : a32) + comma + ((a42 < min && a42 > -min) ? zero : a42) + comma + ((a13 < min && a13 > -min) ? zero : a13);
transform += comma + ((a23 < min && a23 > -min) ? zero : a23) + comma + ((a33 < min && a33 > -min) ? zero : a33) + comma + ((a43 < min && a43 > -min) ? zero : a43) + comma;
} else {
transform += ",0,0,0,0,1,0,";
}
transform += x + comma + y + comma + z + comma + (perspective ? (1 + (-z / perspective)) : 1) + ")";
style[_transformProp] = transform;
};
p = Transform.prototype;
p.x = p.y = p.z = p.skewX = p.skewY = p.rotation = p.rotationX = p.rotationY = p.zOrigin = p.xPercent = p.yPercent = p.xOffset = p.yOffset = 0;
p.scaleX = p.scaleY = p.scaleZ = 1;
_registerComplexSpecialProp("transform,scale,scaleX,scaleY,scaleZ,x,y,z,rotation,rotationX,rotationY,rotationZ,skewX,skewY,shortRotation,shortRotationX,shortRotationY,shortRotationZ,transformOrigin,svgOrigin,transformPerspective,directionalRotation,parseTransform,force3D,skewType,xPercent,yPercent,smoothOrigin", {parser:function(t, e, parsingProp, cssp, pt, plugin, vars) {
if (cssp._lastParsedTransform === vars) { return pt; } //only need to parse the transform once, and only if the browser supports it.
cssp._lastParsedTransform = vars;
var scaleFunc = (vars.scale && typeof(vars.scale) === "function") ? vars.scale : 0; //if there's a function-based "scale" value, swap in the resulting numeric value temporarily. Otherwise, if it's called for both scaleX and scaleY independently, they may not match (like if the function uses Math.random()).
if (scaleFunc) {
vars.scale = scaleFunc(_index, t);
}
var originalGSTransform = t._gsTransform,
style = t.style,
min = 0.000001,
i = _transformProps.length,
v = vars,
endRotations = {},
transformOriginString = "transformOrigin",
m1 = _getTransform(t, _cs, true, v.parseTransform),
orig = v.transform && ((typeof(v.transform) === "function") ? v.transform(_index, _target) : v.transform),
m2, copy, has3D, hasChange, dr, x, y, matrix, p;
m1.skewType = v.skewType || m1.skewType || CSSPlugin.defaultSkewType;
cssp._transform = m1;
if ("rotationZ" in v) {
v.rotation = v.rotationZ;
}
if (orig && typeof(orig) === "string" && _transformProp) { //for values like transform:"rotate(60deg) scale(0.5, 0.8)"
copy = _tempDiv.style; //don't use the original target because it might be SVG in which case some browsers don't report computed style correctly.
copy[_transformProp] = orig;
copy.display = "block"; //if display is "none", the browser often refuses to report the transform properties correctly.
copy.position = "absolute";
if (orig.indexOf("%") !== -1) { //%-based translations will fail unless we set the width/height to match the original target...
copy.width = _getStyle(t, "width");
copy.height = _getStyle(t, "height");
}
_doc.body.appendChild(_tempDiv);
m2 = _getTransform(_tempDiv, null, false);
if (m1.skewType === "simple") { //the default _getTransform() reports the skewX/scaleY as if skewType is "compensated", thus we need to adjust that here if skewType is "simple".
m2.scaleY *= Math.cos(m2.skewX * _DEG2RAD);
}
if (m1.svg) { //if it's an SVG element, x/y part of the matrix will be affected by whatever we use as the origin and the offsets, so compensate here...
x = m1.xOrigin;
y = m1.yOrigin;
m2.x -= m1.xOffset;
m2.y -= m1.yOffset;
if (v.transformOrigin || v.svgOrigin) { //if this tween is altering the origin, we must factor that in here. The actual work of recording the transformOrigin values and setting up the PropTween is done later (still inside this function) so we cannot leave the changes intact here - we only want to update the x/y accordingly.
orig = {};
_parseSVGOrigin(t, _parsePosition(v.transformOrigin), orig, v.svgOrigin, v.smoothOrigin, true);
x = orig.xOrigin;
y = orig.yOrigin;
m2.x -= orig.xOffset - m1.xOffset;
m2.y -= orig.yOffset - m1.yOffset;
}
if (x || y) {
matrix = _getMatrix(_tempDiv, true);
m2.x -= x - (x * matrix[0] + y * matrix[2]);
m2.y -= y - (x * matrix[1] + y * matrix[3]);
}
}
_doc.body.removeChild(_tempDiv);
if (!m2.perspective) {
m2.perspective = m1.perspective; //tweening to no perspective gives very unintuitive results - just keep the same perspective in that case.
}
if (v.xPercent != null) {
m2.xPercent = _parseVal(v.xPercent, m1.xPercent);
}
if (v.yPercent != null) {
m2.yPercent = _parseVal(v.yPercent, m1.yPercent);
}
} else if (typeof(v) === "object") { //for values like scaleX, scaleY, rotation, x, y, skewX, and skewY or transform:{...} (object)
m2 = {scaleX:_parseVal((v.scaleX != null) ? v.scaleX : v.scale, m1.scaleX),
scaleY:_parseVal((v.scaleY != null) ? v.scaleY : v.scale, m1.scaleY),
scaleZ:_parseVal(v.scaleZ, m1.scaleZ),
x:_parseVal(v.x, m1.x),
y:_parseVal(v.y, m1.y),
z:_parseVal(v.z, m1.z),
xPercent:_parseVal(v.xPercent, m1.xPercent),
yPercent:_parseVal(v.yPercent, m1.yPercent),
perspective:_parseVal(v.transformPerspective, m1.perspective)};
dr = v.directionalRotation;
if (dr != null) {
if (typeof(dr) === "object") {
for (copy in dr) {
v[copy] = dr[copy];
}
} else {
v.rotation = dr;
}
}
if (typeof(v.x) === "string" && v.x.indexOf("%") !== -1) {
m2.x = 0;
m2.xPercent = _parseVal(v.x, m1.xPercent);
}
if (typeof(v.y) === "string" && v.y.indexOf("%") !== -1) {
m2.y = 0;
m2.yPercent = _parseVal(v.y, m1.yPercent);
}
m2.rotation = _parseAngle(("rotation" in v) ? v.rotation : ("shortRotation" in v) ? v.shortRotation + "_short" : m1.rotation, m1.rotation, "rotation", endRotations);
if (_supports3D) {
m2.rotationX = _parseAngle(("rotationX" in v) ? v.rotationX : ("shortRotationX" in v) ? v.shortRotationX + "_short" : m1.rotationX || 0, m1.rotationX, "rotationX", endRotations);
m2.rotationY = _parseAngle(("rotationY" in v) ? v.rotationY : ("shortRotationY" in v) ? v.shortRotationY + "_short" : m1.rotationY || 0, m1.rotationY, "rotationY", endRotations);
}
m2.skewX = _parseAngle(v.skewX, m1.skewX);
m2.skewY = _parseAngle(v.skewY, m1.skewY);
}
if (_supports3D && v.force3D != null) {
m1.force3D = v.force3D;
hasChange = true;
}
has3D = (m1.force3D || m1.z || m1.rotationX || m1.rotationY || m2.z || m2.rotationX || m2.rotationY || m2.perspective);
if (!has3D && v.scale != null) {
m2.scaleZ = 1; //no need to tween scaleZ.
}
while (--i > -1) {
p = _transformProps[i];
orig = m2[p] - m1[p];
if (orig > min || orig < -min || v[p] != null || _forcePT[p] != null) {
hasChange = true;
pt = new CSSPropTween(m1, p, m1[p], orig, pt);
if (p in endRotations) {
pt.e = endRotations[p]; //directional rotations typically have compensated values during the tween, but we need to make sure they end at exactly what the user requested
}
pt.xs0 = 0; //ensures the value stays numeric in setRatio()
pt.plugin = plugin;
cssp._overwriteProps.push(pt.n);
}
}
orig = (typeof(v.transformOrigin) === "function") ? v.transformOrigin(_index, _target) : v.transformOrigin;
if (m1.svg && (orig || v.svgOrigin)) {
x = m1.xOffset; //when we change the origin, in order to prevent things from jumping we adjust the x/y so we must record those here so that we can create PropTweens for them and flip them at the same time as the origin
y = m1.yOffset;
_parseSVGOrigin(t, _parsePosition(orig), m2, v.svgOrigin, v.smoothOrigin);
pt = _addNonTweeningNumericPT(m1, "xOrigin", (originalGSTransform ? m1 : m2).xOrigin, m2.xOrigin, pt, transformOriginString); //note: if there wasn't a transformOrigin defined yet, just start with the destination one; it's wasteful otherwise, and it causes problems with fromTo() tweens. For example, TweenLite.to("#wheel", 3, {rotation:180, transformOrigin:"50% 50%", delay:1}); TweenLite.fromTo("#wheel", 3, {scale:0.5, transformOrigin:"50% 50%"}, {scale:1, delay:2}); would cause a jump when the from values revert at the beginning of the 2nd tween.
pt = _addNonTweeningNumericPT(m1, "yOrigin", (originalGSTransform ? m1 : m2).yOrigin, m2.yOrigin, pt, transformOriginString);
if (x !== m1.xOffset || y !== m1.yOffset) {
pt = _addNonTweeningNumericPT(m1, "xOffset", (originalGSTransform ? x : m1.xOffset), m1.xOffset, pt, transformOriginString);
pt = _addNonTweeningNumericPT(m1, "yOffset", (originalGSTransform ? y : m1.yOffset), m1.yOffset, pt, transformOriginString);
}
orig = "0px 0px"; //certain browsers (like firefox) completely botch transform-origin, so we must remove it to prevent it from contaminating transforms. We manage it ourselves with xOrigin and yOrigin
}
if (orig || (_supports3D && has3D && m1.zOrigin)) { //if anything 3D is happening and there's a transformOrigin with a z component that's non-zero, we must ensure that the transformOrigin's z-component is set to 0 so that we can manually do those calculations to get around Safari bugs. Even if the user didn't specifically define a "transformOrigin" in this particular tween (maybe they did it via css directly).
if (_transformProp) {
hasChange = true;
p = _transformOriginProp;
if (!orig) {
orig = (_getStyle(t, p, _cs, false, "50% 50%") + "").split(" ");
orig = orig[0] + " " + orig[1] + " " + m1.zOrigin + "px";
}
orig += "";
pt = new CSSPropTween(style, p, 0, 0, pt, -1, transformOriginString);
pt.b = style[p];
pt.plugin = plugin;
if (_supports3D) {
copy = m1.zOrigin;
orig = orig.split(" ");
m1.zOrigin = ((orig.length > 2) ? parseFloat(orig[2]) : copy) || 0; //Safari doesn't handle the z part of transformOrigin correctly, so we'll manually handle it in the _set3DTransformRatio() method.
pt.xs0 = pt.e = orig[0] + " " + (orig[1] || "50%") + " 0px"; //we must define a z value of 0px specifically otherwise iOS 5 Safari will stick with the old one (if one was defined)!
pt = new CSSPropTween(m1, "zOrigin", 0, 0, pt, -1, pt.n); //we must create a CSSPropTween for the _gsTransform.zOrigin so that it gets reset properly at the beginning if the tween runs backward (as opposed to just setting m1.zOrigin here)
pt.b = copy;
pt.xs0 = pt.e = m1.zOrigin;
} else {
pt.xs0 = pt.e = orig;
}
//for older versions of IE (6-8), we need to manually calculate things inside the setRatio() function. We record origin x and y (ox and oy) and whether or not the values are percentages (oxp and oyp).
} else {
_parsePosition(orig + "", m1);
}
}
if (hasChange) {
cssp._transformType = (!(m1.svg && _useSVGTransformAttr) && (has3D || this._transformType === 3)) ? 3 : 2; //quicker than calling cssp._enableTransforms();
}
if (scaleFunc) {
vars.scale = scaleFunc;
}
return pt;
}, allowFunc:true, prefix:true});
_registerComplexSpecialProp("boxShadow", {defaultValue:"0px 0px 0px 0px #999", prefix:true, color:true, multi:true, keyword:"inset"});
_registerComplexSpecialProp("clipPath", {defaultValue:"inset(0px)", prefix:true, multi:true, formatter:_getFormatter("inset(0px 0px 0px 0px)", false, true)});
_registerComplexSpecialProp("borderRadius", {defaultValue:"0px", parser:function(t, e, p, cssp, pt, plugin) {
e = this.format(e);
var props = ["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"],
style = t.style,
ea1, i, es2, bs2, bs, es, bn, en, w, h, esfx, bsfx, rel, hn, vn, em;
w = parseFloat(t.offsetWidth);
h = parseFloat(t.offsetHeight);
ea1 = e.split(" ");
for (i = 0; i < props.length; i++) { //if we're dealing with percentages, we must convert things separately for the horizontal and vertical axis!
if (this.p.indexOf("border")) { //older browsers used a prefix
props[i] = _checkPropPrefix(props[i]);
}
bs = bs2 = _getStyle(t, props[i], _cs, false, "0px");
if (bs.indexOf(" ") !== -1) {
bs2 = bs.split(" ");
bs = bs2[0];
bs2 = bs2[1];
}
es = es2 = ea1[i];
bn = parseFloat(bs);
bsfx = bs.substr((bn + "").length);
rel = (es.charAt(1) === "=");
if (rel) {
en = parseInt(es.charAt(0)+"1", 10);
es = es.substr(2);
en *= parseFloat(es);
esfx = es.substr((en + "").length - (en < 0 ? 1 : 0)) || "";
} else {
en = parseFloat(es);
esfx = es.substr((en + "").length);
}
if (esfx === "") {
esfx = _suffixMap[p] || bsfx;
}
if (esfx !== bsfx) {
hn = _convertToPixels(t, "borderLeft", bn, bsfx); //horizontal number (we use a bogus "borderLeft" property just because the _convertToPixels() method searches for the keywords "Left", "Right", "Top", and "Bottom" to determine of it's a horizontal or vertical property, and we need "border" in the name so that it knows it should measure relative to the element itself, not its parent.
vn = _convertToPixels(t, "borderTop", bn, bsfx); //vertical number
if (esfx === "%") {
bs = (hn / w * 100) + "%";
bs2 = (vn / h * 100) + "%";
} else if (esfx === "em") {
em = _convertToPixels(t, "borderLeft", 1, "em");
bs = (hn / em) + "em";
bs2 = (vn / em) + "em";
} else {
bs = hn + "px";
bs2 = vn + "px";
}
if (rel) {
es = (parseFloat(bs) + en) + esfx;
es2 = (parseFloat(bs2) + en) + esfx;
}
}
pt = _parseComplex(style, props[i], bs + " " + bs2, es + " " + es2, false, "0px", pt);
}
return pt;
}, prefix:true, formatter:_getFormatter("0px 0px 0px 0px", false, true)});
_registerComplexSpecialProp("borderBottomLeftRadius,borderBottomRightRadius,borderTopLeftRadius,borderTopRightRadius", {defaultValue:"0px", parser:function(t, e, p, cssp, pt, plugin) {
return _parseComplex(t.style, p, this.format(_getStyle(t, p, _cs, false, "0px 0px")), this.format(e), false, "0px", pt);
}, prefix:true, formatter:_getFormatter("0px 0px", false, true)});
_registerComplexSpecialProp("backgroundPosition", {defaultValue:"0 0", parser:function(t, e, p, cssp, pt, plugin) {
var bp = "background-position",
cs = (_cs || _getComputedStyle(t, null)),
bs = this.format( ((cs) ? _ieVers ? cs.getPropertyValue(bp + "-x") + " " + cs.getPropertyValue(bp + "-y") : cs.getPropertyValue(bp) : t.currentStyle.backgroundPositionX + " " + t.currentStyle.backgroundPositionY) || "0 0"), //Internet Explorer doesn't report background-position correctly - we must query background-position-x and background-position-y and combine them (even in IE10). Before IE9, we must do the same with the currentStyle object and use camelCase
es = this.format(e),
ba, ea, i, pct, overlap, src;
if ((bs.indexOf("%") !== -1) !== (es.indexOf("%") !== -1) && es.split(",").length < 2) {
src = _getStyle(t, "backgroundImage").replace(_urlExp, "");
if (src && src !== "none") {
ba = bs.split(" ");
ea = es.split(" ");
_tempImg.setAttribute("src", src); //set the temp IMG's src to the background-image so that we can measure its width/height
i = 2;
while (--i > -1) {
bs = ba[i];
pct = (bs.indexOf("%") !== -1);
if (pct !== (ea[i].indexOf("%") !== -1)) {
overlap = (i === 0) ? t.offsetWidth - _tempImg.width : t.offsetHeight - _tempImg.height;
ba[i] = pct ? (parseFloat(bs) / 100 * overlap) + "px" : (parseFloat(bs) / overlap * 100) + "%";
}
}
bs = ba.join(" ");
}
}
return this.parseComplex(t.style, bs, es, pt, plugin);
}, formatter:_parsePosition});
_registerComplexSpecialProp("backgroundSize", {defaultValue:"0 0", formatter:function(v) {
v += ""; //ensure it's a string
return (v.substr(0,2) === "co") ? v : _parsePosition(v.indexOf(" ") === -1 ? v + " " + v : v); //if set to something like "100% 100%", Safari typically reports the computed style as just "100%" (no 2nd value), but we should ensure that there are two values, so copy the first one. Otherwise, it'd be interpreted as "100% 0" (wrong). Also remember that it could be "cover" or "contain" which we can't tween but should be able to set.
}});
_registerComplexSpecialProp("perspective", {defaultValue:"0px", prefix:true});
_registerComplexSpecialProp("perspectiveOrigin", {defaultValue:"50% 50%", prefix:true});
_registerComplexSpecialProp("transformStyle", {prefix:true});
_registerComplexSpecialProp("backfaceVisibility", {prefix:true});
_registerComplexSpecialProp("userSelect", {prefix:true});
_registerComplexSpecialProp("margin", {parser:_getEdgeParser("marginTop,marginRight,marginBottom,marginLeft")});
_registerComplexSpecialProp("padding", {parser:_getEdgeParser("paddingTop,paddingRight,paddingBottom,paddingLeft")});
_registerComplexSpecialProp("clip", {defaultValue:"rect(0px,0px,0px,0px)", parser:function(t, e, p, cssp, pt, plugin){
var b, cs, delim;
if (_ieVers < 9) { //IE8 and earlier don't report a "clip" value in the currentStyle - instead, the values are split apart into clipTop, clipRight, clipBottom, and clipLeft. Also, in IE7 and earlier, the values inside rect() are space-delimited, not comma-delimited.
cs = t.currentStyle;
delim = _ieVers < 8 ? " " : ",";
b = "rect(" + cs.clipTop + delim + cs.clipRight + delim + cs.clipBottom + delim + cs.clipLeft + ")";
e = this.format(e).split(",").join(delim);
} else {
b = this.format(_getStyle(t, this.p, _cs, false, this.dflt));
e = this.format(e);
}
return this.parseComplex(t.style, b, e, pt, plugin);
}});
_registerComplexSpecialProp("textShadow", {defaultValue:"0px 0px 0px #999", color:true, multi:true});
_registerComplexSpecialProp("autoRound,strictUnits", {parser:function(t, e, p, cssp, pt) {return pt;}}); //just so that we can ignore these properties (not tween them)
_registerComplexSpecialProp("border", {defaultValue:"0px solid #000", parser:function(t, e, p, cssp, pt, plugin) {
var bw = _getStyle(t, "borderTopWidth", _cs, false, "0px"),
end = this.format(e).split(" "),
esfx = end[0].replace(_suffixExp, "");
if (esfx !== "px") { //if we're animating to a non-px value, we need to convert the beginning width to that unit.
bw = (parseFloat(bw) / _convertToPixels(t, "borderTopWidth", 1, esfx)) + esfx;
}
return this.parseComplex(t.style, this.format(bw + " " + _getStyle(t, "borderTopStyle", _cs, false, "solid") + " " + _getStyle(t, "borderTopColor", _cs, false, "#000")), end.join(" "), pt, plugin);
}, color:true, formatter:function(v) {
var a = v.split(" ");
return a[0] + " " + (a[1] || "solid") + " " + (v.match(_colorExp) || ["#000"])[0];
}});
_registerComplexSpecialProp("borderWidth", {parser:_getEdgeParser("borderTopWidth,borderRightWidth,borderBottomWidth,borderLeftWidth")}); //Firefox doesn't pick up on borderWidth set in style sheets (only inline).
_registerComplexSpecialProp("float,cssFloat,styleFloat", {parser:function(t, e, p, cssp, pt, plugin) {
var s = t.style,
prop = ("cssFloat" in s) ? "cssFloat" : "styleFloat";
return new CSSPropTween(s, prop, 0, 0, pt, -1, p, false, 0, s[prop], e);
}});
//opacity-related
var _setIEOpacityRatio = function(v) {
var t = this.t, //refers to the element's style property
filters = t.filter || _getStyle(this.data, "filter") || "",
val = (this.s + this.c * v) | 0,
skip;
if (val === 100) { //for older versions of IE that need to use a filter to apply opacity, we should remove the filter if opacity hits 1 in order to improve performance, but make sure there isn't a transform (matrix) or gradient in the filters.
if (filters.indexOf("atrix(") === -1 && filters.indexOf("radient(") === -1 && filters.indexOf("oader(") === -1) {
t.removeAttribute("filter");
skip = (!_getStyle(this.data, "filter")); //if a class is applied that has an alpha filter, it will take effect (we don't want that), so re-apply our alpha filter in that case. We must first remove it and then check.
} else {
t.filter = filters.replace(_alphaFilterExp, "");
skip = true;
}
}
if (!skip) {
if (this.xn1) {
t.filter = filters = filters || ("alpha(opacity=" + val + ")"); //works around bug in IE7/8 that prevents changes to "visibility" from being applied properly if the filter is changed to a different alpha on the same frame.
}
if (filters.indexOf("pacity") === -1) { //only used if browser doesn't support the standard opacity style property (IE 7 and 8). We omit the "O" to avoid case-sensitivity issues
if (val !== 0 || !this.xn1) { //bugs in IE7/8 won't render the filter properly if opacity is ADDED on the same frame/render as "visibility" changes (this.xn1 is 1 if this tween is an "autoAlpha" tween)
t.filter = filters + " alpha(opacity=" + val + ")"; //we round the value because otherwise, bugs in IE7/8 can prevent "visibility" changes from being applied properly.
}
} else {
t.filter = filters.replace(_opacityExp, "opacity=" + val);
}
}
};
_registerComplexSpecialProp("opacity,alpha,autoAlpha", {defaultValue:"1", parser:function(t, e, p, cssp, pt, plugin) {
var b = parseFloat(_getStyle(t, "opacity", _cs, false, "1")),
style = t.style,
isAutoAlpha = (p === "autoAlpha");
if (typeof(e) === "string" && e.charAt(1) === "=") {
e = ((e.charAt(0) === "-") ? -1 : 1) * parseFloat(e.substr(2)) + b;
}
if (isAutoAlpha && b === 1 && _getStyle(t, "visibility", _cs) === "hidden" && e !== 0) { //if visibility is initially set to "hidden", we should interpret that as intent to make opacity 0 (a convenience)
b = 0;
}
if (_supportsOpacity) {
pt = new CSSPropTween(style, "opacity", b, e - b, pt);
} else {
pt = new CSSPropTween(style, "opacity", b * 100, (e - b) * 100, pt);
pt.xn1 = isAutoAlpha ? 1 : 0; //we need to record whether or not this is an autoAlpha so that in the setRatio(), we know to duplicate the setting of the alpha in order to work around a bug in IE7 and IE8 that prevents changes to "visibility" from taking effect if the filter is changed to a different alpha(opacity) at the same time. Setting it to the SAME value first, then the new value works around the IE7/8 bug.
style.zoom = 1; //helps correct an IE issue.
pt.type = 2;
pt.b = "alpha(opacity=" + pt.s + ")";
pt.e = "alpha(opacity=" + (pt.s + pt.c) + ")";
pt.data = t;
pt.plugin = plugin;
pt.setRatio = _setIEOpacityRatio;
}
if (isAutoAlpha) { //we have to create the "visibility" PropTween after the opacity one in the linked list so that they run in the order that works properly in IE8 and earlier
pt = new CSSPropTween(style, "visibility", 0, 0, pt, -1, null, false, 0, ((b !== 0) ? "inherit" : "hidden"), ((e === 0) ? "hidden" : "inherit"));
pt.xs0 = "inherit";
cssp._overwriteProps.push(pt.n);
cssp._overwriteProps.push(p);
}
return pt;
}});
var _removeProp = function(s, p) {
if (p) {
if (s.removeProperty) {
if (p.substr(0,2) === "ms" || p.substr(0,6) === "webkit") { //Microsoft and some Webkit browsers don't conform to the standard of capitalizing the first prefix character, so we adjust so that when we prefix the caps with a dash, it's correct (otherwise it'd be "ms-transform" instead of "-ms-transform" for IE9, for example)
p = "-" + p;
}
s.removeProperty(p.replace(_capsExp, "-$1").toLowerCase());
} else { //note: old versions of IE use "removeAttribute()" instead of "removeProperty()"
s.removeAttribute(p);
}
}
},
_setClassNameRatio = function(v) {
this.t._gsClassPT = this;
if (v === 1 || v === 0) {
this.t.setAttribute("class", (v === 0) ? this.b : this.e);
var mpt = this.data, //first MiniPropTween
s = this.t.style;
while (mpt) {
if (!mpt.v) {
_removeProp(s, mpt.p);
} else {
s[mpt.p] = mpt.v;
}
mpt = mpt._next;
}
if (v === 1 && this.t._gsClassPT === this) {
this.t._gsClassPT = null;
}
} else if (this.t.getAttribute("class") !== this.e) {
this.t.setAttribute("class", this.e);
}
};
_registerComplexSpecialProp("className", {parser:function(t, e, p, cssp, pt, plugin, vars) {
var b = t.getAttribute("class") || "", //don't use t.className because it doesn't work consistently on SVG elements; getAttribute("class") and setAttribute("class", value") is more reliable.
cssText = t.style.cssText,
difData, bs, cnpt, cnptLookup, mpt;
pt = cssp._classNamePT = new CSSPropTween(t, p, 0, 0, pt, 2);
pt.setRatio = _setClassNameRatio;
pt.pr = -11;
_hasPriority = true;
pt.b = b;
bs = _getAllStyles(t, _cs);
//if there's a className tween already operating on the target, force it to its end so that the necessary inline styles are removed and the class name is applied before we determine the end state (we don't want inline styles interfering that were there just for class-specific values)
cnpt = t._gsClassPT;
if (cnpt) {
cnptLookup = {};
mpt = cnpt.data; //first MiniPropTween which stores the inline styles - we need to force these so that the inline styles don't contaminate things. Otherwise, there's a small chance that a tween could start and the inline values match the destination values and they never get cleaned.
while (mpt) {
cnptLookup[mpt.p] = 1;
mpt = mpt._next;
}
cnpt.setRatio(1);
}
t._gsClassPT = pt;
pt.e = (e.charAt(1) !== "=") ? e : b.replace(new RegExp("(?:\\s|^)" + e.substr(2) + "(?![\\w-])"), "") + ((e.charAt(0) === "+") ? " " + e.substr(2) : "");
t.setAttribute("class", pt.e);
difData = _cssDif(t, bs, _getAllStyles(t), vars, cnptLookup);
t.setAttribute("class", b);
pt.data = difData.firstMPT;
t.style.cssText = cssText; //we recorded cssText before we swapped classes and ran _getAllStyles() because in cases when a className tween is overwritten, we remove all the related tweening properties from that class change (otherwise class-specific stuff can't override properties we've directly set on the target's style object due to specificity).
pt = pt.xfirst = cssp.parse(t, difData.difs, pt, plugin); //we record the CSSPropTween as the xfirst so that we can handle overwriting propertly (if "className" gets overwritten, we must kill all the properties associated with the className part of the tween, so we can loop through from xfirst to the pt itself)
return pt;
}});
var _setClearPropsRatio = function(v) {
if (v === 1 || v === 0) if (this.data._totalTime === this.data._totalDuration && this.data.data !== "isFromStart") { //this.data refers to the tween. Only clear at the END of the tween (remember, from() tweens make the ratio go from 1 to 0, so we can't just check that and if the tween is the zero-duration one that's created internally to render the starting values in a from() tween, ignore that because otherwise, for example, 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).
var s = this.t.style,
transformParse = _specialProps.transform.parse,
a, p, i, clearTransform, transform;
if (this.e === "all") {
s.cssText = "";
clearTransform = true;
} else {
a = this.e.split(" ").join("").split(",");
i = a.length;
while (--i > -1) {
p = a[i];
if (_specialProps[p]) {
if (_specialProps[p].parse === transformParse) {
clearTransform = true;
} else {
p = (p === "transformOrigin") ? _transformOriginProp : _specialProps[p].p; //ensures that special properties use the proper browser-specific property name, like "scaleX" might be "-webkit-transform" or "boxShadow" might be "-moz-box-shadow"
}
}
_removeProp(s, p);
}
}
if (clearTransform) {
_removeProp(s, _transformProp);
transform = this.t._gsTransform;
if (transform) {
if (transform.svg) {
this.t.removeAttribute("data-svg-origin");
this.t.removeAttribute("transform");
}
delete this.t._gsTransform;
}
}
}
};
_registerComplexSpecialProp("clearProps", {parser:function(t, e, p, cssp, pt) {
pt = new CSSPropTween(t, p, 0, 0, pt, 2);
pt.setRatio = _setClearPropsRatio;
pt.e = e;
pt.pr = -10;
pt.data = cssp._tween;
_hasPriority = true;
return pt;
}});
p = "bezier,throwProps,physicsProps,physics2D".split(",");
i = p.length;
while (i--) {
_registerPluginProp(p[i]);
}
p = CSSPlugin.prototype;
p._firstPT = p._lastParsedTransform = p._transform = null;
//gets called when the tween renders for the first time. This kicks everything off, recording start/end values, etc.
p._onInitTween = function(target, vars, tween, index) {
if (!target.nodeType) { //css is only for dom elements
return false;
}
this._target = _target = target;
this._tween = tween;
this._vars = vars;
_index = index;
_autoRound = vars.autoRound;
_hasPriority = false;
_suffixMap = vars.suffixMap || CSSPlugin.suffixMap;
_cs = _getComputedStyle(target, "");
_overwriteProps = this._overwriteProps;
var style = target.style,
v, pt, pt2, first, last, next, zIndex, tpt, threeD;
if (_reqSafariFix) if (style.zIndex === "") {
v = _getStyle(target, "zIndex", _cs);
if (v === "auto" || v === "") {
//corrects a bug in [non-Android] Safari that prevents it from repainting elements in their new positions if they don't have a zIndex set. We also can't just apply this inside _parseTransform() because anything that's moved in any way (like using "left" or "top" instead of transforms like "x" and "y") can be affected, so it is best to ensure that anything that's tweening has a z-index. Setting "WebkitPerspective" to a non-zero value worked too except that on iOS Safari things would flicker randomly. Plus zIndex is less memory-intensive.
this._addLazySet(style, "zIndex", 0);
}
}
if (typeof(vars) === "string") {
first = style.cssText;
v = _getAllStyles(target, _cs);
style.cssText = first + ";" + vars;
v = _cssDif(target, v, _getAllStyles(target)).difs;
if (!_supportsOpacity && _opacityValExp.test(vars)) {
v.opacity = parseFloat( RegExp.$1 );
}
vars = v;
style.cssText = first;
}
if (vars.className) { //className tweens will combine any differences they find in the css with the vars that are passed in, so {className:"myClass", scale:0.5, left:20} would work.
this._firstPT = pt = _specialProps.className.parse(target, vars.className, "className", this, null, null, vars);
} else {
this._firstPT = pt = this.parse(target, vars, null);
}
if (this._transformType) {
threeD = (this._transformType === 3);
if (!_transformProp) {
style.zoom = 1; //helps correct an IE issue.
} else if (_isSafari) {
_reqSafariFix = true;
//if zIndex isn't set, iOS Safari doesn't repaint things correctly sometimes (seemingly at random).
if (style.zIndex === "") {
zIndex = _getStyle(target, "zIndex", _cs);
if (zIndex === "auto" || zIndex === "") {
this._addLazySet(style, "zIndex", 0);
}
}
//Setting WebkitBackfaceVisibility corrects 3 bugs:
// 1) [non-Android] Safari skips rendering changes to "top" and "left" that are made on the same frame/render as a transform update.
// 2) iOS Safari sometimes neglects to repaint elements in their new positions. Setting "WebkitPerspective" to a non-zero value worked too except that on iOS Safari things would flicker randomly.
// 3) Safari sometimes displayed odd artifacts when tweening the transform (or WebkitTransform) property, like ghosts of the edges of the element remained. Definitely a browser bug.
//Note: we allow the user to override the auto-setting by defining WebkitBackfaceVisibility in the vars of the tween.
if (_isSafariLT6) {
this._addLazySet(style, "WebkitBackfaceVisibility", this._vars.WebkitBackfaceVisibility || (threeD ? "visible" : "hidden"));
}
}
pt2 = pt;
while (pt2 && pt2._next) {
pt2 = pt2._next;
}
tpt = new CSSPropTween(target, "transform", 0, 0, null, 2);
this._linkCSSP(tpt, null, pt2);
tpt.setRatio = _transformProp ? _setTransformRatio : _setIETransformRatio;
tpt.data = this._transform || _getTransform(target, _cs, true);
tpt.tween = tween;
tpt.pr = -1; //ensures that the transforms get applied after the components are updated.
_overwriteProps.pop(); //we don't want to force the overwrite of all "transform" tweens of the target - we only care about individual transform properties like scaleX, rotation, etc. The CSSPropTween constructor automatically adds the property to _overwriteProps which is why we need to pop() here.
}
if (_hasPriority) {
//reorders the linked list in order of pr (priority)
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;
}
this._firstPT = first;
}
return true;
};
p.parse = function(target, vars, pt, plugin) {
var style = target.style,
p, sp, bn, en, bs, es, bsfx, esfx, isStr, rel;
for (p in vars) {
es = vars[p]; //ending value string
sp = _specialProps[p]; //SpecialProp lookup.
if (typeof(es) === "function" && !(sp && sp.allowFunc)) {
es = es(_index, _target);
}
if (sp) {
pt = sp.parse(target, es, p, this, pt, plugin, vars);
} else if (p.substr(0,2) === "--") { //for tweening CSS variables (which always start with "--"). To maximize performance and simplicity, we bypass CSSPlugin altogether and just add a normal property tween to the tween instance itself.
this._tween._propLookup[p] = this._addTween.call(this._tween, target.style, "setProperty", _getComputedStyle(target).getPropertyValue(p) + "", es + "", p, false, p);
continue;
} else {
bs = _getStyle(target, p, _cs) + "";
isStr = (typeof(es) === "string");
if (p === "color" || p === "fill" || p === "stroke" || p.indexOf("Color") !== -1 || (isStr && _rgbhslExp.test(es))) { //Opera uses background: to define color sometimes in addition to backgroundColor:
if (!isStr) {
es = _parseColor(es);
es = ((es.length > 3) ? "rgba(" : "rgb(") + es.join(",") + ")";
}
pt = _parseComplex(style, p, bs, es, true, "transparent", pt, 0, plugin);
} else if (isStr && _complexExp.test(es)) {
pt = _parseComplex(style, p, bs, es, true, null, pt, 0, plugin);
} else {
bn = parseFloat(bs);
bsfx = (bn || bn === 0) ? bs.substr((bn + "").length) : ""; //remember, bs could be non-numeric like "normal" for fontWeight, so we should default to a blank suffix in that case.
if (bs === "" || bs === "auto") {
if (p === "width" || p === "height") {
bn = _getDimension(target, p, _cs);
bsfx = "px";
} else if (p === "left" || p === "top") {
bn = _calculateOffset(target, p, _cs);
bsfx = "px";
} else {
bn = (p !== "opacity") ? 0 : 1;
bsfx = "";
}
}
rel = (isStr && es.charAt(1) === "=");
if (rel) {
en = parseInt(es.charAt(0) + "1", 10);
es = es.substr(2);
en *= parseFloat(es);
esfx = es.replace(_suffixExp, "");
} else {
en = parseFloat(es);
esfx = isStr ? es.replace(_suffixExp, "") : "";
}
if (esfx === "") {
esfx = (p in _suffixMap) ? _suffixMap[p] : bsfx; //populate the end suffix, prioritizing the map, then if none is found, use the beginning suffix.
}
es = (en || en === 0) ? (rel ? en + bn : en) + esfx : vars[p]; //ensures that any += or -= prefixes are taken care of. Record the end value before normalizing the suffix because we always want to end the tween on exactly what they intended even if it doesn't match the beginning value's suffix.
//if the beginning/ending suffixes don't match, normalize them...
if (bsfx !== esfx) if (esfx !== "" || p === "lineHeight") if (en || en === 0) if (bn) { //note: if the beginning value (bn) is 0, we don't need to convert units!
bn = _convertToPixels(target, p, bn, bsfx);
if (esfx === "%") {
bn /= _convertToPixels(target, p, 100, "%") / 100;
if (vars.strictUnits !== true) { //some browsers report only "px" values instead of allowing "%" with getComputedStyle(), so we assume that if we're tweening to a %, we should start there too unless strictUnits:true is defined. This approach is particularly useful for responsive designs that use from() tweens.
bs = bn + "%";
}
} else if (esfx === "em" || esfx === "rem" || esfx === "vw" || esfx === "vh") {
bn /= _convertToPixels(target, p, 1, esfx);
//otherwise convert to pixels.
} else if (esfx !== "px") {
en = _convertToPixels(target, p, en, esfx);
esfx = "px"; //we don't use bsfx after this, so we don't need to set it to px too.
}
if (rel) if (en || en === 0) {
es = (en + bn) + esfx; //the changes we made affect relative calculations, so adjust the end value here.
}
}
if (rel) {
en += bn;
}
if ((bn || bn === 0) && (en || en === 0)) { //faster than isNaN(). Also, previously we required en !== bn but that doesn't really gain much performance and it prevents _parseToProxy() from working properly if beginning and ending values match but need to get tweened by an external plugin anyway. For example, a bezier tween where the target starts at left:0 and has these points: [{left:50},{left:0}] wouldn't work properly because when parsing the last point, it'd match the first (current) one and a non-tweening CSSPropTween would be recorded when we actually need a normal tween (type:0) so that things get updated during the tween properly.
pt = new CSSPropTween(style, p, bn, en - bn, pt, 0, p, (_autoRound !== false && (esfx === "px" || p === "zIndex")), 0, bs, es);
pt.xs0 = esfx;
//DEBUG: _log("tween "+p+" from "+pt.b+" ("+bn+esfx+") to "+pt.e+" with suffix: "+pt.xs0);
} else if (style[p] === undefined || !es && (es + "" === "NaN" || es == null)) {
_log("invalid " + p + " tween value: " + vars[p]);
} else {
pt = new CSSPropTween(style, p, en || bn || 0, 0, pt, -1, p, false, 0, bs, es);
pt.xs0 = (es === "none" && (p === "display" || p.indexOf("Style") !== -1)) ? bs : es; //intermediate value should typically be set immediately (end value) except for "display" or things like borderTopStyle, borderBottomStyle, etc. which should use the beginning value during the tween.
//DEBUG: _log("non-tweening value "+p+": "+pt.xs0);
}
}
}
if (plugin) if (pt && !pt.plugin) {
pt.plugin = plugin;
}
}
return pt;
};
//gets called every time the tween updates, passing the new ratio (typically a value between 0 and 1, but not always (for example, if an Elastic.easeOut is used, the value can jump above 1 mid-tween). It will always start and 0 and end at 1.
p.setRatio = function(v) {
var pt = this._firstPT,
min = 0.000001,
val, str, i;
//at the end of the tween, we set the values to exactly what we received in order to make sure non-tweening values (like "position" or "float" or whatever) are set and so that if the beginning/ending suffixes (units) didn't match and we normalized to px, the value that the user passed in is used here. We check to see if the tween is at its beginning in case it's a from() tween in which case the ratio will actually go from 1 to 0 over the course of the tween (backwards).
if (v === 1 && (this._tween._time === this._tween._duration || this._tween._time === 0)) {
while (pt) {
if (pt.type !== 2) {
if (pt.r && pt.type !== -1) {
val = pt.r(pt.s + pt.c);
if (!pt.type) {
pt.t[pt.p] = val + pt.xs0;
} else if (pt.type === 1) { //complex value (one that typically has multiple numbers inside a string, like "rect(5px,10px,20px,25px)"
i = pt.l;
str = pt.xs0 + val + pt.xs1;
for (i = 1; i < pt.l; i++) {
str += pt["xn"+i] + pt["xs"+(i+1)];
}
pt.t[pt.p] = str;
}
} else {
pt.t[pt.p] = pt.e;
}
} else {
pt.setRatio(v);
}
pt = pt._next;
}
} else if (v || !(this._tween._time === this._tween._duration || this._tween._time === 0) || this._tween._rawPrevTime === -0.000001) {
while (pt) {
val = pt.c * v + pt.s;
if (pt.r) {
val = pt.r(val);
} else if (val < min) if (val > -min) {
val = 0;
}
if (!pt.type) {
pt.t[pt.p] = val + pt.xs0;
} else if (pt.type === 1) { //complex value (one that typically has multiple numbers inside a string, like "rect(5px,10px,20px,25px)"
i = pt.l;
if (i === 2) {
pt.t[pt.p] = pt.xs0 + val + pt.xs1 + pt.xn1 + pt.xs2;
} else if (i === 3) {
pt.t[pt.p] = pt.xs0 + val + pt.xs1 + pt.xn1 + pt.xs2 + pt.xn2 + pt.xs3;
} else if (i === 4) {
pt.t[pt.p] = pt.xs0 + val + pt.xs1 + pt.xn1 + pt.xs2 + pt.xn2 + pt.xs3 + pt.xn3 + pt.xs4;
} else if (i === 5) {
pt.t[pt.p] = pt.xs0 + val + pt.xs1 + pt.xn1 + pt.xs2 + pt.xn2 + pt.xs3 + pt.xn3 + pt.xs4 + pt.xn4 + pt.xs5;
} else {
str = pt.xs0 + val + pt.xs1;
for (i = 1; i < pt.l; i++) {
str += pt["xn"+i] + pt["xs"+(i+1)];
}
pt.t[pt.p] = str;
}
} else if (pt.type === -1) { //non-tweening value
pt.t[pt.p] = pt.xs0;
} else if (pt.setRatio) { //custom setRatio() for things like SpecialProps, external plugins, etc.
pt.setRatio(v);
}
pt = pt._next;
}
//if the tween is reversed all the way back to the beginning, we need to restore the original values which may have different units (like % instead of px or em or whatever).
} else {
while (pt) {
if (pt.type !== 2) {
pt.t[pt.p] = pt.b;
} else {
pt.setRatio(v);
}
pt = pt._next;
}
}
};
/**
* @private
* Forces rendering of the target's transforms (rotation, scale, etc.) whenever the CSSPlugin's setRatio() is called.
* Basically, this tells the CSSPlugin to create a CSSPropTween (type 2) after instantiation that runs last in the linked
* list and calls the appropriate (3D or 2D) rendering function. We separate this into its own method so that we can call
* it from other plugins like BezierPlugin if, for example, it needs to apply an autoRotation and this CSSPlugin
* doesn't have any transform-related properties of its own. You can call this method as many times as you
* want and it won't create duplicate CSSPropTweens.
*
* @param {boolean} threeD if true, it should apply 3D tweens (otherwise, just 2D ones are fine and typically faster)
*/
p._enableTransforms = function(threeD) {
this._transform = this._transform || _getTransform(this._target, _cs, true); //ensures that the element has a _gsTransform property with the appropriate values.
this._transformType = (!(this._transform.svg && _useSVGTransformAttr) && (threeD || this._transformType === 3)) ? 3 : 2;
};
var lazySet = function(v) {
this.t[this.p] = this.e;
this.data._linkCSSP(this, this._next, null, true); //we purposefully keep this._next even though it'd make sense to null it, but this is a performance optimization, as this happens during the while (pt) {} loop in setRatio() at the bottom of which it sets pt = pt._next, so if we null it, the linked list will be broken in that loop.
};
/** @private Gives us a way to set a value on the first render (and only the first render). **/
p._addLazySet = function(t, p, v) {
var pt = this._firstPT = new CSSPropTween(t, p, 0, 0, this._firstPT, 2);
pt.e = v;
pt.setRatio = lazySet;
pt.data = this;
};
/** @private **/
p._linkCSSP = function(pt, next, prev, remove) {
if (pt) {
if (next) {
next._prev = pt;
}
if (pt._next) {
pt._next._prev = pt._prev;
}
if (pt._prev) {
pt._prev._next = pt._next;
} else if (this._firstPT === pt) {
this._firstPT = pt._next;
remove = true; //just to prevent resetting this._firstPT 5 lines down in case pt._next is null. (optimized for speed)
}
if (prev) {
prev._next = pt;
} else if (!remove && this._firstPT === null) {
this._firstPT = pt;
}
pt._next = next;
pt._prev = prev;
}
return pt;
};
p._mod = function(lookup) {
var pt = this._firstPT;
while (pt) {
if (typeof(lookup[pt.p]) === "function") { //only gets called by RoundPropsPlugin (ModifyPlugin manages all the rendering internally for CSSPlugin properties that need modification). Remember, we handle rounding a bit differently in this plugin for performance reasons, leveraging "r" as an indicator that the value should be rounded internally.
pt.r = lookup[pt.p];
}
pt = pt._next;
}
};
//we need to make sure that if alpha or autoAlpha is killed, opacity is too. And autoAlpha affects the "visibility" property.
p._kill = function(lookup) {
var copy = lookup,
pt, p, xfirst;
if (lookup.autoAlpha || lookup.alpha) {
copy = {};
for (p in lookup) { //copy the lookup so that we're not changing the original which may be passed elsewhere.
copy[p] = lookup[p];
}
copy.opacity = 1;
if (copy.autoAlpha) {
copy.visibility = 1;
}
}
if (lookup.className && (pt = this._classNamePT)) { //for className tweens, we need to kill any associated CSSPropTweens too; a linked list starts at the className's "xfirst".
xfirst = pt.xfirst;
if (xfirst && xfirst._prev) {
this._linkCSSP(xfirst._prev, pt._next, xfirst._prev._prev); //break off the prev
} else if (xfirst === this._firstPT) {
this._firstPT = pt._next;
}
if (pt._next) {
this._linkCSSP(pt._next, pt._next._next, xfirst._prev);
}
this._classNamePT = null;
}
pt = this._firstPT;
while (pt) {
if (pt.plugin && pt.plugin !== p && pt.plugin._kill) { //for plugins that are registered with CSSPlugin, we should notify them of the kill.
pt.plugin._kill(lookup);
p = pt.plugin;
}
pt = pt._next;
}
return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["j" /* TweenPlugin */].prototype._kill.call(this, copy);
};
//used by cascadeTo() for gathering all the style properties of each child element into an array for comparison.
var _getChildStyles = function(e, props, targets) {
var children, i, child, type;
if (e.slice) {
i = e.length;
while (--i > -1) {
_getChildStyles(e[i], props, targets);
}
return;
}
children = e.childNodes;
i = children.length;
while (--i > -1) {
child = children[i];
type = child.type;
if (child.style) {
props.push(_getAllStyles(child));
if (targets) {
targets.push(child);
}
}
if ((type === 1 || type === 9 || type === 11) && child.childNodes.length) {
_getChildStyles(child, props, targets);
}
}
};
/**
* Typically only useful for className tweens that may affect child elements, this method creates a TweenLite
* and then compares the style properties of all the target's child elements at the tween's start and end, and
* if any are different, it also creates tweens for those and returns an array containing ALL of the resulting
* tweens (so that you can easily add() them to a TimelineLite, for example). The reason this functionality is
* wrapped into a separate static method of CSSPlugin instead of being integrated into all regular className tweens
* is because it creates entirely new tweens that may have completely different targets than the original tween,
* so if they were all lumped into the original tween instance, it would be inconsistent with the rest of the API
* and it would create other problems. For example:
* - If I create a tween of elementA, that tween instance may suddenly change its target to include 50 other elements (unintuitive if I specifically defined the target I wanted)
* - We can't just create new independent tweens because otherwise, what happens if the original/parent tween is reversed or pause or dropped into a TimelineLite for tight control? You'd expect that tween's behavior to affect all the others.
* - Analyzing every style property of every child before and after the tween is an expensive operation when there are many children, so this behavior shouldn't be imposed on all className tweens by default, especially since it's probably rare that this extra functionality is needed.
*
* @param {Object} target object to be tweened
* @param {number} Duration in seconds (or frames for frames-based tweens)
* @param {Object} Object containing the end values, like {className:"newClass", ease:Linear.easeNone}
* @return {Array} An array of TweenLite instances
*/
CSSPlugin.cascadeTo = function(target, duration, vars) {
var tween = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].to(target, duration, vars),
results = [tween],
b = [],
e = [],
targets = [],
_reservedProps = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */]._internals.reservedProps,
i, difs, p, from;
target = tween._targets || tween.target;
_getChildStyles(target, b, targets);
tween.render(duration, true, true);
_getChildStyles(target, e);
tween.render(0, true, true);
tween._enabled(true);
i = targets.length;
while (--i > -1) {
difs = _cssDif(targets[i], b[i], e[i]);
if (difs.firstMPT) {
difs = difs.difs;
for (p in vars) {
if (_reservedProps[p]) {
difs[p] = vars[p];
}
}
from = {};
for (p in difs) {
from[p] = b[i][p];
}
results.push(__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].fromTo(targets[i], duration, from, difs));
}
}
return results;
};
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["j" /* TweenPlugin */].activate([CSSPlugin]);
return CSSPlugin;
}, true);
var CSSPlugin = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].CSSPlugin;
/***/ }),
/* 223 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export AttrPlugin */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AttrPlugin; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/*!
* VERSION: 0.6.1
* DATE: 2018-08-27
* 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 */
var AttrPlugin = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine.plugin({
propName: "attr",
API: 2,
version: "0.6.1",
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
var p, end;
if (typeof(target.setAttribute) !== "function") {
return false;
}
for (p in value) {
end = value[p];
if (typeof(end) === "function") {
end = end(index, target);
}
this._addTween(target, "setAttribute", target.getAttribute(p) + "", end + "", p, false, p);
this._overwriteProps.push(p);
}
return true;
}
});
/***/ }),
/* 224 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export RoundPropsPlugin */
/* unused harmony export _getRoundFunc */
/* unused harmony export _roundLinkedList */
/* unused harmony export p */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return RoundPropsPlugin; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/*!
* VERSION: 1.6.0
* DATE: 2018-08-27
* 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 */
var RoundPropsPlugin = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine.plugin({
propName: "roundProps",
version: "1.7.0",
priority: -1,
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween) {
this._tween = tween;
return true;
}
}),
_getRoundFunc = function(v) { //pass in 0.1 get a function that'll round to the nearest tenth, or 5 to round to the closest 5, or 0.001 to the closest 1000th, etc.
var p = v < 1 ? Math.pow(10, (v + "").length - 2) : 1; //to avoid floating point math errors (like 24 * 0.1 == 2.4000000000000004), we chop off at a specific number of decimal places (much faster than toFixed()
return function(n) {
return ((Math.round(n / v) * v * p) | 0) / p;
};
},
_roundLinkedList = function(node, mod) {
while (node) {
if (!node.f && !node.blob) {
node.m = mod || Math.round;
}
node = node._next;
}
},
p = RoundPropsPlugin.prototype;
p._onInitAllProps = function() {
var tween = this._tween,
rp = tween.vars.roundProps,
lookup = {},
rpt = tween._propLookup.roundProps,
pt, next, i, p;
if (typeof(rp) === "object" && !rp.push) {
for (p in rp) {
lookup[p] = _getRoundFunc(rp[p]);
}
} else {
if (typeof(rp) === "string") {
rp = rp.split(",");
}
i = rp.length;
while (--i > -1) {
lookup[rp[i]] = Math.round;
}
}
for (p in lookup) {
pt = tween._firstPT;
while (pt) {
next = pt._next; //record here, because it may get removed
if (pt.pg) {
pt.t._mod(lookup);
} else if (pt.n === p) {
if (pt.f === 2 && pt.t) { //a blob (text containing multiple numeric values)
_roundLinkedList(pt.t._firstPT, lookup[p]);
} else {
this._add(pt.t, p, pt.s, pt.c, lookup[p]);
//remove from linked list
if (next) {
next._prev = pt._prev;
}
if (pt._prev) {
pt._prev._next = next;
} else if (tween._firstPT === pt) {
tween._firstPT = next;
}
pt._next = pt._prev = null;
tween._propLookup[p] = rpt;
}
}
pt = next;
}
}
return false;
};
p._add = function(target, p, s, c, mod) {
this._addTween(target, p, s, s + c, p, mod || Math.round);
this._overwriteProps.push(p);
};
/***/ }),
/* 225 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export DirectionalRotationPlugin */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return DirectionalRotationPlugin; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/*!
* VERSION: 0.3.1
* DATE: 2018-08-27
* 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 */
var DirectionalRotationPlugin = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine.plugin({
propName: "directionalRotation",
version: "0.3.1",
API: 2,
//called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, value, tween, index) {
if (typeof(value) !== "object") {
value = {rotation:value};
}
this.finals = {};
var cap = (value.useRadians === true) ? Math.PI * 2 : 360,
min = 0.000001,
p, v, start, end, dif, split;
for (p in value) {
if (p !== "useRadians") {
end = value[p];
if (typeof(end) === "function") {
end = end(index, target);
}
split = (end + "").split("_");
v = split[0];
start = parseFloat( (typeof(target[p]) !== "function") ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() );
end = this.finals[p] = (typeof(v) === "string" && v.charAt(1) === "=") ? start + parseInt(v.charAt(0) + "1", 10) * Number(v.substr(2)) : Number(v) || 0;
dif = end - start;
if (split.length) {
v = split.join("_");
if (v.indexOf("short") !== -1) {
dif = dif % cap;
if (dif !== dif % (cap / 2)) {
dif = (dif < 0) ? dif + cap : dif - cap;
}
}
if (v.indexOf("_cw") !== -1 && dif < 0) {
dif = ((dif + cap * 9999999999) % cap) - ((dif / cap) | 0) * cap;
} else if (v.indexOf("ccw") !== -1 && dif > 0) {
dif = ((dif - cap * 9999999999) % cap) - ((dif / cap) | 0) * cap;
}
}
if (dif > min || dif < -min) {
this._addTween(target, p, start, start + dif, p);
this._overwriteProps.push(p);
}
}
}
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(ratio) {
var pt;
if (ratio !== 1) {
this._super.setRatio.call(this, ratio);
} else {
pt = this._firstPT;
while (pt) {
if (pt.f) {
pt.t[pt.p](this.finals[pt.p]);
} else {
pt.t[pt.p] = this.finals[pt.p];
}
pt = pt._next;
}
}
}
});
DirectionalRotationPlugin._autoCSS = true;
/***/ }),
/* 226 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export BezierPlugin */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return BezierPlugin; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/*!
* VERSION: 1.3.8
* DATE: 2018-05-30
* 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 */
var _RAD2DEG = 180 / Math.PI,
_r1 = [],
_r2 = [],
_r3 = [],
_corProps = {},
_globals = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine.globals,
Segment = function(a, b, c, d) {
if (c === d) { //if c and d match, the final autoRotate value could lock at -90 degrees, so differentiate them slightly.
c = d - (d - b) / 1000000;
}
if (a === b) { //if a and b match, the starting autoRotate value could lock at -90 degrees, so differentiate them slightly.
b = a + (c - a) / 1000000;
}
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.da = d - a;
this.ca = c - a;
this.ba = b - a;
},
_correlate = ",x,y,z,left,top,right,bottom,marginTop,marginLeft,marginRight,marginBottom,paddingLeft,paddingTop,paddingRight,paddingBottom,backgroundPosition,backgroundPosition_y,",
cubicToQuadratic = function(a, b, c, d) {
var q1 = {a:a},
q2 = {},
q3 = {},
q4 = {c:d},
mab = (a + b) / 2,
mbc = (b + c) / 2,
mcd = (c + d) / 2,
mabc = (mab + mbc) / 2,
mbcd = (mbc + mcd) / 2,
m8 = (mbcd - mabc) / 8;
q1.b = mab + (a - mab) / 4;
q2.b = mabc + m8;
q1.c = q2.a = (q1.b + q2.b) / 2;
q2.c = q3.a = (mabc + mbcd) / 2;
q3.b = mbcd - m8;
q4.b = mcd + (d - mcd) / 4;
q3.c = q4.a = (q3.b + q4.b) / 2;
return [q1, q2, q3, q4];
},
_calculateControlPoints = function(a, curviness, quad, basic, correlate) {
var l = a.length - 1,
ii = 0,
cp1 = a[0].a,
i, p1, p2, p3, seg, m1, m2, mm, cp2, qb, r1, r2, tl;
for (i = 0; i < l; i++) {
seg = a[ii];
p1 = seg.a;
p2 = seg.d;
p3 = a[ii+1].d;
if (correlate) {
r1 = _r1[i];
r2 = _r2[i];
tl = ((r2 + r1) * curviness * 0.25) / (basic ? 0.5 : _r3[i] || 0.5);
m1 = p2 - (p2 - p1) * (basic ? curviness * 0.5 : (r1 !== 0 ? tl / r1 : 0));
m2 = p2 + (p3 - p2) * (basic ? curviness * 0.5 : (r2 !== 0 ? tl / r2 : 0));
mm = p2 - (m1 + (((m2 - m1) * ((r1 * 3 / (r1 + r2)) + 0.5) / 4) || 0));
} else {
m1 = p2 - (p2 - p1) * curviness * 0.5;
m2 = p2 + (p3 - p2) * curviness * 0.5;
mm = p2 - (m1 + m2) / 2;
}
m1 += mm;
m2 += mm;
seg.c = cp2 = m1;
if (i !== 0) {
seg.b = cp1;
} else {
seg.b = cp1 = seg.a + (seg.c - seg.a) * 0.6; //instead of placing b on a exactly, we move it inline with c so that if the user specifies an ease like Back.easeIn or Elastic.easeIn which goes BEYOND the beginning, it will do so smoothly.
}
seg.da = p2 - p1;
seg.ca = cp2 - p1;
seg.ba = cp1 - p1;
if (quad) {
qb = cubicToQuadratic(p1, cp1, cp2, p2);
a.splice(ii, 1, qb[0], qb[1], qb[2], qb[3]);
ii += 4;
} else {
ii++;
}
cp1 = m2;
}
seg = a[ii];
seg.b = cp1;
seg.c = cp1 + (seg.d - cp1) * 0.4; //instead of placing c on d exactly, we move it inline with b so that if the user specifies an ease like Back.easeOut or Elastic.easeOut which goes BEYOND the end, it will do so smoothly.
seg.da = seg.d - seg.a;
seg.ca = seg.c - seg.a;
seg.ba = cp1 - seg.a;
if (quad) {
qb = cubicToQuadratic(seg.a, cp1, seg.c, seg.d);
a.splice(ii, 1, qb[0], qb[1], qb[2], qb[3]);
}
},
_parseAnchors = function(values, p, correlate, prepend) {
var a = [],
l, i, p1, p2, p3, tmp;
if (prepend) {
values = [prepend].concat(values);
i = values.length;
while (--i > -1) {
if (typeof( (tmp = values[i][p]) ) === "string") if (tmp.charAt(1) === "=") {
values[i][p] = prepend[p] + Number(tmp.charAt(0) + tmp.substr(2)); //accommodate relative values. Do it inline instead of breaking it out into a function for speed reasons
}
}
}
l = values.length - 2;
if (l < 0) {
a[0] = new Segment(values[0][p], 0, 0, values[0][p]);
return a;
}
for (i = 0; i < l; i++) {
p1 = values[i][p];
p2 = values[i+1][p];
a[i] = new Segment(p1, 0, 0, p2);
if (correlate) {
p3 = values[i+2][p];
_r1[i] = (_r1[i] || 0) + (p2 - p1) * (p2 - p1);
_r2[i] = (_r2[i] || 0) + (p3 - p2) * (p3 - p2);
}
}
a[i] = new Segment(values[i][p], 0, 0, values[i+1][p]);
return a;
},
bezierThrough = function(values, curviness, quadratic, basic, correlate, prepend) {
var obj = {},
props = [],
first = prepend || values[0],
i, p, a, j, r, l, seamless, last;
correlate = (typeof(correlate) === "string") ? ","+correlate+"," : _correlate;
if (curviness == null) {
curviness = 1;
}
for (p in values[0]) {
props.push(p);
}
//check to see if the last and first values are identical (well, within 0.05). If so, make seamless by appending the second element to the very end of the values array and the 2nd-to-last element to the very beginning (we'll remove those segments later)
if (values.length > 1) {
last = values[values.length - 1];
seamless = true;
i = props.length;
while (--i > -1) {
p = props[i];
if (Math.abs(first[p] - last[p]) > 0.05) { //build in a tolerance of +/-0.05 to accommodate rounding errors.
seamless = false;
break;
}
}
if (seamless) {
values = values.concat(); //duplicate the array to avoid contaminating the original which the user may be reusing for other tweens
if (prepend) {
values.unshift(prepend);
}
values.push(values[1]);
prepend = values[values.length - 3];
}
}
_r1.length = _r2.length = _r3.length = 0;
i = props.length;
while (--i > -1) {
p = props[i];
_corProps[p] = (correlate.indexOf(","+p+",") !== -1);
obj[p] = _parseAnchors(values, p, _corProps[p], prepend);
}
i = _r1.length;
while (--i > -1) {
_r1[i] = Math.sqrt(_r1[i]);
_r2[i] = Math.sqrt(_r2[i]);
}
if (!basic) {
i = props.length;
while (--i > -1) {
if (_corProps[p]) {
a = obj[props[i]];
l = a.length - 1;
for (j = 0; j < l; j++) {
r = (a[j+1].da / _r2[j] + a[j].da / _r1[j]) || 0;
_r3[j] = (_r3[j] || 0) + r * r;
}
}
}
i = _r3.length;
while (--i > -1) {
_r3[i] = Math.sqrt(_r3[i]);
}
}
i = props.length;
j = quadratic ? 4 : 1;
while (--i > -1) {
p = props[i];
a = obj[p];
_calculateControlPoints(a, curviness, quadratic, basic, _corProps[p]); //this method requires that _parseAnchors() and _setSegmentRatios() ran first so that _r1, _r2, and _r3 values are populated for all properties
if (seamless) {
a.splice(0, j);
a.splice(a.length - j, j);
}
}
return obj;
},
_parseBezierData = function(values, type, prepend) {
type = type || "soft";
var obj = {},
inc = (type === "cubic") ? 3 : 2,
soft = (type === "soft"),
props = [],
a, b, c, d, cur, i, j, l, p, cnt, tmp;
if (soft && prepend) {
values = [prepend].concat(values);
}
if (values == null || values.length < inc + 1) { throw "invalid Bezier data"; }
for (p in values[0]) {
props.push(p);
}
i = props.length;
while (--i > -1) {
p = props[i];
obj[p] = cur = [];
cnt = 0;
l = values.length;
for (j = 0; j < l; j++) {
a = (prepend == null) ? values[j][p] : (typeof( (tmp = values[j][p]) ) === "string" && tmp.charAt(1) === "=") ? prepend[p] + Number(tmp.charAt(0) + tmp.substr(2)) : Number(tmp);
if (soft) if (j > 1) if (j < l - 1) {
cur[cnt++] = (a + cur[cnt-2]) / 2;
}
cur[cnt++] = a;
}
l = cnt - inc + 1;
cnt = 0;
for (j = 0; j < l; j += inc) {
a = cur[j];
b = cur[j+1];
c = cur[j+2];
d = (inc === 2) ? 0 : cur[j+3];
cur[cnt++] = tmp = (inc === 3) ? new Segment(a, b, c, d) : new Segment(a, (2 * b + a) / 3, (2 * b + c) / 3, c);
}
cur.length = cnt;
}
return obj;
},
_addCubicLengths = function(a, steps, resolution) {
var inc = 1 / resolution,
j = a.length,
d, d1, s, da, ca, ba, p, i, inv, bez, index;
while (--j > -1) {
bez = a[j];
s = bez.a;
da = bez.d - s;
ca = bez.c - s;
ba = bez.b - s;
d = d1 = 0;
for (i = 1; i <= resolution; i++) {
p = inc * i;
inv = 1 - p;
d = d1 - (d1 = (p * p * da + 3 * inv * (p * ca + inv * ba)) * p);
index = j * resolution + i - 1;
steps[index] = (steps[index] || 0) + d * d;
}
}
},
_parseLengthData = function(obj, resolution) {
resolution = resolution >> 0 || 6;
var a = [],
lengths = [],
d = 0,
total = 0,
threshold = resolution - 1,
segments = [],
curLS = [], //current length segments array
p, i, l, index;
for (p in obj) {
_addCubicLengths(obj[p], a, resolution);
}
l = a.length;
for (i = 0; i < l; i++) {
d += Math.sqrt(a[i]);
index = i % resolution;
curLS[index] = d;
if (index === threshold) {
total += d;
index = (i / resolution) >> 0;
segments[index] = curLS;
lengths[index] = total;
d = 0;
curLS = [];
}
}
return {length:total, lengths:lengths, segments:segments};
},
BezierPlugin = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine.plugin({
propName: "bezier",
priority: -1,
version: "1.3.8",
API: 2,
global:true,
//gets called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
init: function(target, vars, tween) {
this._target = target;
if (vars instanceof Array) {
vars = {values:vars};
}
this._func = {};
this._mod = {};
this._props = [];
this._timeRes = (vars.timeResolution == null) ? 6 : parseInt(vars.timeResolution, 10);
var values = vars.values || [],
first = {},
second = values[0],
autoRotate = vars.autoRotate || tween.vars.orientToBezier,
p, isFunc, i, j, prepend;
this._autoRotate = autoRotate ? (autoRotate instanceof Array) ? autoRotate : [["x","y","rotation",((autoRotate === true) ? 0 : Number(autoRotate) || 0)]] : null;
for (p in second) {
this._props.push(p);
}
i = this._props.length;
while (--i > -1) {
p = this._props[i];
this._overwriteProps.push(p);
isFunc = this._func[p] = (typeof(target[p]) === "function");
first[p] = (!isFunc) ? parseFloat(target[p]) : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
if (!prepend) if (first[p] !== values[0][p]) {
prepend = first;
}
}
this._beziers = (vars.type !== "cubic" && vars.type !== "quadratic" && vars.type !== "soft") ? bezierThrough(values, isNaN(vars.curviness) ? 1 : vars.curviness, false, (vars.type === "thruBasic"), vars.correlate, prepend) : _parseBezierData(values, vars.type, first);
this._segCount = this._beziers[p].length;
if (this._timeRes) {
var ld = _parseLengthData(this._beziers, this._timeRes);
this._length = ld.length;
this._lengths = ld.lengths;
this._segments = ld.segments;
this._l1 = this._li = this._s1 = this._si = 0;
this._l2 = this._lengths[0];
this._curSeg = this._segments[0];
this._s2 = this._curSeg[0];
this._prec = 1 / this._curSeg.length;
}
if ((autoRotate = this._autoRotate)) {
this._initialRotations = [];
if (!(autoRotate[0] instanceof Array)) {
this._autoRotate = autoRotate = [autoRotate];
}
i = autoRotate.length;
while (--i > -1) {
for (j = 0; j < 3; j++) {
p = autoRotate[i][j];
this._func[p] = (typeof(target[p]) === "function") ? target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ] : false;
}
p = autoRotate[i][2];
this._initialRotations[i] = (this._func[p] ? this._func[p].call(this._target) : this._target[p]) || 0;
this._overwriteProps.push(p);
}
}
this._startRatio = tween.vars.runBackwards ? 1 : 0; //we determine the starting ratio when the tween inits which is always 0 unless the tween has runBackwards:true (indicating it's a from() tween) in which case it's 1.
return true;
},
//called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
set: function(v) {
var segments = this._segCount,
func = this._func,
target = this._target,
notStart = (v !== this._startRatio),
curIndex, inv, i, p, b, t, val, l, lengths, curSeg;
if (!this._timeRes) {
curIndex = (v < 0) ? 0 : (v >= 1) ? segments - 1 : (segments * v) >> 0;
t = (v - (curIndex * (1 / segments))) * segments;
} else {
lengths = this._lengths;
curSeg = this._curSeg;
v *= this._length;
i = this._li;
//find the appropriate segment (if the currently cached one isn't correct)
if (v > this._l2 && i < segments - 1) {
l = segments - 1;
while (i < l && (this._l2 = lengths[++i]) <= v) { }
this._l1 = lengths[i-1];
this._li = i;
this._curSeg = curSeg = this._segments[i];
this._s2 = curSeg[(this._s1 = this._si = 0)];
} else if (v < this._l1 && i > 0) {
while (i > 0 && (this._l1 = lengths[--i]) >= v) { }
if (i === 0 && v < this._l1) {
this._l1 = 0;
} else {
i++;
}
this._l2 = lengths[i];
this._li = i;
this._curSeg = curSeg = this._segments[i];
this._s1 = curSeg[(this._si = curSeg.length - 1) - 1] || 0;
this._s2 = curSeg[this._si];
}
curIndex = i;
//now find the appropriate sub-segment (we split it into the number of pieces that was defined by "precision" and measured each one)
v -= this._l1;
i = this._si;
if (v > this._s2 && i < curSeg.length - 1) {
l = curSeg.length - 1;
while (i < l && (this._s2 = curSeg[++i]) <= v) { }
this._s1 = curSeg[i-1];
this._si = i;
} else if (v < this._s1 && i > 0) {
while (i > 0 && (this._s1 = curSeg[--i]) >= v) { }
if (i === 0 && v < this._s1) {
this._s1 = 0;
} else {
i++;
}
this._s2 = curSeg[i];
this._si = i;
}
t = ((i + (v - this._s1) / (this._s2 - this._s1)) * this._prec) || 0;
}
inv = 1 - t;
i = this._props.length;
while (--i > -1) {
p = this._props[i];
b = this._beziers[p][curIndex];
val = (t * t * b.da + 3 * inv * (t * b.ca + inv * b.ba)) * t + b.a;
if (this._mod[p]) {
val = this._mod[p](val, target);
}
if (func[p]) {
target[p](val);
} else {
target[p] = val;
}
}
if (this._autoRotate) {
var ar = this._autoRotate,
b2, x1, y1, x2, y2, add, conv;
i = ar.length;
while (--i > -1) {
p = ar[i][2];
add = ar[i][3] || 0;
conv = (ar[i][4] === true) ? 1 : _RAD2DEG;
b = this._beziers[ar[i][0]];
b2 = this._beziers[ar[i][1]];
if (b && b2) { //in case one of the properties got overwritten.
b = b[curIndex];
b2 = b2[curIndex];
x1 = b.a + (b.b - b.a) * t;
x2 = b.b + (b.c - b.b) * t;
x1 += (x2 - x1) * t;
x2 += ((b.c + (b.d - b.c) * t) - x2) * t;
y1 = b2.a + (b2.b - b2.a) * t;
y2 = b2.b + (b2.c - b2.b) * t;
y1 += (y2 - y1) * t;
y2 += ((b2.c + (b2.d - b2.c) * t) - y2) * t;
val = notStart ? Math.atan2(y2 - y1, x2 - x1) * conv + add : this._initialRotations[i];
if (this._mod[p]) {
val = this._mod[p](val, target); //for modProps
}
if (func[p]) {
target[p](val);
} else {
target[p] = val;
}
}
}
}
}
}),
p = BezierPlugin.prototype;
BezierPlugin.bezierThrough = bezierThrough;
BezierPlugin.cubicToQuadratic = cubicToQuadratic;
BezierPlugin._autoCSS = true; //indicates that this plugin can be inserted into the "css" object using the autoCSS feature of TweenLite
BezierPlugin.quadraticToCubic = function(a, b, c) {
return new Segment(a, (2 * b + a) / 3, (2 * b + c) / 3, c);
};
BezierPlugin._cssRegister = function() {
var CSSPlugin = _globals.CSSPlugin;
if (!CSSPlugin) {
return;
}
var _internals = CSSPlugin._internals,
_parseToProxy = _internals._parseToProxy,
_setPluginRatio = _internals._setPluginRatio,
CSSPropTween = _internals.CSSPropTween;
_internals._registerComplexSpecialProp("bezier", {parser:function(t, e, prop, cssp, pt, plugin) {
if (e instanceof Array) {
e = {values:e};
}
plugin = new BezierPlugin();
var values = e.values,
l = values.length - 1,
pluginValues = [],
v = {},
i, p, data;
if (l < 0) {
return pt;
}
for (i = 0; i <= l; i++) {
data = _parseToProxy(t, values[i], cssp, pt, plugin, (l !== i));
pluginValues[i] = data.end;
}
for (p in e) {
v[p] = e[p]; //duplicate the vars object because we need to alter some things which would cause problems if the user plans to reuse the same vars object for another tween.
}
v.values = pluginValues;
pt = new CSSPropTween(t, "bezier", 0, 0, data.pt, 2);
pt.data = data;
pt.plugin = plugin;
pt.setRatio = _setPluginRatio;
if (v.autoRotate === 0) {
v.autoRotate = true;
}
if (v.autoRotate && !(v.autoRotate instanceof Array)) {
i = (v.autoRotate === true) ? 0 : Number(v.autoRotate);
v.autoRotate = (data.end.left != null) ? [["left","top","rotation",i,false]] : (data.end.x != null) ? [["x","y","rotation",i,false]] : false;
}
if (v.autoRotate) {
if (!cssp._transform) {
cssp._enableTransforms(false);
}
data.autoRotate = cssp._target._gsTransform;
data.proxy.rotation = data.autoRotate.rotation || 0;
cssp._overwriteProps.push("rotation");
}
plugin._onInitTween(data.proxy, v, cssp._tween);
return pt;
}});
};
p._mod = function(lookup) {
var op = this._overwriteProps,
i = op.length,
val;
while (--i > -1) {
val = lookup[op[i]];
if (val && typeof(val) === "function") {
this._mod[op[i]] = val;
}
}
};
p._kill = function(lookup) {
var a = this._props,
p, i;
for (p in this._beziers) {
if (p in lookup) {
delete this._beziers[p];
delete this._func[p];
i = a.length;
while (--i > -1) {
if (a[i] === p) {
a.splice(i, 1);
}
}
}
}
a = this._autoRotate;
if (a) {
i = a.length;
while (--i > -1) {
if (lookup[a[i][2]]) {
a.splice(i, 1);
}
}
}
return this._super._kill.call(this, lookup);
};
/***/ }),
/* 227 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Back; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return Elastic; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Bounce; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return RoughEase; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return SlowMo; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return SteppedEase; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Circ; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return Expo; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return Sine; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return ExpoScaleEase; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/* unused harmony reexport Linear */
/* unused harmony reexport Power0 */
/* unused harmony reexport Power1 */
/* unused harmony reexport Power2 */
/* unused harmony reexport Power3 */
/* unused harmony reexport Power4 */
/*!
* VERSION: 1.16.1
* DATE: 2018-08-27
* 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 */
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine("easing.Back", ["easing.Ease"], function() {
var w = (__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */].GreenSockGlobals || __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]),
gs = w.com.greensock,
_2PI = Math.PI * 2,
_HALF_PI = Math.PI / 2,
_class = gs._class,
_create = function(n, f) {
var C = _class("easing." + n, function(){}, true),
p = C.prototype = new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */]();
p.constructor = C;
p.getRatio = f;
return C;
},
_easeReg = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */].register || function(){}, //put an empty function in place just as a safety measure in case someone loads an OLD version of TweenLite.js where Ease.register doesn't exist.
_wrap = function(name, EaseOut, EaseIn, EaseInOut, aliases) {
var C = _class("easing."+name, {
easeOut:new EaseOut(),
easeIn:new EaseIn(),
easeInOut:new EaseInOut()
}, true);
_easeReg(C, name);
return C;
},
EasePoint = function(time, value, next) {
this.t = time;
this.v = value;
if (next) {
this.next = next;
next.prev = this;
this.c = next.v - value;
this.gap = next.t - time;
}
},
//Back
_createBack = function(n, f) {
var C = _class("easing." + n, function(overshoot) {
this._p1 = (overshoot || overshoot === 0) ? overshoot : 1.70158;
this._p2 = this._p1 * 1.525;
}, true),
p = C.prototype = new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */]();
p.constructor = C;
p.getRatio = f;
p.config = function(overshoot) {
return new C(overshoot);
};
return C;
},
Back = _wrap("Back",
_createBack("BackOut", function(p) {
return ((p = p - 1) * p * ((this._p1 + 1) * p + this._p1) + 1);
}),
_createBack("BackIn", function(p) {
return p * p * ((this._p1 + 1) * p - this._p1);
}),
_createBack("BackInOut", function(p) {
return ((p *= 2) < 1) ? 0.5 * p * p * ((this._p2 + 1) * p - this._p2) : 0.5 * ((p -= 2) * p * ((this._p2 + 1) * p + this._p2) + 2);
})
),
//SlowMo
SlowMo = _class("easing.SlowMo", function(linearRatio, power, yoyoMode) {
power = (power || power === 0) ? power : 0.7;
if (linearRatio == null) {
linearRatio = 0.7;
} else if (linearRatio > 1) {
linearRatio = 1;
}
this._p = (linearRatio !== 1) ? power : 0;
this._p1 = (1 - linearRatio) / 2;
this._p2 = linearRatio;
this._p3 = this._p1 + this._p2;
this._calcEnd = (yoyoMode === true);
}, true),
p = SlowMo.prototype = new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */](),
SteppedEase, ExpoScaleEase, RoughEase, _createElastic;
p.constructor = SlowMo;
p.getRatio = function(p) {
var r = p + (0.5 - p) * this._p;
if (p < this._p1) {
return this._calcEnd ? 1 - ((p = 1 - (p / this._p1)) * p) : r - ((p = 1 - (p / this._p1)) * p * p * p * r);
} else if (p > this._p3) {
return this._calcEnd ? (p === 1 ? 0 : 1 - (p = (p - this._p3) / this._p1) * p) : r + ((p - r) * (p = (p - this._p3) / this._p1) * p * p * p); //added p === 1 ? 0 to avoid floating point rounding errors from affecting the final value, like 1 - 0.7 = 0.30000000000000004 instead of 0.3
}
return this._calcEnd ? 1 : r;
};
SlowMo.ease = new SlowMo(0.7, 0.7);
p.config = SlowMo.config = function(linearRatio, power, yoyoMode) {
return new SlowMo(linearRatio, power, yoyoMode);
};
//SteppedEase
SteppedEase = _class("easing.SteppedEase", function(steps, immediateStart) {
steps = steps || 1;
this._p1 = 1 / steps;
this._p2 = steps + (immediateStart ? 0 : 1);
this._p3 = immediateStart ? 1 : 0;
}, true);
p = SteppedEase.prototype = new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */]();
p.constructor = SteppedEase;
p.getRatio = function(p) {
if (p < 0) {
p = 0;
} else if (p >= 1) {
p = 0.999999999;
}
return (((this._p2 * p) | 0) + this._p3) * this._p1;
};
p.config = SteppedEase.config = function(steps, immediateStart) {
return new SteppedEase(steps, immediateStart);
};
//ExpoScaleEase
ExpoScaleEase = _class("easing.ExpoScaleEase", function(start, end, ease) {
this._p1 = Math.log(end / start);
this._p2 = end - start;
this._p3 = start;
this._ease = ease;
}, true);
p = ExpoScaleEase.prototype = new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */]();
p.constructor = ExpoScaleEase;
p.getRatio = function(p) {
if (this._ease) {
p = this._ease.getRatio(p);
}
return (this._p3 * Math.exp(this._p1 * p) - this._p3) / this._p2;
};
p.config = ExpoScaleEase.config = function(start, end, ease) {
return new ExpoScaleEase(start, end, ease);
};
//RoughEase
RoughEase = _class("easing.RoughEase", function(vars) {
vars = vars || {};
var taper = vars.taper || "none",
a = [],
cnt = 0,
points = (vars.points || 20) | 0,
i = points,
randomize = (vars.randomize !== false),
clamp = (vars.clamp === true),
template = (vars.template instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */]) ? vars.template : null,
strength = (typeof(vars.strength) === "number") ? vars.strength * 0.4 : 0.4,
x, y, bump, invX, obj, pnt;
while (--i > -1) {
x = randomize ? Math.random() : (1 / points) * i;
y = template ? template.getRatio(x) : x;
if (taper === "none") {
bump = strength;
} else if (taper === "out") {
invX = 1 - x;
bump = invX * invX * strength;
} else if (taper === "in") {
bump = x * x * strength;
} else if (x < 0.5) { //"both" (start)
invX = x * 2;
bump = invX * invX * 0.5 * strength;
} else { //"both" (end)
invX = (1 - x) * 2;
bump = invX * invX * 0.5 * strength;
}
if (randomize) {
y += (Math.random() * bump) - (bump * 0.5);
} else if (i % 2) {
y += bump * 0.5;
} else {
y -= bump * 0.5;
}
if (clamp) {
if (y > 1) {
y = 1;
} else if (y < 0) {
y = 0;
}
}
a[cnt++] = {x:x, y:y};
}
a.sort(function(a, b) {
return a.x - b.x;
});
pnt = new EasePoint(1, 1, null);
i = points;
while (--i > -1) {
obj = a[i];
pnt = new EasePoint(obj.x, obj.y, pnt);
}
this._prev = new EasePoint(0, 0, (pnt.t !== 0) ? pnt : pnt.next);
}, true);
p = RoughEase.prototype = new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */]();
p.constructor = RoughEase;
p.getRatio = function(p) {
var pnt = this._prev;
if (p > pnt.t) {
while (pnt.next && p >= pnt.t) {
pnt = pnt.next;
}
pnt = pnt.prev;
} else {
while (pnt.prev && p <= pnt.t) {
pnt = pnt.prev;
}
}
this._prev = pnt;
return (pnt.v + ((p - pnt.t) / pnt.gap) * pnt.c);
};
p.config = function(vars) {
return new RoughEase(vars);
};
RoughEase.ease = new RoughEase();
//Bounce
_wrap("Bounce",
_create("BounceOut", function(p) {
if (p < 1 / 2.75) {
return 7.5625 * p * p;
} else if (p < 2 / 2.75) {
return 7.5625 * (p -= 1.5 / 2.75) * p + 0.75;
} else if (p < 2.5 / 2.75) {
return 7.5625 * (p -= 2.25 / 2.75) * p + 0.9375;
}
return 7.5625 * (p -= 2.625 / 2.75) * p + 0.984375;
}),
_create("BounceIn", function(p) {
if ((p = 1 - p) < 1 / 2.75) {
return 1 - (7.5625 * p * p);
} else if (p < 2 / 2.75) {
return 1 - (7.5625 * (p -= 1.5 / 2.75) * p + 0.75);
} else if (p < 2.5 / 2.75) {
return 1 - (7.5625 * (p -= 2.25 / 2.75) * p + 0.9375);
}
return 1 - (7.5625 * (p -= 2.625 / 2.75) * p + 0.984375);
}),
_create("BounceInOut", function(p) {
var invert = (p < 0.5);
if (invert) {
p = 1 - (p * 2);
} else {
p = (p * 2) - 1;
}
if (p < 1 / 2.75) {
p = 7.5625 * p * p;
} else if (p < 2 / 2.75) {
p = 7.5625 * (p -= 1.5 / 2.75) * p + 0.75;
} else if (p < 2.5 / 2.75) {
p = 7.5625 * (p -= 2.25 / 2.75) * p + 0.9375;
} else {
p = 7.5625 * (p -= 2.625 / 2.75) * p + 0.984375;
}
return invert ? (1 - p) * 0.5 : p * 0.5 + 0.5;
})
);
//CIRC
_wrap("Circ",
_create("CircOut", function(p) {
return Math.sqrt(1 - (p = p - 1) * p);
}),
_create("CircIn", function(p) {
return -(Math.sqrt(1 - (p * p)) - 1);
}),
_create("CircInOut", function(p) {
return ((p*=2) < 1) ? -0.5 * (Math.sqrt(1 - p * p) - 1) : 0.5 * (Math.sqrt(1 - (p -= 2) * p) + 1);
})
);
//Elastic
_createElastic = function(n, f, def) {
var C = _class("easing." + n, function(amplitude, period) {
this._p1 = (amplitude >= 1) ? amplitude : 1; //note: if amplitude is < 1, we simply adjust the period for a more natural feel. Otherwise the math doesn't work right and the curve starts at 1.
this._p2 = (period || def) / (amplitude < 1 ? amplitude : 1);
this._p3 = this._p2 / _2PI * (Math.asin(1 / this._p1) || 0);
this._p2 = _2PI / this._p2; //precalculate to optimize
}, true),
p = C.prototype = new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */]();
p.constructor = C;
p.getRatio = f;
p.config = function(amplitude, period) {
return new C(amplitude, period);
};
return C;
};
_wrap("Elastic",
_createElastic("ElasticOut", function(p) {
return this._p1 * Math.pow(2, -10 * p) * Math.sin( (p - this._p3) * this._p2 ) + 1;
}, 0.3),
_createElastic("ElasticIn", function(p) {
return -(this._p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin( (p - this._p3) * this._p2 ));
}, 0.3),
_createElastic("ElasticInOut", function(p) {
return ((p *= 2) < 1) ? -0.5 * (this._p1 * Math.pow(2, 10 * (p -= 1)) * Math.sin( (p - this._p3) * this._p2)) : this._p1 * Math.pow(2, -10 *(p -= 1)) * Math.sin( (p - this._p3) * this._p2 ) * 0.5 + 1;
}, 0.45)
);
//Expo
_wrap("Expo",
_create("ExpoOut", function(p) {
return 1 - Math.pow(2, -10 * p);
}),
_create("ExpoIn", function(p) {
return Math.pow(2, 10 * (p - 1)) - 0.001;
}),
_create("ExpoInOut", function(p) {
return ((p *= 2) < 1) ? 0.5 * Math.pow(2, 10 * (p - 1)) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
})
);
//Sine
_wrap("Sine",
_create("SineOut", function(p) {
return Math.sin(p * _HALF_PI);
}),
_create("SineIn", function(p) {
return -Math.cos(p * _HALF_PI) + 1;
}),
_create("SineInOut", function(p) {
return -0.5 * (Math.cos(Math.PI * p) - 1);
})
);
_class("easing.EaseLookup", {
find:function(s) {
return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */].map[s];
}
}, true);
//register the non-standard eases
_easeReg(w.SlowMo, "SlowMo", "ease,");
_easeReg(RoughEase, "RoughEase", "ease,");
_easeReg(SteppedEase, "SteppedEase", "ease,");
return Back;
}, true);
var Back = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].Back;
var Elastic = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].Elastic;
var Bounce = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].Bounce;
var RoughEase = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].RoughEase;
var SlowMo = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].SlowMo;
var SteppedEase = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].SteppedEase;
var Circ = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].Circ;
var Expo = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].Expo;
var Sine = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].Sine;
var ExpoScaleEase = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].ExpoScaleEase;
/***/ }),
/* 228 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(229);
module.exports = __webpack_require__(431);
/***/ }),
/* 229 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(global) {
__webpack_require__(230);
__webpack_require__(427);
__webpack_require__(428);
if (global._babelPolyfill) {
throw new Error("only one instance of babel-polyfill is allowed");
}
global._babelPolyfill = true;
var DEFINE_PROPERTY = "defineProperty";
function define(O, key, value) {
O[key] || Object[DEFINE_PROPERTY](O, key, {
writable: true,
configurable: true,
value: value
});
}
define(String.prototype, "padLeft", "".padStart);
define(String.prototype, "padRight", "".padEnd);
"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function (key) {
[][key] && define(Array, key, Function.call.bind([][key]));
});
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(53)))
/***/ }),
/* 230 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(231);
__webpack_require__(234);
__webpack_require__(235);
__webpack_require__(236);
__webpack_require__(237);
__webpack_require__(238);
__webpack_require__(239);
__webpack_require__(240);
__webpack_require__(241);
__webpack_require__(242);
__webpack_require__(243);
__webpack_require__(244);
__webpack_require__(245);
__webpack_require__(246);
__webpack_require__(247);
__webpack_require__(248);
__webpack_require__(249);
__webpack_require__(250);
__webpack_require__(251);
__webpack_require__(252);
__webpack_require__(253);
__webpack_require__(254);
__webpack_require__(255);
__webpack_require__(256);
__webpack_require__(257);
__webpack_require__(258);
__webpack_require__(259);
__webpack_require__(260);
__webpack_require__(261);
__webpack_require__(262);
__webpack_require__(263);
__webpack_require__(264);
__webpack_require__(265);
__webpack_require__(266);
__webpack_require__(267);
__webpack_require__(268);
__webpack_require__(269);
__webpack_require__(270);
__webpack_require__(271);
__webpack_require__(272);
__webpack_require__(273);
__webpack_require__(274);
__webpack_require__(275);
__webpack_require__(276);
__webpack_require__(277);
__webpack_require__(278);
__webpack_require__(279);
__webpack_require__(280);
__webpack_require__(281);
__webpack_require__(282);
__webpack_require__(283);
__webpack_require__(284);
__webpack_require__(285);
__webpack_require__(286);
__webpack_require__(287);
__webpack_require__(288);
__webpack_require__(289);
__webpack_require__(290);
__webpack_require__(291);
__webpack_require__(292);
__webpack_require__(293);
__webpack_require__(294);
__webpack_require__(295);
__webpack_require__(296);
__webpack_require__(297);
__webpack_require__(298);
__webpack_require__(299);
__webpack_require__(300);
__webpack_require__(301);
__webpack_require__(302);
__webpack_require__(303);
__webpack_require__(304);
__webpack_require__(305);
__webpack_require__(306);
__webpack_require__(307);
__webpack_require__(308);
__webpack_require__(309);
__webpack_require__(311);
__webpack_require__(312);
__webpack_require__(314);
__webpack_require__(315);
__webpack_require__(316);
__webpack_require__(317);
__webpack_require__(318);
__webpack_require__(319);
__webpack_require__(320);
__webpack_require__(322);
__webpack_require__(323);
__webpack_require__(324);
__webpack_require__(325);
__webpack_require__(326);
__webpack_require__(327);
__webpack_require__(328);
__webpack_require__(329);
__webpack_require__(330);
__webpack_require__(331);
__webpack_require__(332);
__webpack_require__(333);
__webpack_require__(334);
__webpack_require__(109);
__webpack_require__(335);
__webpack_require__(152);
__webpack_require__(336);
__webpack_require__(153);
__webpack_require__(337);
__webpack_require__(338);
__webpack_require__(339);
__webpack_require__(340);
__webpack_require__(341);
__webpack_require__(156);
__webpack_require__(158);
__webpack_require__(159);
__webpack_require__(342);
__webpack_require__(343);
__webpack_require__(344);
__webpack_require__(345);
__webpack_require__(346);
__webpack_require__(347);
__webpack_require__(348);
__webpack_require__(349);
__webpack_require__(350);
__webpack_require__(351);
__webpack_require__(352);
__webpack_require__(353);
__webpack_require__(354);
__webpack_require__(355);
__webpack_require__(356);
__webpack_require__(357);
__webpack_require__(358);
__webpack_require__(359);
__webpack_require__(360);
__webpack_require__(361);
__webpack_require__(362);
__webpack_require__(363);
__webpack_require__(364);
__webpack_require__(365);
__webpack_require__(366);
__webpack_require__(367);
__webpack_require__(368);
__webpack_require__(369);
__webpack_require__(370);
__webpack_require__(371);
__webpack_require__(372);
__webpack_require__(373);
__webpack_require__(374);
__webpack_require__(375);
__webpack_require__(376);
__webpack_require__(377);
__webpack_require__(378);
__webpack_require__(379);
__webpack_require__(380);
__webpack_require__(381);
__webpack_require__(382);
__webpack_require__(383);
__webpack_require__(384);
__webpack_require__(385);
__webpack_require__(386);
__webpack_require__(387);
__webpack_require__(388);
__webpack_require__(389);
__webpack_require__(390);
__webpack_require__(391);
__webpack_require__(392);
__webpack_require__(393);
__webpack_require__(394);
__webpack_require__(395);
__webpack_require__(396);
__webpack_require__(397);
__webpack_require__(398);
__webpack_require__(399);
__webpack_require__(400);
__webpack_require__(401);
__webpack_require__(402);
__webpack_require__(403);
__webpack_require__(404);
__webpack_require__(405);
__webpack_require__(406);
__webpack_require__(407);
__webpack_require__(408);
__webpack_require__(409);
__webpack_require__(410);
__webpack_require__(411);
__webpack_require__(412);
__webpack_require__(413);
__webpack_require__(414);
__webpack_require__(415);
__webpack_require__(416);
__webpack_require__(417);
__webpack_require__(418);
__webpack_require__(419);
__webpack_require__(420);
__webpack_require__(421);
__webpack_require__(422);
__webpack_require__(423);
__webpack_require__(424);
__webpack_require__(425);
__webpack_require__(426);
module.exports = __webpack_require__(24);
/***/ }),
/* 231 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// ECMAScript 6 symbols shim
var global = __webpack_require__(2);
var has = __webpack_require__(19);
var DESCRIPTORS = __webpack_require__(10);
var $export = __webpack_require__(0);
var redefine = __webpack_require__(17);
var META = __webpack_require__(38).KEY;
var $fails = __webpack_require__(4);
var shared = __webpack_require__(59);
var setToStringTag = __webpack_require__(54);
var uid = __webpack_require__(42);
var wks = __webpack_require__(8);
var wksExt = __webpack_require__(134);
var wksDefine = __webpack_require__(90);
var enumKeys = __webpack_require__(233);
var isArray = __webpack_require__(72);
var anObject = __webpack_require__(1);
var isObject = __webpack_require__(6);
var toIObject = __webpack_require__(20);
var toPrimitive = __webpack_require__(30);
var createDesc = __webpack_require__(41);
var _create = __webpack_require__(45);
var gOPNExt = __webpack_require__(137);
var $GOPD = __webpack_require__(21);
var $DP = __webpack_require__(11);
var $keys = __webpack_require__(43);
var gOPD = $GOPD.f;
var dP = $DP.f;
var gOPN = gOPNExt.f;
var $Symbol = global.Symbol;
var $JSON = global.JSON;
var _stringify = $JSON && $JSON.stringify;
var PROTOTYPE = 'prototype';
var HIDDEN = wks('_hidden');
var TO_PRIMITIVE = wks('toPrimitive');
var isEnum = {}.propertyIsEnumerable;
var SymbolRegistry = shared('symbol-registry');
var AllSymbols = shared('symbols');
var OPSymbols = shared('op-symbols');
var ObjectProto = Object[PROTOTYPE];
var USE_NATIVE = typeof $Symbol == 'function';
var QObject = global.QObject;
// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
var setSymbolDesc = DESCRIPTORS && $fails(function () {
return _create(dP({}, 'a', {
get: function () { return dP(this, 'a', { value: 7 }).a; }
})).a != 7;
}) ? function (it, key, D) {
var protoDesc = gOPD(ObjectProto, key);
if (protoDesc) delete ObjectProto[key];
dP(it, key, D);
if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
} : dP;
var wrap = function (tag) {
var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
sym._k = tag;
return sym;
};
var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
return typeof it == 'symbol';
} : function (it) {
return it instanceof $Symbol;
};
var $defineProperty = function defineProperty(it, key, D) {
if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
anObject(it);
key = toPrimitive(key, true);
anObject(D);
if (has(AllSymbols, key)) {
if (!D.enumerable) {
if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
it[HIDDEN][key] = true;
} else {
if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
D = _create(D, { enumerable: createDesc(0, false) });
} return setSymbolDesc(it, key, D);
} return dP(it, key, D);
};
var $defineProperties = function defineProperties(it, P) {
anObject(it);
var keys = enumKeys(P = toIObject(P));
var i = 0;
var l = keys.length;
var key;
while (l > i) $defineProperty(it, key = keys[i++], P[key]);
return it;
};
var $create = function create(it, P) {
return P === undefined ? _create(it) : $defineProperties(_create(it), P);
};
var $propertyIsEnumerable = function propertyIsEnumerable(key) {
var E = isEnum.call(this, key = toPrimitive(key, true));
if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
};
var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
it = toIObject(it);
key = toPrimitive(key, true);
if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
var D = gOPD(it, key);
if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
return D;
};
var $getOwnPropertyNames = function getOwnPropertyNames(it) {
var names = gOPN(toIObject(it));
var result = [];
var i = 0;
var key;
while (names.length > i) {
if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
} return result;
};
var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
var IS_OP = it === ObjectProto;
var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
var result = [];
var i = 0;
var key;
while (names.length > i) {
if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
} return result;
};
// 19.4.1.1 Symbol([description])
if (!USE_NATIVE) {
$Symbol = function Symbol() {
if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
var $set = function (value) {
if (this === ObjectProto) $set.call(OPSymbols, value);
if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
setSymbolDesc(this, tag, createDesc(1, value));
};
if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
return wrap(tag);
};
redefine($Symbol[PROTOTYPE], 'toString', function toString() {
return this._k;
});
$GOPD.f = $getOwnPropertyDescriptor;
$DP.f = $defineProperty;
__webpack_require__(46).f = gOPNExt.f = $getOwnPropertyNames;
__webpack_require__(61).f = $propertyIsEnumerable;
__webpack_require__(71).f = $getOwnPropertySymbols;
if (DESCRIPTORS && !__webpack_require__(37)) {
redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
}
wksExt.f = function (name) {
return wrap(wks(name));
};
}
$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
for (var es6Symbols = (
// 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
// 19.4.2.1 Symbol.for(key)
'for': function (key) {
return has(SymbolRegistry, key += '')
? SymbolRegistry[key]
: SymbolRegistry[key] = $Symbol(key);
},
// 19.4.2.5 Symbol.keyFor(sym)
keyFor: function keyFor(sym) {
if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
},
useSetter: function () { setter = true; },
useSimple: function () { setter = false; }
});
$export($export.S + $export.F * !USE_NATIVE, 'Object', {
// 19.1.2.2 Object.create(O [, Properties])
create: $create,
// 19.1.2.4 Object.defineProperty(O, P, Attributes)
defineProperty: $defineProperty,
// 19.1.2.3 Object.defineProperties(O, Properties)
defineProperties: $defineProperties,
// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
// 19.1.2.7 Object.getOwnPropertyNames(O)
getOwnPropertyNames: $getOwnPropertyNames,
// 19.1.2.8 Object.getOwnPropertySymbols(O)
getOwnPropertySymbols: $getOwnPropertySymbols
});
// 24.3.2 JSON.stringify(value [, replacer [, space]])
$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
var S = $Symbol();
// MS Edge converts symbol values to JSON as {}
// WebKit converts symbol values to JSON as null
// V8 throws on boxed symbols
return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
})), 'JSON', {
stringify: function stringify(it) {
var args = [it];
var i = 1;
var replacer, $replacer;
while (arguments.length > i) args.push(arguments[i++]);
$replacer = replacer = args[1];
if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
if (!isArray(replacer)) replacer = function (key, value) {
if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
if (!isSymbol(value)) return value;
};
args[1] = replacer;
return _stringify.apply($JSON, args);
}
});
// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
$Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(16)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
// 19.4.3.5 Symbol.prototype[@@toStringTag]
setToStringTag($Symbol, 'Symbol');
// 20.2.1.9 Math[@@toStringTag]
setToStringTag(Math, 'Math', true);
// 24.3.3 JSON[@@toStringTag]
setToStringTag(global.JSON, 'JSON', true);
/***/ }),
/* 232 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(59)('native-function-to-string', Function.toString);
/***/ }),
/* 233 */
/***/ (function(module, exports, __webpack_require__) {
// all enumerable object keys, includes symbols
var getKeys = __webpack_require__(43);
var gOPS = __webpack_require__(71);
var pIE = __webpack_require__(61);
module.exports = function (it) {
var result = getKeys(it);
var getSymbols = gOPS.f;
if (getSymbols) {
var symbols = getSymbols(it);
var isEnum = pIE.f;
var i = 0;
var key;
while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
} return result;
};
/***/ }),
/* 234 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
$export($export.S, 'Object', { create: __webpack_require__(45) });
/***/ }),
/* 235 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
$export($export.S + $export.F * !__webpack_require__(10), 'Object', { defineProperty: __webpack_require__(11).f });
/***/ }),
/* 236 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
// 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties)
$export($export.S + $export.F * !__webpack_require__(10), 'Object', { defineProperties: __webpack_require__(136) });
/***/ }),
/* 237 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
var toIObject = __webpack_require__(20);
var $getOwnPropertyDescriptor = __webpack_require__(21).f;
__webpack_require__(32)('getOwnPropertyDescriptor', function () {
return function getOwnPropertyDescriptor(it, key) {
return $getOwnPropertyDescriptor(toIObject(it), key);
};
});
/***/ }),
/* 238 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.9 Object.getPrototypeOf(O)
var toObject = __webpack_require__(12);
var $getPrototypeOf = __webpack_require__(22);
__webpack_require__(32)('getPrototypeOf', function () {
return function getPrototypeOf(it) {
return $getPrototypeOf(toObject(it));
};
});
/***/ }),
/* 239 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.14 Object.keys(O)
var toObject = __webpack_require__(12);
var $keys = __webpack_require__(43);
__webpack_require__(32)('keys', function () {
return function keys(it) {
return $keys(toObject(it));
};
});
/***/ }),
/* 240 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.7 Object.getOwnPropertyNames(O)
__webpack_require__(32)('getOwnPropertyNames', function () {
return __webpack_require__(137).f;
});
/***/ }),
/* 241 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.5 Object.freeze(O)
var isObject = __webpack_require__(6);
var meta = __webpack_require__(38).onFreeze;
__webpack_require__(32)('freeze', function ($freeze) {
return function freeze(it) {
return $freeze && isObject(it) ? $freeze(meta(it)) : it;
};
});
/***/ }),
/* 242 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.17 Object.seal(O)
var isObject = __webpack_require__(6);
var meta = __webpack_require__(38).onFreeze;
__webpack_require__(32)('seal', function ($seal) {
return function seal(it) {
return $seal && isObject(it) ? $seal(meta(it)) : it;
};
});
/***/ }),
/* 243 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.15 Object.preventExtensions(O)
var isObject = __webpack_require__(6);
var meta = __webpack_require__(38).onFreeze;
__webpack_require__(32)('preventExtensions', function ($preventExtensions) {
return function preventExtensions(it) {
return $preventExtensions && isObject(it) ? $preventExtensions(meta(it)) : it;
};
});
/***/ }),
/* 244 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.12 Object.isFrozen(O)
var isObject = __webpack_require__(6);
__webpack_require__(32)('isFrozen', function ($isFrozen) {
return function isFrozen(it) {
return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true;
};
});
/***/ }),
/* 245 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.13 Object.isSealed(O)
var isObject = __webpack_require__(6);
__webpack_require__(32)('isSealed', function ($isSealed) {
return function isSealed(it) {
return isObject(it) ? $isSealed ? $isSealed(it) : false : true;
};
});
/***/ }),
/* 246 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.11 Object.isExtensible(O)
var isObject = __webpack_require__(6);
__webpack_require__(32)('isExtensible', function ($isExtensible) {
return function isExtensible(it) {
return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false;
};
});
/***/ }),
/* 247 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.3.1 Object.assign(target, source)
var $export = __webpack_require__(0);
$export($export.S + $export.F, 'Object', { assign: __webpack_require__(138) });
/***/ }),
/* 248 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.3.10 Object.is(value1, value2)
var $export = __webpack_require__(0);
$export($export.S, 'Object', { is: __webpack_require__(139) });
/***/ }),
/* 249 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.3.19 Object.setPrototypeOf(O, proto)
var $export = __webpack_require__(0);
$export($export.S, 'Object', { setPrototypeOf: __webpack_require__(94).set });
/***/ }),
/* 250 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 19.1.3.6 Object.prototype.toString()
var classof = __webpack_require__(55);
var test = {};
test[__webpack_require__(8)('toStringTag')] = 'z';
if (test + '' != '[object z]') {
__webpack_require__(17)(Object.prototype, 'toString', function toString() {
return '[object ' + classof(this) + ']';
}, true);
}
/***/ }),
/* 251 */
/***/ (function(module, exports, __webpack_require__) {
// 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...)
var $export = __webpack_require__(0);
$export($export.P, 'Function', { bind: __webpack_require__(140) });
/***/ }),
/* 252 */
/***/ (function(module, exports, __webpack_require__) {
var dP = __webpack_require__(11).f;
var FProto = Function.prototype;
var nameRE = /^\s*function ([^ (]*)/;
var NAME = 'name';
// 19.2.4.2 name
NAME in FProto || __webpack_require__(10) && dP(FProto, NAME, {
configurable: true,
get: function () {
try {
return ('' + this).match(nameRE)[1];
} catch (e) {
return '';
}
}
});
/***/ }),
/* 253 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var isObject = __webpack_require__(6);
var getPrototypeOf = __webpack_require__(22);
var HAS_INSTANCE = __webpack_require__(8)('hasInstance');
var FunctionProto = Function.prototype;
// 19.2.3.6 Function.prototype[@@hasInstance](V)
if (!(HAS_INSTANCE in FunctionProto)) __webpack_require__(11).f(FunctionProto, HAS_INSTANCE, { value: function (O) {
if (typeof this != 'function' || !isObject(O)) return false;
if (!isObject(this.prototype)) return O instanceof this;
// for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
while (O = getPrototypeOf(O)) if (this.prototype === O) return true;
return false;
} });
/***/ }),
/* 254 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
var $parseInt = __webpack_require__(142);
// 18.2.5 parseInt(string, radix)
$export($export.G + $export.F * (parseInt != $parseInt), { parseInt: $parseInt });
/***/ }),
/* 255 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
var $parseFloat = __webpack_require__(143);
// 18.2.4 parseFloat(string)
$export($export.G + $export.F * (parseFloat != $parseFloat), { parseFloat: $parseFloat });
/***/ }),
/* 256 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var global = __webpack_require__(2);
var has = __webpack_require__(19);
var cof = __webpack_require__(26);
var inheritIfRequired = __webpack_require__(96);
var toPrimitive = __webpack_require__(30);
var fails = __webpack_require__(4);
var gOPN = __webpack_require__(46).f;
var gOPD = __webpack_require__(21).f;
var dP = __webpack_require__(11).f;
var $trim = __webpack_require__(56).trim;
var NUMBER = 'Number';
var $Number = global[NUMBER];
var Base = $Number;
var proto = $Number.prototype;
// Opera ~12 has broken Object#toString
var BROKEN_COF = cof(__webpack_require__(45)(proto)) == NUMBER;
var TRIM = 'trim' in String.prototype;
// 7.1.3 ToNumber(argument)
var toNumber = function (argument) {
var it = toPrimitive(argument, false);
if (typeof it == 'string' && it.length > 2) {
it = TRIM ? it.trim() : $trim(it, 3);
var first = it.charCodeAt(0);
var third, radix, maxCode;
if (first === 43 || first === 45) {
third = it.charCodeAt(2);
if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
} else if (first === 48) {
switch (it.charCodeAt(1)) {
case 66: case 98: radix = 2; maxCode = 49; break; // fast equal /^0b[01]+$/i
case 79: case 111: radix = 8; maxCode = 55; break; // fast equal /^0o[0-7]+$/i
default: return +it;
}
for (var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++) {
code = digits.charCodeAt(i);
// parseInt parses a string to a first unavailable symbol
// but ToNumber should return NaN if a string contains unavailable symbols
if (code < 48 || code > maxCode) return NaN;
} return parseInt(digits, radix);
}
} return +it;
};
if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) {
$Number = function Number(value) {
var it = arguments.length < 1 ? 0 : value;
var that = this;
return that instanceof $Number
// check on 1..constructor(foo) case
&& (BROKEN_COF ? fails(function () { proto.valueOf.call(that); }) : cof(that) != NUMBER)
? inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it);
};
for (var keys = __webpack_require__(10) ? gOPN(Base) : (
// ES3:
'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
// ES6 (in case, if modules with ES6 Number statics required before):
'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
).split(','), j = 0, key; keys.length > j; j++) {
if (has(Base, key = keys[j]) && !has($Number, key)) {
dP($Number, key, gOPD(Base, key));
}
}
$Number.prototype = proto;
proto.constructor = $Number;
__webpack_require__(17)(global, NUMBER, $Number);
}
/***/ }),
/* 257 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var toInteger = __webpack_require__(27);
var aNumberValue = __webpack_require__(144);
var repeat = __webpack_require__(97);
var $toFixed = 1.0.toFixed;
var floor = Math.floor;
var data = [0, 0, 0, 0, 0, 0];
var ERROR = 'Number.toFixed: incorrect invocation!';
var ZERO = '0';
var multiply = function (n, c) {
var i = -1;
var c2 = c;
while (++i < 6) {
c2 += n * data[i];
data[i] = c2 % 1e7;
c2 = floor(c2 / 1e7);
}
};
var divide = function (n) {
var i = 6;
var c = 0;
while (--i >= 0) {
c += data[i];
data[i] = floor(c / n);
c = (c % n) * 1e7;
}
};
var numToString = function () {
var i = 6;
var s = '';
while (--i >= 0) {
if (s !== '' || i === 0 || data[i] !== 0) {
var t = String(data[i]);
s = s === '' ? t : s + repeat.call(ZERO, 7 - t.length) + t;
}
} return s;
};
var pow = function (x, n, acc) {
return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);
};
var log = function (x) {
var n = 0;
var x2 = x;
while (x2 >= 4096) {
n += 12;
x2 /= 4096;
}
while (x2 >= 2) {
n += 1;
x2 /= 2;
} return n;
};
$export($export.P + $export.F * (!!$toFixed && (
0.00008.toFixed(3) !== '0.000' ||
0.9.toFixed(0) !== '1' ||
1.255.toFixed(2) !== '1.25' ||
1000000000000000128.0.toFixed(0) !== '1000000000000000128'
) || !__webpack_require__(4)(function () {
// V8 ~ Android 4.3-
$toFixed.call({});
})), 'Number', {
toFixed: function toFixed(fractionDigits) {
var x = aNumberValue(this, ERROR);
var f = toInteger(fractionDigits);
var s = '';
var m = ZERO;
var e, z, j, k;
if (f < 0 || f > 20) throw RangeError(ERROR);
// eslint-disable-next-line no-self-compare
if (x != x) return 'NaN';
if (x <= -1e21 || x >= 1e21) return String(x);
if (x < 0) {
s = '-';
x = -x;
}
if (x > 1e-21) {
e = log(x * pow(2, 69, 1)) - 69;
z = e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1);
z *= 0x10000000000000;
e = 52 - e;
if (e > 0) {
multiply(0, z);
j = f;
while (j >= 7) {
multiply(1e7, 0);
j -= 7;
}
multiply(pow(10, j, 1), 0);
j = e - 1;
while (j >= 23) {
divide(1 << 23);
j -= 23;
}
divide(1 << j);
multiply(1, 1);
divide(2);
m = numToString();
} else {
multiply(0, z);
multiply(1 << -e, 0);
m = numToString() + repeat.call(ZERO, f);
}
}
if (f > 0) {
k = m.length;
m = s + (k <= f ? '0.' + repeat.call(ZERO, f - k) + m : m.slice(0, k - f) + '.' + m.slice(k - f));
} else {
m = s + m;
} return m;
}
});
/***/ }),
/* 258 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $fails = __webpack_require__(4);
var aNumberValue = __webpack_require__(144);
var $toPrecision = 1.0.toPrecision;
$export($export.P + $export.F * ($fails(function () {
// IE7-
return $toPrecision.call(1, undefined) !== '1';
}) || !$fails(function () {
// V8 ~ Android 4.3-
$toPrecision.call({});
})), 'Number', {
toPrecision: function toPrecision(precision) {
var that = aNumberValue(this, 'Number#toPrecision: incorrect invocation!');
return precision === undefined ? $toPrecision.call(that) : $toPrecision.call(that, precision);
}
});
/***/ }),
/* 259 */
/***/ (function(module, exports, __webpack_require__) {
// 20.1.2.1 Number.EPSILON
var $export = __webpack_require__(0);
$export($export.S, 'Number', { EPSILON: Math.pow(2, -52) });
/***/ }),
/* 260 */
/***/ (function(module, exports, __webpack_require__) {
// 20.1.2.2 Number.isFinite(number)
var $export = __webpack_require__(0);
var _isFinite = __webpack_require__(2).isFinite;
$export($export.S, 'Number', {
isFinite: function isFinite(it) {
return typeof it == 'number' && _isFinite(it);
}
});
/***/ }),
/* 261 */
/***/ (function(module, exports, __webpack_require__) {
// 20.1.2.3 Number.isInteger(number)
var $export = __webpack_require__(0);
$export($export.S, 'Number', { isInteger: __webpack_require__(145) });
/***/ }),
/* 262 */
/***/ (function(module, exports, __webpack_require__) {
// 20.1.2.4 Number.isNaN(number)
var $export = __webpack_require__(0);
$export($export.S, 'Number', {
isNaN: function isNaN(number) {
// eslint-disable-next-line no-self-compare
return number != number;
}
});
/***/ }),
/* 263 */
/***/ (function(module, exports, __webpack_require__) {
// 20.1.2.5 Number.isSafeInteger(number)
var $export = __webpack_require__(0);
var isInteger = __webpack_require__(145);
var abs = Math.abs;
$export($export.S, 'Number', {
isSafeInteger: function isSafeInteger(number) {
return isInteger(number) && abs(number) <= 0x1fffffffffffff;
}
});
/***/ }),
/* 264 */
/***/ (function(module, exports, __webpack_require__) {
// 20.1.2.6 Number.MAX_SAFE_INTEGER
var $export = __webpack_require__(0);
$export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff });
/***/ }),
/* 265 */
/***/ (function(module, exports, __webpack_require__) {
// 20.1.2.10 Number.MIN_SAFE_INTEGER
var $export = __webpack_require__(0);
$export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff });
/***/ }),
/* 266 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
var $parseFloat = __webpack_require__(143);
// 20.1.2.12 Number.parseFloat(string)
$export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', { parseFloat: $parseFloat });
/***/ }),
/* 267 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
var $parseInt = __webpack_require__(142);
// 20.1.2.13 Number.parseInt(string, radix)
$export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', { parseInt: $parseInt });
/***/ }),
/* 268 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.3 Math.acosh(x)
var $export = __webpack_require__(0);
var log1p = __webpack_require__(146);
var sqrt = Math.sqrt;
var $acosh = Math.acosh;
$export($export.S + $export.F * !($acosh
// V8 bug: https://code.google.com/p/v8/issues/detail?id=3509
&& Math.floor($acosh(Number.MAX_VALUE)) == 710
// Tor Browser bug: Math.acosh(Infinity) -> NaN
&& $acosh(Infinity) == Infinity
), 'Math', {
acosh: function acosh(x) {
return (x = +x) < 1 ? NaN : x > 94906265.62425156
? Math.log(x) + Math.LN2
: log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));
}
});
/***/ }),
/* 269 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.5 Math.asinh(x)
var $export = __webpack_require__(0);
var $asinh = Math.asinh;
function asinh(x) {
return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : Math.log(x + Math.sqrt(x * x + 1));
}
// Tor Browser bug: Math.asinh(0) -> -0
$export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { asinh: asinh });
/***/ }),
/* 270 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.7 Math.atanh(x)
var $export = __webpack_require__(0);
var $atanh = Math.atanh;
// Tor Browser bug: Math.atanh(-0) -> 0
$export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', {
atanh: function atanh(x) {
return (x = +x) == 0 ? x : Math.log((1 + x) / (1 - x)) / 2;
}
});
/***/ }),
/* 271 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.9 Math.cbrt(x)
var $export = __webpack_require__(0);
var sign = __webpack_require__(98);
$export($export.S, 'Math', {
cbrt: function cbrt(x) {
return sign(x = +x) * Math.pow(Math.abs(x), 1 / 3);
}
});
/***/ }),
/* 272 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.11 Math.clz32(x)
var $export = __webpack_require__(0);
$export($export.S, 'Math', {
clz32: function clz32(x) {
return (x >>>= 0) ? 31 - Math.floor(Math.log(x + 0.5) * Math.LOG2E) : 32;
}
});
/***/ }),
/* 273 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.12 Math.cosh(x)
var $export = __webpack_require__(0);
var exp = Math.exp;
$export($export.S, 'Math', {
cosh: function cosh(x) {
return (exp(x = +x) + exp(-x)) / 2;
}
});
/***/ }),
/* 274 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.14 Math.expm1(x)
var $export = __webpack_require__(0);
var $expm1 = __webpack_require__(99);
$export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', { expm1: $expm1 });
/***/ }),
/* 275 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.16 Math.fround(x)
var $export = __webpack_require__(0);
$export($export.S, 'Math', { fround: __webpack_require__(147) });
/***/ }),
/* 276 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
var $export = __webpack_require__(0);
var abs = Math.abs;
$export($export.S, 'Math', {
hypot: function hypot(value1, value2) { // eslint-disable-line no-unused-vars
var sum = 0;
var i = 0;
var aLen = arguments.length;
var larg = 0;
var arg, div;
while (i < aLen) {
arg = abs(arguments[i++]);
if (larg < arg) {
div = larg / arg;
sum = sum * div * div + 1;
larg = arg;
} else if (arg > 0) {
div = arg / larg;
sum += div * div;
} else sum += arg;
}
return larg === Infinity ? Infinity : larg * Math.sqrt(sum);
}
});
/***/ }),
/* 277 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.18 Math.imul(x, y)
var $export = __webpack_require__(0);
var $imul = Math.imul;
// some WebKit versions fails with big numbers, some has wrong arity
$export($export.S + $export.F * __webpack_require__(4)(function () {
return $imul(0xffffffff, 5) != -5 || $imul.length != 2;
}), 'Math', {
imul: function imul(x, y) {
var UINT16 = 0xffff;
var xn = +x;
var yn = +y;
var xl = UINT16 & xn;
var yl = UINT16 & yn;
return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
}
});
/***/ }),
/* 278 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.21 Math.log10(x)
var $export = __webpack_require__(0);
$export($export.S, 'Math', {
log10: function log10(x) {
return Math.log(x) * Math.LOG10E;
}
});
/***/ }),
/* 279 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.20 Math.log1p(x)
var $export = __webpack_require__(0);
$export($export.S, 'Math', { log1p: __webpack_require__(146) });
/***/ }),
/* 280 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.22 Math.log2(x)
var $export = __webpack_require__(0);
$export($export.S, 'Math', {
log2: function log2(x) {
return Math.log(x) / Math.LN2;
}
});
/***/ }),
/* 281 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.28 Math.sign(x)
var $export = __webpack_require__(0);
$export($export.S, 'Math', { sign: __webpack_require__(98) });
/***/ }),
/* 282 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.30 Math.sinh(x)
var $export = __webpack_require__(0);
var expm1 = __webpack_require__(99);
var exp = Math.exp;
// V8 near Chromium 38 has a problem with very small numbers
$export($export.S + $export.F * __webpack_require__(4)(function () {
return !Math.sinh(-2e-17) != -2e-17;
}), 'Math', {
sinh: function sinh(x) {
return Math.abs(x = +x) < 1
? (expm1(x) - expm1(-x)) / 2
: (exp(x - 1) - exp(-x - 1)) * (Math.E / 2);
}
});
/***/ }),
/* 283 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.33 Math.tanh(x)
var $export = __webpack_require__(0);
var expm1 = __webpack_require__(99);
var exp = Math.exp;
$export($export.S, 'Math', {
tanh: function tanh(x) {
var a = expm1(x = +x);
var b = expm1(-x);
return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
}
});
/***/ }),
/* 284 */
/***/ (function(module, exports, __webpack_require__) {
// 20.2.2.34 Math.trunc(x)
var $export = __webpack_require__(0);
$export($export.S, 'Math', {
trunc: function trunc(it) {
return (it > 0 ? Math.floor : Math.ceil)(it);
}
});
/***/ }),
/* 285 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
var toAbsoluteIndex = __webpack_require__(44);
var fromCharCode = String.fromCharCode;
var $fromCodePoint = String.fromCodePoint;
// length should be 1, old FF problem
$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
// 21.1.2.2 String.fromCodePoint(...codePoints)
fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
var res = [];
var aLen = arguments.length;
var i = 0;
var code;
while (aLen > i) {
code = +arguments[i++];
if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
res.push(code < 0x10000
? fromCharCode(code)
: fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
);
} return res.join('');
}
});
/***/ }),
/* 286 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
var toIObject = __webpack_require__(20);
var toLength = __webpack_require__(9);
$export($export.S, 'String', {
// 21.1.2.4 String.raw(callSite, ...substitutions)
raw: function raw(callSite) {
var tpl = toIObject(callSite.raw);
var len = toLength(tpl.length);
var aLen = arguments.length;
var res = [];
var i = 0;
while (len > i) {
res.push(String(tpl[i++]));
if (i < aLen) res.push(String(arguments[i]));
} return res.join('');
}
});
/***/ }),
/* 287 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 21.1.3.25 String.prototype.trim()
__webpack_require__(56)('trim', function ($trim) {
return function trim() {
return $trim(this, 3);
};
});
/***/ }),
/* 288 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $at = __webpack_require__(73)(true);
// 21.1.3.27 String.prototype[@@iterator]()
__webpack_require__(100)(String, 'String', function (iterated) {
this._t = String(iterated); // target
this._i = 0; // next index
// 21.1.5.2.1 %StringIteratorPrototype%.next()
}, function () {
var O = this._t;
var index = this._i;
var point;
if (index >= O.length) return { value: undefined, done: true };
point = $at(O, index);
this._i += point.length;
return { value: point, done: false };
});
/***/ }),
/* 289 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $at = __webpack_require__(73)(false);
$export($export.P, 'String', {
// 21.1.3.3 String.prototype.codePointAt(pos)
codePointAt: function codePointAt(pos) {
return $at(this, pos);
}
});
/***/ }),
/* 290 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
var $export = __webpack_require__(0);
var toLength = __webpack_require__(9);
var context = __webpack_require__(102);
var ENDS_WITH = 'endsWith';
var $endsWith = ''[ENDS_WITH];
$export($export.P + $export.F * __webpack_require__(103)(ENDS_WITH), 'String', {
endsWith: function endsWith(searchString /* , endPosition = @length */) {
var that = context(this, searchString, ENDS_WITH);
var endPosition = arguments.length > 1 ? arguments[1] : undefined;
var len = toLength(that.length);
var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
var search = String(searchString);
return $endsWith
? $endsWith.call(that, search, end)
: that.slice(end - search.length, end) === search;
}
});
/***/ }),
/* 291 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 21.1.3.7 String.prototype.includes(searchString, position = 0)
var $export = __webpack_require__(0);
var context = __webpack_require__(102);
var INCLUDES = 'includes';
$export($export.P + $export.F * __webpack_require__(103)(INCLUDES), 'String', {
includes: function includes(searchString /* , position = 0 */) {
return !!~context(this, searchString, INCLUDES)
.indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
}
});
/***/ }),
/* 292 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
$export($export.P, 'String', {
// 21.1.3.13 String.prototype.repeat(count)
repeat: __webpack_require__(97)
});
/***/ }),
/* 293 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 21.1.3.18 String.prototype.startsWith(searchString [, position ])
var $export = __webpack_require__(0);
var toLength = __webpack_require__(9);
var context = __webpack_require__(102);
var STARTS_WITH = 'startsWith';
var $startsWith = ''[STARTS_WITH];
$export($export.P + $export.F * __webpack_require__(103)(STARTS_WITH), 'String', {
startsWith: function startsWith(searchString /* , position = 0 */) {
var that = context(this, searchString, STARTS_WITH);
var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));
var search = String(searchString);
return $startsWith
? $startsWith.call(that, search, index)
: that.slice(index, index + search.length) === search;
}
});
/***/ }),
/* 294 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.2 String.prototype.anchor(name)
__webpack_require__(18)('anchor', function (createHTML) {
return function anchor(name) {
return createHTML(this, 'a', 'name', name);
};
});
/***/ }),
/* 295 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.3 String.prototype.big()
__webpack_require__(18)('big', function (createHTML) {
return function big() {
return createHTML(this, 'big', '', '');
};
});
/***/ }),
/* 296 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.4 String.prototype.blink()
__webpack_require__(18)('blink', function (createHTML) {
return function blink() {
return createHTML(this, 'blink', '', '');
};
});
/***/ }),
/* 297 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.5 String.prototype.bold()
__webpack_require__(18)('bold', function (createHTML) {
return function bold() {
return createHTML(this, 'b', '', '');
};
});
/***/ }),
/* 298 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.6 String.prototype.fixed()
__webpack_require__(18)('fixed', function (createHTML) {
return function fixed() {
return createHTML(this, 'tt', '', '');
};
});
/***/ }),
/* 299 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.7 String.prototype.fontcolor(color)
__webpack_require__(18)('fontcolor', function (createHTML) {
return function fontcolor(color) {
return createHTML(this, 'font', 'color', color);
};
});
/***/ }),
/* 300 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.8 String.prototype.fontsize(size)
__webpack_require__(18)('fontsize', function (createHTML) {
return function fontsize(size) {
return createHTML(this, 'font', 'size', size);
};
});
/***/ }),
/* 301 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.9 String.prototype.italics()
__webpack_require__(18)('italics', function (createHTML) {
return function italics() {
return createHTML(this, 'i', '', '');
};
});
/***/ }),
/* 302 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.10 String.prototype.link(url)
__webpack_require__(18)('link', function (createHTML) {
return function link(url) {
return createHTML(this, 'a', 'href', url);
};
});
/***/ }),
/* 303 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.11 String.prototype.small()
__webpack_require__(18)('small', function (createHTML) {
return function small() {
return createHTML(this, 'small', '', '');
};
});
/***/ }),
/* 304 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.12 String.prototype.strike()
__webpack_require__(18)('strike', function (createHTML) {
return function strike() {
return createHTML(this, 'strike', '', '');
};
});
/***/ }),
/* 305 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.13 String.prototype.sub()
__webpack_require__(18)('sub', function (createHTML) {
return function sub() {
return createHTML(this, 'sub', '', '');
};
});
/***/ }),
/* 306 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// B.2.3.14 String.prototype.sup()
__webpack_require__(18)('sup', function (createHTML) {
return function sup() {
return createHTML(this, 'sup', '', '');
};
});
/***/ }),
/* 307 */
/***/ (function(module, exports, __webpack_require__) {
// 20.3.3.1 / 15.9.4.4 Date.now()
var $export = __webpack_require__(0);
$export($export.S, 'Date', { now: function () { return new Date().getTime(); } });
/***/ }),
/* 308 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var toObject = __webpack_require__(12);
var toPrimitive = __webpack_require__(30);
$export($export.P + $export.F * __webpack_require__(4)(function () {
return new Date(NaN).toJSON() !== null
|| Date.prototype.toJSON.call({ toISOString: function () { return 1; } }) !== 1;
}), 'Date', {
// eslint-disable-next-line no-unused-vars
toJSON: function toJSON(key) {
var O = toObject(this);
var pv = toPrimitive(O);
return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
}
});
/***/ }),
/* 309 */
/***/ (function(module, exports, __webpack_require__) {
// 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
var $export = __webpack_require__(0);
var toISOString = __webpack_require__(310);
// PhantomJS / old WebKit has a broken implementations
$export($export.P + $export.F * (Date.prototype.toISOString !== toISOString), 'Date', {
toISOString: toISOString
});
/***/ }),
/* 310 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
var fails = __webpack_require__(4);
var getTime = Date.prototype.getTime;
var $toISOString = Date.prototype.toISOString;
var lz = function (num) {
return num > 9 ? num : '0' + num;
};
// PhantomJS / old WebKit has a broken implementations
module.exports = (fails(function () {
return $toISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z';
}) || !fails(function () {
$toISOString.call(new Date(NaN));
})) ? function toISOString() {
if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value');
var d = this;
var y = d.getUTCFullYear();
var m = d.getUTCMilliseconds();
var s = y < 0 ? '-' : y > 9999 ? '+' : '';
return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +
'-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +
'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +
':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';
} : $toISOString;
/***/ }),
/* 311 */
/***/ (function(module, exports, __webpack_require__) {
var DateProto = Date.prototype;
var INVALID_DATE = 'Invalid Date';
var TO_STRING = 'toString';
var $toString = DateProto[TO_STRING];
var getTime = DateProto.getTime;
if (new Date(NaN) + '' != INVALID_DATE) {
__webpack_require__(17)(DateProto, TO_STRING, function toString() {
var value = getTime.call(this);
// eslint-disable-next-line no-self-compare
return value === value ? $toString.call(this) : INVALID_DATE;
});
}
/***/ }),
/* 312 */
/***/ (function(module, exports, __webpack_require__) {
var TO_PRIMITIVE = __webpack_require__(8)('toPrimitive');
var proto = Date.prototype;
if (!(TO_PRIMITIVE in proto)) __webpack_require__(16)(proto, TO_PRIMITIVE, __webpack_require__(313));
/***/ }),
/* 313 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var anObject = __webpack_require__(1);
var toPrimitive = __webpack_require__(30);
var NUMBER = 'number';
module.exports = function (hint) {
if (hint !== 'string' && hint !== NUMBER && hint !== 'default') throw TypeError('Incorrect hint');
return toPrimitive(anObject(this), hint != NUMBER);
};
/***/ }),
/* 314 */
/***/ (function(module, exports, __webpack_require__) {
// 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
var $export = __webpack_require__(0);
$export($export.S, 'Array', { isArray: __webpack_require__(72) });
/***/ }),
/* 315 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var ctx = __webpack_require__(25);
var $export = __webpack_require__(0);
var toObject = __webpack_require__(12);
var call = __webpack_require__(148);
var isArrayIter = __webpack_require__(104);
var toLength = __webpack_require__(9);
var createProperty = __webpack_require__(105);
var getIterFn = __webpack_require__(106);
$export($export.S + $export.F * !__webpack_require__(75)(function (iter) { Array.from(iter); }), 'Array', {
// 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
var O = toObject(arrayLike);
var C = typeof this == 'function' ? this : Array;
var aLen = arguments.length;
var mapfn = aLen > 1 ? arguments[1] : undefined;
var mapping = mapfn !== undefined;
var index = 0;
var iterFn = getIterFn(O);
var length, result, step, iterator;
if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
// if object isn't iterable or it's array with default iterator - use simple case
if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
}
} else {
length = toLength(O.length);
for (result = new C(length); length > index; index++) {
createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
}
}
result.length = index;
return result;
}
});
/***/ }),
/* 316 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var createProperty = __webpack_require__(105);
// WebKit Array.of isn't generic
$export($export.S + $export.F * __webpack_require__(4)(function () {
function F() { /* empty */ }
return !(Array.of.call(F) instanceof F);
}), 'Array', {
// 22.1.2.3 Array.of( ...items)
of: function of(/* ...args */) {
var index = 0;
var aLen = arguments.length;
var result = new (typeof this == 'function' ? this : Array)(aLen);
while (aLen > index) createProperty(result, index, arguments[index++]);
result.length = aLen;
return result;
}
});
/***/ }),
/* 317 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 22.1.3.13 Array.prototype.join(separator)
var $export = __webpack_require__(0);
var toIObject = __webpack_require__(20);
var arrayJoin = [].join;
// fallback for not array-like strings
$export($export.P + $export.F * (__webpack_require__(60) != Object || !__webpack_require__(28)(arrayJoin)), 'Array', {
join: function join(separator) {
return arrayJoin.call(toIObject(this), separator === undefined ? ',' : separator);
}
});
/***/ }),
/* 318 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var html = __webpack_require__(93);
var cof = __webpack_require__(26);
var toAbsoluteIndex = __webpack_require__(44);
var toLength = __webpack_require__(9);
var arraySlice = [].slice;
// fallback for not array-like ES3 strings and DOM objects
$export($export.P + $export.F * __webpack_require__(4)(function () {
if (html) arraySlice.call(html);
}), 'Array', {
slice: function slice(begin, end) {
var len = toLength(this.length);
var klass = cof(this);
end = end === undefined ? len : end;
if (klass == 'Array') return arraySlice.call(this, begin, end);
var start = toAbsoluteIndex(begin, len);
var upTo = toAbsoluteIndex(end, len);
var size = toLength(upTo - start);
var cloned = new Array(size);
var i = 0;
for (; i < size; i++) cloned[i] = klass == 'String'
? this.charAt(start + i)
: this[start + i];
return cloned;
}
});
/***/ }),
/* 319 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var aFunction = __webpack_require__(15);
var toObject = __webpack_require__(12);
var fails = __webpack_require__(4);
var $sort = [].sort;
var test = [1, 2, 3];
$export($export.P + $export.F * (fails(function () {
// IE8-
test.sort(undefined);
}) || !fails(function () {
// V8 bug
test.sort(null);
// Old WebKit
}) || !__webpack_require__(28)($sort)), 'Array', {
// 22.1.3.25 Array.prototype.sort(comparefn)
sort: function sort(comparefn) {
return comparefn === undefined
? $sort.call(toObject(this))
: $sort.call(toObject(this), aFunction(comparefn));
}
});
/***/ }),
/* 320 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $forEach = __webpack_require__(33)(0);
var STRICT = __webpack_require__(28)([].forEach, true);
$export($export.P + $export.F * !STRICT, 'Array', {
// 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
forEach: function forEach(callbackfn /* , thisArg */) {
return $forEach(this, callbackfn, arguments[1]);
}
});
/***/ }),
/* 321 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(6);
var isArray = __webpack_require__(72);
var SPECIES = __webpack_require__(8)('species');
module.exports = function (original) {
var C;
if (isArray(original)) {
C = original.constructor;
// cross-realm fallback
if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
if (isObject(C)) {
C = C[SPECIES];
if (C === null) C = undefined;
}
} return C === undefined ? Array : C;
};
/***/ }),
/* 322 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $map = __webpack_require__(33)(1);
$export($export.P + $export.F * !__webpack_require__(28)([].map, true), 'Array', {
// 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
map: function map(callbackfn /* , thisArg */) {
return $map(this, callbackfn, arguments[1]);
}
});
/***/ }),
/* 323 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $filter = __webpack_require__(33)(2);
$export($export.P + $export.F * !__webpack_require__(28)([].filter, true), 'Array', {
// 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
filter: function filter(callbackfn /* , thisArg */) {
return $filter(this, callbackfn, arguments[1]);
}
});
/***/ }),
/* 324 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $some = __webpack_require__(33)(3);
$export($export.P + $export.F * !__webpack_require__(28)([].some, true), 'Array', {
// 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
some: function some(callbackfn /* , thisArg */) {
return $some(this, callbackfn, arguments[1]);
}
});
/***/ }),
/* 325 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $every = __webpack_require__(33)(4);
$export($export.P + $export.F * !__webpack_require__(28)([].every, true), 'Array', {
// 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
every: function every(callbackfn /* , thisArg */) {
return $every(this, callbackfn, arguments[1]);
}
});
/***/ }),
/* 326 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $reduce = __webpack_require__(149);
$export($export.P + $export.F * !__webpack_require__(28)([].reduce, true), 'Array', {
// 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
reduce: function reduce(callbackfn /* , initialValue */) {
return $reduce(this, callbackfn, arguments.length, arguments[1], false);
}
});
/***/ }),
/* 327 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $reduce = __webpack_require__(149);
$export($export.P + $export.F * !__webpack_require__(28)([].reduceRight, true), 'Array', {
// 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
reduceRight: function reduceRight(callbackfn /* , initialValue */) {
return $reduce(this, callbackfn, arguments.length, arguments[1], true);
}
});
/***/ }),
/* 328 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $indexOf = __webpack_require__(70)(false);
var $native = [].indexOf;
var NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0;
$export($export.P + $export.F * (NEGATIVE_ZERO || !__webpack_require__(28)($native)), 'Array', {
// 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
return NEGATIVE_ZERO
// convert -0 to +0
? $native.apply(this, arguments) || 0
: $indexOf(this, searchElement, arguments[1]);
}
});
/***/ }),
/* 329 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var toIObject = __webpack_require__(20);
var toInteger = __webpack_require__(27);
var toLength = __webpack_require__(9);
var $native = [].lastIndexOf;
var NEGATIVE_ZERO = !!$native && 1 / [1].lastIndexOf(1, -0) < 0;
$export($export.P + $export.F * (NEGATIVE_ZERO || !__webpack_require__(28)($native)), 'Array', {
// 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
lastIndexOf: function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {
// convert -0 to +0
if (NEGATIVE_ZERO) return $native.apply(this, arguments) || 0;
var O = toIObject(this);
var length = toLength(O.length);
var index = length - 1;
if (arguments.length > 1) index = Math.min(index, toInteger(arguments[1]));
if (index < 0) index = length + index;
for (;index >= 0; index--) if (index in O) if (O[index] === searchElement) return index || 0;
return -1;
}
});
/***/ }),
/* 330 */
/***/ (function(module, exports, __webpack_require__) {
// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
var $export = __webpack_require__(0);
$export($export.P, 'Array', { copyWithin: __webpack_require__(150) });
__webpack_require__(39)('copyWithin');
/***/ }),
/* 331 */
/***/ (function(module, exports, __webpack_require__) {
// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
var $export = __webpack_require__(0);
$export($export.P, 'Array', { fill: __webpack_require__(108) });
__webpack_require__(39)('fill');
/***/ }),
/* 332 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
var $export = __webpack_require__(0);
var $find = __webpack_require__(33)(5);
var KEY = 'find';
var forced = true;
// Shouldn't skip holes
if (KEY in []) Array(1)[KEY](function () { forced = false; });
$export($export.P + $export.F * forced, 'Array', {
find: function find(callbackfn /* , that = undefined */) {
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
}
});
__webpack_require__(39)(KEY);
/***/ }),
/* 333 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
var $export = __webpack_require__(0);
var $find = __webpack_require__(33)(6);
var KEY = 'findIndex';
var forced = true;
// Shouldn't skip holes
if (KEY in []) Array(1)[KEY](function () { forced = false; });
$export($export.P + $export.F * forced, 'Array', {
findIndex: function findIndex(callbackfn /* , that = undefined */) {
return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
}
});
__webpack_require__(39)(KEY);
/***/ }),
/* 334 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(47)('Array');
/***/ }),
/* 335 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(2);
var inheritIfRequired = __webpack_require__(96);
var dP = __webpack_require__(11).f;
var gOPN = __webpack_require__(46).f;
var isRegExp = __webpack_require__(74);
var $flags = __webpack_require__(62);
var $RegExp = global.RegExp;
var Base = $RegExp;
var proto = $RegExp.prototype;
var re1 = /a/g;
var re2 = /a/g;
// "new" creates a new object, old webkit buggy here
var CORRECT_NEW = new $RegExp(re1) !== re1;
if (__webpack_require__(10) && (!CORRECT_NEW || __webpack_require__(4)(function () {
re2[__webpack_require__(8)('match')] = false;
// RegExp constructor can alter flags and IsRegExp works correct with @@match
return $RegExp(re1) != re1 || $RegExp(re2) == re2 || $RegExp(re1, 'i') != '/a/i';
}))) {
$RegExp = function RegExp(p, f) {
var tiRE = this instanceof $RegExp;
var piRE = isRegExp(p);
var fiU = f === undefined;
return !tiRE && piRE && p.constructor === $RegExp && fiU ? p
: inheritIfRequired(CORRECT_NEW
? new Base(piRE && !fiU ? p.source : p, f)
: Base((piRE = p instanceof $RegExp) ? p.source : p, piRE && fiU ? $flags.call(p) : f)
, tiRE ? this : proto, $RegExp);
};
var proxy = function (key) {
key in $RegExp || dP($RegExp, key, {
configurable: true,
get: function () { return Base[key]; },
set: function (it) { Base[key] = it; }
});
};
for (var keys = gOPN(Base), i = 0; keys.length > i;) proxy(keys[i++]);
proto.constructor = $RegExp;
$RegExp.prototype = proto;
__webpack_require__(17)(global, 'RegExp', $RegExp);
}
__webpack_require__(47)('RegExp');
/***/ }),
/* 336 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
__webpack_require__(153);
var anObject = __webpack_require__(1);
var $flags = __webpack_require__(62);
var DESCRIPTORS = __webpack_require__(10);
var TO_STRING = 'toString';
var $toString = /./[TO_STRING];
var define = function (fn) {
__webpack_require__(17)(RegExp.prototype, TO_STRING, fn, true);
};
// 21.2.5.14 RegExp.prototype.toString()
if (__webpack_require__(4)(function () { return $toString.call({ source: 'a', flags: 'b' }) != '/a/b'; })) {
define(function toString() {
var R = anObject(this);
return '/'.concat(R.source, '/',
'flags' in R ? R.flags : !DESCRIPTORS && R instanceof RegExp ? $flags.call(R) : undefined);
});
// FF44- RegExp#toString has a wrong name
} else if ($toString.name != TO_STRING) {
define(function toString() {
return $toString.call(this);
});
}
/***/ }),
/* 337 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var anObject = __webpack_require__(1);
var toLength = __webpack_require__(9);
var advanceStringIndex = __webpack_require__(111);
var regExpExec = __webpack_require__(76);
// @@match logic
__webpack_require__(77)('match', 1, function (defined, MATCH, $match, maybeCallNative) {
return [
// `String.prototype.match` method
// https://tc39.github.io/ecma262/#sec-string.prototype.match
function match(regexp) {
var O = defined(this);
var fn = regexp == undefined ? undefined : regexp[MATCH];
return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
},
// `RegExp.prototype[@@match]` method
// https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
function (regexp) {
var res = maybeCallNative($match, regexp, this);
if (res.done) return res.value;
var rx = anObject(regexp);
var S = String(this);
if (!rx.global) return regExpExec(rx, S);
var fullUnicode = rx.unicode;
rx.lastIndex = 0;
var A = [];
var n = 0;
var result;
while ((result = regExpExec(rx, S)) !== null) {
var matchStr = String(result[0]);
A[n] = matchStr;
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
n++;
}
return n === 0 ? null : A;
}
];
});
/***/ }),
/* 338 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var anObject = __webpack_require__(1);
var toObject = __webpack_require__(12);
var toLength = __webpack_require__(9);
var toInteger = __webpack_require__(27);
var advanceStringIndex = __webpack_require__(111);
var regExpExec = __webpack_require__(76);
var max = Math.max;
var min = Math.min;
var floor = Math.floor;
var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
var maybeToString = function (it) {
return it === undefined ? it : String(it);
};
// @@replace logic
__webpack_require__(77)('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) {
return [
// `String.prototype.replace` method
// https://tc39.github.io/ecma262/#sec-string.prototype.replace
function replace(searchValue, replaceValue) {
var O = defined(this);
var fn = searchValue == undefined ? undefined : searchValue[REPLACE];
return fn !== undefined
? fn.call(searchValue, O, replaceValue)
: $replace.call(String(O), searchValue, replaceValue);
},
// `RegExp.prototype[@@replace]` method
// https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
function (regexp, replaceValue) {
var res = maybeCallNative($replace, regexp, this, replaceValue);
if (res.done) return res.value;
var rx = anObject(regexp);
var S = String(this);
var functionalReplace = typeof replaceValue === 'function';
if (!functionalReplace) replaceValue = String(replaceValue);
var global = rx.global;
if (global) {
var fullUnicode = rx.unicode;
rx.lastIndex = 0;
}
var results = [];
while (true) {
var result = regExpExec(rx, S);
if (result === null) break;
results.push(result);
if (!global) break;
var matchStr = String(result[0]);
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
}
var accumulatedResult = '';
var nextSourcePosition = 0;
for (var i = 0; i < results.length; i++) {
result = results[i];
var matched = String(result[0]);
var position = max(min(toInteger(result.index), S.length), 0);
var captures = [];
// NOTE: This is equivalent to
// captures = result.slice(1).map(maybeToString)
// but for some reason `nativeSlice.call(result, 1, result.length)` (called in
// the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
// causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
var namedCaptures = result.groups;
if (functionalReplace) {
var replacerArgs = [matched].concat(captures, position, S);
if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
var replacement = String(replaceValue.apply(undefined, replacerArgs));
} else {
replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
}
if (position >= nextSourcePosition) {
accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
nextSourcePosition = position + matched.length;
}
}
return accumulatedResult + S.slice(nextSourcePosition);
}
];
// https://tc39.github.io/ecma262/#sec-getsubstitution
function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
var tailPos = position + matched.length;
var m = captures.length;
var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
if (namedCaptures !== undefined) {
namedCaptures = toObject(namedCaptures);
symbols = SUBSTITUTION_SYMBOLS;
}
return $replace.call(replacement, symbols, function (match, ch) {
var capture;
switch (ch.charAt(0)) {
case '$': return '$';
case '&': return matched;
case '`': return str.slice(0, position);
case "'": return str.slice(tailPos);
case '<':
capture = namedCaptures[ch.slice(1, -1)];
break;
default: // \d\d?
var n = +ch;
if (n === 0) return match;
if (n > m) {
var f = floor(n / 10);
if (f === 0) return match;
if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
return match;
}
capture = captures[n - 1];
}
return capture === undefined ? '' : capture;
});
}
});
/***/ }),
/* 339 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var anObject = __webpack_require__(1);
var sameValue = __webpack_require__(139);
var regExpExec = __webpack_require__(76);
// @@search logic
__webpack_require__(77)('search', 1, function (defined, SEARCH, $search, maybeCallNative) {
return [
// `String.prototype.search` method
// https://tc39.github.io/ecma262/#sec-string.prototype.search
function search(regexp) {
var O = defined(this);
var fn = regexp == undefined ? undefined : regexp[SEARCH];
return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
},
// `RegExp.prototype[@@search]` method
// https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search
function (regexp) {
var res = maybeCallNative($search, regexp, this);
if (res.done) return res.value;
var rx = anObject(regexp);
var S = String(this);
var previousLastIndex = rx.lastIndex;
if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;
var result = regExpExec(rx, S);
if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;
return result === null ? -1 : result.index;
}
];
});
/***/ }),
/* 340 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var isRegExp = __webpack_require__(74);
var anObject = __webpack_require__(1);
var speciesConstructor = __webpack_require__(63);
var advanceStringIndex = __webpack_require__(111);
var toLength = __webpack_require__(9);
var callRegExpExec = __webpack_require__(76);
var regexpExec = __webpack_require__(110);
var fails = __webpack_require__(4);
var $min = Math.min;
var $push = [].push;
var $SPLIT = 'split';
var LENGTH = 'length';
var LAST_INDEX = 'lastIndex';
var MAX_UINT32 = 0xffffffff;
// babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError
var SUPPORTS_Y = !fails(function () { RegExp(MAX_UINT32, 'y'); });
// @@split logic
__webpack_require__(77)('split', 2, function (defined, SPLIT, $split, maybeCallNative) {
var internalSplit;
if (
'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
'.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
'.'[$SPLIT](/()()/)[LENGTH] > 1 ||
''[$SPLIT](/.?/)[LENGTH]
) {
// based on es5-shim implementation, need to rework it
internalSplit = function (separator, limit) {
var string = String(this);
if (separator === undefined && limit === 0) return [];
// If `separator` is not a regex, use native split
if (!isRegExp(separator)) return $split.call(string, separator, limit);
var output = [];
var flags = (separator.ignoreCase ? 'i' : '') +
(separator.multiline ? 'm' : '') +
(separator.unicode ? 'u' : '') +
(separator.sticky ? 'y' : '');
var lastLastIndex = 0;
var splitLimit = limit === undefined ? MAX_UINT32 : limit >>> 0;
// Make `global` and avoid `lastIndex` issues by working with a copy
var separatorCopy = new RegExp(separator.source, flags + 'g');
var match, lastIndex, lastLength;
while (match = regexpExec.call(separatorCopy, string)) {
lastIndex = separatorCopy[LAST_INDEX];
if (lastIndex > lastLastIndex) {
output.push(string.slice(lastLastIndex, match.index));
if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1));
lastLength = match[0][LENGTH];
lastLastIndex = lastIndex;
if (output[LENGTH] >= splitLimit) break;
}
if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
}
if (lastLastIndex === string[LENGTH]) {
if (lastLength || !separatorCopy.test('')) output.push('');
} else output.push(string.slice(lastLastIndex));
return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
};
// Chakra, V8
} else if ('0'[$SPLIT](undefined, 0)[LENGTH]) {
internalSplit = function (separator, limit) {
return separator === undefined && limit === 0 ? [] : $split.call(this, separator, limit);
};
} else {
internalSplit = $split;
}
return [
// `String.prototype.split` method
// https://tc39.github.io/ecma262/#sec-string.prototype.split
function split(separator, limit) {
var O = defined(this);
var splitter = separator == undefined ? undefined : separator[SPLIT];
return splitter !== undefined
? splitter.call(separator, O, limit)
: internalSplit.call(String(O), separator, limit);
},
// `RegExp.prototype[@@split]` method
// https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split
//
// NOTE: This cannot be properly polyfilled in engines that don't support
// the 'y' flag.
function (regexp, limit) {
var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== $split);
if (res.done) return res.value;
var rx = anObject(regexp);
var S = String(this);
var C = speciesConstructor(rx, RegExp);
var unicodeMatching = rx.unicode;
var flags = (rx.ignoreCase ? 'i' : '') +
(rx.multiline ? 'm' : '') +
(rx.unicode ? 'u' : '') +
(SUPPORTS_Y ? 'y' : 'g');
// ^(? + rx + ) is needed, in combination with some S slicing, to
// simulate the 'y' flag.
var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
if (lim === 0) return [];
if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];
var p = 0;
var q = 0;
var A = [];
while (q < S.length) {
splitter.lastIndex = SUPPORTS_Y ? q : 0;
var z = callRegExpExec(splitter, SUPPORTS_Y ? S : S.slice(q));
var e;
if (
z === null ||
(e = $min(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p
) {
q = advanceStringIndex(S, q, unicodeMatching);
} else {
A.push(S.slice(p, q));
if (A.length === lim) return A;
for (var i = 1; i <= z.length - 1; i++) {
A.push(z[i]);
if (A.length === lim) return A;
}
q = p = e;
}
}
A.push(S.slice(p));
return A;
}
];
});
/***/ }),
/* 341 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var LIBRARY = __webpack_require__(37);
var global = __webpack_require__(2);
var ctx = __webpack_require__(25);
var classof = __webpack_require__(55);
var $export = __webpack_require__(0);
var isObject = __webpack_require__(6);
var aFunction = __webpack_require__(15);
var anInstance = __webpack_require__(48);
var forOf = __webpack_require__(49);
var speciesConstructor = __webpack_require__(63);
var task = __webpack_require__(112).set;
var microtask = __webpack_require__(113)();
var newPromiseCapabilityModule = __webpack_require__(114);
var perform = __webpack_require__(154);
var userAgent = __webpack_require__(78);
var promiseResolve = __webpack_require__(155);
var PROMISE = 'Promise';
var TypeError = global.TypeError;
var process = global.process;
var versions = process && process.versions;
var v8 = versions && versions.v8 || '';
var $Promise = global[PROMISE];
var isNode = classof(process) == 'process';
var empty = function () { /* empty */ };
var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
var USE_NATIVE = !!function () {
try {
// correct subclassing with @@species support
var promise = $Promise.resolve(1);
var FakePromise = (promise.constructor = {})[__webpack_require__(8)('species')] = function (exec) {
exec(empty, empty);
};
// unhandled rejections tracking support, NodeJS Promise without it fails @@species test
return (isNode || typeof PromiseRejectionEvent == 'function')
&& promise.then(empty) instanceof FakePromise
// v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
// https://bugs.chromium.org/p/chromium/issues/detail?id=830565
// we can't detect it synchronously, so just check versions
&& v8.indexOf('6.6') !== 0
&& userAgent.indexOf('Chrome/66') === -1;
} catch (e) { /* empty */ }
}();
// helpers
var isThenable = function (it) {
var then;
return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
};
var notify = function (promise, isReject) {
if (promise._n) return;
promise._n = true;
var chain = promise._c;
microtask(function () {
var value = promise._v;
var ok = promise._s == 1;
var i = 0;
var run = function (reaction) {
var handler = ok ? reaction.ok : reaction.fail;
var resolve = reaction.resolve;
var reject = reaction.reject;
var domain = reaction.domain;
var result, then, exited;
try {
if (handler) {
if (!ok) {
if (promise._h == 2) onHandleUnhandled(promise);
promise._h = 1;
}
if (handler === true) result = value;
else {
if (domain) domain.enter();
result = handler(value); // may throw
if (domain) {
domain.exit();
exited = true;
}
}
if (result === reaction.promise) {
reject(TypeError('Promise-chain cycle'));
} else if (then = isThenable(result)) {
then.call(result, resolve, reject);
} else resolve(result);
} else reject(value);
} catch (e) {
if (domain && !exited) domain.exit();
reject(e);
}
};
while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
promise._c = [];
promise._n = false;
if (isReject && !promise._h) onUnhandled(promise);
});
};
var onUnhandled = function (promise) {
task.call(global, function () {
var value = promise._v;
var unhandled = isUnhandled(promise);
var result, handler, console;
if (unhandled) {
result = perform(function () {
if (isNode) {
process.emit('unhandledRejection', value, promise);
} else if (handler = global.onunhandledrejection) {
handler({ promise: promise, reason: value });
} else if ((console = global.console) && console.error) {
console.error('Unhandled promise rejection', value);
}
});
// Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
promise._h = isNode || isUnhandled(promise) ? 2 : 1;
} promise._a = undefined;
if (unhandled && result.e) throw result.v;
});
};
var isUnhandled = function (promise) {
return promise._h !== 1 && (promise._a || promise._c).length === 0;
};
var onHandleUnhandled = function (promise) {
task.call(global, function () {
var handler;
if (isNode) {
process.emit('rejectionHandled', promise);
} else if (handler = global.onrejectionhandled) {
handler({ promise: promise, reason: promise._v });
}
});
};
var $reject = function (value) {
var promise = this;
if (promise._d) return;
promise._d = true;
promise = promise._w || promise; // unwrap
promise._v = value;
promise._s = 2;
if (!promise._a) promise._a = promise._c.slice();
notify(promise, true);
};
var $resolve = function (value) {
var promise = this;
var then;
if (promise._d) return;
promise._d = true;
promise = promise._w || promise; // unwrap
try {
if (promise === value) throw TypeError("Promise can't be resolved itself");
if (then = isThenable(value)) {
microtask(function () {
var wrapper = { _w: promise, _d: false }; // wrap
try {
then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
} catch (e) {
$reject.call(wrapper, e);
}
});
} else {
promise._v = value;
promise._s = 1;
notify(promise, false);
}
} catch (e) {
$reject.call({ _w: promise, _d: false }, e); // wrap
}
};
// constructor polyfill
if (!USE_NATIVE) {
// 25.4.3.1 Promise(executor)
$Promise = function Promise(executor) {
anInstance(this, $Promise, PROMISE, '_h');
aFunction(executor);
Internal.call(this);
try {
executor(ctx($resolve, this, 1), ctx($reject, this, 1));
} catch (err) {
$reject.call(this, err);
}
};
// eslint-disable-next-line no-unused-vars
Internal = function Promise(executor) {
this._c = []; // <- awaiting reactions
this._a = undefined; // <- checked in isUnhandled reactions
this._s = 0; // <- state
this._d = false; // <- done
this._v = undefined; // <- value
this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
this._n = false; // <- notify
};
Internal.prototype = __webpack_require__(50)($Promise.prototype, {
// 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
then: function then(onFulfilled, onRejected) {
var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
reaction.fail = typeof onRejected == 'function' && onRejected;
reaction.domain = isNode ? process.domain : undefined;
this._c.push(reaction);
if (this._a) this._a.push(reaction);
if (this._s) notify(this, false);
return reaction.promise;
},
// 25.4.5.1 Promise.prototype.catch(onRejected)
'catch': function (onRejected) {
return this.then(undefined, onRejected);
}
});
OwnPromiseCapability = function () {
var promise = new Internal();
this.promise = promise;
this.resolve = ctx($resolve, promise, 1);
this.reject = ctx($reject, promise, 1);
};
newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
return C === $Promise || C === Wrapper
? new OwnPromiseCapability(C)
: newGenericPromiseCapability(C);
};
}
$export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
__webpack_require__(54)($Promise, PROMISE);
__webpack_require__(47)(PROMISE);
Wrapper = __webpack_require__(24)[PROMISE];
// statics
$export($export.S + $export.F * !USE_NATIVE, PROMISE, {
// 25.4.4.5 Promise.reject(r)
reject: function reject(r) {
var capability = newPromiseCapability(this);
var $$reject = capability.reject;
$$reject(r);
return capability.promise;
}
});
$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
// 25.4.4.6 Promise.resolve(x)
resolve: function resolve(x) {
return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
}
});
$export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(75)(function (iter) {
$Promise.all(iter)['catch'](empty);
})), PROMISE, {
// 25.4.4.1 Promise.all(iterable)
all: function all(iterable) {
var C = this;
var capability = newPromiseCapability(C);
var resolve = capability.resolve;
var reject = capability.reject;
var result = perform(function () {
var values = [];
var index = 0;
var remaining = 1;
forOf(iterable, false, function (promise) {
var $index = index++;
var alreadyCalled = false;
values.push(undefined);
remaining++;
C.resolve(promise).then(function (value) {
if (alreadyCalled) return;
alreadyCalled = true;
values[$index] = value;
--remaining || resolve(values);
}, reject);
});
--remaining || resolve(values);
});
if (result.e) reject(result.v);
return capability.promise;
},
// 25.4.4.4 Promise.race(iterable)
race: function race(iterable) {
var C = this;
var capability = newPromiseCapability(C);
var reject = capability.reject;
var result = perform(function () {
forOf(iterable, false, function (promise) {
C.resolve(promise).then(capability.resolve, reject);
});
});
if (result.e) reject(result.v);
return capability.promise;
}
});
/***/ }),
/* 342 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var weak = __webpack_require__(160);
var validate = __webpack_require__(51);
var WEAK_SET = 'WeakSet';
// 23.4 WeakSet Objects
__webpack_require__(79)(WEAK_SET, function (get) {
return function WeakSet() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
}, {
// 23.4.3.1 WeakSet.prototype.add(value)
add: function add(value) {
return weak.def(validate(this, WEAK_SET), value, true);
}
}, weak, false, true);
/***/ }),
/* 343 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var $typed = __webpack_require__(80);
var buffer = __webpack_require__(115);
var anObject = __webpack_require__(1);
var toAbsoluteIndex = __webpack_require__(44);
var toLength = __webpack_require__(9);
var isObject = __webpack_require__(6);
var ArrayBuffer = __webpack_require__(2).ArrayBuffer;
var speciesConstructor = __webpack_require__(63);
var $ArrayBuffer = buffer.ArrayBuffer;
var $DataView = buffer.DataView;
var $isView = $typed.ABV && ArrayBuffer.isView;
var $slice = $ArrayBuffer.prototype.slice;
var VIEW = $typed.VIEW;
var ARRAY_BUFFER = 'ArrayBuffer';
$export($export.G + $export.W + $export.F * (ArrayBuffer !== $ArrayBuffer), { ArrayBuffer: $ArrayBuffer });
$export($export.S + $export.F * !$typed.CONSTR, ARRAY_BUFFER, {
// 24.1.3.1 ArrayBuffer.isView(arg)
isView: function isView(it) {
return $isView && $isView(it) || isObject(it) && VIEW in it;
}
});
$export($export.P + $export.U + $export.F * __webpack_require__(4)(function () {
return !new $ArrayBuffer(2).slice(1, undefined).byteLength;
}), ARRAY_BUFFER, {
// 24.1.4.3 ArrayBuffer.prototype.slice(start, end)
slice: function slice(start, end) {
if ($slice !== undefined && end === undefined) return $slice.call(anObject(this), start); // FF fix
var len = anObject(this).byteLength;
var first = toAbsoluteIndex(start, len);
var fin = toAbsoluteIndex(end === undefined ? len : end, len);
var result = new (speciesConstructor(this, $ArrayBuffer))(toLength(fin - first));
var viewS = new $DataView(this);
var viewT = new $DataView(result);
var index = 0;
while (first < fin) {
viewT.setUint8(index++, viewS.getUint8(first++));
} return result;
}
});
__webpack_require__(47)(ARRAY_BUFFER);
/***/ }),
/* 344 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
$export($export.G + $export.W + $export.F * !__webpack_require__(80).ABV, {
DataView: __webpack_require__(115).DataView
});
/***/ }),
/* 345 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(35)('Int8', 1, function (init) {
return function Int8Array(data, byteOffset, length) {
return init(this, data, byteOffset, length);
};
});
/***/ }),
/* 346 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(35)('Uint8', 1, function (init) {
return function Uint8Array(data, byteOffset, length) {
return init(this, data, byteOffset, length);
};
});
/***/ }),
/* 347 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(35)('Uint8', 1, function (init) {
return function Uint8ClampedArray(data, byteOffset, length) {
return init(this, data, byteOffset, length);
};
}, true);
/***/ }),
/* 348 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(35)('Int16', 2, function (init) {
return function Int16Array(data, byteOffset, length) {
return init(this, data, byteOffset, length);
};
});
/***/ }),
/* 349 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(35)('Uint16', 2, function (init) {
return function Uint16Array(data, byteOffset, length) {
return init(this, data, byteOffset, length);
};
});
/***/ }),
/* 350 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(35)('Int32', 4, function (init) {
return function Int32Array(data, byteOffset, length) {
return init(this, data, byteOffset, length);
};
});
/***/ }),
/* 351 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(35)('Uint32', 4, function (init) {
return function Uint32Array(data, byteOffset, length) {
return init(this, data, byteOffset, length);
};
});
/***/ }),
/* 352 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(35)('Float32', 4, function (init) {
return function Float32Array(data, byteOffset, length) {
return init(this, data, byteOffset, length);
};
});
/***/ }),
/* 353 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(35)('Float64', 8, function (init) {
return function Float64Array(data, byteOffset, length) {
return init(this, data, byteOffset, length);
};
});
/***/ }),
/* 354 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.1 Reflect.apply(target, thisArgument, argumentsList)
var $export = __webpack_require__(0);
var aFunction = __webpack_require__(15);
var anObject = __webpack_require__(1);
var rApply = (__webpack_require__(2).Reflect || {}).apply;
var fApply = Function.apply;
// MS Edge argumentsList argument is optional
$export($export.S + $export.F * !__webpack_require__(4)(function () {
rApply(function () { /* empty */ });
}), 'Reflect', {
apply: function apply(target, thisArgument, argumentsList) {
var T = aFunction(target);
var L = anObject(argumentsList);
return rApply ? rApply(T, thisArgument, L) : fApply.call(T, thisArgument, L);
}
});
/***/ }),
/* 355 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.2 Reflect.construct(target, argumentsList [, newTarget])
var $export = __webpack_require__(0);
var create = __webpack_require__(45);
var aFunction = __webpack_require__(15);
var anObject = __webpack_require__(1);
var isObject = __webpack_require__(6);
var fails = __webpack_require__(4);
var bind = __webpack_require__(140);
var rConstruct = (__webpack_require__(2).Reflect || {}).construct;
// MS Edge supports only 2 arguments and argumentsList argument is optional
// FF Nightly sets third argument as `new.target`, but does not create `this` from it
var NEW_TARGET_BUG = fails(function () {
function F() { /* empty */ }
return !(rConstruct(function () { /* empty */ }, [], F) instanceof F);
});
var ARGS_BUG = !fails(function () {
rConstruct(function () { /* empty */ });
});
$export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', {
construct: function construct(Target, args /* , newTarget */) {
aFunction(Target);
anObject(args);
var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);
if (ARGS_BUG && !NEW_TARGET_BUG) return rConstruct(Target, args, newTarget);
if (Target == newTarget) {
// w/o altered newTarget, optimization for 0-4 arguments
switch (args.length) {
case 0: return new Target();
case 1: return new Target(args[0]);
case 2: return new Target(args[0], args[1]);
case 3: return new Target(args[0], args[1], args[2]);
case 4: return new Target(args[0], args[1], args[2], args[3]);
}
// w/o altered newTarget, lot of arguments case
var $args = [null];
$args.push.apply($args, args);
return new (bind.apply(Target, $args))();
}
// with altered newTarget, not support built-in constructors
var proto = newTarget.prototype;
var instance = create(isObject(proto) ? proto : Object.prototype);
var result = Function.apply.call(Target, instance, args);
return isObject(result) ? result : instance;
}
});
/***/ }),
/* 356 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
var dP = __webpack_require__(11);
var $export = __webpack_require__(0);
var anObject = __webpack_require__(1);
var toPrimitive = __webpack_require__(30);
// MS Edge has broken Reflect.defineProperty - throwing instead of returning false
$export($export.S + $export.F * __webpack_require__(4)(function () {
// eslint-disable-next-line no-undef
Reflect.defineProperty(dP.f({}, 1, { value: 1 }), 1, { value: 2 });
}), 'Reflect', {
defineProperty: function defineProperty(target, propertyKey, attributes) {
anObject(target);
propertyKey = toPrimitive(propertyKey, true);
anObject(attributes);
try {
dP.f(target, propertyKey, attributes);
return true;
} catch (e) {
return false;
}
}
});
/***/ }),
/* 357 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.4 Reflect.deleteProperty(target, propertyKey)
var $export = __webpack_require__(0);
var gOPD = __webpack_require__(21).f;
var anObject = __webpack_require__(1);
$export($export.S, 'Reflect', {
deleteProperty: function deleteProperty(target, propertyKey) {
var desc = gOPD(anObject(target), propertyKey);
return desc && !desc.configurable ? false : delete target[propertyKey];
}
});
/***/ }),
/* 358 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 26.1.5 Reflect.enumerate(target)
var $export = __webpack_require__(0);
var anObject = __webpack_require__(1);
var Enumerate = function (iterated) {
this._t = anObject(iterated); // target
this._i = 0; // next index
var keys = this._k = []; // keys
var key;
for (key in iterated) keys.push(key);
};
__webpack_require__(101)(Enumerate, 'Object', function () {
var that = this;
var keys = that._k;
var key;
do {
if (that._i >= keys.length) return { value: undefined, done: true };
} while (!((key = keys[that._i++]) in that._t));
return { value: key, done: false };
});
$export($export.S, 'Reflect', {
enumerate: function enumerate(target) {
return new Enumerate(target);
}
});
/***/ }),
/* 359 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.6 Reflect.get(target, propertyKey [, receiver])
var gOPD = __webpack_require__(21);
var getPrototypeOf = __webpack_require__(22);
var has = __webpack_require__(19);
var $export = __webpack_require__(0);
var isObject = __webpack_require__(6);
var anObject = __webpack_require__(1);
function get(target, propertyKey /* , receiver */) {
var receiver = arguments.length < 3 ? target : arguments[2];
var desc, proto;
if (anObject(target) === receiver) return target[propertyKey];
if (desc = gOPD.f(target, propertyKey)) return has(desc, 'value')
? desc.value
: desc.get !== undefined
? desc.get.call(receiver)
: undefined;
if (isObject(proto = getPrototypeOf(target))) return get(proto, propertyKey, receiver);
}
$export($export.S, 'Reflect', { get: get });
/***/ }),
/* 360 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)
var gOPD = __webpack_require__(21);
var $export = __webpack_require__(0);
var anObject = __webpack_require__(1);
$export($export.S, 'Reflect', {
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {
return gOPD.f(anObject(target), propertyKey);
}
});
/***/ }),
/* 361 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.8 Reflect.getPrototypeOf(target)
var $export = __webpack_require__(0);
var getProto = __webpack_require__(22);
var anObject = __webpack_require__(1);
$export($export.S, 'Reflect', {
getPrototypeOf: function getPrototypeOf(target) {
return getProto(anObject(target));
}
});
/***/ }),
/* 362 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.9 Reflect.has(target, propertyKey)
var $export = __webpack_require__(0);
$export($export.S, 'Reflect', {
has: function has(target, propertyKey) {
return propertyKey in target;
}
});
/***/ }),
/* 363 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.10 Reflect.isExtensible(target)
var $export = __webpack_require__(0);
var anObject = __webpack_require__(1);
var $isExtensible = Object.isExtensible;
$export($export.S, 'Reflect', {
isExtensible: function isExtensible(target) {
anObject(target);
return $isExtensible ? $isExtensible(target) : true;
}
});
/***/ }),
/* 364 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.11 Reflect.ownKeys(target)
var $export = __webpack_require__(0);
$export($export.S, 'Reflect', { ownKeys: __webpack_require__(162) });
/***/ }),
/* 365 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.12 Reflect.preventExtensions(target)
var $export = __webpack_require__(0);
var anObject = __webpack_require__(1);
var $preventExtensions = Object.preventExtensions;
$export($export.S, 'Reflect', {
preventExtensions: function preventExtensions(target) {
anObject(target);
try {
if ($preventExtensions) $preventExtensions(target);
return true;
} catch (e) {
return false;
}
}
});
/***/ }),
/* 366 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
var dP = __webpack_require__(11);
var gOPD = __webpack_require__(21);
var getPrototypeOf = __webpack_require__(22);
var has = __webpack_require__(19);
var $export = __webpack_require__(0);
var createDesc = __webpack_require__(41);
var anObject = __webpack_require__(1);
var isObject = __webpack_require__(6);
function set(target, propertyKey, V /* , receiver */) {
var receiver = arguments.length < 4 ? target : arguments[3];
var ownDesc = gOPD.f(anObject(target), propertyKey);
var existingDescriptor, proto;
if (!ownDesc) {
if (isObject(proto = getPrototypeOf(target))) {
return set(proto, propertyKey, V, receiver);
}
ownDesc = createDesc(0);
}
if (has(ownDesc, 'value')) {
if (ownDesc.writable === false || !isObject(receiver)) return false;
if (existingDescriptor = gOPD.f(receiver, propertyKey)) {
if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;
existingDescriptor.value = V;
dP.f(receiver, propertyKey, existingDescriptor);
} else dP.f(receiver, propertyKey, createDesc(0, V));
return true;
}
return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
}
$export($export.S, 'Reflect', { set: set });
/***/ }),
/* 367 */
/***/ (function(module, exports, __webpack_require__) {
// 26.1.14 Reflect.setPrototypeOf(target, proto)
var $export = __webpack_require__(0);
var setProto = __webpack_require__(94);
if (setProto) $export($export.S, 'Reflect', {
setPrototypeOf: function setPrototypeOf(target, proto) {
setProto.check(target, proto);
try {
setProto.set(target, proto);
return true;
} catch (e) {
return false;
}
}
});
/***/ }),
/* 368 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://github.com/tc39/Array.prototype.includes
var $export = __webpack_require__(0);
var $includes = __webpack_require__(70)(true);
$export($export.P, 'Array', {
includes: function includes(el /* , fromIndex = 0 */) {
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
}
});
__webpack_require__(39)('includes');
/***/ }),
/* 369 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap
var $export = __webpack_require__(0);
var flattenIntoArray = __webpack_require__(163);
var toObject = __webpack_require__(12);
var toLength = __webpack_require__(9);
var aFunction = __webpack_require__(15);
var arraySpeciesCreate = __webpack_require__(107);
$export($export.P, 'Array', {
flatMap: function flatMap(callbackfn /* , thisArg */) {
var O = toObject(this);
var sourceLen, A;
aFunction(callbackfn);
sourceLen = toLength(O.length);
A = arraySpeciesCreate(O, 0);
flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments[1]);
return A;
}
});
__webpack_require__(39)('flatMap');
/***/ }),
/* 370 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatten
var $export = __webpack_require__(0);
var flattenIntoArray = __webpack_require__(163);
var toObject = __webpack_require__(12);
var toLength = __webpack_require__(9);
var toInteger = __webpack_require__(27);
var arraySpeciesCreate = __webpack_require__(107);
$export($export.P, 'Array', {
flatten: function flatten(/* depthArg = 1 */) {
var depthArg = arguments[0];
var O = toObject(this);
var sourceLen = toLength(O.length);
var A = arraySpeciesCreate(O, 0);
flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));
return A;
}
});
__webpack_require__(39)('flatten');
/***/ }),
/* 371 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://github.com/mathiasbynens/String.prototype.at
var $export = __webpack_require__(0);
var $at = __webpack_require__(73)(true);
$export($export.P, 'String', {
at: function at(pos) {
return $at(this, pos);
}
});
/***/ }),
/* 372 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://github.com/tc39/proposal-string-pad-start-end
var $export = __webpack_require__(0);
var $pad = __webpack_require__(164);
var userAgent = __webpack_require__(78);
// https://github.com/zloirock/core-js/issues/280
var WEBKIT_BUG = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent);
$export($export.P + $export.F * WEBKIT_BUG, 'String', {
padStart: function padStart(maxLength /* , fillString = ' ' */) {
return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
}
});
/***/ }),
/* 373 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://github.com/tc39/proposal-string-pad-start-end
var $export = __webpack_require__(0);
var $pad = __webpack_require__(164);
var userAgent = __webpack_require__(78);
// https://github.com/zloirock/core-js/issues/280
var WEBKIT_BUG = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent);
$export($export.P + $export.F * WEBKIT_BUG, 'String', {
padEnd: function padEnd(maxLength /* , fillString = ' ' */) {
return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
}
});
/***/ }),
/* 374 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://github.com/sebmarkbage/ecmascript-string-left-right-trim
__webpack_require__(56)('trimLeft', function ($trim) {
return function trimLeft() {
return $trim(this, 1);
};
}, 'trimStart');
/***/ }),
/* 375 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://github.com/sebmarkbage/ecmascript-string-left-right-trim
__webpack_require__(56)('trimRight', function ($trim) {
return function trimRight() {
return $trim(this, 2);
};
}, 'trimEnd');
/***/ }),
/* 376 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://tc39.github.io/String.prototype.matchAll/
var $export = __webpack_require__(0);
var defined = __webpack_require__(31);
var toLength = __webpack_require__(9);
var isRegExp = __webpack_require__(74);
var getFlags = __webpack_require__(62);
var RegExpProto = RegExp.prototype;
var $RegExpStringIterator = function (regexp, string) {
this._r = regexp;
this._s = string;
};
__webpack_require__(101)($RegExpStringIterator, 'RegExp String', function next() {
var match = this._r.exec(this._s);
return { value: match, done: match === null };
});
$export($export.P, 'String', {
matchAll: function matchAll(regexp) {
defined(this);
if (!isRegExp(regexp)) throw TypeError(regexp + ' is not a regexp!');
var S = String(this);
var flags = 'flags' in RegExpProto ? String(regexp.flags) : getFlags.call(regexp);
var rx = new RegExp(regexp.source, ~flags.indexOf('g') ? flags : 'g' + flags);
rx.lastIndex = toLength(regexp.lastIndex);
return new $RegExpStringIterator(rx, S);
}
});
/***/ }),
/* 377 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(90)('asyncIterator');
/***/ }),
/* 378 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(90)('observable');
/***/ }),
/* 379 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/tc39/proposal-object-getownpropertydescriptors
var $export = __webpack_require__(0);
var ownKeys = __webpack_require__(162);
var toIObject = __webpack_require__(20);
var gOPD = __webpack_require__(21);
var createProperty = __webpack_require__(105);
$export($export.S, 'Object', {
getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
var O = toIObject(object);
var getDesc = gOPD.f;
var keys = ownKeys(O);
var result = {};
var i = 0;
var key, desc;
while (keys.length > i) {
desc = getDesc(O, key = keys[i++]);
if (desc !== undefined) createProperty(result, key, desc);
}
return result;
}
});
/***/ }),
/* 380 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/tc39/proposal-object-values-entries
var $export = __webpack_require__(0);
var $values = __webpack_require__(165)(false);
$export($export.S, 'Object', {
values: function values(it) {
return $values(it);
}
});
/***/ }),
/* 381 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/tc39/proposal-object-values-entries
var $export = __webpack_require__(0);
var $entries = __webpack_require__(165)(true);
$export($export.S, 'Object', {
entries: function entries(it) {
return $entries(it);
}
});
/***/ }),
/* 382 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var toObject = __webpack_require__(12);
var aFunction = __webpack_require__(15);
var $defineProperty = __webpack_require__(11);
// B.2.2.2 Object.prototype.__defineGetter__(P, getter)
__webpack_require__(10) && $export($export.P + __webpack_require__(81), 'Object', {
__defineGetter__: function __defineGetter__(P, getter) {
$defineProperty.f(toObject(this), P, { get: aFunction(getter), enumerable: true, configurable: true });
}
});
/***/ }),
/* 383 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var toObject = __webpack_require__(12);
var aFunction = __webpack_require__(15);
var $defineProperty = __webpack_require__(11);
// B.2.2.3 Object.prototype.__defineSetter__(P, setter)
__webpack_require__(10) && $export($export.P + __webpack_require__(81), 'Object', {
__defineSetter__: function __defineSetter__(P, setter) {
$defineProperty.f(toObject(this), P, { set: aFunction(setter), enumerable: true, configurable: true });
}
});
/***/ }),
/* 384 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var toObject = __webpack_require__(12);
var toPrimitive = __webpack_require__(30);
var getPrototypeOf = __webpack_require__(22);
var getOwnPropertyDescriptor = __webpack_require__(21).f;
// B.2.2.4 Object.prototype.__lookupGetter__(P)
__webpack_require__(10) && $export($export.P + __webpack_require__(81), 'Object', {
__lookupGetter__: function __lookupGetter__(P) {
var O = toObject(this);
var K = toPrimitive(P, true);
var D;
do {
if (D = getOwnPropertyDescriptor(O, K)) return D.get;
} while (O = getPrototypeOf(O));
}
});
/***/ }),
/* 385 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var $export = __webpack_require__(0);
var toObject = __webpack_require__(12);
var toPrimitive = __webpack_require__(30);
var getPrototypeOf = __webpack_require__(22);
var getOwnPropertyDescriptor = __webpack_require__(21).f;
// B.2.2.5 Object.prototype.__lookupSetter__(P)
__webpack_require__(10) && $export($export.P + __webpack_require__(81), 'Object', {
__lookupSetter__: function __lookupSetter__(P) {
var O = toObject(this);
var K = toPrimitive(P, true);
var D;
do {
if (D = getOwnPropertyDescriptor(O, K)) return D.set;
} while (O = getPrototypeOf(O));
}
});
/***/ }),
/* 386 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
var $export = __webpack_require__(0);
$export($export.P + $export.R, 'Map', { toJSON: __webpack_require__(166)('Map') });
/***/ }),
/* 387 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
var $export = __webpack_require__(0);
$export($export.P + $export.R, 'Set', { toJSON: __webpack_require__(166)('Set') });
/***/ }),
/* 388 */
/***/ (function(module, exports, __webpack_require__) {
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
__webpack_require__(82)('Map');
/***/ }),
/* 389 */
/***/ (function(module, exports, __webpack_require__) {
// https://tc39.github.io/proposal-setmap-offrom/#sec-set.of
__webpack_require__(82)('Set');
/***/ }),
/* 390 */
/***/ (function(module, exports, __webpack_require__) {
// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of
__webpack_require__(82)('WeakMap');
/***/ }),
/* 391 */
/***/ (function(module, exports, __webpack_require__) {
// https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.of
__webpack_require__(82)('WeakSet');
/***/ }),
/* 392 */
/***/ (function(module, exports, __webpack_require__) {
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
__webpack_require__(83)('Map');
/***/ }),
/* 393 */
/***/ (function(module, exports, __webpack_require__) {
// https://tc39.github.io/proposal-setmap-offrom/#sec-set.from
__webpack_require__(83)('Set');
/***/ }),
/* 394 */
/***/ (function(module, exports, __webpack_require__) {
// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from
__webpack_require__(83)('WeakMap');
/***/ }),
/* 395 */
/***/ (function(module, exports, __webpack_require__) {
// https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.from
__webpack_require__(83)('WeakSet');
/***/ }),
/* 396 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/tc39/proposal-global
var $export = __webpack_require__(0);
$export($export.G, { global: __webpack_require__(2) });
/***/ }),
/* 397 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/tc39/proposal-global
var $export = __webpack_require__(0);
$export($export.S, 'System', { global: __webpack_require__(2) });
/***/ }),
/* 398 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/ljharb/proposal-is-error
var $export = __webpack_require__(0);
var cof = __webpack_require__(26);
$export($export.S, 'Error', {
isError: function isError(it) {
return cof(it) === 'Error';
}
});
/***/ }),
/* 399 */
/***/ (function(module, exports, __webpack_require__) {
// https://rwaldron.github.io/proposal-math-extensions/
var $export = __webpack_require__(0);
$export($export.S, 'Math', {
clamp: function clamp(x, lower, upper) {
return Math.min(upper, Math.max(lower, x));
}
});
/***/ }),
/* 400 */
/***/ (function(module, exports, __webpack_require__) {
// https://rwaldron.github.io/proposal-math-extensions/
var $export = __webpack_require__(0);
$export($export.S, 'Math', { DEG_PER_RAD: Math.PI / 180 });
/***/ }),
/* 401 */
/***/ (function(module, exports, __webpack_require__) {
// https://rwaldron.github.io/proposal-math-extensions/
var $export = __webpack_require__(0);
var RAD_PER_DEG = 180 / Math.PI;
$export($export.S, 'Math', {
degrees: function degrees(radians) {
return radians * RAD_PER_DEG;
}
});
/***/ }),
/* 402 */
/***/ (function(module, exports, __webpack_require__) {
// https://rwaldron.github.io/proposal-math-extensions/
var $export = __webpack_require__(0);
var scale = __webpack_require__(168);
var fround = __webpack_require__(147);
$export($export.S, 'Math', {
fscale: function fscale(x, inLow, inHigh, outLow, outHigh) {
return fround(scale(x, inLow, inHigh, outLow, outHigh));
}
});
/***/ }),
/* 403 */
/***/ (function(module, exports, __webpack_require__) {
// https://gist.github.com/BrendanEich/4294d5c212a6d2254703
var $export = __webpack_require__(0);
$export($export.S, 'Math', {
iaddh: function iaddh(x0, x1, y0, y1) {
var $x0 = x0 >>> 0;
var $x1 = x1 >>> 0;
var $y0 = y0 >>> 0;
return $x1 + (y1 >>> 0) + (($x0 & $y0 | ($x0 | $y0) & ~($x0 + $y0 >>> 0)) >>> 31) | 0;
}
});
/***/ }),
/* 404 */
/***/ (function(module, exports, __webpack_require__) {
// https://gist.github.com/BrendanEich/4294d5c212a6d2254703
var $export = __webpack_require__(0);
$export($export.S, 'Math', {
isubh: function isubh(x0, x1, y0, y1) {
var $x0 = x0 >>> 0;
var $x1 = x1 >>> 0;
var $y0 = y0 >>> 0;
return $x1 - (y1 >>> 0) - ((~$x0 & $y0 | ~($x0 ^ $y0) & $x0 - $y0 >>> 0) >>> 31) | 0;
}
});
/***/ }),
/* 405 */
/***/ (function(module, exports, __webpack_require__) {
// https://gist.github.com/BrendanEich/4294d5c212a6d2254703
var $export = __webpack_require__(0);
$export($export.S, 'Math', {
imulh: function imulh(u, v) {
var UINT16 = 0xffff;
var $u = +u;
var $v = +v;
var u0 = $u & UINT16;
var v0 = $v & UINT16;
var u1 = $u >> 16;
var v1 = $v >> 16;
var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
return u1 * v1 + (t >> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >> 16);
}
});
/***/ }),
/* 406 */
/***/ (function(module, exports, __webpack_require__) {
// https://rwaldron.github.io/proposal-math-extensions/
var $export = __webpack_require__(0);
$export($export.S, 'Math', { RAD_PER_DEG: 180 / Math.PI });
/***/ }),
/* 407 */
/***/ (function(module, exports, __webpack_require__) {
// https://rwaldron.github.io/proposal-math-extensions/
var $export = __webpack_require__(0);
var DEG_PER_RAD = Math.PI / 180;
$export($export.S, 'Math', {
radians: function radians(degrees) {
return degrees * DEG_PER_RAD;
}
});
/***/ }),
/* 408 */
/***/ (function(module, exports, __webpack_require__) {
// https://rwaldron.github.io/proposal-math-extensions/
var $export = __webpack_require__(0);
$export($export.S, 'Math', { scale: __webpack_require__(168) });
/***/ }),
/* 409 */
/***/ (function(module, exports, __webpack_require__) {
// https://gist.github.com/BrendanEich/4294d5c212a6d2254703
var $export = __webpack_require__(0);
$export($export.S, 'Math', {
umulh: function umulh(u, v) {
var UINT16 = 0xffff;
var $u = +u;
var $v = +v;
var u0 = $u & UINT16;
var v0 = $v & UINT16;
var u1 = $u >>> 16;
var v1 = $v >>> 16;
var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16);
}
});
/***/ }),
/* 410 */
/***/ (function(module, exports, __webpack_require__) {
// http://jfbastien.github.io/papers/Math.signbit.html
var $export = __webpack_require__(0);
$export($export.S, 'Math', { signbit: function signbit(x) {
// eslint-disable-next-line no-self-compare
return (x = +x) != x ? x : x == 0 ? 1 / x == Infinity : x > 0;
} });
/***/ }),
/* 411 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://github.com/tc39/proposal-promise-finally
var $export = __webpack_require__(0);
var core = __webpack_require__(24);
var global = __webpack_require__(2);
var speciesConstructor = __webpack_require__(63);
var promiseResolve = __webpack_require__(155);
$export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {
var C = speciesConstructor(this, core.Promise || global.Promise);
var isFunction = typeof onFinally == 'function';
return this.then(
isFunction ? function (x) {
return promiseResolve(C, onFinally()).then(function () { return x; });
} : onFinally,
isFunction ? function (e) {
return promiseResolve(C, onFinally()).then(function () { throw e; });
} : onFinally
);
} });
/***/ }),
/* 412 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://github.com/tc39/proposal-promise-try
var $export = __webpack_require__(0);
var newPromiseCapability = __webpack_require__(114);
var perform = __webpack_require__(154);
$export($export.S, 'Promise', { 'try': function (callbackfn) {
var promiseCapability = newPromiseCapability.f(this);
var result = perform(callbackfn);
(result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
return promiseCapability.promise;
} });
/***/ }),
/* 413 */
/***/ (function(module, exports, __webpack_require__) {
var metadata = __webpack_require__(36);
var anObject = __webpack_require__(1);
var toMetaKey = metadata.key;
var ordinaryDefineOwnMetadata = metadata.set;
metadata.exp({ defineMetadata: function defineMetadata(metadataKey, metadataValue, target, targetKey) {
ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject(target), toMetaKey(targetKey));
} });
/***/ }),
/* 414 */
/***/ (function(module, exports, __webpack_require__) {
var metadata = __webpack_require__(36);
var anObject = __webpack_require__(1);
var toMetaKey = metadata.key;
var getOrCreateMetadataMap = metadata.map;
var store = metadata.store;
metadata.exp({ deleteMetadata: function deleteMetadata(metadataKey, target /* , targetKey */) {
var targetKey = arguments.length < 3 ? undefined : toMetaKey(arguments[2]);
var metadataMap = getOrCreateMetadataMap(anObject(target), targetKey, false);
if (metadataMap === undefined || !metadataMap['delete'](metadataKey)) return false;
if (metadataMap.size) return true;
var targetMetadata = store.get(target);
targetMetadata['delete'](targetKey);
return !!targetMetadata.size || store['delete'](target);
} });
/***/ }),
/* 415 */
/***/ (function(module, exports, __webpack_require__) {
var metadata = __webpack_require__(36);
var anObject = __webpack_require__(1);
var getPrototypeOf = __webpack_require__(22);
var ordinaryHasOwnMetadata = metadata.has;
var ordinaryGetOwnMetadata = metadata.get;
var toMetaKey = metadata.key;
var ordinaryGetMetadata = function (MetadataKey, O, P) {
var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
if (hasOwn) return ordinaryGetOwnMetadata(MetadataKey, O, P);
var parent = getPrototypeOf(O);
return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined;
};
metadata.exp({ getMetadata: function getMetadata(metadataKey, target /* , targetKey */) {
return ordinaryGetMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
} });
/***/ }),
/* 416 */
/***/ (function(module, exports, __webpack_require__) {
var Set = __webpack_require__(158);
var from = __webpack_require__(167);
var metadata = __webpack_require__(36);
var anObject = __webpack_require__(1);
var getPrototypeOf = __webpack_require__(22);
var ordinaryOwnMetadataKeys = metadata.keys;
var toMetaKey = metadata.key;
var ordinaryMetadataKeys = function (O, P) {
var oKeys = ordinaryOwnMetadataKeys(O, P);
var parent = getPrototypeOf(O);
if (parent === null) return oKeys;
var pKeys = ordinaryMetadataKeys(parent, P);
return pKeys.length ? oKeys.length ? from(new Set(oKeys.concat(pKeys))) : pKeys : oKeys;
};
metadata.exp({ getMetadataKeys: function getMetadataKeys(target /* , targetKey */) {
return ordinaryMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
} });
/***/ }),
/* 417 */
/***/ (function(module, exports, __webpack_require__) {
var metadata = __webpack_require__(36);
var anObject = __webpack_require__(1);
var ordinaryGetOwnMetadata = metadata.get;
var toMetaKey = metadata.key;
metadata.exp({ getOwnMetadata: function getOwnMetadata(metadataKey, target /* , targetKey */) {
return ordinaryGetOwnMetadata(metadataKey, anObject(target)
, arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
} });
/***/ }),
/* 418 */
/***/ (function(module, exports, __webpack_require__) {
var metadata = __webpack_require__(36);
var anObject = __webpack_require__(1);
var ordinaryOwnMetadataKeys = metadata.keys;
var toMetaKey = metadata.key;
metadata.exp({ getOwnMetadataKeys: function getOwnMetadataKeys(target /* , targetKey */) {
return ordinaryOwnMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
} });
/***/ }),
/* 419 */
/***/ (function(module, exports, __webpack_require__) {
var metadata = __webpack_require__(36);
var anObject = __webpack_require__(1);
var getPrototypeOf = __webpack_require__(22);
var ordinaryHasOwnMetadata = metadata.has;
var toMetaKey = metadata.key;
var ordinaryHasMetadata = function (MetadataKey, O, P) {
var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
if (hasOwn) return true;
var parent = getPrototypeOf(O);
return parent !== null ? ordinaryHasMetadata(MetadataKey, parent, P) : false;
};
metadata.exp({ hasMetadata: function hasMetadata(metadataKey, target /* , targetKey */) {
return ordinaryHasMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
} });
/***/ }),
/* 420 */
/***/ (function(module, exports, __webpack_require__) {
var metadata = __webpack_require__(36);
var anObject = __webpack_require__(1);
var ordinaryHasOwnMetadata = metadata.has;
var toMetaKey = metadata.key;
metadata.exp({ hasOwnMetadata: function hasOwnMetadata(metadataKey, target /* , targetKey */) {
return ordinaryHasOwnMetadata(metadataKey, anObject(target)
, arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
} });
/***/ }),
/* 421 */
/***/ (function(module, exports, __webpack_require__) {
var $metadata = __webpack_require__(36);
var anObject = __webpack_require__(1);
var aFunction = __webpack_require__(15);
var toMetaKey = $metadata.key;
var ordinaryDefineOwnMetadata = $metadata.set;
$metadata.exp({ metadata: function metadata(metadataKey, metadataValue) {
return function decorator(target, targetKey) {
ordinaryDefineOwnMetadata(
metadataKey, metadataValue,
(targetKey !== undefined ? anObject : aFunction)(target),
toMetaKey(targetKey)
);
};
} });
/***/ }),
/* 422 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-09/sept-25.md#510-globalasap-for-enqueuing-a-microtask
var $export = __webpack_require__(0);
var microtask = __webpack_require__(113)();
var process = __webpack_require__(2).process;
var isNode = __webpack_require__(26)(process) == 'process';
$export($export.G, {
asap: function asap(fn) {
var domain = isNode && process.domain;
microtask(domain ? domain.bind(fn) : fn);
}
});
/***/ }),
/* 423 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// https://github.com/zenparsing/es-observable
var $export = __webpack_require__(0);
var global = __webpack_require__(2);
var core = __webpack_require__(24);
var microtask = __webpack_require__(113)();
var OBSERVABLE = __webpack_require__(8)('observable');
var aFunction = __webpack_require__(15);
var anObject = __webpack_require__(1);
var anInstance = __webpack_require__(48);
var redefineAll = __webpack_require__(50);
var hide = __webpack_require__(16);
var forOf = __webpack_require__(49);
var RETURN = forOf.RETURN;
var getMethod = function (fn) {
return fn == null ? undefined : aFunction(fn);
};
var cleanupSubscription = function (subscription) {
var cleanup = subscription._c;
if (cleanup) {
subscription._c = undefined;
cleanup();
}
};
var subscriptionClosed = function (subscription) {
return subscription._o === undefined;
};
var closeSubscription = function (subscription) {
if (!subscriptionClosed(subscription)) {
subscription._o = undefined;
cleanupSubscription(subscription);
}
};
var Subscription = function (observer, subscriber) {
anObject(observer);
this._c = undefined;
this._o = observer;
observer = new SubscriptionObserver(this);
try {
var cleanup = subscriber(observer);
var subscription = cleanup;
if (cleanup != null) {
if (typeof cleanup.unsubscribe === 'function') cleanup = function () { subscription.unsubscribe(); };
else aFunction(cleanup);
this._c = cleanup;
}
} catch (e) {
observer.error(e);
return;
} if (subscriptionClosed(this)) cleanupSubscription(this);
};
Subscription.prototype = redefineAll({}, {
unsubscribe: function unsubscribe() { closeSubscription(this); }
});
var SubscriptionObserver = function (subscription) {
this._s = subscription;
};
SubscriptionObserver.prototype = redefineAll({}, {
next: function next(value) {
var subscription = this._s;
if (!subscriptionClosed(subscription)) {
var observer = subscription._o;
try {
var m = getMethod(observer.next);
if (m) return m.call(observer, value);
} catch (e) {
try {
closeSubscription(subscription);
} finally {
throw e;
}
}
}
},
error: function error(value) {
var subscription = this._s;
if (subscriptionClosed(subscription)) throw value;
var observer = subscription._o;
subscription._o = undefined;
try {
var m = getMethod(observer.error);
if (!m) throw value;
value = m.call(observer, value);
} catch (e) {
try {
cleanupSubscription(subscription);
} finally {
throw e;
}
} cleanupSubscription(subscription);
return value;
},
complete: function complete(value) {
var subscription = this._s;
if (!subscriptionClosed(subscription)) {
var observer = subscription._o;
subscription._o = undefined;
try {
var m = getMethod(observer.complete);
value = m ? m.call(observer, value) : undefined;
} catch (e) {
try {
cleanupSubscription(subscription);
} finally {
throw e;
}
} cleanupSubscription(subscription);
return value;
}
}
});
var $Observable = function Observable(subscriber) {
anInstance(this, $Observable, 'Observable', '_f')._f = aFunction(subscriber);
};
redefineAll($Observable.prototype, {
subscribe: function subscribe(observer) {
return new Subscription(observer, this._f);
},
forEach: function forEach(fn) {
var that = this;
return new (core.Promise || global.Promise)(function (resolve, reject) {
aFunction(fn);
var subscription = that.subscribe({
next: function (value) {
try {
return fn(value);
} catch (e) {
reject(e);
subscription.unsubscribe();
}
},
error: reject,
complete: resolve
});
});
}
});
redefineAll($Observable, {
from: function from(x) {
var C = typeof this === 'function' ? this : $Observable;
var method = getMethod(anObject(x)[OBSERVABLE]);
if (method) {
var observable = anObject(method.call(x));
return observable.constructor === C ? observable : new C(function (observer) {
return observable.subscribe(observer);
});
}
return new C(function (observer) {
var done = false;
microtask(function () {
if (!done) {
try {
if (forOf(x, false, function (it) {
observer.next(it);
if (done) return RETURN;
}) === RETURN) return;
} catch (e) {
if (done) throw e;
observer.error(e);
return;
} observer.complete();
}
});
return function () { done = true; };
});
},
of: function of() {
for (var i = 0, l = arguments.length, items = new Array(l); i < l;) items[i] = arguments[i++];
return new (typeof this === 'function' ? this : $Observable)(function (observer) {
var done = false;
microtask(function () {
if (!done) {
for (var j = 0; j < items.length; ++j) {
observer.next(items[j]);
if (done) return;
} observer.complete();
}
});
return function () { done = true; };
});
}
});
hide($Observable.prototype, OBSERVABLE, function () { return this; });
$export($export.G, { Observable: $Observable });
__webpack_require__(47)('Observable');
/***/ }),
/* 424 */
/***/ (function(module, exports, __webpack_require__) {
// ie9- setTimeout & setInterval additional parameters fix
var global = __webpack_require__(2);
var $export = __webpack_require__(0);
var userAgent = __webpack_require__(78);
var slice = [].slice;
var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
var wrap = function (set) {
return function (fn, time /* , ...args */) {
var boundArgs = arguments.length > 2;
var args = boundArgs ? slice.call(arguments, 2) : false;
return set(boundArgs ? function () {
// eslint-disable-next-line no-new-func
(typeof fn == 'function' ? fn : Function(fn)).apply(this, args);
} : fn, time);
};
};
$export($export.G + $export.B + $export.F * MSIE, {
setTimeout: wrap(global.setTimeout),
setInterval: wrap(global.setInterval)
});
/***/ }),
/* 425 */
/***/ (function(module, exports, __webpack_require__) {
var $export = __webpack_require__(0);
var $task = __webpack_require__(112);
$export($export.G + $export.B, {
setImmediate: $task.set,
clearImmediate: $task.clear
});
/***/ }),
/* 426 */
/***/ (function(module, exports, __webpack_require__) {
var $iterators = __webpack_require__(109);
var getKeys = __webpack_require__(43);
var redefine = __webpack_require__(17);
var global = __webpack_require__(2);
var hide = __webpack_require__(16);
var Iterators = __webpack_require__(57);
var wks = __webpack_require__(8);
var ITERATOR = wks('iterator');
var TO_STRING_TAG = wks('toStringTag');
var ArrayValues = Iterators.Array;
var DOMIterables = {
CSSRuleList: true, // TODO: Not spec compliant, should be false.
CSSStyleDeclaration: false,
CSSValueList: false,
ClientRectList: false,
DOMRectList: false,
DOMStringList: false,
DOMTokenList: true,
DataTransferItemList: false,
FileList: false,
HTMLAllCollection: false,
HTMLCollection: false,
HTMLFormElement: false,
HTMLSelectElement: false,
MediaList: true, // TODO: Not spec compliant, should be false.
MimeTypeArray: false,
NamedNodeMap: false,
NodeList: true,
PaintRequestList: false,
Plugin: false,
PluginArray: false,
SVGLengthList: false,
SVGNumberList: false,
SVGPathSegList: false,
SVGPointList: false,
SVGStringList: false,
SVGTransformList: false,
SourceBufferList: false,
StyleSheetList: true, // TODO: Not spec compliant, should be false.
TextTrackCueList: false,
TextTrackList: false,
TouchList: false
};
for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
var NAME = collections[i];
var explicit = DOMIterables[NAME];
var Collection = global[NAME];
var proto = Collection && Collection.prototype;
var key;
if (proto) {
if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
Iterators[NAME] = ArrayValues;
if (explicit) for (key in $iterators) if (!proto[key]) redefine(proto, key, $iterators[key], true);
}
}
/***/ }),
/* 427 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global) {/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* https://raw.github.com/facebook/regenerator/master/LICENSE file. An
* additional grant of patent rights can be found in the PATENTS file in
* the same directory.
*/
!(function(global) {
"use strict";
var Op = Object.prototype;
var hasOwn = Op.hasOwnProperty;
var undefined; // More compressible than void 0.
var $Symbol = typeof Symbol === "function" ? Symbol : {};
var iteratorSymbol = $Symbol.iterator || "@@iterator";
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
var inModule = typeof module === "object";
var runtime = global.regeneratorRuntime;
if (runtime) {
if (inModule) {
// If regeneratorRuntime is defined globally and we're in a module,
// make the exports object identical to regeneratorRuntime.
module.exports = runtime;
}
// Don't bother evaluating the rest of this file if the runtime was
// already defined globally.
return;
}
// Define the runtime globally (as expected by generated code) as either
// module.exports (if we're in a module) or a new, empty object.
runtime = global.regeneratorRuntime = inModule ? module.exports : {};
function wrap(innerFn, outerFn, self, tryLocsList) {
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
var generator = Object.create(protoGenerator.prototype);
var context = new Context(tryLocsList || []);
// The ._invoke method unifies the implementations of the .next,
// .throw, and .return methods.
generator._invoke = makeInvokeMethod(innerFn, self, context);
return generator;
}
runtime.wrap = wrap;
// Try/catch helper to minimize deoptimizations. Returns a completion
// record like context.tryEntries[i].completion. This interface could
// have been (and was previously) designed to take a closure to be
// invoked without arguments, but in all the cases we care about we
// already have an existing method we want to call, so there's no need
// to create a new function object. We can even get away with assuming
// the method takes exactly one argument, since that happens to be true
// in every case, so we don't have to touch the arguments object. The
// only additional allocation required is the completion record, which
// has a stable shape and so hopefully should be cheap to allocate.
function tryCatch(fn, obj, arg) {
try {
return { type: "normal", arg: fn.call(obj, arg) };
} catch (err) {
return { type: "throw", arg: err };
}
}
var GenStateSuspendedStart = "suspendedStart";
var GenStateSuspendedYield = "suspendedYield";
var GenStateExecuting = "executing";
var GenStateCompleted = "completed";
// Returning this object from the innerFn has the same effect as
// breaking out of the dispatch switch statement.
var ContinueSentinel = {};
// Dummy constructor functions that we use as the .constructor and
// .constructor.prototype properties for functions that return Generator
// objects. For full spec compliance, you may wish to configure your
// minifier not to mangle the names of these two functions.
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
// This is a polyfill for %IteratorPrototype% for environments that
// don't natively support it.
var IteratorPrototype = {};
IteratorPrototype[iteratorSymbol] = function () {
return this;
};
var getProto = Object.getPrototypeOf;
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
if (NativeIteratorPrototype &&
NativeIteratorPrototype !== Op &&
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
// This environment has a native %IteratorPrototype%; use it instead
// of the polyfill.
IteratorPrototype = NativeIteratorPrototype;
}
var Gp = GeneratorFunctionPrototype.prototype =
Generator.prototype = Object.create(IteratorPrototype);
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
GeneratorFunctionPrototype.constructor = GeneratorFunction;
GeneratorFunctionPrototype[toStringTagSymbol] =
GeneratorFunction.displayName = "GeneratorFunction";
// Helper for defining the .next, .throw, and .return methods of the
// Iterator interface in terms of a single ._invoke method.
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function(method) {
prototype[method] = function(arg) {
return this._invoke(method, arg);
};
});
}
runtime.isGeneratorFunction = function(genFun) {
var ctor = typeof genFun === "function" && genFun.constructor;
return ctor
? ctor === GeneratorFunction ||
// For the native GeneratorFunction constructor, the best we can
// do is to check its .name property.
(ctor.displayName || ctor.name) === "GeneratorFunction"
: false;
};
runtime.mark = function(genFun) {
if (Object.setPrototypeOf) {
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
} else {
genFun.__proto__ = GeneratorFunctionPrototype;
if (!(toStringTagSymbol in genFun)) {
genFun[toStringTagSymbol] = "GeneratorFunction";
}
}
genFun.prototype = Object.create(Gp);
return genFun;
};
// Within the body of any async function, `await x` is transformed to
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
// `hasOwn.call(value, "__await")` to determine if the yielded value is
// meant to be awaited.
runtime.awrap = function(arg) {
return { __await: arg };
};
function AsyncIterator(generator) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if (record.type === "throw") {
reject(record.arg);
} else {
var result = record.arg;
var value = result.value;
if (value &&
typeof value === "object" &&
hasOwn.call(value, "__await")) {
return Promise.resolve(value.__await).then(function(value) {
invoke("next", value, resolve, reject);
}, function(err) {
invoke("throw", err, resolve, reject);
});
}
return Promise.resolve(value).then(function(unwrapped) {
// When a yielded Promise is resolved, its final value becomes
// the .value of the Promise<{value,done}> result for the
// current iteration. If the Promise is rejected, however, the
// result for this iteration will be rejected with the same
// reason. Note that rejections of yielded Promises are not
// thrown back into the generator function, as is the case
// when an awaited Promise is rejected. This difference in
// behavior between yield and await is important, because it
// allows the consumer to decide what to do with the yielded
// rejection (swallow it and continue, manually .throw it back
// into the generator, abandon iteration, whatever). With
// await, by contrast, there is no opportunity to examine the
// rejection reason outside the generator function, so the
// only option is to throw it from the await expression, and
// let the generator function handle the exception.
result.value = unwrapped;
resolve(result);
}, reject);
}
}
if (typeof global.process === "object" && global.process.domain) {
invoke = global.process.domain.bind(invoke);
}
var previousPromise;
function enqueue(method, arg) {
function callInvokeWithMethodAndArg() {
return new Promise(function(resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise =
// If enqueue has been called before, then we want to wait until
// all previous Promises have been resolved before calling invoke,
// so that results are always delivered in the correct order. If
// enqueue has not been called before, then it is important to
// call invoke immediately, without waiting on a callback to fire,
// so that the async generator function has the opportunity to do
// any necessary setup in a predictable way. This predictability
// is why the Promise constructor synchronously invokes its
// executor callback, and why async functions synchronously
// execute code before the first await. Since we implement simple
// async functions in terms of async generators, it is especially
// important to get this right, even though it requires care.
previousPromise ? previousPromise.then(
callInvokeWithMethodAndArg,
// Avoid propagating failures to Promises returned by later
// invocations of the iterator.
callInvokeWithMethodAndArg
) : callInvokeWithMethodAndArg();
}
// Define the unified helper method that is used to implement .next,
// .throw, and .return (see defineIteratorMethods).
this._invoke = enqueue;
}
defineIteratorMethods(AsyncIterator.prototype);
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
return this;
};
runtime.AsyncIterator = AsyncIterator;
// Note that simple async functions are implemented on top of
// AsyncIterator objects; they just return a Promise for the value of
// the final result produced by the iterator.
runtime.async = function(innerFn, outerFn, self, tryLocsList) {
var iter = new AsyncIterator(
wrap(innerFn, outerFn, self, tryLocsList)
);
return runtime.isGeneratorFunction(outerFn)
? iter // If outerFn is a generator, return the full iterator.
: iter.next().then(function(result) {
return result.done ? result.value : iter.next();
});
};
function makeInvokeMethod(innerFn, self, context) {
var state = GenStateSuspendedStart;
return function invoke(method, arg) {
if (state === GenStateExecuting) {
throw new Error("Generator is already running");
}
if (state === GenStateCompleted) {
if (method === "throw") {
throw arg;
}
// Be forgiving, per 25.3.3.3.3 of the spec:
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
return doneResult();
}
context.method = method;
context.arg = arg;
while (true) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if (context.method === "next") {
// Setting context._sent for legacy support of Babel's
// function.sent implementation.
context.sent = context._sent = context.arg;
} else if (context.method === "throw") {
if (state === GenStateSuspendedStart) {
state = GenStateCompleted;
throw context.arg;
}
context.dispatchException(context.arg);
} else if (context.method === "return") {
context.abrupt("return", context.arg);
}
state = GenStateExecuting;
var record = tryCatch(innerFn, self, context);
if (record.type === "normal") {
// If an exception is thrown from innerFn, we leave state ===
// GenStateExecuting and loop back for another invocation.
state = context.done
? GenStateCompleted
: GenStateSuspendedYield;
if (record.arg === ContinueSentinel) {
continue;
}
return {
value: record.arg,
done: context.done
};
} else if (record.type === "throw") {
state = GenStateCompleted;
// Dispatch the exception by looping back around to the
// context.dispatchException(context.arg) call above.
context.method = "throw";
context.arg = record.arg;
}
}
};
}
// Call delegate.iterator[context.method](context.arg) and handle the
// result, either by returning a { value, done } result from the
// delegate iterator, or by modifying context.method and context.arg,
// setting context.delegate to null, and returning the ContinueSentinel.
function maybeInvokeDelegate(delegate, context) {
var method = delegate.iterator[context.method];
if (method === undefined) {
// A .throw or .return when the delegate iterator has no .throw
// method always terminates the yield* loop.
context.delegate = null;
if (context.method === "throw") {
if (delegate.iterator.return) {
// If the delegate iterator has a return method, give it a
// chance to clean up.
context.method = "return";
context.arg = undefined;
maybeInvokeDelegate(delegate, context);
if (context.method === "throw") {
// If maybeInvokeDelegate(context) changed context.method from
// "return" to "throw", let that override the TypeError below.
return ContinueSentinel;
}
}
context.method = "throw";
context.arg = new TypeError(
"The iterator does not provide a 'throw' method");
}
return ContinueSentinel;
}
var record = tryCatch(method, delegate.iterator, context.arg);
if (record.type === "throw") {
context.method = "throw";
context.arg = record.arg;
context.delegate = null;
return ContinueSentinel;
}
var info = record.arg;
if (! info) {
context.method = "throw";
context.arg = new TypeError("iterator result is not an object");
context.delegate = null;
return ContinueSentinel;
}
if (info.done) {
// Assign the result of the finished delegate to the temporary
// variable specified by delegate.resultName (see delegateYield).
context[delegate.resultName] = info.value;
// Resume execution at the desired location (see delegateYield).
context.next = delegate.nextLoc;
// If context.method was "throw" but the delegate handled the
// exception, let the outer generator proceed normally. If
// context.method was "next", forget context.arg since it has been
// "consumed" by the delegate iterator. If context.method was
// "return", allow the original .return call to continue in the
// outer generator.
if (context.method !== "return") {
context.method = "next";
context.arg = undefined;
}
} else {
// Re-yield the result returned by the delegate method.
return info;
}
// The delegate iterator is finished, so forget it and continue with
// the outer generator.
context.delegate = null;
return ContinueSentinel;
}
// Define Generator.prototype.{next,throw,return} in terms of the
// unified ._invoke helper method.
defineIteratorMethods(Gp);
Gp[toStringTagSymbol] = "Generator";
// A Generator should always return itself as the iterator object when the
// @@iterator function is called on it. Some browsers' implementations of the
// iterator prototype chain incorrectly implement this, causing the Generator
// object to not be returned from this call. This ensures that doesn't happen.
// See https://github.com/facebook/regenerator/issues/274 for more details.
Gp[iteratorSymbol] = function() {
return this;
};
Gp.toString = function() {
return "[object Generator]";
};
function pushTryEntry(locs) {
var entry = { tryLoc: locs[0] };
if (1 in locs) {
entry.catchLoc = locs[1];
}
if (2 in locs) {
entry.finallyLoc = locs[2];
entry.afterLoc = locs[3];
}
this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal";
delete record.arg;
entry.completion = record;
}
function Context(tryLocsList) {
// The root entry object (effectively a try statement without a catch
// or a finally block) gives us a place to store values thrown from
// locations where there is no enclosing try statement.
this.tryEntries = [{ tryLoc: "root" }];
tryLocsList.forEach(pushTryEntry, this);
this.reset(true);
}
runtime.keys = function(object) {
var keys = [];
for (var key in object) {
keys.push(key);
}
keys.reverse();
// Rather than returning an object with a next method, we keep
// things simple and return the next function itself.
return function next() {
while (keys.length) {
var key = keys.pop();
if (key in object) {
next.value = key;
next.done = false;
return next;
}
}
// To avoid creating an additional object, we just hang the .value
// and .done properties off the next function object itself. This
// also ensures that the minifier will not anonymize the function.
next.done = true;
return next;
};
};
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) {
return iteratorMethod.call(iterable);
}
if (typeof iterable.next === "function") {
return iterable;
}
if (!isNaN(iterable.length)) {
var i = -1, next = function next() {
while (++i < iterable.length) {
if (hasOwn.call(iterable, i)) {
next.value = iterable[i];
next.done = false;
return next;
}
}
next.value = undefined;
next.done = true;
return next;
};
return next.next = next;
}
}
// Return an iterator with no values.
return { next: doneResult };
}
runtime.values = values;
function doneResult() {
return { value: undefined, done: true };
}
Context.prototype = {
constructor: Context,
reset: function(skipTempReset) {
this.prev = 0;
this.next = 0;
// Resetting context._sent for legacy support of Babel's
// function.sent implementation.
this.sent = this._sent = undefined;
this.done = false;
this.delegate = null;
this.method = "next";
this.arg = undefined;
this.tryEntries.forEach(resetTryEntry);
if (!skipTempReset) {
for (var name in this) {
// Not sure about the optimal order of these conditions:
if (name.charAt(0) === "t" &&
hasOwn.call(this, name) &&
!isNaN(+name.slice(1))) {
this[name] = undefined;
}
}
}
},
stop: function() {
this.done = true;
var rootEntry = this.tryEntries[0];
var rootRecord = rootEntry.completion;
if (rootRecord.type === "throw") {
throw rootRecord.arg;
}
return this.rval;
},
dispatchException: function(exception) {
if (this.done) {
throw exception;
}
var context = this;
function handle(loc, caught) {
record.type = "throw";
record.arg = exception;
context.next = loc;
if (caught) {
// If the dispatched exception was caught by a catch block,
// then let that catch block handle the exception normally.
context.method = "next";
context.arg = undefined;
}
return !! caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
var record = entry.completion;
if (entry.tryLoc === "root") {
// Exception thrown outside of any try block that could handle
// it, so set the completion value of the entire function to
// throw the exception.
return handle("end");
}
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc");
var hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
} else if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
} else if (hasCatch) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
}
} else if (hasFinally) {
if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
} else {
throw new Error("try statement without catch or finally");
}
}
}
},
abrupt: function(type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev &&
hasOwn.call(entry, "finallyLoc") &&
this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
if (finallyEntry &&
(type === "break" ||
type === "continue") &&
finallyEntry.tryLoc <= arg &&
arg <= finallyEntry.finallyLoc) {
// Ignore the finally entry if control is not jumping to a
// location outside the try/catch block.
finallyEntry = null;
}
var record = finallyEntry ? finallyEntry.completion : {};
record.type = type;
record.arg = arg;
if (finallyEntry) {
this.method = "next";
this.next = finallyEntry.finallyLoc;
return ContinueSentinel;
}
return this.complete(record);
},
complete: function(record, afterLoc) {
if (record.type === "throw") {
throw record.arg;
}
if (record.type === "break" ||
record.type === "continue") {
this.next = record.arg;
} else if (record.type === "return") {
this.rval = this.arg = record.arg;
this.method = "return";
this.next = "end";
} else if (record.type === "normal" && afterLoc) {
this.next = afterLoc;
}
return ContinueSentinel;
},
finish: function(finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) {
this.complete(entry.completion, entry.afterLoc);
resetTryEntry(entry);
return ContinueSentinel;
}
}
},
"catch": function(tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if (record.type === "throw") {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
// The context.catch method must only be called with a location
// argument that corresponds to a known catch block.
throw new Error("illegal catch attempt");
},
delegateYield: function(iterable, resultName, nextLoc) {
this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
};
if (this.method === "next") {
// Deliberately forget the last sent value so that we don't
// accidentally pass it on to the delegate.
this.arg = undefined;
}
return ContinueSentinel;
}
};
})(
// Among the various tricks for obtaining a reference to the global
// object, this seems to be the most reliable technique that does not
// use indirect eval (which violates Content Security Policy).
typeof global === "object" ? global :
typeof window === "object" ? window :
typeof self === "object" ? self : this
);
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(53)))
/***/ }),
/* 428 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(429);
module.exports = __webpack_require__(24).RegExp.escape;
/***/ }),
/* 429 */
/***/ (function(module, exports, __webpack_require__) {
// https://github.com/benjamingr/RexExp.escape
var $export = __webpack_require__(0);
var $re = __webpack_require__(430)(/[\\^$*+?.()|[\]{}]/g, '\\$&');
$export($export.S, 'RegExp', { escape: function escape(it) { return $re(it); } });
/***/ }),
/* 430 */
/***/ (function(module, exports) {
module.exports = function (regExp, replace) {
var replacer = replace === Object(replace) ? function (part) {
return replace[part];
} : replace;
return function (it) {
return String(it).replace(regExp, replacer);
};
};
/***/ }),
/* 431 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: 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 _browser = __webpack_require__(169);
var _browser2 = _interopRequireDefault(_browser);
var _svg = __webpack_require__(432);
var _svg2 = _interopRequireDefault(_svg);
var _bg = __webpack_require__(433);
var _bg2 = _interopRequireDefault(_bg);
__webpack_require__(539);
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"); } }
var Main = function () {
function Main() {
var _this = this;
_classCallCheck(this, Main);
this.Debug = new Debug();
this.bg = new _bg2.default();
this.nowScrollTop = 0;
this.questionOpenAnimationIs = false;
this.triggerDesign = 736;
$(document).ready(function () {
_this.init();
_this.setEvent();
});
$(window).on('load', function () {
// loaded()
});
}
_createClass(Main, [{
key: 'init',
value: function init() {
if (_browser2.default.isMobile) {
$('.davidlynch-hover').removeClass('hover');
}
this.bg.init('davidlynch-canvas-bg');
this.bg.setEvent();
this.questionScrollAreaInit();
this.fadeinAnimation();
}
}, {
key: 'setEvent',
value: function setEvent() {
var _this2 = this;
var that = this;
$(window).keydown(function () {
// ==============================================================================
//
// type [D] design 68
// type [H] html 72
// type [C] color 67
//
// ==============================================================================
if (event.keyCode === 68 || event.keyCode === 72 || event.keyCode === 67) {
that.Debug.init(event.keyCode);
}
});
$('.davidlynch-area-menu li').on('click', function () {
if ($(this).attr('status') == 'current') return false;
that.questionScroll(this);
});
$('#davidlynch-question .davidlynch-area-contents li').on('click', function () {
var num = $(this).attr('question');
that.questionOpen(num);
});
$('#davidlynch-question .davidlynch-view-detail').on('click', function () {
var num = 1;
_this2.questionOpen(num);
});
$(window).on('scroll resize', function () {
_this2.questionScrollAreaInit();
_this2.questionScrollInit();
_this2.fixedElementFitLeft();
_this2.fadeinAnimation();
// if(!this.questionOpenAnimationIs) {
// this.questionScrollInit()
// }
});
$(window).on('resize', function () {
var design = $(window).width() > _this2.triggerDesign ? 'pc' : 'sp';
if (design !== _this2.resetStyle()) {
_this2.resetStyle();
}
_this2.saveDesign = design;
});
$('.davidlynch-btn-overview').on('click', function () {
var dest = $('.davidlynch-information').offset().top;
TweenMax.to($('html,body'), 2.5, { 'scrollTop': dest, ease: Power3.easeInOut });
});
}
}, {
key: 'questionScroll',
value: function questionScroll(its) {
var getDirect = function getDirect() {
var currentNum = $('.davidlynch-area-menu li[status=\'current\']').attr('question');
var clickNum = $(its).attr('question');
var direct = clickNum - currentNum > 0 ? 'next' : 'prev';
return direct;
};
var getDest = function getDest(direct) {
var num = $(its).attr('question');
var target = $('.davidlynch-area-contents li[question=\'' + num + '\']');
var adjust = 0;
if (direct == 'next') {
adjust = -94;
}
if (direct == 'prev') {
adjust = -40;
}
var dest = $(target).offset().top - ($(its).offset().top - $(window).scrollTop() + adjust);
// const dest = $(target).offset().top - $(window).height() / 2
return dest;
};
var direct = getDirect();
var dest = getDest(direct);
TweenMax.to($('html,body'), 1.6, { 'scrollTop': dest, ease: Power3.easeInOut
// onStart: ()=> {
// this.menuCurrentChangeLock = true
// },
// onComplete: ()=> {
// this.menuCurrentChangeLock = false
// this.questionScrollInit()
// },
});
}
// ==============================================================================
//
// SPデザイン時のQUESTIONアコーディオン open
//
// ==============================================================================
}, {
key: 'questionOpen',
value: function questionOpen(num) {
if (this.questionOpenAnimationIs) return false;
if ($(window).width() > this.triggerDesign) return false;
this.questionOpenAnimationIs = true;
var target = $('#davidlynch-question .davidlynch-area-contents li[question=\'' + num + '\']');
var others = $('#davidlynch-question .davidlynch-area-contents li:not([question=\'' + num + '\'])');
var all = $('#davidlynch-question .davidlynch-area-contents ul');
$('li', all).removeClass('davidlynch-hover');
$('[davidlynch-sp-status-fast]').attr('davidlynch-sp-status-fast', 'open');
var main = function main() {
// ==============================================================================
// &[davidlynch-sp-status='open']のpadding-top分マイナス
// ==============================================================================
var dest = target.offset().top - 46;
TweenMax.to($('html,body'), 1, { 'scrollTop': dest, ease: Power2.easeInOut, delay: 0 });
var detail = $('.davidlynch-box-detail', target);
var openHeight = $(detail)[0].scrollHeight;
TweenMax.to($(detail), 1, { 'height': openHeight, ease: Power2.easeInOut, delay: 1.1,
onComplete: function onComplete() {
$('[davidlynch-sp-status]').attr('davidlynch-sp-status', 'open');
// ==============================================================================
// 一回移動してから、もう一回、移動する。
// * paddingなどが変わるため
// ==============================================================================
dest = target.offset().top;
$('html,body').scrollTop(dest);
}
});
};
var sub = function sub() {
TweenMax.to($(others), 0.5, { 'opacity': 0, ease: Power0.easeNone, delay: 0 });
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = others[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var other = _step.value;
var detail = $('.davidlynch-box-detail', $(other));
var openHeight = $(detail)[0].scrollHeight;
TweenMax.to($(detail), 0, { 'height': openHeight, ease: Power2.easeInOut, delay: 1.1,
onComplete: function onComplete() {
var dest = target.offset().top - 46;
$('html,body').scrollTop(dest);
}
});
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
TweenMax.to($(others), 0.5, { 'opacity': 1, ease: Power0.easeNone, delay: 2.1,
onStart: function onStart() {
$(window).scrollTop(target.offset().top);
},
onComplete: function onComplete() {
$('#davidlynch-question li .davidlynch-box-detail').removeClass('hidden');
$('#davidlynch-question li .davidlynch-box-detail').removeAttr('style');
var dest = target.offset().top;
$('html,body').scrollTop(dest);
}
});
};
var sideNav = function sideNav() {
var menu = $('.davidlynch-area-menu');
TweenMax.to($(menu), 0.5, { 'opacity': 0, ease: Power0.easeNone, delay: 0 });
TweenMax.to($(menu), 0.5, { 'opacity': 1, ease: Power0.easeNone, delay: 3.2 });
};
var img = function img() {
$('.davidlynch-image-wrap').addClass('in');
};
main();
sub();
sideNav();
img();
}
}, {
key: 'questionScrollAreaInit',
value: function questionScrollAreaInit() {
// const target = $('.davidlynch-area-menu')
// const adjust = $('#davidlynch-question .davidlynch-firstview .davidlynch-text').height() + parseInt($('.davidlynch-10questions').css('padding-top'))
// target.css({
// 'margin-top': -adjust,
// 'height' : $('.davidlynch-10questions').height() + adjust - parseInt($('.davidlynch-10questions li').css('padding-bottom'))
// })
}
}, {
key: 'questionScrollInit',
value: function questionScrollInit() {
var _this3 = this;
var st = $(window).scrollTop();
var wh = $(window)[0].innerHeight;
var firstviewFixed = function firstviewFixed() {
var scrollArea = $('.davidlynch-firstview-scroll-area');
var fixedContents = $('.davidlynch-firstview', scrollArea);
var ot = scrollArea.offset().top;
if (st < ot && fixedContents.hasClass('fixed')) {
fixedContents.removeClass('fixed');
} else if (st >= ot && st + wh < ot + scrollArea.height() && !fixedContents.hasClass('fixed')) {
fixedContents.removeClass('bottom').addClass('fixed');
} else if (st + wh >= ot + scrollArea.height() && !fixedContents.hasClass('bottom')) {
fixedContents.removeClass('fixed').addClass('bottom');
}
};
var menuFixed = function menuFixed() {
var target = {
elem: $('.davidlynch-fixed-content'),
h: $('.davidlynch-fixed-content').height()
};
var area = {
ot: $('.davidlynch-area-menu').offset().top,
h: $('.davidlynch-area-menu').height()
};
var targetTop = st + (wh - target.h) / 2;
var targetBottom = st + ((wh - target.h) / 2 + target.h);
if (targetTop < area.ot && target.elem.hasClass('fixed')) {
target.elem.removeClass('fixed');
} else if (targetTop >= area.ot && targetBottom < area.ot + area.h && !target.elem.hasClass('fixed')) {
target.elem.removeClass('bottom').addClass('fixed');
} else if (targetBottom >= area.ot + area.h && !target.elem.hasClass('bottom')) {
target.elem.removeClass('fixed').addClass('bottom');
}
};
var currentChange = function currentChange() {
// if(this.menuCurrentChangeLock) return false
var wheelDirect = st - _this3.nowScrollTop > 0 ? 'down' : 'up';
_this3.nowScrollTop = st;
var currentQuestionNum = parseInt($('.davidlynch-fixed-content li[status=\'current\']').attr('question'));
var waitQuestionNum = wheelDirect == 'down' ? currentQuestionNum + 1 : currentQuestionNum - 1;
if (waitQuestionNum > 10) {
waitQuestionNum = 10;
}
if (waitQuestionNum < 1) {
waitQuestionNum = 1;
}
var waitQuestion = {
menu: $('.davidlynch-fixed-content li[question=\'' + waitQuestionNum + '\']'),
content: $('.davidlynch-area-contents li[question=\'' + waitQuestionNum + '\']')
};
var changeStatus = function changeStatus() {
var oldCurrent = $('.davidlynch-fixed-content li[status=\'current\'] .davidlynch-list-inner');
if (oldCurrent.length > 0) {
TweenMax.to(oldCurrent, 0, { 'left': 0, ease: Power2.easeInOut, delay: 0 });
}
$('.davidlynch-fixed-content li').attr('status', '');
$(waitQuestion.menu).attr('status', 'current');
var menuTip = $('.davidlynch-list-inner', waitQuestion.menu);
var ol = menuTip.offset().left;
var w = menuTip.width();
var dest = $('.davidlynch-fixed-content').offset().left + $('.davidlynch-fixed-content').width();
var diff = dest - (ol + w);
if ($(window).width() >= _this3.triggerDesign) {
TweenMax.to(menuTip, 0, { 'left': diff, ease: Power2.easeInOut, delay: 0 });
}
};
var menuAnimation = function menuAnimation() {
// const num = $(target).attr('question')
};
if ($(window).width() > 750) {
if (wheelDirect === 'down') {
if ($(waitQuestion.menu).offset().top - 0 >= $(waitQuestion.content).offset().top) {
changeStatus();
menuAnimation();
}
}
if (wheelDirect === 'up') {
if ($(waitQuestion.menu).offset().top <= $(waitQuestion.content).offset().top + $(waitQuestion.content).height()) {
changeStatus();
menuAnimation();
}
}
}
if ($(window).width() <= 750) {
if (wheelDirect === 'down') {
if (st + 80 >= $(waitQuestion.content).offset().top) {
changeStatus();
menuAnimation();
}
}
if (wheelDirect === 'up') {
if (st + 80 <= $(waitQuestion.content).offset().top + $(waitQuestion.content).height()) {
changeStatus();
menuAnimation();
}
}
}
};
menuFixed();
firstviewFixed();
currentChange();
}
}, {
key: 'fixedElementFitLeft',
value: function fixedElementFitLeft() {
var left = $(window).scrollLeft();
var w = $('#davidlynch-container').width();
$('#davidlynch-canvas-bg').css({
'left': '-' + left + 'px',
'width': w + 'px'
});
$('#davidlynch-question .davidlynch-firstview.fixed').css({
'left': '-' + left + 'px',
'width': w + 'px'
});
var menuLeft = $('.davidlynch-area-menu-inner').offset().left;
$('#davidlynch-question .davidlynch-fixed-content.fixed').css({
'left': menuLeft - left + 'px',
'width': $('.davidlynch-area-menu-inner').width()
});
if (!$('#davidlynch-question .davidlynch-fixed-content').hasClass('fixed')) {
$('#davidlynch-question .davidlynch-fixed-content').removeAttr('style');
}
}
}, {
key: 'resetStyle',
value: function resetStyle() {
$('#davidlynch-question .davidlynch-area-menu .davidlynch-list-inner').removeAttr('style');
}
}, {
key: 'fadeinAnimation',
value: function fadeinAnimation() {
var targets = $('.davidlynch-anim-fadein');
var st = $(window).scrollTop();
var wh = $(window).height();
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = targets[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var v = _step2.value;
var target = $(v);
var ot = $(target).offset().top;
if (st + wh >= ot && $(target).hasClass('davidlynch-anim-fadein')) {
$(target).removeClass('davidlynch-anim-fadein');
$(target).addClass('anim-fadein');
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
}]);
return Main;
}();
exports.default = Main;
var Debug = function () {
function Debug() {
_classCallCheck(this, Debug);
}
_createClass(Debug, [{
key: 'init',
value: function init(keycode) {
var target = void 0;
switch (keycode) {
case 68:
target = $('.design-debug');
break;
case 72:
target = $('.davidlynch-wrap-article');
break;
case 67:
target = $('.__color');
break;
}
var view = function view() {
target.addClass('view').removeClass('destroy');
};
var destroy = function destroy() {
target.addClass('destroy').removeClass('view');
};
if (target.hasClass('view')) {
destroy();
} else {
view();
}
}
}]);
return Debug;
}();
new Main();
/***/ }),
/* 432 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// import ItemFadein from './itemFadein'
Object.defineProperty(exports, "__esModule", {
value: 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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Svg = function () {
function Svg() {
var _this = this;
_classCallCheck(this, Svg);
$(document).ready(function () {
_this.init();
});
$(window).on('resize', function () {
_this.init();
});
}
_createClass(Svg, [{
key: 'init',
value: function init() {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = $('#davidlynch-container svg')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var v = _step.value;
var target = $(v);
var viewbox = target.attr("viewBox");
viewbox = viewbox.split(" ");
var svg = {
'origin': {
'w': parseFloat(viewbox[2]),
'h': parseFloat(viewbox[3])
},
'css': {
'h': parseFloat(target.css("height"))
}
};
var w = svg.origin.w * (svg.css.h / svg.origin.h);
target.css({ 'width': w + 'px' });
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
}]);
return Svg;
}();
exports.default = Svg;
module.exports = new Svg();
/***/ }),
/* 433 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: 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 _browser = __webpack_require__(169);
var _browser2 = _interopRequireDefault(_browser);
var _filterBulgePinch = __webpack_require__(434);
var _filterAdvancedBloom = __webpack_require__(537);
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"); } }
var Bg = function () {
function Bg() {
_classCallCheck(this, Bg);
this.VINYLIS = true;
this.heightAdjustSP = _browser2.default.isMobile ? 1.2 : 1;
this.triggerDesign = 736;
this.backgroundScale = 1.1;
this.articles = {
'kv': {
img: [{ pc: { w: 2840, h: 1680 }, sp: { w: 750, h: 1200 } }, { pc: { w: 2840, h: 1680 }, sp: { w: 750, h: 1200 } }],
backgrounds: [],
trigger: {},
fadeDuration: { alpha: 0.5, y: 0.5 }
},
'question': {
img: [{ pc: { w: 2840, h: 3427 }, sp: { w: 750, h: 1700 } }],
backgrounds: [],
trigger: {},
fadeDuration: { alpha: 0.5, y: 0.5 }
},
'profile': {
img: [{ pc: { w: 2840, h: 2840 }, sp: { w: 750, h: 1700 } }],
backgrounds: [],
trigger: {},
fadeDuration: { alpha: 1.4, y: 0.5 }
},
'other': {
img: [{ pc: { w: 2840, h: 2840 }, sp: { w: 750, h: 1700 } }],
backgrounds: [],
trigger: {},
fadeDuration: { alpha: 1.4, y: 0.5 }
}
};
}
_createClass(Bg, [{
key: 'init',
value: function init(target) {
var _this = this;
this.setDesign();
var ww = $('#davidlynch-container').width();
var wh = $(window).height() * this.heightAdjustSP;
this.app = new PIXI.Application(ww, wh, {
transparent: true,
// antialias : true,
// resolution : 2,
autoResize: true
});
var containerInit = function containerInit() {
_this.container = new PIXI.Container();
_this.container.width = ww;
_this.container.height = wh;
_this.app.stage.addChild(_this.container);
$('#' + target).append(_this.app.view);
};
containerInit();
var filterInit = function filterInit() {
_this.displacementSprite = PIXI.Sprite.fromImage('/assets/img/art-detail/davidlynch/clouds-3.jpg');
_this.displacementSprite.texture.baseTexture.wrapMode = PIXI.WRAP_MODES.REPEAT;
// this.displacementSprite.scale.x = 8
// this.displacementSprite.scale.y = 8
// this.app.stage.addChild(this.displacementSprite)
_this.displacementFilter = new PIXI.filters.DisplacementFilter(_this.displacementSprite);
_this.displacementFilter.autoFit = true;
// this.container.filters = [this.displacementFilter];
};
filterInit();
var design = $(window).width() > this.triggerDesign ? 'pc' : 'sp';
this.changeDesign(design);
this.backgroundChange();
this.app.ticker.autoStart = false;
this.app.ticker.stop();
this.kvSlideCheck();
this.loopHundlar(60, function () {
_this.move();
});
}
// ==============================================================================
//
// アクセス時にPC SP判別して画像をセットする
// PC/SPデザイン切り替え時に画像差し替えを行う
//
// ==============================================================================
}, {
key: 'changeDesign',
value: function changeDesign(design) {
var _this2 = this;
var ww = $(window).width();
var wh = $(window).height() * this.heightAdjustSP;
var reset = function reset() {
_this2.container.removeChildren();
};
reset();
var set = function set() {
var colors = {
'kv': 0x0000ff,
'question': 0x00ff00,
'profile': 0xff0000,
'other': 0xff00ff
};
var _loop = function _loop(k) {
var v = _this2.articles[k];
var mask = new PIXI.Graphics();
var boxArticle = new PIXI.Container(0, 0, 100, 100);
var boxBackground = new PIXI.Container(0, 0, 100, 100);
// ==============================================================================
// box_maskをコンテナーに追加
// ==============================================================================
var maskInit = function maskInit() {
// const ot = $(`#davidlynch-${k}`).offset().top
var h = $('#davidlynch-' + k)[0].clientHeight;
mask.beginFill(colors[k]);
if (k === 'question') {
var _design = ww > _this2.triggerDesign ? 'pc' : 'sp';
mask.drawRect(0, 0, ww, ww * v.img[0][_design].h / v.img[0][_design].w);
} else {
mask.drawRect(0, 0, ww, wh);
}
mask.endFill();
// mask.y = ot
_this2.container.addChild(mask);
// this.container.addChild(boxArticle)
boxArticle.mask = mask;
v.box_mask = mask;
// v.box_article = boxArticle
};
maskInit();
// ==============================================================================
// box_articleをコンテナーに追加
// box_articleはbox_maskによってmaskされる
// ==============================================================================
var articleInit = function articleInit() {
_this2.container.addChild(boxArticle);
v.box_article = boxArticle;
};
articleInit();
// ==============================================================================
// box_backgroundをbox_articleに追加
// ==============================================================================
var backgroundInit = function backgroundInit() {
for (var i in v.img) {
var numPrefix = v.img.length > 1 ? '-' + (parseInt(i) + 1) : '';
var background = PIXI.Sprite.fromImage('/assets/img/art-detail/davidlynch/bg-' + k + numPrefix + '-' + design + '.jpg');
background.anchor.x = 0.5;
if (k === 'kv') {
background.anchor.y = 0.5;
} else {
background.anchor.y = 0;
}
boxBackground.addChild(background);
v.backgrounds.push(background);
}
var filterInit = function filterInit() {
var cloud = PIXI.Sprite.fromImage('/assets/img/art-detail/davidlynch/clouds-3.jpg');
cloud.texture.baseTexture.wrapMode = PIXI.WRAP_MODES.REPEAT;
// cloud.scale.x = design === 'pc' ? 2.7 : 1.4
// cloud.scale.y = design === 'pc' ? 2.7 : 1.4
cloud.scale.x = 12;
cloud.scale.y = 12;
boxBackground.addChild(cloud);
v.cloud = cloud;
var filter = new PIXI.filters.DisplacementFilter(cloud);
filter.autoFit = true;
boxBackground.filters = [filter];
};
filterInit();
v.box_article.addChild(boxBackground);
v.box_background = boxBackground;
};
backgroundInit();
};
for (var k in _this2.articles) {
_loop(k);
}
};
set();
this.resizeItems(design);
// this.app.ticker.update()
}
}, {
key: 'setEvent',
value: function setEvent() {
var _this3 = this;
var that = this;
$(window).on('resize', function () {
var ww = $(window).width();
var wh = $(window).height() * _this3.heightAdjustSP;
var checkDesign = function checkDesign() {
var design = $(window).width() > _this3.triggerDesign ? 'pc' : 'sp';
if (design !== _this3.saveDesign) {
_this3.changeDesign(design);
}
_this3.saveDesign = design;
};
_this3.app.renderer.resize($('#davidlynch-container').width(), wh);
checkDesign();
_this3.resizeItems(_this3.saveDesign);
});
$(window).on('scroll resize', function () {
// this.fadeinSet()
_this3.backgroundChange();
_this3.backgroundScroll();
// this.parallax()
// this.move()
// this.app.ticker.update()
_this3.kvSlideCheck();
// this.fadeInBackground()
// if(this.looptimer) {
// // this.cancel()
// this.moveScrollTrigger()
// }
});
// $(window).on('scroll', function() {
// // that.move()
// })
// $(window).keydown(function(){
// // type [R] remove child
// if(event.keyCode === 82) {
// that.container.removeChild(that.articles.question.container)
// }
// });
}
// fadeInBackground() {
// const st = $(window).scrollTop()
// const wh = $(window).height()
// for(let k in this.articles) {
// const target = $(`#davidlynch-${k}`)
// const ot = $(target).offset().top
// if( st + wh >= ot && st + wh < ot + $(target)[0].clientHeight && $(target).attr('status') !== 'in' ) {
// $('article').removeAttr('status')
// $(target).attr('status', 'in')
// TweenMax.to(
// {
// alpha: 0,
// },
// 1,
// {
// alpha: 1,
// ease: Power0.easeNone,
// onStart: ()=>{
// // this.container.addChild(this.articles[current].container)
// },
// onUpdate: ( tween )=>{
// let alpha = tween.target.alpha;
// this.articles[k].box_article.alpha = alpha
// this.app.ticker.update()
// // if(current = 'kv') {
// // this.articles[current].backgrounds[1].alpha = alpha
// // }
// },
// onUpdateParams: [ "{self}" ]
// }
// );
// }
// }
// }
// ==============================================================================
//
// 各articleのfadein, fadeoutを設定
//
// ==============================================================================
// fadeinSet() {
// const wh = $(window).height()
// this.articles['kv'].trigger = {
// fadein: 0,
// fadeout: $('#davidlynch-question').offset().top - (wh / 2),
// }
// this.articles['question'].trigger = {
// fadein: $('#davidlynch-question').offset().top - (wh / 2),
// fadeout: $('#davidlynch-question').offset().top + ($('#davidlynch-question').height() / 2),
// }
// this.articles['profile'].trigger = {
// fadein: $('#davidlynch-question').offset().top + ($('#davidlynch-question').height() / 2),
// fadeout: $('#davidlynch-other').offset().top - wh,
// }
// this.articles['other'].trigger = {
// fadein: $('#davidlynch-other').offset().top - wh,
// fadeout: $('#davidlynch-other').offset().top,
// }
// }
}, {
key: 'setDesign',
value: function setDesign() {
var design = $(window).width() > this.triggerDesign ? 'pc' : 'sp';
this.saveDesign = design;
}
// // ==============================================================================
// //
// // articleが切り替わったタイミングで背景画像を切り替えを行う
// //
// // ==============================================================================
}, {
key: 'backgroundChange',
value: function backgroundChange() {
var _this4 = this;
var getCurrentArticle = function getCurrentArticle() {
var st = $(window).scrollTop();
var wh = $(window).height();
if (st + wh >= $('#davidlynch-question').offset().top) {}
for (var k in _this4.articles) {
var _v = _this4.articles[k];
var target = $('#davidlynch-' + k);
var article = {
ot: target.offset().top,
h: target.height()
};
var trigger = st + wh / 2;
if (trigger >= article.ot && article.ot + article.h > trigger && _this4.currentArticle !== k) {
_this4.currentArticle = k;
return {
current: _this4.currentArticle,
save: _this4.saveArticle
};
}
}
_this4.saveArticle = _this4.currentArticle;
};
var changeBg = function changeBg(vars) {
if (!vars) return false;
for (var k in _this4.articles) {
// const v = this.articles[k]
if (k !== vars.save && k !== vars.current) {
_this4.container.removeChild(_this4.articles[k].box_article);
}
}
// if(vars.save) {
// this.container.removeChild(this.articles[vars.save].box_article)
// this.container.addChild(this.articles[vars.save].box_article)
// this.articles[vars.save].box_article.alpha = 1
// }
_this4.container.removeChild(_this4.articles[vars.current].box_article);
TweenMax.to({
y: 300
}, _this4.articles[vars.current].fadeDuration.y, {
y: 0,
ease: Power2.easeOut,
onStart: function onStart() {},
onUpdate: function onUpdate(tween) {
var y = tween.target.y;
if (vars.current === 'profile' || vars.current === 'other') {
_this4.articles[vars.current].box_article.y = y;
}
},
onUpdateParams: ["{self}"]
});
TweenMax.to({
alpha: 0
}, _this4.articles[vars.current].fadeDuration.alpha, {
alpha: 1,
ease: Power0.easeNone,
onStart: function onStart() {
_this4.articles[vars.current].box_article.alpha = 0;
_this4.container.addChild(_this4.articles[vars.current].box_article);
},
onUpdate: function onUpdate(tween) {
var alpha = tween.target.alpha;
_this4.articles[vars.current].box_article.alpha = alpha;
if (vars.save) {
_this4.articles[vars.save].box_article.alpha = 1 - alpha;
}
},
onUpdateParams: ["{self}"]
});
if (vars.current === 'profile' || vars.current === 'other') {
var direct = vars.save === 'other' && vars.current === 'profile' ? -1 : 1;
TweenMax.to({
y: 300 * direct
}, 2, {
y: 0,
ease: Power3.easeOut,
onUpdate: function onUpdate(tween) {
var y = tween.target.y;
_this4.articles[vars.current].box_article.y = y;
_this4.articles[vars.current].box_mask.y = y;
// this.app.ticker.update()
},
onUpdateParams: ["{self}"]
});
}
};
changeBg(getCurrentArticle());
}
// ==============================================================================
//
// scrollに応じて、背景もscroll
//
// ==============================================================================
}, {
key: 'backgroundScroll',
value: function backgroundScroll() {
var _this5 = this;
var st = $(window).scrollTop();
this.articles.question.box_article.y = $('#davidlynch-question').offset().top - st;
var boxMask = function boxMask() {
var ww = $('#davidlynch-container').width();
var wh = $(window).height() * _this5.heightAdjustSP;
var ot = $('#davidlynch-question').offset().top;
var h = $('#davidlynch-question')[0].clientHeight;
_this5.articles.question.box_mask.position.set(0, ot - st);
// this.articles.question.box_mask.beginFill(0x0000ff);
// // this.articles.question.box_mask.drawRect(0, 0, ww/3, wh);
// this.articles.question.box_mask.drawRect(400, 400, ww/3, wh);
// this.articles.question.box_mask.endFill();
};
boxMask();
}
// ==============================================================================
//
// parallaxの移動距離を計算して実行
//
// ==============================================================================
}, {
key: 'parallax',
value: function parallax() {}
// const st = $(window).scrollTop()
// const wh = $(window).height() * this.heightAdjustSP
// const ww = $(window).width()
// const area = {
// ot: $(`#davidlynch-container`).offset().top,
// h : $(`#davidlynch-container`).height(),
// }
// // const dest = parseInt(area.ot - st)
// // this.container.y = dest
// for(let k in this.articles) {
// const article = k
// const area = {
// ot: $(`#davidlynch-${article}`).offset().top,
// h : $(`#davidlynch-${article}`).height(),
// }
// const dest = parseInt(area.ot - st)
// this.articles[article].box_mask.y = dest
// this.articles[article].box_background.y = dest
// }
// // if(area.ot >= st) {
// // this.articles[article].container.y = 0
// // }
// // else if(area.ot <= st && area.ot + area.h >= st) {
// // const dest = area.ot - st
// // this.articles[article].container.y = dest
// // }
// // else if(area.ot + area.h < st) {
// // const bgh = ww * this.articles[article].img[0][this.saveDesign].h / this.articles[article].img[0][this.saveDesign].w
// // this.articles[article].container.y = wh - bgh
// // }
// ==============================================================================
//
// 最初と、スクロールされるたびに実行。
// kv firstareaが画面内に収まっている場合は、play, それ以外はstop
//
// ==============================================================================
}, {
key: 'kvSlideCheck',
value: function kvSlideCheck() {
var _this6 = this;
var st = $(window).scrollTop();
var kvArea = $('#davidlynch-kv .davidlynch-firstview');
var play = function play() {
var i = 0;
_this6.slideTimer = setInterval(function () {
var num = i % 2;
_this6.articles.kv.box_background.removeChild(_this6.articles.kv.backgrounds[num]);
_this6.articles.kv.box_background.addChild(_this6.articles.kv.backgrounds[num]);
_this6.articles.kv.backgrounds[num].alpha = 0;
TweenMax.to({
alpha: 0
}, 1, {
alpha: 1,
ease: Power0.easeNone,
onUpdate: function onUpdate(tween) {
var alpha = tween.target.alpha;
_this6.articles.kv.backgrounds[num].alpha = alpha;
// this.app.ticker.update()
},
onComplete: function onComplete() {
// this.app.ticker.stop();
// this.slideTimerPlayIs = false
},
onUpdateParams: ["{self}"]
});
i++;
}, 5000);
};
var stop = function stop() {
if (_this6.slideTimer) {
clearInterval(_this6.slideTimer);
}
};
if (st <= $(kvArea).offset().top + $(kvArea).height() && !this.slideTimerPlayIs) {
this.slideTimerPlayIs = true;
play();
} else if (st > $(kvArea).offset().top + $(kvArea).height() && this.slideTimerPlayIs) {
this.slideTimerPlayIs = false;
stop();
}
// if(type === 'play') {
// play()
// }
// if(type === 'stop') {
// stop()
// }
}
}, {
key: 'move',
value: function move() {
// const st = $(window).scrollTop()
// const stSave = this.stSave ? this.stSave : st
// let diff = st - stSave
// if(diff > 50) { diff = 50 }
// if(diff < -50) { diff = -50 }
// this.cloudPositionAdjust = 0
// if(!this.scrollIs) {
// this.scrollIs = true
// TweenMax.to(
// {
// adjust: 20,
// },
// 1,
// {
// adjust: 0,
// ease: Power0.easeNone,
// onUpdate: ( tween )=>{
// this.cloudPositionAdjust = tween.target.adjust;
// console.log(tween.target.adjust)
// },
// onComplete:() => {
// this.scrollIs = false
// },
// onUpdateParams: [ "{self}" ]
// }
// );
// }
// console.log(this.cloudPositionAdjust)
var adjust = $(window).width() > this.triggerDesign ? 0.8 : 0.5;
for (var k in this.articles) {
var _v2 = this.articles[k];
if (_v2.cloud) {
// v.cloud.rotation += 0.003
_v2.cloud.position.x += 5;
_v2.cloud.position.y += 10;
}
}
this.app.ticker.update();
// this.stSave = st
// // this.displacementSprite.position.x += 6
// // this.displacementSprite.position.y += 10
}
// moveScrollTrigger() {
// if(!this.scrollIs) {
// this.scrollIs = true
// TweenMax.to(
// {
// y: 20,
// scale: 20,
// rotation: 0,
// },
// 1,
// {
// y: 8,
// scale: 12,
// rotation: 0.3,
// ease: Power1.easeOut,
// onStart: ( tween )=>{
// // for(let k in this.articles) {
// // const v = this.articles[k]
// // if(v.cloud) {
// // v.cloud.scale.x = 1
// // v.cloud.scale.y = 1
// // }
// // }
// },
// onUpdate: ( tween )=>{
// let y = tween.target.y;
// let scale = tween.target.scale;
// let rotation = tween.target.rotation;
// for(let k in this.articles) {
// const v = this.articles[k]
// if(v.cloud) {
// // v.cloud.position.x += 4
// // v.cloud.position.y += 8
// // v.cloud.scale.x = scale
// v.cloud.rotation = rotation
// // v.cloud.rotation
// }
// }
// // this.app.ticker.update()
// },
// onComplete:() => {
// // for(let k in this.articles) {
// // const v = this.articles[k]
// // if(v.cloud) {
// // v.cloud.scale.x = 8
// // v.cloud.scale.y = 8
// // }
// // }
// // this.loopHundlar( 60, ()=>{ this.move() } )
// this.scrollIs = false
// },
// onUpdateParams: [ "{self}" ]
// }
// );
// }
// }
// ==============================================================================
//
// windowsizeに応じて背景をcover状態にする
// background-position: top center
//
// ==============================================================================
}, {
key: 'resizeItems',
value: function resizeItems(design) {
var _this7 = this;
var ww = $('#davidlynch-container').width();
var wh = $(window).height() * this.heightAdjustSP;
var getWindowRatio = function getWindowRatio(size) {
return ww >= wh * size.w / size.h ? 'yoko' : 'tate';
};
var backgroundSize = function backgroundSize(size) {
var ratio = getWindowRatio(size);
var w = ratio === 'yoko' ? ww : $(window).height() * size.w / size.h;
var h = ratio === 'yoko' ? ww * size.h / size.w : $(window).height();
return { w: w, h: h };
};
var colors = {
'kv': 0x0000ff,
'question': 0x00ff00,
'profile': 0xff0000,
'other': 0xff00ff
};
var _loop2 = function _loop2(k) {
var v = _this7.articles[k];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
var _loop3 = function _loop3() {
var pixiSprite = _step.value;
var img = function img() {
pixiSprite.width = backgroundSize(v.img[0][design]).w * _this7.backgroundScale;
pixiSprite.height = backgroundSize(v.img[0][design]).h * _this7.backgroundScale;
pixiSprite.x = ww / 2;
// pixiSprite.y = 0
// pixiSprite.y = wh / 2
if (k === 'kv') {
pixiSprite.y = wh / 2 + (pixiSprite.height - pixiSprite.height * _this7.backgroundScale) / 2;
} else {
pixiSprite.y = (pixiSprite.height - pixiSprite.height * _this7.backgroundScale) / 2;
}
// pixiSprite.y = 0
};
img();
};
for (var _iterator = v.backgrounds[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
_loop3();
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var boxMask = function boxMask() {
var ot = $('#davidlynch-' + k).offset().top;
var h = $('#davidlynch-' + k)[0].clientHeight;
v.box_mask.clear();
v.box_mask.beginFill();
if (k === 'question') {
var _design2 = ww > _this7.triggerDesign ? 'pc' : 'sp';
var mask_h = ww * v.img[0][_design2].h / v.img[0][_design2].w;
// if(design === 'sp') {
// if(mask_h <= v.img[0][design].h / 2) {
// mask_h = v.img[0][design].h / 2
// }
// }
v.box_mask.drawRect(0, 0, ww, mask_h);
} else {
v.box_mask.drawRect(0, 0, ww, wh);
}
v.box_mask.endFill();
// v.box_mask.y = ot
};
boxMask();
// const boxArticle = () => {
// }
// boxArticle()
};
for (var k in this.articles) {
_loop2(k);
}
}
// ==============================================================================
//
// 指定されたfpsで常にcallback関数が実行される
//
// ==============================================================================
}, {
key: 'loopHundlar',
value: function loopHundlar(fps, cb) {
var _this8 = this;
// const fps = 3;
//----------------------------------------
// 指定されたfpsで繰り返す
//----------------------------------------
var framelate = function framelate() {
cb();
// console.log('aaa')
};
//----------------------------------------
// cpuで繰り返す
// flamerateを呼び出す。
//----------------------------------------
var step = function step() {
var lastTime = new Date().getTime();
var elapsedTime = Math.floor((lastTime - _this8.startTime) / (1000 / fps));
if (elapsedTime !== _this8.totalframe) {
_this8.totalframe = elapsedTime;
framelate();
}
_this8.looptimer = window.requestAnimationFrame(step);
};
this.startTime = new Date().getTime();
this.looptimer = window.requestAnimationFrame(step);
}
}, {
key: 'cancel',
value: function cancel() {
if (this.looptimer) {
window.cancelAnimationFrame(this.looptimer);
this.looptimer = false;
}
}
}]);
return Bg;
}();
// module.exports = new Vinyl()
exports.default = Bg;
/***/ }),
/* 434 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BulgePinchFilter", function() { return t; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_pixi_js__ = __webpack_require__(116);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_pixi_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_pixi_js__);
/*!
* @pixi/filter-bulge-pinch - v2.7.0
* Compiled Sun, 13 Jan 2019 22:51:52 UTC
*
* @pixi/filter-bulge-pinch is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
var e="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",r="uniform float radius;\nuniform float strength;\nuniform vec2 center;\nuniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\nuniform vec2 dimensions;\n\nvoid main()\n{\n vec2 coord = vTextureCoord * filterArea.xy;\n coord -= center * dimensions.xy;\n float distance = length(coord);\n if (distance < radius) {\n float percent = distance / radius;\n if (strength > 0.0) {\n coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75);\n } else {\n coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent);\n }\n }\n coord += center * dimensions.xy;\n coord /= filterArea.xy;\n vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw);\n vec4 color = texture2D(uSampler, clampedCoord);\n if (coord != clampedCoord) {\n color *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n gl_FragColor = color;\n}\n",t=function(n){function t(t,o,i){n.call(this,e,r),this.uniforms.dimensions=new Float32Array(2),this.center=t||[.5,.5],this.radius="number"==typeof o?o:100,this.strength="number"==typeof i?i:1}n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t;var o={radius:{configurable:!0},strength:{configurable:!0},center:{configurable:!0}};return t.prototype.apply=function(n,e,r,t){this.uniforms.dimensions[0]=e.sourceFrame.width,this.uniforms.dimensions[1]=e.sourceFrame.height,n.applyFilter(this,e,r,t)},o.radius.get=function(){return this.uniforms.radius},o.radius.set=function(n){this.uniforms.radius=n},o.strength.get=function(){return this.uniforms.strength},o.strength.set=function(n){this.uniforms.strength=n},o.center.get=function(){return this.uniforms.center},o.center.set=function(n){this.uniforms.center=n},Object.defineProperties(t.prototype,o),t}(__WEBPACK_IMPORTED_MODULE_0_pixi_js__["Filter"]);
//# sourceMappingURL=filter-bulge-pinch.esm.js.map
/***/ }),
/* 435 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
__webpack_require__(436);
__webpack_require__(438);
__webpack_require__(439);
__webpack_require__(440);
if (!window.ArrayBuffer) {
window.ArrayBuffer = Array;
}
if (!window.Float32Array) {
window.Float32Array = Array;
}
if (!window.Uint32Array) {
window.Uint32Array = Array;
}
if (!window.Uint16Array) {
window.Uint16Array = Array;
}
//# sourceMappingURL=index.js.map
/***/ }),
/* 436 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _objectAssign = __webpack_require__(437);
var _objectAssign2 = _interopRequireDefault(_objectAssign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
if (!Object.assign) {
Object.assign = _objectAssign2.default;
} // References:
// https://github.com/sindresorhus/object-assign
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
//# sourceMappingURL=Object.assign.js.map
/***/ }),
/* 437 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* eslint-disable no-unused-vars */
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !==
'abcdefghijklmnopqrst') {
return false;
}
return true;
} catch (err) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
if (getOwnPropertySymbols) {
symbols = getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}
return to;
};
/***/ }),
/* 438 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(global) {
// References:
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// https://gist.github.com/1579671
// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision
// https://gist.github.com/timhall/4078614
// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame
// Expected to be used with Browserfiy
// Browserify automatically detects the use of `global` and passes the
// correct reference of `global`, `self`, and finally `window`
var ONE_FRAME_TIME = 16;
// Date.now
if (!(Date.now && Date.prototype.getTime)) {
Date.now = function now() {
return new Date().getTime();
};
}
// performance.now
if (!(global.performance && global.performance.now)) {
var startTime = Date.now();
if (!global.performance) {
global.performance = {};
}
global.performance.now = function () {
return Date.now() - startTime;
};
}
// requestAnimationFrame
var lastTime = Date.now();
var vendors = ['ms', 'moz', 'webkit', 'o'];
for (var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) {
var p = vendors[x];
global.requestAnimationFrame = global[p + 'RequestAnimationFrame'];
global.cancelAnimationFrame = global[p + 'CancelAnimationFrame'] || global[p + 'CancelRequestAnimationFrame'];
}
if (!global.requestAnimationFrame) {
global.requestAnimationFrame = function (callback) {
if (typeof callback !== 'function') {
throw new TypeError(callback + 'is not a function');
}
var currentTime = Date.now();
var delay = ONE_FRAME_TIME + lastTime - currentTime;
if (delay < 0) {
delay = 0;
}
lastTime = currentTime;
return setTimeout(function () {
lastTime = Date.now();
callback(performance.now());
}, delay);
};
}
if (!global.cancelAnimationFrame) {
global.cancelAnimationFrame = function (id) {
return clearTimeout(id);
};
}
//# sourceMappingURL=requestAnimationFrame.js.map
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(53)))
/***/ }),
/* 439 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// References:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
if (!Math.sign) {
Math.sign = function mathSign(x) {
x = Number(x);
if (x === 0 || isNaN(x)) {
return x;
}
return x > 0 ? 1 : -1;
};
}
//# sourceMappingURL=Math.sign.js.map
/***/ }),
/* 440 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// References:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
if (!Number.isInteger) {
Number.isInteger = function numberIsInteger(value) {
return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
};
}
//# sourceMappingURL=Number.isInteger.js.map
/***/ }),
/* 441 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Rectangle = __webpack_require__(119);
var _Rectangle2 = _interopRequireDefault(_Rectangle);
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 Circle object can be used to specify a hit area for displayObjects
*
* @class
* @memberof PIXI
*/
var Circle = function () {
/**
* @param {number} [x=0] - The X coordinate of the center of this circle
* @param {number} [y=0] - The Y coordinate of the center of this circle
* @param {number} [radius=0] - The radius of the circle
*/
function Circle() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var radius = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
_classCallCheck(this, Circle);
/**
* @member {number}
* @default 0
*/
this.x = x;
/**
* @member {number}
* @default 0
*/
this.y = y;
/**
* @member {number}
* @default 0
*/
this.radius = radius;
/**
* The type of the object, mainly used to avoid `instanceof` checks
*
* @member {number}
* @readOnly
* @default PIXI.SHAPES.CIRC
* @see PIXI.SHAPES
*/
this.type = _const.SHAPES.CIRC;
}
/**
* Creates a clone of this Circle instance
*
* @return {PIXI.Circle} a copy of the Circle
*/
Circle.prototype.clone = function clone() {
return new Circle(this.x, this.y, this.radius);
};
/**
* Checks whether the x and y coordinates given are contained within this circle
*
* @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 Circle
*/
Circle.prototype.contains = function contains(x, y) {
if (this.radius <= 0) {
return false;
}
var r2 = this.radius * this.radius;
var dx = this.x - x;
var dy = this.y - y;
dx *= dx;
dy *= dy;
return dx + dy <= r2;
};
/**
* Returns the framing rectangle of the circle as a Rectangle object
*
* @return {PIXI.Rectangle} the framing rectangle
*/
Circle.prototype.getBounds = function getBounds() {
return new _Rectangle2.default(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2);
};
return Circle;
}();
exports.default = Circle;
//# sourceMappingURL=Circle.js.map
/***/ }),
/* 442 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Rectangle = __webpack_require__(119);
var _Rectangle2 = _interopRequireDefault(_Rectangle);
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 Ellipse object can be used to specify a hit area for displayObjects
*
* @class
* @memberof PIXI
*/
var Ellipse = function () {
/**
* @param {number} [x=0] - The X coordinate of the center of this ellipse
* @param {number} [y=0] - The Y coordinate of the center of this ellipse
* @param {number} [halfWidth=0] - The half width of this ellipse
* @param {number} [halfHeight=0] - The half height of this ellipse
*/
function Ellipse() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var halfWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var halfHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
_classCallCheck(this, Ellipse);
/**
* @member {number}
* @default 0
*/
this.x = x;
/**
* @member {number}
* @default 0
*/
this.y = y;
/**
* @member {number}
* @default 0
*/
this.width = halfWidth;
/**
* @member {number}
* @default 0
*/
this.height = halfHeight;
/**
* The type of the object, mainly used to avoid `instanceof` checks
*
* @member {number}
* @readOnly
* @default PIXI.SHAPES.ELIP
* @see PIXI.SHAPES
*/
this.type = _const.SHAPES.ELIP;
}
/**
* Creates a clone of this Ellipse instance
*
* @return {PIXI.Ellipse} a copy of the ellipse
*/
Ellipse.prototype.clone = function clone() {
return new Ellipse(this.x, this.y, this.width, this.height);
};
/**
* Checks whether the x and y coordinates given are contained within this ellipse
*
* @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 coords are within this ellipse
*/
Ellipse.prototype.contains = function contains(x, y) {
if (this.width <= 0 || this.height <= 0) {
return false;
}
// normalize the coords to an ellipse with center 0,0
var normx = (x - this.x) / this.width;
var normy = (y - this.y) / this.height;
normx *= normx;
normy *= normy;
return normx + normy <= 1;
};
/**
* Returns the framing rectangle of the ellipse as a Rectangle object
*
* @return {PIXI.Rectangle} the framing rectangle
*/
Ellipse.prototype.getBounds = function getBounds() {
return new _Rectangle2.default(this.x - this.width, this.y - this.height, this.width, this.height);
};
return Ellipse;
}();
exports.default = Ellipse;
//# sourceMappingURL=Ellipse.js.map
/***/ }),
/* 443 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
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"); } }
/**
* @class
* @memberof PIXI
*/
var Polygon = function () {
/**
* @param {PIXI.Point[]|number[]} points - This can be an array of Points
* that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], or
* the arguments passed can be all the points of the polygon e.g.
* `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the arguments passed can be flat
* x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are Numbers.
*/
function Polygon() {
for (var _len = arguments.length, points = Array(_len), _key = 0; _key < _len; _key++) {
points[_key] = arguments[_key];
}
_classCallCheck(this, Polygon);
if (Array.isArray(points[0])) {
points = points[0];
}
// if this is an array of points, convert it to a flat array of numbers
if (points[0] instanceof _Point2.default) {
var p = [];
for (var i = 0, il = points.length; i < il; i++) {
p.push(points[i].x, points[i].y);
}
points = p;
}
this.closed = true;
/**
* An array of the points of this polygon
*
* @member {number[]}
*/
this.points = points;
/**
* The type of the object, mainly used to avoid `instanceof` checks
*
* @member {number}
* @readOnly
* @default PIXI.SHAPES.POLY
* @see PIXI.SHAPES
*/
this.type = _const.SHAPES.POLY;
}
/**
* Creates a clone of this polygon
*
* @return {PIXI.Polygon} a copy of the polygon
*/
Polygon.prototype.clone = function clone() {
return new Polygon(this.points.slice());
};
/**
* Closes the polygon, adding points if necessary.
*
*/
Polygon.prototype.close = function close() {
var points = this.points;
// close the poly if the value is true!
if (points[0] !== points[points.length - 2] || points[1] !== points[points.length - 1]) {
points.push(points[0], points[1]);
}
};
/**
* Checks whether the x and y coordinates passed to this function are contained within this polygon
*
* @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 polygon
*/
Polygon.prototype.contains = function contains(x, y) {
var inside = false;
// use some raycasting to test hits
// https://github.com/substack/point-in-polygon/blob/master/index.js
var length = this.points.length / 2;
for (var i = 0, j = length - 1; i < length; j = i++) {
var xi = this.points[i * 2];
var yi = this.points[i * 2 + 1];
var xj = this.points[j * 2];
var yj = this.points[j * 2 + 1];
var intersect = yi > y !== yj > y && x < (xj - xi) * ((y - yi) / (yj - yi)) + xi;
if (intersect) {
inside = !inside;
}
}
return inside;
};
return Polygon;
}();
exports.default = Polygon;
//# sourceMappingURL=Polygon.js.map
/***/ }),
/* 444 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _const = __webpack_require__(3);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* The Rounded Rectangle object is an area that has nice rounded corners, as indicated by its
* top-left corner point (x, y) and by its width and its height and its radius.
*
* @class
* @memberof PIXI
*/
var RoundedRectangle = function () {
/**
* @param {number} [x=0] - The X coordinate of the upper-left corner of the rounded rectangle
* @param {number} [y=0] - The Y coordinate of the upper-left corner of the rounded rectangle
* @param {number} [width=0] - The overall width of this rounded rectangle
* @param {number} [height=0] - The overall height of this rounded rectangle
* @param {number} [radius=20] - Controls the radius of the rounded corners
*/
function RoundedRectangle() {
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;
var radius = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 20;
_classCallCheck(this, RoundedRectangle);
/**
* @member {number}
* @default 0
*/
this.x = x;
/**
* @member {number}
* @default 0
*/
this.y = y;
/**
* @member {number}
* @default 0
*/
this.width = width;
/**
* @member {number}
* @default 0
*/
this.height = height;
/**
* @member {number}
* @default 20
*/
this.radius = radius;
/**
* The type of the object, mainly used to avoid `instanceof` checks
*
* @member {number}
* @readonly
* @default PIXI.SHAPES.RREC
* @see PIXI.SHAPES
*/
this.type = _const.SHAPES.RREC;
}
/**
* Creates a clone of this Rounded Rectangle
*
* @return {PIXI.RoundedRectangle} a copy of the rounded rectangle
*/
RoundedRectangle.prototype.clone = function clone() {
return new RoundedRectangle(this.x, this.y, this.width, this.height, this.radius);
};
/**
* Checks whether the x and y coordinates given are contained within this Rounded 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 Rounded Rectangle
*/
RoundedRectangle.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) {
if (y >= this.y + this.radius && y <= this.y + this.height - this.radius || x >= this.x + this.radius && x <= this.x + this.width - this.radius) {
return true;
}
var dx = x - (this.x + this.radius);
var dy = y - (this.y + this.radius);
var radius2 = this.radius * this.radius;
if (dx * dx + dy * dy <= radius2) {
return true;
}
dx = x - (this.x + this.width - this.radius);
if (dx * dx + dy * dy <= radius2) {
return true;
}
dy = y - (this.y + this.height - this.radius);
if (dx * dx + dy * dy <= radius2) {
return true;
}
dx = x - (this.x + this.radius);
if (dx * dx + dy * dy <= radius2) {
return true;
}
}
}
return false;
};
return RoundedRectangle;
}();
exports.default = RoundedRectangle;
//# sourceMappingURL=RoundedRectangle.js.map
/***/ }),
/* 445 */
/***/ (function(module, exports) {
/**
* Helper class to create a webGL Context
*
* @class
* @memberof PIXI.glCore
* @param canvas {HTMLCanvasElement} the canvas element that we will get the context from
* @param options {Object} An options object that gets passed in to the canvas element containing the context attributes,
* see https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement/getContext for the options available
* @return {WebGLRenderingContext} the WebGL context
*/
var createContext = function(canvas, options)
{
var gl = canvas.getContext('webgl', options) ||
canvas.getContext('experimental-webgl', options);
if (!gl)
{
// fail, not able to get a context
throw new Error('This browser does not support webGL. Try using the canvas renderer');
}
return gl;
};
module.exports = createContext;
/***/ }),
/* 446 */
/***/ (function(module, exports) {
var EMPTY_ARRAY_BUFFER = new ArrayBuffer(0);
/**
* Helper class to create a webGL buffer
*
* @class
* @memberof PIXI.glCore
* @param gl {WebGLRenderingContext} The current WebGL rendering context
* @param type {gl.ARRAY_BUFFER | gl.ELEMENT_ARRAY_BUFFER} @mat
* @param data {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} an array of data
* @param drawType {gl.STATIC_DRAW|gl.DYNAMIC_DRAW|gl.STREAM_DRAW}
*/
var Buffer = function(gl, type, data, drawType)
{
/**
* The current WebGL rendering context
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
/**
* The WebGL buffer, created upon instantiation
*
* @member {WebGLBuffer}
*/
this.buffer = gl.createBuffer();
/**
* The type of the buffer
*
* @member {gl.ARRAY_BUFFER|gl.ELEMENT_ARRAY_BUFFER}
*/
this.type = type || gl.ARRAY_BUFFER;
/**
* The draw type of the buffer
*
* @member {gl.STATIC_DRAW|gl.DYNAMIC_DRAW|gl.STREAM_DRAW}
*/
this.drawType = drawType || gl.STATIC_DRAW;
/**
* The data in the buffer, as a typed array
*
* @member {ArrayBuffer| SharedArrayBuffer|ArrayBufferView}
*/
this.data = EMPTY_ARRAY_BUFFER;
if(data)
{
this.upload(data);
}
this._updateID = 0;
};
/**
* Uploads the buffer to the GPU
* @param data {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} an array of data to upload
* @param offset {Number} if only a subset of the data should be uploaded, this is the amount of data to subtract
* @param dontBind {Boolean} whether to bind the buffer before uploading it
*/
Buffer.prototype.upload = function(data, offset, dontBind)
{
// todo - needed?
if(!dontBind) this.bind();
var gl = this.gl;
data = data || this.data;
offset = offset || 0;
if(this.data.byteLength >= data.byteLength)
{
gl.bufferSubData(this.type, offset, data);
}
else
{
gl.bufferData(this.type, data, this.drawType);
}
this.data = data;
};
/**
* Binds the buffer
*
*/
Buffer.prototype.bind = function()
{
var gl = this.gl;
gl.bindBuffer(this.type, this.buffer);
};
Buffer.createVertexBuffer = function(gl, data, drawType)
{
return new Buffer(gl, gl.ARRAY_BUFFER, data, drawType);
};
Buffer.createIndexBuffer = function(gl, data, drawType)
{
return new Buffer(gl, gl.ELEMENT_ARRAY_BUFFER, data, drawType);
};
Buffer.create = function(gl, type, data, drawType)
{
return new Buffer(gl, type, data, drawType);
};
/**
* Destroys the buffer
*
*/
Buffer.prototype.destroy = function(){
this.gl.deleteBuffer(this.buffer);
};
module.exports = Buffer;
/***/ }),
/* 447 */
/***/ (function(module, exports, __webpack_require__) {
var Texture = __webpack_require__(173);
/**
* Helper class to create a webGL Framebuffer
*
* @class
* @memberof PIXI.glCore
* @param gl {WebGLRenderingContext} The current WebGL rendering context
* @param width {Number} the width of the drawing area of the frame buffer
* @param height {Number} the height of the drawing area of the frame buffer
*/
var Framebuffer = function(gl, width, height)
{
/**
* The current WebGL rendering context
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
/**
* The frame buffer
*
* @member {WebGLFramebuffer}
*/
this.framebuffer = gl.createFramebuffer();
/**
* The stencil buffer
*
* @member {WebGLRenderbuffer}
*/
this.stencil = null;
/**
* The stencil buffer
*
* @member {PIXI.glCore.GLTexture}
*/
this.texture = null;
/**
* The width of the drawing area of the buffer
*
* @member {Number}
*/
this.width = width || 100;
/**
* The height of the drawing area of the buffer
*
* @member {Number}
*/
this.height = height || 100;
};
/**
* Adds a texture to the frame buffer
* @param texture {PIXI.glCore.GLTexture}
*/
Framebuffer.prototype.enableTexture = function(texture)
{
var gl = this.gl;
this.texture = texture || new Texture(gl);
this.texture.bind();
//gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
this.bind();
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture.texture, 0);
};
/**
* Initialises the stencil buffer
*/
Framebuffer.prototype.enableStencil = function()
{
if(this.stencil)return;
var gl = this.gl;
this.stencil = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, this.stencil);
// TODO.. this is depth AND stencil?
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this.stencil);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, this.width , this.height );
};
/**
* Erases the drawing area and fills it with a colour
* @param r {Number} the red value of the clearing colour
* @param g {Number} the green value of the clearing colour
* @param b {Number} the blue value of the clearing colour
* @param a {Number} the alpha value of the clearing colour
*/
Framebuffer.prototype.clear = function( r, g, b, a )
{
this.bind();
var gl = this.gl;
gl.clearColor(r, g, b, a);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
};
/**
* Binds the frame buffer to the WebGL context
*/
Framebuffer.prototype.bind = function()
{
var gl = this.gl;
gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer );
};
/**
* Unbinds the frame buffer to the WebGL context
*/
Framebuffer.prototype.unbind = function()
{
var gl = this.gl;
gl.bindFramebuffer(gl.FRAMEBUFFER, null );
};
/**
* Resizes the drawing area of the buffer to the given width and height
* @param width {Number} the new width
* @param height {Number} the new height
*/
Framebuffer.prototype.resize = function(width, height)
{
var gl = this.gl;
this.width = width;
this.height = height;
if ( this.texture )
{
this.texture.uploadData(null, width, height);
}
if ( this.stencil )
{
// update the stencil buffer width and height
gl.bindRenderbuffer(gl.RENDERBUFFER, this.stencil);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
}
};
/**
* Destroys this buffer
*/
Framebuffer.prototype.destroy = function()
{
var gl = this.gl;
//TODO
if(this.texture)
{
this.texture.destroy();
}
gl.deleteFramebuffer(this.framebuffer);
this.gl = null;
this.stencil = null;
this.texture = null;
};
/**
* Creates a frame buffer with a texture containing the given data
* @static
* @param gl {WebGLRenderingContext} The current WebGL rendering context
* @param width {Number} the width of the drawing area of the frame buffer
* @param height {Number} the height of the drawing area of the frame buffer
* @param data {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} an array of data
*/
Framebuffer.createRGBA = function(gl, width, height, data)
{
var texture = Texture.fromData(gl, null, width, height);
texture.enableNearestScaling();
texture.enableWrapClamp();
//now create the framebuffer object and attach the texture to it.
var fbo = new Framebuffer(gl, width, height);
fbo.enableTexture(texture);
//fbo.enableStencil(); // get this back on soon!
//fbo.enableStencil(); // get this back on soon!
fbo.unbind();
return fbo;
};
/**
* Creates a frame buffer with a texture containing the given data
* @static
* @param gl {WebGLRenderingContext} The current WebGL rendering context
* @param width {Number} the width of the drawing area of the frame buffer
* @param height {Number} the height of the drawing area of the frame buffer
* @param data {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} an array of data
*/
Framebuffer.createFloat32 = function(gl, width, height, data)
{
// create a new texture..
var texture = new Texture.fromData(gl, data, width, height);
texture.enableNearestScaling();
texture.enableWrapClamp();
//now create the framebuffer object and attach the texture to it.
var fbo = new Framebuffer(gl, width, height);
fbo.enableTexture(texture);
fbo.unbind();
return fbo;
};
module.exports = Framebuffer;
/***/ }),
/* 448 */
/***/ (function(module, exports, __webpack_require__) {
var compileProgram = __webpack_require__(174),
extractAttributes = __webpack_require__(175),
extractUniforms = __webpack_require__(177),
setPrecision = __webpack_require__(179),
generateUniformAccessObject = __webpack_require__(180);
/**
* Helper class to create a webGL Shader
*
* @class
* @memberof PIXI.glCore
* @param gl {WebGLRenderingContext}
* @param vertexSrc {string|string[]} The vertex shader source as an array of strings.
* @param fragmentSrc {string|string[]} The fragment shader source as an array of strings.
* @param precision {string} The float precision of the shader. Options are 'lowp', 'mediump' or 'highp'.
* @param attributeLocations {object} A key value pair showing which location eact attribute should sit eg {position:0, uvs:1}
*/
var Shader = function(gl, vertexSrc, fragmentSrc, precision, attributeLocations)
{
/**
* The current WebGL rendering context
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
if(precision)
{
vertexSrc = setPrecision(vertexSrc, precision);
fragmentSrc = setPrecision(fragmentSrc, precision);
}
/**
* The shader program
*
* @member {WebGLProgram}
*/
// First compile the program..
this.program = compileProgram(gl, vertexSrc, fragmentSrc, attributeLocations);
/**
* The attributes of the shader as an object containing the following properties
* {
* type,
* size,
* location,
* pointer
* }
* @member {Object}
*/
// next extract the attributes
this.attributes = extractAttributes(gl, this.program);
this.uniformData = extractUniforms(gl, this.program);
/**
* The uniforms of the shader as an object containing the following properties
* {
* gl,
* data
* }
* @member {Object}
*/
this.uniforms = generateUniformAccessObject( gl, this.uniformData );
};
/**
* Uses this shader
*
* @return {PIXI.glCore.GLShader} Returns itself.
*/
Shader.prototype.bind = function()
{
this.gl.useProgram(this.program);
return this;
};
/**
* Destroys this shader
* TODO
*/
Shader.prototype.destroy = function()
{
this.attributes = null;
this.uniformData = null;
this.uniforms = null;
var gl = this.gl;
gl.deleteProgram(this.program);
};
module.exports = Shader;
/***/ }),
/* 449 */
/***/ (function(module, exports, __webpack_require__) {
// state object//
var setVertexAttribArrays = __webpack_require__( 172 );
/**
* Helper class to work with WebGL VertexArrayObjects (vaos)
* Only works if WebGL extensions are enabled (they usually are)
*
* @class
* @memberof PIXI.glCore
* @param gl {WebGLRenderingContext} The current WebGL rendering context
*/
function VertexArrayObject(gl, state)
{
this.nativeVaoExtension = null;
if(!VertexArrayObject.FORCE_NATIVE)
{
this.nativeVaoExtension = gl.getExtension('OES_vertex_array_object') ||
gl.getExtension('MOZ_OES_vertex_array_object') ||
gl.getExtension('WEBKIT_OES_vertex_array_object');
}
this.nativeState = state;
if(this.nativeVaoExtension)
{
this.nativeVao = this.nativeVaoExtension.createVertexArrayOES();
var maxAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
// VAO - overwrite the state..
this.nativeState = {
tempAttribState: new Array(maxAttribs),
attribState: new Array(maxAttribs)
};
}
/**
* The current WebGL rendering context
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
/**
* An array of attributes
*
* @member {Array}
*/
this.attributes = [];
/**
* @member {PIXI.glCore.GLBuffer}
*/
this.indexBuffer = null;
/**
* A boolean flag
*
* @member {Boolean}
*/
this.dirty = false;
}
VertexArrayObject.prototype.constructor = VertexArrayObject;
module.exports = VertexArrayObject;
/**
* Some devices behave a bit funny when using the newer extensions (im looking at you ipad 2!)
* If you find on older devices that things have gone a bit weird then set this to true.
*/
/**
* Lets the VAO know if you should use the WebGL extension or the native methods.
* Some devices behave a bit funny when using the newer extensions (im looking at you ipad 2!)
* If you find on older devices that things have gone a bit weird then set this to true.
* @static
* @property {Boolean} FORCE_NATIVE
*/
VertexArrayObject.FORCE_NATIVE = false;
/**
* Binds the buffer
*/
VertexArrayObject.prototype.bind = function()
{
if(this.nativeVao)
{
this.nativeVaoExtension.bindVertexArrayOES(this.nativeVao);
if(this.dirty)
{
this.dirty = false;
this.activate();
return this;
}
if (this.indexBuffer)
{
this.indexBuffer.bind();
}
}
else
{
this.activate();
}
return this;
};
/**
* Unbinds the buffer
*/
VertexArrayObject.prototype.unbind = function()
{
if(this.nativeVao)
{
this.nativeVaoExtension.bindVertexArrayOES(null);
}
return this;
};
/**
* Uses this vao
*/
VertexArrayObject.prototype.activate = function()
{
var gl = this.gl;
var lastBuffer = null;
for (var i = 0; i < this.attributes.length; i++)
{
var attrib = this.attributes[i];
if(lastBuffer !== attrib.buffer)
{
attrib.buffer.bind();
lastBuffer = attrib.buffer;
}
gl.vertexAttribPointer(attrib.attribute.location,
attrib.attribute.size,
attrib.type || gl.FLOAT,
attrib.normalized || false,
attrib.stride || 0,
attrib.start || 0);
}
setVertexAttribArrays(gl, this.attributes, this.nativeState);
if(this.indexBuffer)
{
this.indexBuffer.bind();
}
return this;
};
/**
*
* @param buffer {PIXI.gl.GLBuffer}
* @param attribute {*}
* @param type {String}
* @param normalized {Boolean}
* @param stride {Number}
* @param start {Number}
*/
VertexArrayObject.prototype.addAttribute = function(buffer, attribute, type, normalized, stride, start)
{
this.attributes.push({
buffer: buffer,
attribute: attribute,
location: attribute.location,
type: type || this.gl.FLOAT,
normalized: normalized || false,
stride: stride || 0,
start: start || 0
});
this.dirty = true;
return this;
};
/**
*
* @param buffer {PIXI.gl.GLBuffer}
*/
VertexArrayObject.prototype.addIndex = function(buffer/*, options*/)
{
this.indexBuffer = buffer;
this.dirty = true;
return this;
};
/**
* Unbinds this vao and disables it
*/
VertexArrayObject.prototype.clear = function()
{
// var gl = this.gl;
// TODO - should this function unbind after clear?
// for now, no but lets see what happens in the real world!
if(this.nativeVao)
{
this.nativeVaoExtension.bindVertexArrayOES(this.nativeVao);
}
this.attributes.length = 0;
this.indexBuffer = null;
return this;
};
/**
* @param type {Number}
* @param size {Number}
* @param start {Number}
*/
VertexArrayObject.prototype.draw = function(type, size, start)
{
var gl = this.gl;
if(this.indexBuffer)
{
gl.drawElements(type, size || this.indexBuffer.data.length, gl.UNSIGNED_SHORT, (start || 0) * 2 );
}
else
{
// TODO need a better way to calculate size..
gl.drawArrays(type, start, size || this.getSize());
}
return this;
};
/**
* Destroy this vao
*/
VertexArrayObject.prototype.destroy = function()
{
// lose references
this.gl = null;
this.indexBuffer = null;
this.attributes = null;
this.nativeState = null;
if(this.nativeVao)
{
this.nativeVaoExtension.deleteVertexArrayOES(this.nativeVao);
}
this.nativeVaoExtension = null;
this.nativeVao = null;
};
VertexArrayObject.prototype.getSize = function()
{
var attrib = this.attributes[0];
return attrib.buffer.data.length / (( attrib.stride/4 ) || attrib.attribute.size);
};
/***/ }),
/* 450 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
compileProgram: __webpack_require__(174),
defaultValue: __webpack_require__(178),
extractAttributes: __webpack_require__(175),
extractUniforms: __webpack_require__(177),
generateUniformAccessObject: __webpack_require__(180),
setPrecision: __webpack_require__(179),
mapSize: __webpack_require__(176),
mapType: __webpack_require__(120)
};
/***/ }),
/* 451 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = maxRecommendedTextures;
var _ismobilejs = __webpack_require__(122);
var _ismobilejs2 = _interopRequireDefault(_ismobilejs);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function maxRecommendedTextures(max) {
if (_ismobilejs2.default.tablet || _ismobilejs2.default.phone) {
// check if the res is iphone 6 or higher..
return 4;
}
// desktop should be ok
return max;
}
//# sourceMappingURL=maxRecommendedTextures.js.map
/***/ }),
/* 452 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = canUploadSameBuffer;
function canUploadSameBuffer() {
// Uploading the same buffer multiple times in a single frame can cause perf issues.
// Apparent on IOS so only check for that at the moment
// this check may become more complex if this issue pops up elsewhere.
var ios = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
return !ios;
}
//# sourceMappingURL=canUploadSameBuffer.js.map
/***/ }),
/* 453 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
/**
* Mixins functionality to make an object have "plugins".
*
* @example
* function MyObject() {}
*
* pluginTarget.mixin(MyObject);
*
* @mixin
* @memberof PIXI.utils
* @param {object} obj - The object to mix into.
*/
function pluginTarget(obj) {
obj.__plugins = {};
/**
* Adds a plugin to an object
*
* @param {string} pluginName - The events that should be listed.
* @param {Function} ctor - The constructor function for the plugin.
*/
obj.registerPlugin = function registerPlugin(pluginName, ctor) {
obj.__plugins[pluginName] = ctor;
};
/**
* Instantiates all the plugins of this object
*
*/
obj.prototype.initPlugins = function initPlugins() {
this.plugins = this.plugins || {};
for (var o in obj.__plugins) {
this.plugins[o] = new obj.__plugins[o](this);
}
};
/**
* Removes all the plugins of this object
*
*/
obj.prototype.destroyPlugins = function destroyPlugins() {
for (var o in this.plugins) {
this.plugins[o].destroy();
this.plugins[o] = null;
}
this.plugins = null;
};
}
exports.default = {
/**
* Mixes in the properties of the pluginTarget into another object
*
* @param {object} obj - The obj to mix into
*/
mixin: function mixin(obj) {
pluginTarget(obj);
}
};
//# sourceMappingURL=pluginTarget.js.map
/***/ }),
/* 454 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.mixin = mixin;
exports.delayMixin = delayMixin;
exports.performMixins = performMixins;
/**
* Mixes all enumerable properties and methods from a source object to a target object.
*
* @memberof PIXI.utils.mixins
* @function mixin
* @param {object} target The prototype or instance that properties and methods should be added to.
* @param {object} source The source of properties and methods to mix in.
*/
function mixin(target, source) {
if (!target || !source) return;
// in ES8/ES2017, this would be really easy:
// Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
// get all the enumerable property keys
var keys = Object.keys(source);
// loop through properties
for (var i = 0; i < keys.length; ++i) {
var propertyName = keys[i];
// Set the property using the property descriptor - this works for accessors and normal value properties
Object.defineProperty(target, propertyName, Object.getOwnPropertyDescriptor(source, propertyName));
}
}
var mixins = [];
/**
* Queues a mixin to be handled towards the end of the initialization of PIXI, so that deprecation
* can take effect.
*
* @memberof PIXI.utils.mixins
* @function delayMixin
* @private
* @param {object} target The prototype or instance that properties and methods should be added to.
* @param {object} source The source of properties and methods to mix in.
*/
function delayMixin(target, source) {
mixins.push(target, source);
}
/**
* Handles all mixins queued via delayMixin().
*
* @memberof PIXI.utils.mixins
* @function performMixins
* @private
*/
function performMixins() {
for (var i = 0; i < mixins.length; i += 2) {
mixin(mixins[i], mixins[i + 1]);
}
mixins.length = 0;
}
//# sourceMappingURL=mixin.js.map
/***/ }),
/* 455 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Remove a range of items from an array
*
* @function removeItems
* @param {Array<*>} arr The target array
* @param {number} startIdx The index to begin removing from (inclusive)
* @param {number} removeCount How many items to remove
*/
module.exports = function removeItems (arr, startIdx, removeCount) {
var i, length = arr.length
if (startIdx >= length || removeCount === 0) {
return
}
removeCount = (startIdx + removeCount > length ? length - startIdx : removeCount)
var len = length - removeCount
for (i = startIdx; i < len; ++i) {
arr[i] = arr[i + removeCount]
}
arr.length = len
}
/***/ }),
/* 456 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = mapPremultipliedBlendModes;
var _const = __webpack_require__(3);
/**
* Corrects PixiJS blend, takes premultiplied alpha into account
*
* @memberof PIXI
* @function mapPremultipliedBlendModes
* @private
* @param {Array<number[]>} [array] - The array to output into.
* @return {Array<number[]>} Mapped modes.
*/
function mapPremultipliedBlendModes() {
var pm = [];
var npm = [];
for (var i = 0; i < 32; i++) {
pm[i] = i;
npm[i] = i;
}
pm[_const.BLEND_MODES.NORMAL_NPM] = _const.BLEND_MODES.NORMAL;
pm[_const.BLEND_MODES.ADD_NPM] = _const.BLEND_MODES.ADD;
pm[_const.BLEND_MODES.SCREEN_NPM] = _const.BLEND_MODES.SCREEN;
npm[_const.BLEND_MODES.NORMAL] = _const.BLEND_MODES.NORMAL_NPM;
npm[_const.BLEND_MODES.ADD] = _const.BLEND_MODES.ADD_NPM;
npm[_const.BLEND_MODES.SCREEN] = _const.BLEND_MODES.SCREEN_NPM;
var array = [];
array.push(npm);
array.push(pm);
return array;
}
//# sourceMappingURL=mapPremultipliedBlendModes.js.map
/***/ }),
/* 457 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */
;(function(root) {
/** Detect free variables */
var freeExports = typeof exports == 'object' && exports &&
!exports.nodeType && exports;
var freeModule = typeof module == 'object' && module &&
!module.nodeType && module;
var freeGlobal = typeof global == 'object' && global;
if (
freeGlobal.global === freeGlobal ||
freeGlobal.window === freeGlobal ||
freeGlobal.self === freeGlobal
) {
root = freeGlobal;
}
/**
* The `punycode` object.
* @name punycode
* @type Object
*/
var punycode,
/** Highest positive signed 32-bit float value */
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
/** Bootstring parameters */
base = 36,
tMin = 1,
tMax = 26,
skew = 38,
damp = 700,
initialBias = 72,
initialN = 128, // 0x80
delimiter = '-', // '\x2D'
/** Regular expressions */
regexPunycode = /^xn--/,
regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
/** Error messages */
errors = {
'overflow': 'Overflow: input needs wider integers to process',
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
'invalid-input': 'Invalid input'
},
/** Convenience shortcuts */
baseMinusTMin = base - tMin,
floor = Math.floor,
stringFromCharCode = String.fromCharCode,
/** Temporary variable */
key;
/*--------------------------------------------------------------------------*/
/**
* A generic error utility function.
* @private
* @param {String} type The error type.
* @returns {Error} Throws a `RangeError` with the applicable error message.
*/
function error(type) {
throw new RangeError(errors[type]);
}
/**
* A generic `Array#map` utility function.
* @private
* @param {Array} array The array to iterate over.
* @param {Function} callback The function that gets called for every array
* item.
* @returns {Array} A new array of values returned by the callback function.
*/
function map(array, fn) {
var length = array.length;
var result = [];
while (length--) {
result[length] = fn(array[length]);
}
return result;
}
/**
* A simple `Array#map`-like wrapper to work with domain name strings or email
* addresses.
* @private
* @param {String} domain The domain name or email address.
* @param {Function} callback The function that gets called for every
* character.
* @returns {Array} A new string of characters returned by the callback
* function.
*/
function mapDomain(string, fn) {
var parts = string.split('@');
var result = '';
if (parts.length > 1) {
// In email addresses, only the domain name should be punycoded. Leave
// the local part (i.e. everything up to `@`) intact.
result = parts[0] + '@';
string = parts[1];
}
// Avoid `split(regex)` for IE8 compatibility. See #17.
string = string.replace(regexSeparators, '\x2E');
var labels = string.split('.');
var encoded = map(labels, fn).join('.');
return result + encoded;
}
/**
* Creates an array containing the numeric code points of each Unicode
* character in the string. While JavaScript uses UCS-2 internally,
* this function will convert a pair of surrogate halves (each of which
* UCS-2 exposes as separate characters) into a single code point,
* matching UTF-16.
* @see `punycode.ucs2.encode`
* @see <https://mathiasbynens.be/notes/javascript-encoding>
* @memberOf punycode.ucs2
* @name decode
* @param {String} string The Unicode input string (UCS-2).
* @returns {Array} The new array of code points.
*/
function ucs2decode(string) {
var output = [],
counter = 0,
length = string.length,
value,
extra;
while (counter < length) {
value = string.charCodeAt(counter++);
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
// high surrogate, and there is a next character
extra = string.charCodeAt(counter++);
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
} else {
// unmatched surrogate; only append this code unit, in case the next
// code unit is the high surrogate of a surrogate pair
output.push(value);
counter--;
}
} else {
output.push(value);
}
}
return output;
}
/**
* Creates a string based on an array of numeric code points.
* @see `punycode.ucs2.decode`
* @memberOf punycode.ucs2
* @name encode
* @param {Array} codePoints The array of numeric code points.
* @returns {String} The new Unicode string (UCS-2).
*/
function ucs2encode(array) {
return map(array, function(value) {
var output = '';
if (value > 0xFFFF) {
value -= 0x10000;
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
value = 0xDC00 | value & 0x3FF;
}
output += stringFromCharCode(value);
return output;
}).join('');
}
/**
* Converts a basic code point into a digit/integer.
* @see `digitToBasic()`
* @private
* @param {Number} codePoint The basic numeric code point value.
* @returns {Number} The numeric value of a basic code point (for use in
* representing integers) in the range `0` to `base - 1`, or `base` if
* the code point does not represent a value.
*/
function basicToDigit(codePoint) {
if (codePoint - 48 < 10) {
return codePoint - 22;
}
if (codePoint - 65 < 26) {
return codePoint - 65;
}
if (codePoint - 97 < 26) {
return codePoint - 97;
}
return base;
}
/**
* Converts a digit/integer into a basic code point.
* @see `basicToDigit()`
* @private
* @param {Number} digit The numeric value of a basic code point.
* @returns {Number} The basic code point whose value (when used for
* representing integers) is `digit`, which needs to be in the range
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
* used; else, the lowercase form is used. The behavior is undefined
* if `flag` is non-zero and `digit` has no uppercase form.
*/
function digitToBasic(digit, flag) {
// 0..25 map to ASCII a..z or A..Z
// 26..35 map to ASCII 0..9
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
}
/**
* Bias adaptation function as per section 3.4 of RFC 3492.
* https://tools.ietf.org/html/rfc3492#section-3.4
* @private
*/
function adapt(delta, numPoints, firstTime) {
var k = 0;
delta = firstTime ? floor(delta / damp) : delta >> 1;
delta += floor(delta / numPoints);
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
delta = floor(delta / baseMinusTMin);
}
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
}
/**
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
* symbols.
* @memberOf punycode
* @param {String} input The Punycode string of ASCII-only symbols.
* @returns {String} The resulting string of Unicode symbols.
*/
function decode(input) {
// Don't use UCS-2
var output = [],
inputLength = input.length,
out,
i = 0,
n = initialN,
bias = initialBias,
basic,
j,
index,
oldi,
w,
k,
digit,
t,
/** Cached calculation results */
baseMinusT;
// Handle the basic code points: let `basic` be the number of input code
// points before the last delimiter, or `0` if there is none, then copy
// the first basic code points to the output.
basic = input.lastIndexOf(delimiter);
if (basic < 0) {
basic = 0;
}
for (j = 0; j < basic; ++j) {
// if it's not a basic code point
if (input.charCodeAt(j) >= 0x80) {
error('not-basic');
}
output.push(input.charCodeAt(j));
}
// Main decoding loop: start just after the last delimiter if any basic code
// points were copied; start at the beginning otherwise.
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
// `index` is the index of the next character to be consumed.
// Decode a generalized variable-length integer into `delta`,
// which gets added to `i`. The overflow checking is easier
// if we increase `i` as we go, then subtract off its starting
// value at the end to obtain `delta`.
for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
if (index >= inputLength) {
error('invalid-input');
}
digit = basicToDigit(input.charCodeAt(index++));
if (digit >= base || digit > floor((maxInt - i) / w)) {
error('overflow');
}
i += digit * w;
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
if (digit < t) {
break;
}
baseMinusT = base - t;
if (w > floor(maxInt / baseMinusT)) {
error('overflow');
}
w *= baseMinusT;
}
out = output.length + 1;
bias = adapt(i - oldi, out, oldi == 0);
// `i` was supposed to wrap around from `out` to `0`,
// incrementing `n` each time, so we'll fix that now:
if (floor(i / out) > maxInt - n) {
error('overflow');
}
n += floor(i / out);
i %= out;
// Insert `n` at position `i` of the output
output.splice(i++, 0, n);
}
return ucs2encode(output);
}
/**
* Converts a string of Unicode symbols (e.g. a domain name label) to a
* Punycode string of ASCII-only symbols.
* @memberOf punycode
* @param {String} input The string of Unicode symbols.
* @returns {String} The resulting Punycode string of ASCII-only symbols.
*/
function encode(input) {
var n,
delta,
handledCPCount,
basicLength,
bias,
j,
m,
q,
k,
t,
currentValue,
output = [],
/** `inputLength` will hold the number of code points in `input`. */
inputLength,
/** Cached calculation results */
handledCPCountPlusOne,
baseMinusT,
qMinusT;
// Convert the input in UCS-2 to Unicode
input = ucs2decode(input);
// Cache the length
inputLength = input.length;
// Initialize the state
n = initialN;
delta = 0;
bias = initialBias;
// Handle the basic code points
for (j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue < 0x80) {
output.push(stringFromCharCode(currentValue));
}
}
handledCPCount = basicLength = output.length;
// `handledCPCount` is the number of code points that have been handled;
// `basicLength` is the number of basic code points.
// Finish the basic string - if it is not empty - with a delimiter
if (basicLength) {
output.push(delimiter);
}
// Main encoding loop:
while (handledCPCount < inputLength) {
// All non-basic code points < n have been handled already. Find the next
// larger one:
for (m = maxInt, j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue >= n && currentValue < m) {
m = currentValue;
}
}
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
// but guard against overflow
handledCPCountPlusOne = handledCPCount + 1;
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
error('overflow');
}
delta += (m - n) * handledCPCountPlusOne;
n = m;
for (j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue < n && ++delta > maxInt) {
error('overflow');
}
if (currentValue == n) {
// Represent delta as a generalized variable-length integer
for (q = delta, k = base; /* no condition */; k += base) {
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
if (q < t) {
break;
}
qMinusT = q - t;
baseMinusT = base - t;
output.push(
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
);
q = floor(qMinusT / baseMinusT);
}
output.push(stringFromCharCode(digitToBasic(q, 0)));
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
delta = 0;
++handledCPCount;
}
}
++delta;
++n;
}
return output.join('');
}
/**
* Converts a Punycode string representing a domain name or an email address
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
* it doesn't matter if you call it on a string that has already been
* converted to Unicode.
* @memberOf punycode
* @param {String} input The Punycoded domain name or email address to
* convert to Unicode.
* @returns {String} The Unicode representation of the given Punycode
* string.
*/
function toUnicode(input) {
return mapDomain(input, function(string) {
return regexPunycode.test(string)
? decode(string.slice(4).toLowerCase())
: string;
});
}
/**
* Converts a Unicode string representing a domain name or an email address to
* Punycode. Only the non-ASCII parts of the domain name will be converted,
* i.e. it doesn't matter if you call it with a domain that's already in
* ASCII.
* @memberOf punycode
* @param {String} input The domain name or email address to convert, as a
* Unicode string.
* @returns {String} The Punycode representation of the given domain name or
* email address.
*/
function toASCII(input) {
return mapDomain(input, function(string) {
return regexNonASCII.test(string)
? 'xn--' + encode(string)
: string;
});
}
/*--------------------------------------------------------------------------*/
/** Define the public API */
punycode = {
/**
* A string representing the current Punycode.js version number.
* @memberOf punycode
* @type String
*/
'version': '1.4.1',
/**
* An object of methods to convert from JavaScript's internal character
* representation (UCS-2) to Unicode code points, and back.
* @see <https://mathiasbynens.be/notes/javascript-encoding>
* @memberOf punycode
* @type Object
*/
'ucs2': {
'decode': ucs2decode,
'encode': ucs2encode
},
'decode': decode,
'encode': encode,
'toASCII': toASCII,
'toUnicode': toUnicode
};
/** Expose `punycode` */
// Some AMD build optimizers, like r.js, check for specific condition patterns
// like the following:
if (
true
) {
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
return punycode;
}).call(exports, __webpack_require__, exports, module),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else if (freeExports && freeModule) {
if (module.exports == freeExports) {
// in Node.js, io.js, or RingoJS v0.8.0+
freeModule.exports = punycode;
} else {
// in Narwhal or RingoJS v0.7.0-
for (key in punycode) {
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
}
}
} else {
// in Rhino or a web browser
root.punycode = punycode;
}
}(this));
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(458)(module), __webpack_require__(53)))
/***/ }),
/* 458 */
/***/ (function(module, exports) {
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
if(!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
get: function() {
return module.i;
}
});
module.webpackPolyfill = 1;
}
return module;
};
/***/ }),
/* 459 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = {
isString: function(arg) {
return typeof(arg) === 'string';
},
isObject: function(arg) {
return typeof(arg) === 'object' && arg !== null;
},
isNull: function(arg) {
return arg === null;
},
isNullOrUndefined: function(arg) {
return arg == null;
}
};
/***/ }),
/* 460 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.decode = exports.parse = __webpack_require__(461);
exports.encode = exports.stringify = __webpack_require__(462);
/***/ }),
/* 461 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 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.
// If obj.hasOwnProperty has been overridden, then calling
// obj.hasOwnProperty(prop) will break.
// See: https://github.com/joyent/node/issues/1707
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
module.exports = function(qs, sep, eq, options) {
sep = sep || '&';
eq = eq || '=';
var obj = {};
if (typeof qs !== 'string' || qs.length === 0) {
return obj;
}
var regexp = /\+/g;
qs = qs.split(sep);
var maxKeys = 1000;
if (options && typeof options.maxKeys === 'number') {
maxKeys = options.maxKeys;
}
var len = qs.length;
// maxKeys <= 0 means that we should not limit keys count
if (maxKeys > 0 && len > maxKeys) {
len = maxKeys;
}
for (var i = 0; i < len; ++i) {
var x = qs[i].replace(regexp, '%20'),
idx = x.indexOf(eq),
kstr, vstr, k, v;
if (idx >= 0) {
kstr = x.substr(0, idx);
vstr = x.substr(idx + 1);
} else {
kstr = x;
vstr = '';
}
k = decodeURIComponent(kstr);
v = decodeURIComponent(vstr);
if (!hasOwnProperty(obj, k)) {
obj[k] = v;
} else if (isArray(obj[k])) {
obj[k].push(v);
} else {
obj[k] = [obj[k], v];
}
}
return obj;
};
var isArray = Array.isArray || function (xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
};
/***/ }),
/* 462 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// 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.
var stringifyPrimitive = function(v) {
switch (typeof v) {
case 'string':
return v;
case 'boolean':
return v ? 'true' : 'false';
case 'number':
return isFinite(v) ? v : '';
default:
return '';
}
};
module.exports = function(obj, sep, eq, name) {
sep = sep || '&';
eq = eq || '=';
if (obj === null) {
obj = undefined;
}
if (typeof obj === 'object') {
return map(objectKeys(obj), function(k) {
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
if (isArray(obj[k])) {
return map(obj[k], function(v) {
return ks + encodeURIComponent(stringifyPrimitive(v));
}).join(sep);
} else {
return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
}
}).join(sep);
}
if (!name) return '';
return encodeURIComponent(stringifyPrimitive(name)) + eq +
encodeURIComponent(stringifyPrimitive(obj));
};
var isArray = Array.isArray || function (xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
};
function map (xs, f) {
if (xs.map) return xs.map(f);
var res = [];
for (var i = 0; i < xs.length; i++) {
res.push(f(xs[i], i));
}
return res;
}
var objectKeys = Object.keys || function (obj) {
var res = [];
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
}
return res;
};
/***/ }),
/* 463 */
/***/ (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 _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
var _const = __webpack_require__(3);
var _TickerListener = __webpack_require__(464);
var _TickerListener2 = _interopRequireDefault(_TickerListener);
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"); } }
/**
* A Ticker class that runs an update loop that other objects listen to.
* This class is composed around listeners
* meant for execution on the next requested animation frame.
* Animation frames are requested only when necessary,
* e.g. When the ticker is started and the emitter has listeners.
*
* @class
* @memberof PIXI.ticker
*/
var Ticker = function () {
/**
*
*/
function Ticker() {
var _this = this;
_classCallCheck(this, Ticker);
/**
* The first listener. All new listeners added are chained on this.
* @private
* @type {TickerListener}
*/
this._head = new _TickerListener2.default(null, null, Infinity);
/**
* Internal current frame request ID
* @private
*/
this._requestId = null;
/**
* Internal value managed by minFPS property setter and getter.
* This is the maximum allowed milliseconds between updates.
* @private
*/
this._maxElapsedMS = 100;
/**
* Whether or not this ticker should invoke the method
* {@link PIXI.ticker.Ticker#start} automatically
* when a listener is added.
*
* @member {boolean}
* @default false
*/
this.autoStart = false;
/**
* Scalar time value from last frame to this frame.
* This value is capped by setting {@link PIXI.ticker.Ticker#minFPS}
* and is scaled with {@link PIXI.ticker.Ticker#speed}.
* **Note:** The cap may be exceeded by scaling.
*
* @member {number}
* @default 1
*/
this.deltaTime = 1;
/**
* Time elapsed in milliseconds from last frame to this frame.
* Opposed to what the scalar {@link PIXI.ticker.Ticker#deltaTime}
* is based, this value is neither capped nor scaled.
* If the platform supports DOMHighResTimeStamp,
* this value will have a precision of 1 µs.
* Defaults to target frame time
*
* @member {number}
* @default 16.66
*/
this.elapsedMS = 1 / _settings2.default.TARGET_FPMS;
/**
* The last time {@link PIXI.ticker.Ticker#update} was invoked.
* This value is also reset internally outside of invoking
* update, but only when a new animation frame is requested.
* If the platform supports DOMHighResTimeStamp,
* this value will have a precision of 1 µs.
*
* @member {number}
* @default -1
*/
this.lastTime = -1;
/**
* Factor of current {@link PIXI.ticker.Ticker#deltaTime}.
* @example
* // Scales ticker.deltaTime to what would be
* // the equivalent of approximately 120 FPS
* ticker.speed = 2;
*
* @member {number}
* @default 1
*/
this.speed = 1;
/**
* Whether or not this ticker has been started.
* `true` if {@link PIXI.ticker.Ticker#start} has been called.
* `false` if {@link PIXI.ticker.Ticker#stop} has been called.
* While `false`, this value may change to `true` in the
* event of {@link PIXI.ticker.Ticker#autoStart} being `true`
* and a listener is added.
*
* @member {boolean}
* @default false
*/
this.started = false;
/**
* Internal tick method bound to ticker instance.
* This is because in early 2015, Function.bind
* is still 60% slower in high performance scenarios.
* Also separating frame requests from update method
* so listeners may be called at any time and with
* any animation API, just invoke ticker.update(time).
*
* @private
* @param {number} time - Time since last tick.
*/
this._tick = function (time) {
_this._requestId = null;
if (_this.started) {
// Invoke listeners now
_this.update(time);
// Listener side effects may have modified ticker state.
if (_this.started && _this._requestId === null && _this._head.next) {
_this._requestId = requestAnimationFrame(_this._tick);
}
}
};
}
/**
* Conditionally requests a new animation frame.
* If a frame has not already been requested, and if the internal
* emitter has listeners, a new frame is requested.
*
* @private
*/
Ticker.prototype._requestIfNeeded = function _requestIfNeeded() {
if (this._requestId === null && this._head.next) {
// ensure callbacks get correct delta
this.lastTime = performance.now();
this._requestId = requestAnimationFrame(this._tick);
}
};
/**
* Conditionally cancels a pending animation frame.
*
* @private
*/
Ticker.prototype._cancelIfNeeded = function _cancelIfNeeded() {
if (this._requestId !== null) {
cancelAnimationFrame(this._requestId);
this._requestId = null;
}
};
/**
* Conditionally requests a new animation frame.
* If the ticker has been started it checks if a frame has not already
* been requested, and if the internal emitter has listeners. If these
* conditions are met, a new frame is requested. If the ticker has not
* been started, but autoStart is `true`, then the ticker starts now,
* and continues with the previous conditions to request a new frame.
*
* @private
*/
Ticker.prototype._startIfPossible = function _startIfPossible() {
if (this.started) {
this._requestIfNeeded();
} else if (this.autoStart) {
this.start();
}
};
/**
* Register a handler for tick events. Calls continuously unless
* it is removed or the ticker is stopped.
*
* @param {Function} fn - The listener function to be added for updates
* @param {Function} [context] - The listener context
* @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting
* @returns {PIXI.ticker.Ticker} This instance of a ticker
*/
Ticker.prototype.add = function add(fn, context) {
var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _const.UPDATE_PRIORITY.NORMAL;
return this._addListener(new _TickerListener2.default(fn, context, priority));
};
/**
* Add a handler for the tick event which is only execute once.
*
* @param {Function} fn - The listener function to be added for one update
* @param {Function} [context] - The listener context
* @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting
* @returns {PIXI.ticker.Ticker} This instance of a ticker
*/
Ticker.prototype.addOnce = function addOnce(fn, context) {
var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _const.UPDATE_PRIORITY.NORMAL;
return this._addListener(new _TickerListener2.default(fn, context, priority, true));
};
/**
* Internally adds the event handler so that it can be sorted by priority.
* Priority allows certain handler (user, AnimatedSprite, Interaction) to be run
* before the rendering.
*
* @private
* @param {TickerListener} listener - Current listener being added.
* @returns {PIXI.ticker.Ticker} This instance of a ticker
*/
Ticker.prototype._addListener = function _addListener(listener) {
// For attaching to head
var current = this._head.next;
var previous = this._head;
// Add the first item
if (!current) {
listener.connect(previous);
} else {
// Go from highest to lowest priority
while (current) {
if (listener.priority > current.priority) {
listener.connect(previous);
break;
}
previous = current;
current = current.next;
}
// Not yet connected
if (!listener.previous) {
listener.connect(previous);
}
}
this._startIfPossible();
return this;
};
/**
* Removes any handlers matching the function and context parameters.
* If no handlers are left after removing, then it cancels the animation frame.
*
* @param {Function} fn - The listener function to be removed
* @param {Function} [context] - The listener context to be removed
* @returns {PIXI.ticker.Ticker} This instance of a ticker
*/
Ticker.prototype.remove = function remove(fn, context) {
var listener = this._head.next;
while (listener) {
// We found a match, lets remove it
// no break to delete all possible matches
// incase a listener was added 2+ times
if (listener.match(fn, context)) {
listener = listener.destroy();
} else {
listener = listener.next;
}
}
if (!this._head.next) {
this._cancelIfNeeded();
}
return this;
};
/**
* Starts the ticker. If the ticker has listeners
* a new animation frame is requested at this point.
*/
Ticker.prototype.start = function start() {
if (!this.started) {
this.started = true;
this._requestIfNeeded();
}
};
/**
* Stops the ticker. If the ticker has requested
* an animation frame it is canceled at this point.
*/
Ticker.prototype.stop = function stop() {
if (this.started) {
this.started = false;
this._cancelIfNeeded();
}
};
/**
* Destroy the ticker and don't use after this. Calling
* this method removes all references to internal events.
*/
Ticker.prototype.destroy = function destroy() {
this.stop();
var listener = this._head.next;
while (listener) {
listener = listener.destroy(true);
}
this._head.destroy();
this._head = null;
};
/**
* Triggers an update. An update entails setting the
* current {@link PIXI.ticker.Ticker#elapsedMS},
* the current {@link PIXI.ticker.Ticker#deltaTime},
* invoking all listeners with current deltaTime,
* and then finally setting {@link PIXI.ticker.Ticker#lastTime}
* with the value of currentTime that was provided.
* This method will be called automatically by animation
* frame callbacks if the ticker instance has been started
* and listeners are added.
*
* @param {number} [currentTime=performance.now()] - the current time of execution
*/
Ticker.prototype.update = function update() {
var currentTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : performance.now();
var elapsedMS = void 0;
// If the difference in time is zero or negative, we ignore most of the work done here.
// If there is no valid difference, then should be no reason to let anyone know about it.
// A zero delta, is exactly that, nothing should update.
//
// The difference in time can be negative, and no this does not mean time traveling.
// This can be the result of a race condition between when an animation frame is requested
// on the current JavaScript engine event loop, and when the ticker's start method is invoked
// (which invokes the internal _requestIfNeeded method). If a frame is requested before
// _requestIfNeeded is invoked, then the callback for the animation frame the ticker requests,
// can receive a time argument that can be less than the lastTime value that was set within
// _requestIfNeeded. This difference is in microseconds, but this is enough to cause problems.
//
// This check covers this browser engine timing issue, as well as if consumers pass an invalid
// currentTime value. This may happen if consumers opt-out of the autoStart, and update themselves.
if (currentTime > this.lastTime) {
// Save uncapped elapsedMS for measurement
elapsedMS = this.elapsedMS = currentTime - this.lastTime;
// cap the milliseconds elapsed used for deltaTime
if (elapsedMS > this._maxElapsedMS) {
elapsedMS = this._maxElapsedMS;
}
this.deltaTime = elapsedMS * _settings2.default.TARGET_FPMS * this.speed;
// Cache a local reference, in-case ticker is destroyed
// during the emit, we can still check for head.next
var head = this._head;
// Invoke listeners added to internal emitter
var listener = head.next;
while (listener) {
listener = listener.emit(this.deltaTime);
}
if (!head.next) {
this._cancelIfNeeded();
}
} else {
this.deltaTime = this.elapsedMS = 0;
}
this.lastTime = currentTime;
};
/**
* The frames per second at which this ticker is running.
* The default is approximately 60 in most modern browsers.
* **Note:** This does not factor in the value of
* {@link PIXI.ticker.Ticker#speed}, which is specific
* to scaling {@link PIXI.ticker.Ticker#deltaTime}.
*
* @member {number}
* @readonly
*/
_createClass(Ticker, [{
key: 'FPS',
get: function get() {
return 1000 / this.elapsedMS;
}
/**
* Manages the maximum amount of milliseconds allowed to
* elapse between invoking {@link PIXI.ticker.Ticker#update}.
* This value is used to cap {@link PIXI.ticker.Ticker#deltaTime},
* but does not effect the measured value of {@link PIXI.ticker.Ticker#FPS}.
* When setting this property it is clamped to a value between
* `0` and `PIXI.settings.TARGET_FPMS * 1000`.
*
* @member {number}
* @default 10
*/
}, {
key: 'minFPS',
get: function get() {
return 1000 / this._maxElapsedMS;
},
set: function set(fps) // eslint-disable-line require-jsdoc
{
// Clamp: 0 to TARGET_FPMS
var minFPMS = Math.min(Math.max(0, fps) / 1000, _settings2.default.TARGET_FPMS);
this._maxElapsedMS = 1 / minFPMS;
}
}]);
return Ticker;
}();
exports.default = Ticker;
//# sourceMappingURL=Ticker.js.map
/***/ }),
/* 464 */
/***/ (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"); } }
/**
* Internal class for handling the priority sorting of ticker handlers.
*
* @private
* @class
* @memberof PIXI.ticker
*/
var TickerListener = function () {
/**
* Constructor
*
* @param {Function} fn - The listener function to be added for one update
* @param {Function} [context=null] - The listener context
* @param {number} [priority=0] - The priority for emitting
* @param {boolean} [once=false] - If the handler should fire once
*/
function TickerListener(fn) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var once = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
_classCallCheck(this, TickerListener);
/**
* The handler function to execute.
* @member {Function}
*/
this.fn = fn;
/**
* The calling to execute.
* @member {Function}
*/
this.context = context;
/**
* The current priority.
* @member {number}
*/
this.priority = priority;
/**
* If this should only execute once.
* @member {boolean}
*/
this.once = once;
/**
* The next item in chain.
* @member {TickerListener}
*/
this.next = null;
/**
* The previous item in chain.
* @member {TickerListener}
*/
this.previous = null;
/**
* `true` if this listener has been destroyed already.
* @member {boolean}
* @private
*/
this._destroyed = false;
}
/**
* Simple compare function to figure out if a function and context match.
*
* @param {Function} fn - The listener function to be added for one update
* @param {Function} context - The listener context
* @return {boolean} `true` if the listener match the arguments
*/
TickerListener.prototype.match = function match(fn, context) {
context = context || null;
return this.fn === fn && this.context === context;
};
/**
* Emit by calling the current function.
* @param {number} deltaTime - time since the last emit.
* @return {TickerListener} Next ticker
*/
TickerListener.prototype.emit = function emit(deltaTime) {
if (this.fn) {
if (this.context) {
this.fn.call(this.context, deltaTime);
} else {
this.fn(deltaTime);
}
}
var redirect = this.next;
if (this.once) {
this.destroy(true);
}
// Soft-destroying should remove
// the next reference
if (this._destroyed) {
this.next = null;
}
return redirect;
};
/**
* Connect to the list.
* @param {TickerListener} previous - Input node, previous listener
*/
TickerListener.prototype.connect = function connect(previous) {
this.previous = previous;
if (previous.next) {
previous.next.previous = this;
}
this.next = previous.next;
previous.next = this;
};
/**
* Destroy and don't use after this.
* @param {boolean} [hard = false] `true` to remove the `next` reference, this
* is considered a hard destroy. Soft destroy maintains the next reference.
* @return {TickerListener} The listener to redirect while emitting or removing.
*/
TickerListener.prototype.destroy = function destroy() {
var hard = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
this._destroyed = true;
this.fn = null;
this.context = null;
// Disconnect, hook up next and previous
if (this.previous) {
this.previous.next = this.next;
}
if (this.next) {
this.next.previous = this.previous;
}
// Redirect to the next item
var redirect = this.next;
// Remove references
this.next = hard ? null : redirect;
this.previous = null;
return redirect;
};
return TickerListener;
}();
exports.default = TickerListener;
//# sourceMappingURL=TickerListener.js.map
/***/ }),
/* 465 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _CanvasRenderer = __webpack_require__(65);
var _CanvasRenderer2 = _interopRequireDefault(_CanvasRenderer);
var _const = __webpack_require__(3);
var _math = __webpack_require__(14);
var _CanvasTinter = __webpack_require__(84);
var _CanvasTinter2 = _interopRequireDefault(_CanvasTinter);
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"); } }
var canvasRenderWorldTransform = new _math.Matrix();
/**
* @author Mat Groves
*
* Big thanks to the very clever Matt DesLauriers <mattdesl> https://github.com/mattdesl/
* for creating the original PixiJS version!
* Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that they now
* share 4 bytes on the vertex buffer
*
* Heavily inspired by LibGDX's CanvasSpriteRenderer:
* https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/CanvasSpriteRenderer.java
*/
/**
* Renderer dedicated to drawing and batching sprites.
*
* @class
* @private
* @memberof PIXI
*/
var CanvasSpriteRenderer = function () {
/**
* @param {PIXI.WebGLRenderer} renderer -The renderer sprite this batch works for.
*/
function CanvasSpriteRenderer(renderer) {
_classCallCheck(this, CanvasSpriteRenderer);
this.renderer = renderer;
}
/**
* Renders the sprite object.
*
* @param {PIXI.Sprite} sprite - the sprite to render when using this spritebatch
*/
CanvasSpriteRenderer.prototype.render = function render(sprite) {
var texture = sprite._texture;
var renderer = this.renderer;
var width = texture._frame.width;
var height = texture._frame.height;
var wt = sprite.transform.worldTransform;
var dx = 0;
var dy = 0;
if (texture.orig.width <= 0 || texture.orig.height <= 0 || !texture.baseTexture.source) {
return;
}
renderer.setBlendMode(sprite.blendMode);
// Ignore null sources
if (texture.valid) {
renderer.context.globalAlpha = sprite.worldAlpha;
// If smoothingEnabled is supported and we need to change the smoothing property for sprite texture
var smoothingEnabled = texture.baseTexture.scaleMode === _const.SCALE_MODES.LINEAR;
if (renderer.smoothProperty && renderer.context[renderer.smoothProperty] !== smoothingEnabled) {
renderer.context[renderer.smoothProperty] = smoothingEnabled;
}
if (texture.trim) {
dx = texture.trim.width / 2 + texture.trim.x - sprite.anchor.x * texture.orig.width;
dy = texture.trim.height / 2 + texture.trim.y - sprite.anchor.y * texture.orig.height;
} else {
dx = (0.5 - sprite.anchor.x) * texture.orig.width;
dy = (0.5 - sprite.anchor.y) * texture.orig.height;
}
if (texture.rotate) {
wt.copy(canvasRenderWorldTransform);
wt = canvasRenderWorldTransform;
_math.GroupD8.matrixAppendRotationInv(wt, texture.rotate, dx, dy);
// the anchor has already been applied above, so lets set it to zero
dx = 0;
dy = 0;
}
dx -= width / 2;
dy -= height / 2;
// Allow for pixel rounding
if (renderer.roundPixels) {
renderer.context.setTransform(wt.a, wt.b, wt.c, wt.d, wt.tx * renderer.resolution | 0, wt.ty * renderer.resolution | 0);
dx = dx | 0;
dy = dy | 0;
} else {
renderer.context.setTransform(wt.a, wt.b, wt.c, wt.d, wt.tx * renderer.resolution, wt.ty * renderer.resolution);
}
var resolution = texture.baseTexture.resolution;
if (sprite.tint !== 0xFFFFFF) {
if (sprite.cachedTint !== sprite.tint || sprite.tintedTexture.tintId !== sprite._texture._updateID) {
sprite.cachedTint = sprite.tint;
// TODO clean up caching - how to clean up the caches?
sprite.tintedTexture = _CanvasTinter2.default.getTintedTexture(sprite, sprite.tint);
}
renderer.context.drawImage(sprite.tintedTexture, 0, 0, width * resolution, height * resolution, dx * renderer.resolution, dy * renderer.resolution, width * renderer.resolution, height * renderer.resolution);
} else {
renderer.context.drawImage(texture.baseTexture.source, texture._frame.x * resolution, texture._frame.y * resolution, width * resolution, height * resolution, dx * renderer.resolution, dy * renderer.resolution, width * renderer.resolution, height * renderer.resolution);
}
}
};
/**
* destroy the sprite object.
*
*/
CanvasSpriteRenderer.prototype.destroy = function destroy() {
this.renderer = null;
};
return CanvasSpriteRenderer;
}();
exports.default = CanvasSpriteRenderer;
_CanvasRenderer2.default.registerPlugin('sprite', CanvasSpriteRenderer);
//# sourceMappingURL=CanvasSpriteRenderer.js.map
/***/ }),
/* 466 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _const = __webpack_require__(3);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* A set of functions used to handle masking.
*
* @class
* @memberof PIXI
*/
var CanvasMaskManager = function () {
/**
* @param {PIXI.CanvasRenderer} renderer - The canvas renderer.
*/
function CanvasMaskManager(renderer) {
_classCallCheck(this, CanvasMaskManager);
this.renderer = renderer;
}
/**
* This method adds it to the current stack of masks.
*
* @param {object} maskData - the maskData that will be pushed
*/
CanvasMaskManager.prototype.pushMask = function pushMask(maskData) {
var renderer = this.renderer;
renderer.context.save();
var cacheAlpha = maskData.alpha;
var transform = maskData.transform.worldTransform;
var resolution = renderer.resolution;
renderer.context.setTransform(transform.a * resolution, transform.b * resolution, transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution);
// TODO suport sprite alpha masks??
// lots of effort required. If demand is great enough..
if (!maskData._texture) {
this.renderGraphicsShape(maskData);
renderer.context.clip();
}
maskData.worldAlpha = cacheAlpha;
};
/**
* Renders a PIXI.Graphics shape.
*
* @param {PIXI.Graphics} graphics - The object to render.
*/
CanvasMaskManager.prototype.renderGraphicsShape = function renderGraphicsShape(graphics) {
var context = this.renderer.context;
var len = graphics.graphicsData.length;
if (len === 0) {
return;
}
context.beginPath();
for (var i = 0; i < len; i++) {
var data = graphics.graphicsData[i];
var shape = data.shape;
if (data.type === _const.SHAPES.POLY) {
var points = shape.points;
var holes = data.holes;
var outerArea = void 0;
var innerArea = void 0;
context.moveTo(points[0], points[1]);
for (var j = 2; j < points.length; j += 2) {
context.lineTo(points[j], points[j + 1]);
}
// if the first and last point are the same close the path - much neater :)
if (points[0] === points[points.length - 2] && points[1] === points[points.length - 1]) {
context.closePath();
}
if (holes.length > 0) {
outerArea = 0;
for (var _j = 0; _j < points.length; _j += 2) {
outerArea += points[_j] * points[_j + 3] - points[_j + 1] * points[_j + 2];
}
for (var k = 0; k < holes.length; k++) {
points = holes[k].points;
innerArea = 0;
for (var _j2 = 0; _j2 < points.length; _j2 += 2) {
innerArea += points[_j2] * points[_j2 + 3] - points[_j2 + 1] * points[_j2 + 2];
}
context.moveTo(points[0], points[1]);
if (innerArea * outerArea < 0) {
for (var _j3 = 2; _j3 < points.length; _j3 += 2) {
context.lineTo(points[_j3], points[_j3 + 1]);
}
} else {
for (var _j4 = points.length - 2; _j4 >= 2; _j4 -= 2) {
context.lineTo(points[_j4], points[_j4 + 1]);
}
}
}
}
} else if (data.type === _const.SHAPES.RECT) {
context.rect(shape.x, shape.y, shape.width, shape.height);
context.closePath();
} else if (data.type === _const.SHAPES.CIRC) {
// TODO - need to be Undefined!
context.arc(shape.x, shape.y, shape.radius, 0, 2 * Math.PI);
context.closePath();
} else if (data.type === _const.SHAPES.ELIP) {
// ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
var w = shape.width * 2;
var h = shape.height * 2;
var x = shape.x - w / 2;
var y = shape.y - h / 2;
var kappa = 0.5522848;
var ox = w / 2 * kappa; // control point offset horizontal
var oy = h / 2 * kappa; // control point offset vertical
var xe = x + w; // x-end
var ye = y + h; // y-end
var xm = x + w / 2; // x-middle
var ym = y + h / 2; // y-middle
context.moveTo(x, ym);
context.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
context.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
context.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
context.closePath();
} else if (data.type === _const.SHAPES.RREC) {
var rx = shape.x;
var ry = shape.y;
var width = shape.width;
var height = shape.height;
var radius = shape.radius;
var maxRadius = Math.min(width, height) / 2 | 0;
radius = radius > maxRadius ? maxRadius : radius;
context.moveTo(rx, ry + radius);
context.lineTo(rx, ry + height - radius);
context.quadraticCurveTo(rx, ry + height, rx + radius, ry + height);
context.lineTo(rx + width - radius, ry + height);
context.quadraticCurveTo(rx + width, ry + height, rx + width, ry + height - radius);
context.lineTo(rx + width, ry + radius);
context.quadraticCurveTo(rx + width, ry, rx + width - radius, ry);
context.lineTo(rx + radius, ry);
context.quadraticCurveTo(rx, ry, rx, ry + radius);
context.closePath();
}
}
};
/**
* Restores the current drawing context to the state it was before the mask was applied.
*
* @param {PIXI.CanvasRenderer} renderer - The renderer context to use.
*/
CanvasMaskManager.prototype.popMask = function popMask(renderer) {
renderer.context.restore();
renderer.invalidateBlendMode();
};
/**
* Destroys this canvas mask manager.
*
*/
CanvasMaskManager.prototype.destroy = function destroy() {
/* empty */
};
return CanvasMaskManager;
}();
exports.default = CanvasMaskManager;
//# sourceMappingURL=CanvasMaskManager.js.map
/***/ }),
/* 467 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = mapCanvasBlendModesToPixi;
var _const = __webpack_require__(3);
var _canUseNewCanvasBlendModes = __webpack_require__(191);
var _canUseNewCanvasBlendModes2 = _interopRequireDefault(_canUseNewCanvasBlendModes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Maps blend combinations to Canvas.
*
* @memberof PIXI
* @function mapCanvasBlendModesToPixi
* @private
* @param {string[]} [array=[]] - The array to output into.
* @return {string[]} Mapped modes.
*/
function mapCanvasBlendModesToPixi() {
var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
if ((0, _canUseNewCanvasBlendModes2.default)()) {
array[_const.BLEND_MODES.NORMAL] = 'source-over';
array[_const.BLEND_MODES.ADD] = 'lighter'; // IS THIS OK???
array[_const.BLEND_MODES.MULTIPLY] = 'multiply';
array[_const.BLEND_MODES.SCREEN] = 'screen';
array[_const.BLEND_MODES.OVERLAY] = 'overlay';
array[_const.BLEND_MODES.DARKEN] = 'darken';
array[_const.BLEND_MODES.LIGHTEN] = 'lighten';
array[_const.BLEND_MODES.COLOR_DODGE] = 'color-dodge';
array[_const.BLEND_MODES.COLOR_BURN] = 'color-burn';
array[_const.BLEND_MODES.HARD_LIGHT] = 'hard-light';
array[_const.BLEND_MODES.SOFT_LIGHT] = 'soft-light';
array[_const.BLEND_MODES.DIFFERENCE] = 'difference';
array[_const.BLEND_MODES.EXCLUSION] = 'exclusion';
array[_const.BLEND_MODES.HUE] = 'hue';
array[_const.BLEND_MODES.SATURATION] = 'saturate';
array[_const.BLEND_MODES.COLOR] = 'color';
array[_const.BLEND_MODES.LUMINOSITY] = 'luminosity';
} else {
// this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough'
array[_const.BLEND_MODES.NORMAL] = 'source-over';
array[_const.BLEND_MODES.ADD] = 'lighter'; // IS THIS OK???
array[_const.BLEND_MODES.MULTIPLY] = 'source-over';
array[_const.BLEND_MODES.SCREEN] = 'source-over';
array[_const.BLEND_MODES.OVERLAY] = 'source-over';
array[_const.BLEND_MODES.DARKEN] = 'source-over';
array[_const.BLEND_MODES.LIGHTEN] = 'source-over';
array[_const.BLEND_MODES.COLOR_DODGE] = 'source-over';
array[_const.BLEND_MODES.COLOR_BURN] = 'source-over';
array[_const.BLEND_MODES.HARD_LIGHT] = 'source-over';
array[_const.BLEND_MODES.SOFT_LIGHT] = 'source-over';
array[_const.BLEND_MODES.DIFFERENCE] = 'source-over';
array[_const.BLEND_MODES.EXCLUSION] = 'source-over';
array[_const.BLEND_MODES.HUE] = 'source-over';
array[_const.BLEND_MODES.SATURATION] = 'source-over';
array[_const.BLEND_MODES.COLOR] = 'source-over';
array[_const.BLEND_MODES.LUMINOSITY] = 'source-over';
}
// not-premultiplied, only for webgl
array[_const.BLEND_MODES.NORMAL_NPM] = array[_const.BLEND_MODES.NORMAL];
array[_const.BLEND_MODES.ADD_NPM] = array[_const.BLEND_MODES.ADD];
array[_const.BLEND_MODES.SCREEN_NPM] = array[_const.BLEND_MODES.SCREEN];
return array;
}
//# sourceMappingURL=mapCanvasBlendModesToPixi.js.map
/***/ }),
/* 468 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _ObjectRenderer2 = __webpack_require__(85);
var _ObjectRenderer3 = _interopRequireDefault(_ObjectRenderer2);
var _WebGLRenderer = __webpack_require__(86);
var _WebGLRenderer2 = _interopRequireDefault(_WebGLRenderer);
var _createIndicesForQuads = __webpack_require__(129);
var _createIndicesForQuads2 = _interopRequireDefault(_createIndicesForQuads);
var _generateMultiTextureShader = __webpack_require__(481);
var _generateMultiTextureShader2 = _interopRequireDefault(_generateMultiTextureShader);
var _checkMaxIfStatmentsInShader = __webpack_require__(482);
var _checkMaxIfStatmentsInShader2 = _interopRequireDefault(_checkMaxIfStatmentsInShader);
var _BatchBuffer = __webpack_require__(483);
var _BatchBuffer2 = _interopRequireDefault(_BatchBuffer);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
var _utils = __webpack_require__(7);
var _pixiGlCore = __webpack_require__(23);
var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore);
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; }
var TICK = 0;
var TEXTURE_TICK = 0;
/**
* Renderer dedicated to drawing and batching sprites.
*
* @class
* @private
* @memberof PIXI
* @extends PIXI.ObjectRenderer
*/
var SpriteRenderer = function (_ObjectRenderer) {
_inherits(SpriteRenderer, _ObjectRenderer);
/**
* @param {PIXI.WebGLRenderer} renderer - The renderer this sprite batch works for.
*/
function SpriteRenderer(renderer) {
_classCallCheck(this, SpriteRenderer);
/**
* Number of values sent in the vertex buffer.
* aVertexPosition(2), aTextureCoord(1), aColor(1), aTextureId(1) = 5
*
* @member {number}
*/
var _this = _possibleConstructorReturn(this, _ObjectRenderer.call(this, renderer));
_this.vertSize = 5;
/**
* The size of the vertex information in bytes.
*
* @member {number}
*/
_this.vertByteSize = _this.vertSize * 4;
/**
* The number of images in the SpriteRenderer before it flushes.
*
* @member {number}
*/
_this.size = _settings2.default.SPRITE_BATCH_SIZE; // 2000 is a nice balance between mobile / desktop
// the total number of bytes in our batch
// let numVerts = this.size * 4 * this.vertByteSize;
_this.buffers = [];
for (var i = 1; i <= _bitTwiddle2.default.nextPow2(_this.size); i *= 2) {
_this.buffers.push(new _BatchBuffer2.default(i * 4 * _this.vertByteSize));
}
/**
* Holds the indices of the geometry (quads) to draw
*
* @member {Uint16Array}
*/
_this.indices = (0, _createIndicesForQuads2.default)(_this.size);
/**
* The default shaders that is used if a sprite doesn't have a more specific one.
* there is a shader for each number of textures that can be rendererd.
* These shaders will also be generated on the fly as required.
* @member {PIXI.Shader[]}
*/
_this.shader = null;
_this.currentIndex = 0;
_this.groups = [];
for (var k = 0; k < _this.size; k++) {
_this.groups[k] = { textures: [], textureCount: 0, ids: [], size: 0, start: 0, blend: 0 };
}
_this.sprites = [];
_this.vertexBuffers = [];
_this.vaos = [];
_this.vaoMax = 2;
_this.vertexCount = 0;
_this.renderer.on('prerender', _this.onPrerender, _this);
return _this;
}
/**
* Sets up the renderer context and necessary buffers.
*
* @private
*/
SpriteRenderer.prototype.onContextChange = function onContextChange() {
var gl = this.renderer.gl;
if (this.renderer.legacy) {
this.MAX_TEXTURES = 1;
} else {
// step 1: first check max textures the GPU can handle.
this.MAX_TEXTURES = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), _settings2.default.SPRITE_MAX_TEXTURES);
// step 2: check the maximum number of if statements the shader can have too..
this.MAX_TEXTURES = (0, _checkMaxIfStatmentsInShader2.default)(this.MAX_TEXTURES, gl);
}
this.shader = (0, _generateMultiTextureShader2.default)(gl, this.MAX_TEXTURES);
// create a couple of buffers
this.indexBuffer = _pixiGlCore2.default.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW);
// we use the second shader as the first one depending on your browser may omit aTextureId
// as it is not used by the shader so is optimized out.
this.renderer.bindVao(null);
var attrs = this.shader.attributes;
for (var i = 0; i < this.vaoMax; i++) {
/* eslint-disable max-len */
var vertexBuffer = this.vertexBuffers[i] = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW);
/* eslint-enable max-len */
// build the vao object that will render..
var vao = this.renderer.createVao().addIndex(this.indexBuffer).addAttribute(vertexBuffer, attrs.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0).addAttribute(vertexBuffer, attrs.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4).addAttribute(vertexBuffer, attrs.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4);
if (attrs.aTextureId) {
vao.addAttribute(vertexBuffer, attrs.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4);
}
this.vaos[i] = vao;
}
this.vao = this.vaos[0];
this.currentBlendMode = 99999;
this.boundTextures = new Array(this.MAX_TEXTURES);
};
/**
* Called before the renderer starts rendering.
*
*/
SpriteRenderer.prototype.onPrerender = function onPrerender() {
this.vertexCount = 0;
};
/**
* Renders the sprite object.
*
* @param {PIXI.Sprite} sprite - the sprite to render when using this spritebatch
*/
SpriteRenderer.prototype.render = function render(sprite) {
// TODO set blend modes..
// check texture..
if (this.currentIndex >= this.size) {
this.flush();
}
// get the uvs for the texture
// if the uvs have not updated then no point rendering just yet!
if (!sprite._texture._uvs) {
return;
}
// push a texture.
// increment the batchsize
this.sprites[this.currentIndex++] = sprite;
};
/**
* Renders the content and empties the current batch.
*
*/
SpriteRenderer.prototype.flush = function flush() {
if (this.currentIndex === 0) {
return;
}
var gl = this.renderer.gl;
var MAX_TEXTURES = this.MAX_TEXTURES;
var np2 = _bitTwiddle2.default.nextPow2(this.currentIndex);
var log2 = _bitTwiddle2.default.log2(np2);
var buffer = this.buffers[log2];
var sprites = this.sprites;
var groups = this.groups;
var float32View = buffer.float32View;
var uint32View = buffer.uint32View;
var boundTextures = this.boundTextures;
var rendererBoundTextures = this.renderer.boundTextures;
var touch = this.renderer.textureGC.count;
var index = 0;
var nextTexture = void 0;
var currentTexture = void 0;
var groupCount = 1;
var textureCount = 0;
var currentGroup = groups[0];
var vertexData = void 0;
var uvs = void 0;
var blendMode = _utils.premultiplyBlendMode[sprites[0]._texture.baseTexture.premultipliedAlpha ? 1 : 0][sprites[0].blendMode];
currentGroup.textureCount = 0;
currentGroup.start = 0;
currentGroup.blend = blendMode;
TICK++;
var i = void 0;
// copy textures..
for (i = 0; i < MAX_TEXTURES; ++i) {
var bt = rendererBoundTextures[i];
if (bt._enabled === TICK) {
boundTextures[i] = this.renderer.emptyTextures[i];
continue;
}
boundTextures[i] = bt;
bt._virtalBoundId = i;
bt._enabled = TICK;
}
TICK++;
for (i = 0; i < this.currentIndex; ++i) {
// upload the sprite elemetns...
// they have all ready been calculated so we just need to push them into the buffer.
var sprite = sprites[i];
sprites[i] = null;
nextTexture = sprite._texture.baseTexture;
var spriteBlendMode = _utils.premultiplyBlendMode[Number(nextTexture.premultipliedAlpha)][sprite.blendMode];
if (blendMode !== spriteBlendMode) {
// finish a group..
blendMode = spriteBlendMode;
// force the batch to break!
currentTexture = null;
textureCount = MAX_TEXTURES;
TICK++;
}
if (currentTexture !== nextTexture) {
currentTexture = nextTexture;
if (nextTexture._enabled !== TICK) {
if (textureCount === MAX_TEXTURES) {
TICK++;
currentGroup.size = i - currentGroup.start;
textureCount = 0;
currentGroup = groups[groupCount++];
currentGroup.blend = blendMode;
currentGroup.textureCount = 0;
currentGroup.start = i;
}
nextTexture.touched = touch;
if (nextTexture._virtalBoundId === -1) {
for (var j = 0; j < MAX_TEXTURES; ++j) {
var tIndex = (j + TEXTURE_TICK) % MAX_TEXTURES;
var t = boundTextures[tIndex];
if (t._enabled !== TICK) {
TEXTURE_TICK++;
t._virtalBoundId = -1;
nextTexture._virtalBoundId = tIndex;
boundTextures[tIndex] = nextTexture;
break;
}
}
}
nextTexture._enabled = TICK;
currentGroup.textureCount++;
currentGroup.ids[textureCount] = nextTexture._virtalBoundId;
currentGroup.textures[textureCount++] = nextTexture;
}
}
vertexData = sprite.vertexData;
// TODO this sum does not need to be set each frame..
uvs = sprite._texture._uvs.uvsUint32;
if (this.renderer.roundPixels) {
var resolution = this.renderer.resolution;
// xy
float32View[index] = (vertexData[0] * resolution | 0) / resolution;
float32View[index + 1] = (vertexData[1] * resolution | 0) / resolution;
// xy
float32View[index + 5] = (vertexData[2] * resolution | 0) / resolution;
float32View[index + 6] = (vertexData[3] * resolution | 0) / resolution;
// xy
float32View[index + 10] = (vertexData[4] * resolution | 0) / resolution;
float32View[index + 11] = (vertexData[5] * resolution | 0) / resolution;
// xy
float32View[index + 15] = (vertexData[6] * resolution | 0) / resolution;
float32View[index + 16] = (vertexData[7] * resolution | 0) / resolution;
} else {
// xy
float32View[index] = vertexData[0];
float32View[index + 1] = vertexData[1];
// xy
float32View[index + 5] = vertexData[2];
float32View[index + 6] = vertexData[3];
// xy
float32View[index + 10] = vertexData[4];
float32View[index + 11] = vertexData[5];
// xy
float32View[index + 15] = vertexData[6];
float32View[index + 16] = vertexData[7];
}
uint32View[index + 2] = uvs[0];
uint32View[index + 7] = uvs[1];
uint32View[index + 12] = uvs[2];
uint32View[index + 17] = uvs[3];
/* eslint-disable max-len */
var alpha = Math.min(sprite.worldAlpha, 1.0);
// we dont call extra function if alpha is 1.0, that's faster
var argb = alpha < 1.0 && nextTexture.premultipliedAlpha ? (0, _utils.premultiplyTint)(sprite._tintRGB, alpha) : sprite._tintRGB + (alpha * 255 << 24);
uint32View[index + 3] = uint32View[index + 8] = uint32View[index + 13] = uint32View[index + 18] = argb;
float32View[index + 4] = float32View[index + 9] = float32View[index + 14] = float32View[index + 19] = nextTexture._virtalBoundId;
/* eslint-enable max-len */
index += 20;
}
currentGroup.size = i - currentGroup.start;
if (!_settings2.default.CAN_UPLOAD_SAME_BUFFER) {
// this is still needed for IOS performance..
// it really does not like uploading to the same buffer in a single frame!
if (this.vaoMax <= this.vertexCount) {
this.vaoMax++;
var attrs = this.shader.attributes;
/* eslint-disable max-len */
var vertexBuffer = this.vertexBuffers[this.vertexCount] = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW);
/* eslint-enable max-len */
// build the vao object that will render..
var vao = this.renderer.createVao().addIndex(this.indexBuffer).addAttribute(vertexBuffer, attrs.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0).addAttribute(vertexBuffer, attrs.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4).addAttribute(vertexBuffer, attrs.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4);
if (attrs.aTextureId) {
vao.addAttribute(vertexBuffer, attrs.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4);
}
this.vaos[this.vertexCount] = vao;
}
this.renderer.bindVao(this.vaos[this.vertexCount]);
this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0, false);
this.vertexCount++;
} else {
// lets use the faster option, always use buffer number 0
this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0, true);
}
for (i = 0; i < MAX_TEXTURES; ++i) {
rendererBoundTextures[i]._virtalBoundId = -1;
}
// render the groups..
for (i = 0; i < groupCount; ++i) {
var group = groups[i];
var groupTextureCount = group.textureCount;
for (var _j = 0; _j < groupTextureCount; _j++) {
currentTexture = group.textures[_j];
// reset virtual ids..
// lets do a quick check..
if (rendererBoundTextures[group.ids[_j]] !== currentTexture) {
this.renderer.bindTexture(currentTexture, group.ids[_j], true);
}
// reset the virtualId..
currentTexture._virtalBoundId = -1;
}
// set the blend mode..
this.renderer.state.setBlendMode(group.blend);
gl.drawElements(gl.TRIANGLES, group.size * 6, gl.UNSIGNED_SHORT, group.start * 6 * 2);
}
// reset elements for the next flush
this.currentIndex = 0;
};
/**
* Starts a new sprite batch.
*/
SpriteRenderer.prototype.start = function start() {
this.renderer.bindShader(this.shader);
if (_settings2.default.CAN_UPLOAD_SAME_BUFFER) {
// bind buffer #0, we don't need others
this.renderer.bindVao(this.vaos[this.vertexCount]);
this.vertexBuffers[this.vertexCount].bind();
}
};
/**
* Stops and flushes the current batch.
*
*/
SpriteRenderer.prototype.stop = function stop() {
this.flush();
};
/**
* Destroys the SpriteRenderer.
*
*/
SpriteRenderer.prototype.destroy = function destroy() {
for (var i = 0; i < this.vaoMax; i++) {
if (this.vertexBuffers[i]) {
this.vertexBuffers[i].destroy();
}
if (this.vaos[i]) {
this.vaos[i].destroy();
}
}
if (this.indexBuffer) {
this.indexBuffer.destroy();
}
this.renderer.off('prerender', this.onPrerender, this);
_ObjectRenderer.prototype.destroy.call(this);
if (this.shader) {
this.shader.destroy();
this.shader = null;
}
this.vertexBuffers = null;
this.vaos = null;
this.indexBuffer = null;
this.indices = null;
this.sprites = null;
for (var _i = 0; _i < this.buffers.length; ++_i) {
this.buffers[_i].destroy();
}
};
return SpriteRenderer;
}(_ObjectRenderer3.default);
exports.default = SpriteRenderer;
_WebGLRenderer2.default.registerPlugin('sprite', SpriteRenderer);
//# sourceMappingURL=SpriteRenderer.js.map
/***/ }),
/* 469 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _WebGLManager2 = __webpack_require__(66);
var _WebGLManager3 = _interopRequireDefault(_WebGLManager2);
var _SpriteMaskFilter = __webpack_require__(192);
var _SpriteMaskFilter2 = _interopRequireDefault(_SpriteMaskFilter);
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; }
/**
* @class
* @extends PIXI.WebGLManager
* @memberof PIXI
*/
var MaskManager = function (_WebGLManager) {
_inherits(MaskManager, _WebGLManager);
/**
* @param {PIXI.WebGLRenderer} renderer - The renderer this manager works for.
*/
function MaskManager(renderer) {
_classCallCheck(this, MaskManager);
// TODO - we don't need both!
var _this = _possibleConstructorReturn(this, _WebGLManager.call(this, renderer));
_this.scissor = false;
_this.scissorData = null;
_this.scissorRenderTarget = null;
_this.enableScissor = true;
_this.alphaMaskPool = [];
_this.alphaMaskIndex = 0;
return _this;
}
/**
* Applies the Mask and adds it to the current filter stack.
*
* @param {PIXI.DisplayObject} target - Display Object to push the mask to
* @param {PIXI.Sprite|PIXI.Graphics} maskData - The masking data.
*/
MaskManager.prototype.pushMask = function pushMask(target, maskData) {
// TODO the root check means scissor rect will not
// be used on render textures more info here:
// https://github.com/pixijs/pixi.js/pull/3545
if (maskData.texture) {
this.pushSpriteMask(target, maskData);
} else if (this.enableScissor && !this.scissor && this.renderer._activeRenderTarget.root && !this.renderer.stencilManager.stencilMaskStack.length && maskData.isFastRect()) {
var matrix = maskData.worldTransform;
var rot = Math.atan2(matrix.b, matrix.a);
// use the nearest degree!
rot = Math.round(rot * (180 / Math.PI));
if (rot % 90) {
this.pushStencilMask(maskData);
} else {
this.pushScissorMask(target, maskData);
}
} else {
this.pushStencilMask(maskData);
}
};
/**
* Removes the last mask from the mask stack and doesn't return it.
*
* @param {PIXI.DisplayObject} target - Display Object to pop the mask from
* @param {PIXI.Sprite|PIXI.Graphics} maskData - The masking data.
*/
MaskManager.prototype.popMask = function popMask(target, maskData) {
if (maskData.texture) {
this.popSpriteMask(target, maskData);
} else if (this.enableScissor && !this.renderer.stencilManager.stencilMaskStack.length) {
this.popScissorMask(target, maskData);
} else {
this.popStencilMask(target, maskData);
}
};
/**
* Applies the Mask and adds it to the current filter stack.
*
* @param {PIXI.RenderTarget} target - Display Object to push the sprite mask to
* @param {PIXI.Sprite} maskData - Sprite to be used as the mask
*/
MaskManager.prototype.pushSpriteMask = function pushSpriteMask(target, maskData) {
var alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex];
if (!alphaMaskFilter) {
alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex] = [new _SpriteMaskFilter2.default(maskData)];
}
alphaMaskFilter[0].resolution = this.renderer.resolution;
alphaMaskFilter[0].maskSprite = maskData;
var stashFilterArea = target.filterArea;
target.filterArea = maskData.getBounds(true);
this.renderer.filterManager.pushFilter(target, alphaMaskFilter);
target.filterArea = stashFilterArea;
this.alphaMaskIndex++;
};
/**
* Removes the last filter from the filter stack and doesn't return it.
*
*/
MaskManager.prototype.popSpriteMask = function popSpriteMask() {
this.renderer.filterManager.popFilter();
this.alphaMaskIndex--;
};
/**
* Applies the Mask and adds it to the current filter stack.
*
* @param {PIXI.Sprite|PIXI.Graphics} maskData - The masking data.
*/
MaskManager.prototype.pushStencilMask = function pushStencilMask(maskData) {
this.renderer.currentRenderer.stop();
this.renderer.stencilManager.pushStencil(maskData);
};
/**
* Removes the last filter from the filter stack and doesn't return it.
*
*/
MaskManager.prototype.popStencilMask = function popStencilMask() {
this.renderer.currentRenderer.stop();
this.renderer.stencilManager.popStencil();
};
/**
*
* @param {PIXI.DisplayObject} target - Display Object to push the mask to
* @param {PIXI.Graphics} maskData - The masking data.
*/
MaskManager.prototype.pushScissorMask = function pushScissorMask(target, maskData) {
maskData.renderable = true;
var renderTarget = this.renderer._activeRenderTarget;
var bounds = maskData.getBounds();
bounds.fit(renderTarget.size);
maskData.renderable = false;
this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST);
var resolution = this.renderer.resolution;
this.renderer.gl.scissor(bounds.x * resolution, (renderTarget.root ? renderTarget.size.height - bounds.y - bounds.height : bounds.y) * resolution, bounds.width * resolution, bounds.height * resolution);
this.scissorRenderTarget = renderTarget;
this.scissorData = maskData;
this.scissor = true;
};
/**
*
*
*/
MaskManager.prototype.popScissorMask = function popScissorMask() {
this.scissorRenderTarget = null;
this.scissorData = null;
this.scissor = false;
// must be scissor!
var gl = this.renderer.gl;
gl.disable(gl.SCISSOR_TEST);
};
return MaskManager;
}(_WebGLManager3.default);
exports.default = MaskManager;
//# sourceMappingURL=MaskManager.js.map
/***/ }),
/* 470 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = extractUniformsFromSrc;
var _pixiGlCore = __webpack_require__(23);
var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var defaultValue = _pixiGlCore2.default.shader.defaultValue;
function extractUniformsFromSrc(vertexSrc, fragmentSrc, mask) {
var vertUniforms = extractUniformsFromString(vertexSrc, mask);
var fragUniforms = extractUniformsFromString(fragmentSrc, mask);
return Object.assign(vertUniforms, fragUniforms);
}
function extractUniformsFromString(string) {
var maskRegex = new RegExp('^(projectionMatrix|uSampler|filterArea|filterClamp)$');
var uniforms = {};
var nameSplit = void 0;
// clean the lines a little - remove extra spaces / tabs etc
// then split along ';'
var lines = string.replace(/\s+/g, ' ').split(/\s*;\s*/);
// loop through..
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim();
if (line.indexOf('uniform') > -1) {
var splitLine = line.split(' ');
var type = splitLine[1];
var name = splitLine[2];
var size = 1;
if (name.indexOf('[') > -1) {
// array!
nameSplit = name.split(/\[|]/);
name = nameSplit[0];
size *= Number(nameSplit[1]);
}
if (!name.match(maskRegex)) {
uniforms[name] = {
value: defaultValue(type, size),
name: name,
type: type
};
}
}
}
return uniforms;
}
//# sourceMappingURL=extractUniformsFromSrc.js.map
/***/ }),
/* 471 */
/***/ (function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }),
/* 472 */
/***/ (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; }
/**
* @class
* @extends PIXI.WebGLManager
* @memberof PIXI
*/
var StencilManager = function (_WebGLManager) {
_inherits(StencilManager, _WebGLManager);
/**
* @param {PIXI.WebGLRenderer} renderer - The renderer this manager works for.
*/
function StencilManager(renderer) {
_classCallCheck(this, StencilManager);
var _this = _possibleConstructorReturn(this, _WebGLManager.call(this, renderer));
_this.stencilMaskStack = null;
return _this;
}
/**
* Changes the mask stack that is used by this manager.
*
* @param {PIXI.Graphics[]} stencilMaskStack - The mask stack
*/
StencilManager.prototype.setMaskStack = function setMaskStack(stencilMaskStack) {
this.stencilMaskStack = stencilMaskStack;
var gl = this.renderer.gl;
if (stencilMaskStack.length === 0) {
gl.disable(gl.STENCIL_TEST);
} else {
gl.enable(gl.STENCIL_TEST);
}
};
/**
* Applies the Mask and adds it to the current stencil stack. @alvin
*
* @param {PIXI.Graphics} graphics - The mask
*/
StencilManager.prototype.pushStencil = function pushStencil(graphics) {
this.renderer.setObjectRenderer(this.renderer.plugins.graphics);
this.renderer._activeRenderTarget.attachStencilBuffer();
var gl = this.renderer.gl;
var prevMaskCount = this.stencilMaskStack.length;
if (prevMaskCount === 0) {
gl.enable(gl.STENCIL_TEST);
}
this.stencilMaskStack.push(graphics);
// Increment the reference stencil value where the new mask overlaps with the old ones.
gl.colorMask(false, false, false, false);
gl.stencilFunc(gl.EQUAL, prevMaskCount, this._getBitwiseMask());
gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR);
this.renderer.plugins.graphics.render(graphics);
this._useCurrent();
};
/**
* Removes the last mask from the stencil stack. @alvin
*/
StencilManager.prototype.popStencil = function popStencil() {
this.renderer.setObjectRenderer(this.renderer.plugins.graphics);
var gl = this.renderer.gl;
var graphics = this.stencilMaskStack.pop();
if (this.stencilMaskStack.length === 0) {
// the stack is empty!
gl.disable(gl.STENCIL_TEST);
gl.clear(gl.STENCIL_BUFFER_BIT);
gl.clearStencil(0);
} else {
// Decrement the reference stencil value where the popped mask overlaps with the other ones
gl.colorMask(false, false, false, false);
gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR);
this.renderer.plugins.graphics.render(graphics);
this._useCurrent();
}
};
/**
* Setup renderer to use the current stencil data.
*/
StencilManager.prototype._useCurrent = function _useCurrent() {
var gl = this.renderer.gl;
gl.colorMask(true, true, true, true);
gl.stencilFunc(gl.EQUAL, this.stencilMaskStack.length, this._getBitwiseMask());
gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
};
/**
* Fill 1s equal to the number of acitve stencil masks.
*
* @return {number} The bitwise mask.
*/
StencilManager.prototype._getBitwiseMask = function _getBitwiseMask() {
return (1 << this.stencilMaskStack.length) - 1;
};
/**
* Destroys the mask stack.
*
*/
StencilManager.prototype.destroy = function destroy() {
_WebGLManager3.default.prototype.destroy.call(this);
this.stencilMaskStack.stencilStack = null;
};
return StencilManager;
}(_WebGLManager3.default);
exports.default = StencilManager;
//# sourceMappingURL=StencilManager.js.map
/***/ }),
/* 473 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _WebGLManager2 = __webpack_require__(66);
var _WebGLManager3 = _interopRequireDefault(_WebGLManager2);
var _RenderTarget = __webpack_require__(87);
var _RenderTarget2 = _interopRequireDefault(_RenderTarget);
var _Quad = __webpack_require__(195);
var _Quad2 = _interopRequireDefault(_Quad);
var _math = __webpack_require__(14);
var _Shader = __webpack_require__(67);
var _Shader2 = _interopRequireDefault(_Shader);
var _filterTransforms = __webpack_require__(474);
var filterTransforms = _interopRequireWildcard(_filterTransforms);
var _bitTwiddle = __webpack_require__(126);
var _bitTwiddle2 = _interopRequireDefault(_bitTwiddle);
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 }; }
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* @ignore
* @class
*/
var FilterState = function () {
/**
*
*/
function FilterState() {
_classCallCheck(this, FilterState);
this.renderTarget = null;
this.target = null;
this.resolution = 1;
// those three objects are used only for root
// re-assigned for everything else
this.sourceFrame = new _math.Rectangle();
this.destinationFrame = new _math.Rectangle();
this.filters = [];
}
/**
* clears the state
*/
FilterState.prototype.clear = function clear() {
this.filters = null;
this.target = null;
this.renderTarget = null;
};
return FilterState;
}();
var screenKey = 'screen';
/**
* @class
* @memberof PIXI
* @extends PIXI.WebGLManager
*/
var FilterManager = function (_WebGLManager) {
_inherits(FilterManager, _WebGLManager);
/**
* @param {PIXI.WebGLRenderer} renderer - The renderer this manager works for.
*/
function FilterManager(renderer) {
_classCallCheck(this, FilterManager);
var _this = _possibleConstructorReturn(this, _WebGLManager.call(this, renderer));
_this.gl = _this.renderer.gl;
// know about sprites!
_this.quad = new _Quad2.default(_this.gl, renderer.state.attribState);
_this.shaderCache = {};
// todo add default!
_this.pool = {};
_this.filterData = null;
_this.managedFilters = [];
_this.renderer.on('prerender', _this.onPrerender, _this);
_this._screenWidth = renderer.view.width;
_this._screenHeight = renderer.view.height;
return _this;
}
/**
* Adds a new filter to the manager.
*
* @param {PIXI.DisplayObject} target - The target of the filter to render.
* @param {PIXI.Filter[]} filters - The filters to apply.
*/
FilterManager.prototype.pushFilter = function pushFilter(target, filters) {
var renderer = this.renderer;
var filterData = this.filterData;
if (!filterData) {
filterData = this.renderer._activeRenderTarget.filterStack;
// add new stack
var filterState = new FilterState();
filterState.sourceFrame = filterState.destinationFrame = this.renderer._activeRenderTarget.size;
filterState.renderTarget = renderer._activeRenderTarget;
this.renderer._activeRenderTarget.filterData = filterData = {
index: 0,
stack: [filterState]
};
this.filterData = filterData;
}
// get the current filter state..
var currentState = filterData.stack[++filterData.index];
var renderTargetFrame = filterData.stack[0].destinationFrame;
if (!currentState) {
currentState = filterData.stack[filterData.index] = new FilterState();
}
var fullScreen = target.filterArea && target.filterArea.x === 0 && target.filterArea.y === 0 && target.filterArea.width === renderer.screen.width && target.filterArea.height === renderer.screen.height;
// for now we go off the filter of the first resolution..
var resolution = filters[0].resolution;
var padding = filters[0].padding | 0;
var targetBounds = fullScreen ? renderer.screen : target.filterArea || target.getBounds(true);
var sourceFrame = currentState.sourceFrame;
var destinationFrame = currentState.destinationFrame;
sourceFrame.x = (targetBounds.x * resolution | 0) / resolution;
sourceFrame.y = (targetBounds.y * resolution | 0) / resolution;
sourceFrame.width = (targetBounds.width * resolution | 0) / resolution;
sourceFrame.height = (targetBounds.height * resolution | 0) / resolution;
if (!fullScreen) {
if (filterData.stack[0].renderTarget.transform) {//
// TODO we should fit the rect around the transform..
} else if (filters[0].autoFit) {
sourceFrame.fit(renderTargetFrame);
}
// lets apply the padding After we fit the element to the screen.
// this should stop the strange side effects that can occur when cropping to the edges
sourceFrame.pad(padding);
}
destinationFrame.width = sourceFrame.width;
destinationFrame.height = sourceFrame.height;
// lets play the padding after we fit the element to the screen.
// this should stop the strange side effects that can occur when cropping to the edges
var renderTarget = this.getPotRenderTarget(renderer.gl, sourceFrame.width, sourceFrame.height, resolution);
currentState.target = target;
currentState.filters = filters;
currentState.resolution = resolution;
currentState.renderTarget = renderTarget;
// bind the render target to draw the shape in the top corner..
renderTarget.setFrame(destinationFrame, sourceFrame);
// bind the render target
renderer.bindRenderTarget(renderTarget);
renderTarget.clear();
};
/**
* Pops off the filter and applies it.
*
*/
FilterManager.prototype.popFilter = function popFilter() {
var filterData = this.filterData;
var lastState = filterData.stack[filterData.index - 1];
var currentState = filterData.stack[filterData.index];
this.quad.map(currentState.renderTarget.size, currentState.sourceFrame).upload();
var filters = currentState.filters;
if (filters.length === 1) {
filters[0].apply(this, currentState.renderTarget, lastState.renderTarget, false, currentState);
this.freePotRenderTarget(currentState.renderTarget);
} else {
var flip = currentState.renderTarget;
var flop = this.getPotRenderTarget(this.renderer.gl, currentState.sourceFrame.width, currentState.sourceFrame.height, currentState.resolution);
flop.setFrame(currentState.destinationFrame, currentState.sourceFrame);
// finally lets clear the render target before drawing to it..
flop.clear();
var i = 0;
for (i = 0; i < filters.length - 1; ++i) {
filters[i].apply(this, flip, flop, true, currentState);
var t = flip;
flip = flop;
flop = t;
}
filters[i].apply(this, flip, lastState.renderTarget, false, currentState);
this.freePotRenderTarget(flip);
this.freePotRenderTarget(flop);
}
currentState.clear();
filterData.index--;
if (filterData.index === 0) {
this.filterData = null;
}
};
/**
* Draws a filter.
*
* @param {PIXI.Filter} filter - The filter to draw.
* @param {PIXI.RenderTarget} input - The input render target.
* @param {PIXI.RenderTarget} output - The target to output to.
* @param {boolean} clear - Should the output be cleared before rendering to it
*/
FilterManager.prototype.applyFilter = function applyFilter(filter, input, output, clear) {
var renderer = this.renderer;
var gl = renderer.gl;
var shader = filter.glShaders[renderer.CONTEXT_UID];
// caching..
if (!shader) {
if (filter.glShaderKey) {
shader = this.shaderCache[filter.glShaderKey];
if (!shader) {
shader = new _Shader2.default(this.gl, filter.vertexSrc, filter.fragmentSrc);
filter.glShaders[renderer.CONTEXT_UID] = this.shaderCache[filter.glShaderKey] = shader;
this.managedFilters.push(filter);
}
} else {
shader = filter.glShaders[renderer.CONTEXT_UID] = new _Shader2.default(this.gl, filter.vertexSrc, filter.fragmentSrc);
this.managedFilters.push(filter);
}
// TODO - this only needs to be done once?
renderer.bindVao(null);
this.quad.initVao(shader);
}
renderer.bindVao(this.quad.vao);
renderer.bindRenderTarget(output);
if (clear) {
gl.disable(gl.SCISSOR_TEST);
renderer.clear(); // [1, 1, 1, 1]);
gl.enable(gl.SCISSOR_TEST);
}
// in case the render target is being masked using a scissor rect
if (output === renderer.maskManager.scissorRenderTarget) {
renderer.maskManager.pushScissorMask(null, renderer.maskManager.scissorData);
}
renderer.bindShader(shader);
// free unit 0 for us, doesn't matter what was there
// don't try to restore it, because syncUniforms can upload it to another slot
// and it'll be a problem
var tex = this.renderer.emptyTextures[0];
this.renderer.boundTextures[0] = tex;
// this syncs the PixiJS filters uniforms with glsl uniforms
this.syncUniforms(shader, filter);
renderer.state.setBlendMode(filter.blendMode);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, input.texture.texture);
this.quad.vao.draw(this.renderer.gl.TRIANGLES, 6, 0);
gl.bindTexture(gl.TEXTURE_2D, tex._glTextures[this.renderer.CONTEXT_UID].texture);
};
/**
* Uploads the uniforms of the filter.
*
* @param {GLShader} shader - The underlying gl shader.
* @param {PIXI.Filter} filter - The filter we are synchronizing.
*/
FilterManager.prototype.syncUniforms = function syncUniforms(shader, filter) {
var uniformData = filter.uniformData;
var uniforms = filter.uniforms;
// 0 is reserved for the PixiJS texture so we start at 1!
var textureCount = 1;
var currentState = void 0;
// filterArea and filterClamp that are handled by FilterManager directly
// they must not appear in uniformData
if (shader.uniforms.filterArea) {
currentState = this.filterData.stack[this.filterData.index];
var filterArea = shader.uniforms.filterArea;
filterArea[0] = currentState.renderTarget.size.width;
filterArea[1] = currentState.renderTarget.size.height;
filterArea[2] = currentState.sourceFrame.x;
filterArea[3] = currentState.sourceFrame.y;
shader.uniforms.filterArea = filterArea;
}
// use this to clamp displaced texture coords so they belong to filterArea
// see displacementFilter fragment shader for an example
if (shader.uniforms.filterClamp) {
currentState = currentState || this.filterData.stack[this.filterData.index];
var filterClamp = shader.uniforms.filterClamp;
filterClamp[0] = 0;
filterClamp[1] = 0;
filterClamp[2] = (currentState.sourceFrame.width - 1) / currentState.renderTarget.size.width;
filterClamp[3] = (currentState.sourceFrame.height - 1) / currentState.renderTarget.size.height;
shader.uniforms.filterClamp = filterClamp;
}
// TODO Caching layer..
for (var i in uniformData) {
if (!shader.uniforms.data[i]) {
continue;
}
var type = uniformData[i].type;
if (type === 'sampler2d' && uniforms[i] !== 0) {
if (uniforms[i].baseTexture) {
shader.uniforms[i] = this.renderer.bindTexture(uniforms[i].baseTexture, textureCount);
} else {
shader.uniforms[i] = textureCount;
// TODO
// this is helpful as renderTargets can also be set.
// Although thinking about it, we could probably
// make the filter texture cache return a RenderTexture
// rather than a renderTarget
var gl = this.renderer.gl;
this.renderer.boundTextures[textureCount] = this.renderer.emptyTextures[textureCount];
gl.activeTexture(gl.TEXTURE0 + textureCount);
uniforms[i].texture.bind();
}
textureCount++;
} else if (type === 'mat3') {
// check if its PixiJS matrix..
if (uniforms[i].a !== undefined) {
shader.uniforms[i] = uniforms[i].toArray(true);
} else {
shader.uniforms[i] = uniforms[i];
}
} else if (type === 'vec2') {
// check if its a point..
if (uniforms[i].x !== undefined) {
var val = shader.uniforms[i] || new Float32Array(2);
val[0] = uniforms[i].x;
val[1] = uniforms[i].y;
shader.uniforms[i] = val;
} else {
shader.uniforms[i] = uniforms[i];
}
} else if (type === 'float') {
if (shader.uniforms.data[i].value !== uniformData[i]) {
shader.uniforms[i] = uniforms[i];
}
} else {
shader.uniforms[i] = uniforms[i];
}
}
};
/**
* Gets a render target from the pool, or creates a new one.
*
* @param {boolean} clear - Should we clear the render texture when we get it?
* @param {number} resolution - The resolution of the target.
* @return {PIXI.RenderTarget} The new render target
*/
FilterManager.prototype.getRenderTarget = function getRenderTarget(clear, resolution) {
var currentState = this.filterData.stack[this.filterData.index];
var renderTarget = this.getPotRenderTarget(this.renderer.gl, currentState.sourceFrame.width, currentState.sourceFrame.height, resolution || currentState.resolution);
renderTarget.setFrame(currentState.destinationFrame, currentState.sourceFrame);
return renderTarget;
};
/**
* Returns a render target to the pool.
*
* @param {PIXI.RenderTarget} renderTarget - The render target to return.
*/
FilterManager.prototype.returnRenderTarget = function returnRenderTarget(renderTarget) {
this.freePotRenderTarget(renderTarget);
};
/**
* Calculates the mapped matrix.
*
* TODO playing around here.. this is temporary - (will end up in the shader)
* this returns a matrix that will normalise map filter cords in the filter to screen space
*
* @param {PIXI.Matrix} outputMatrix - the matrix to output to.
* @return {PIXI.Matrix} The mapped matrix.
*/
FilterManager.prototype.calculateScreenSpaceMatrix = function calculateScreenSpaceMatrix(outputMatrix) {
var currentState = this.filterData.stack[this.filterData.index];
return filterTransforms.calculateScreenSpaceMatrix(outputMatrix, currentState.sourceFrame, currentState.renderTarget.size);
};
/**
* Multiply vTextureCoord to this matrix to achieve (0,0,1,1) for filterArea
*
* @param {PIXI.Matrix} outputMatrix - The matrix to output to.
* @return {PIXI.Matrix} The mapped matrix.
*/
FilterManager.prototype.calculateNormalizedScreenSpaceMatrix = function calculateNormalizedScreenSpaceMatrix(outputMatrix) {
var currentState = this.filterData.stack[this.filterData.index];
return filterTransforms.calculateNormalizedScreenSpaceMatrix(outputMatrix, currentState.sourceFrame, currentState.renderTarget.size, currentState.destinationFrame);
};
/**
* This will map the filter coord so that a texture can be used based on the transform of a sprite
*
* @param {PIXI.Matrix} outputMatrix - The matrix to output to.
* @param {PIXI.Sprite} sprite - The sprite to map to.
* @return {PIXI.Matrix} The mapped matrix.
*/
FilterManager.prototype.calculateSpriteMatrix = function calculateSpriteMatrix(outputMatrix, sprite) {
var currentState = this.filterData.stack[this.filterData.index];
return filterTransforms.calculateSpriteMatrix(outputMatrix, currentState.sourceFrame, currentState.renderTarget.size, sprite);
};
/**
* Destroys this Filter Manager.
*
* @param {boolean} [contextLost=false] context was lost, do not free shaders
*
*/
FilterManager.prototype.destroy = function destroy() {
var contextLost = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var renderer = this.renderer;
var filters = this.managedFilters;
renderer.off('prerender', this.onPrerender, this);
for (var i = 0; i < filters.length; i++) {
if (!contextLost) {
filters[i].glShaders[renderer.CONTEXT_UID].destroy();
}
delete filters[i].glShaders[renderer.CONTEXT_UID];
}
this.shaderCache = {};
if (!contextLost) {
this.emptyPool();
} else {
this.pool = {};
}
};
/**
* Gets a Power-of-Two render texture.
*
* TODO move to a separate class could be on renderer?
* also - could cause issue with multiple contexts?
*
* @private
* @param {WebGLRenderingContext} gl - The webgl rendering context
* @param {number} minWidth - The minimum width of the render target.
* @param {number} minHeight - The minimum height of the render target.
* @param {number} resolution - The resolution of the render target.
* @return {PIXI.RenderTarget} The new render target.
*/
FilterManager.prototype.getPotRenderTarget = function getPotRenderTarget(gl, minWidth, minHeight, resolution) {
var key = screenKey;
minWidth *= resolution;
minHeight *= resolution;
if (minWidth !== this._screenWidth || minHeight !== this._screenHeight) {
// TODO you could return a bigger texture if there is not one in the pool?
minWidth = _bitTwiddle2.default.nextPow2(minWidth);
minHeight = _bitTwiddle2.default.nextPow2(minHeight);
key = (minWidth & 0xFFFF) << 16 | minHeight & 0xFFFF;
}
if (!this.pool[key]) {
this.pool[key] = [];
}
var renderTarget = this.pool[key].pop();
// creating render target will cause texture to be bound!
if (!renderTarget) {
// temporary bypass cache..
var tex = this.renderer.boundTextures[0];
gl.activeTexture(gl.TEXTURE0);
// internally - this will cause a texture to be bound..
renderTarget = new _RenderTarget2.default(gl, minWidth, minHeight, null, 1);
// set the current one back
gl.bindTexture(gl.TEXTURE_2D, tex._glTextures[this.renderer.CONTEXT_UID].texture);
}
// manually tweak the resolution...
// this will not modify the size of the frame buffer, just its resolution.
renderTarget.resolution = resolution;
renderTarget.defaultFrame.width = renderTarget.size.width = minWidth / resolution;
renderTarget.defaultFrame.height = renderTarget.size.height = minHeight / resolution;
renderTarget.filterPoolKey = key;
return renderTarget;
};
/**
* Empties the texture pool.
*
*/
FilterManager.prototype.emptyPool = function emptyPool() {
for (var i in this.pool) {
var textures = this.pool[i];
if (textures) {
for (var j = 0; j < textures.length; j++) {
textures[j].destroy(true);
}
}
}
this.pool = {};
};
/**
* Frees a render target back into the pool.
*
* @param {PIXI.RenderTarget} renderTarget - The renderTarget to free
*/
FilterManager.prototype.freePotRenderTarget = function freePotRenderTarget(renderTarget) {
this.pool[renderTarget.filterPoolKey].push(renderTarget);
};
/**
* Called before the renderer starts rendering.
*
*/
FilterManager.prototype.onPrerender = function onPrerender() {
if (this._screenWidth !== this.renderer.view.width || this._screenHeight !== this.renderer.view.height) {
this._screenWidth = this.renderer.view.width;
this._screenHeight = this.renderer.view.height;
var textures = this.pool[screenKey];
if (textures) {
for (var j = 0; j < textures.length; j++) {
textures[j].destroy(true);
}
}
this.pool[screenKey] = [];
}
};
return FilterManager;
}(_WebGLManager3.default);
exports.default = FilterManager;
//# sourceMappingURL=FilterManager.js.map
/***/ }),
/* 474 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.calculateScreenSpaceMatrix = calculateScreenSpaceMatrix;
exports.calculateNormalizedScreenSpaceMatrix = calculateNormalizedScreenSpaceMatrix;
exports.calculateSpriteMatrix = calculateSpriteMatrix;
var _math = __webpack_require__(14);
/**
* Calculates the mapped matrix
* @param filterArea {Rectangle} The filter area
* @param sprite {Sprite} the target sprite
* @param outputMatrix {Matrix} @alvin
* @private
*/
// TODO playing around here.. this is temporary - (will end up in the shader)
// this returns a matrix that will normalise map filter cords in the filter to screen space
function calculateScreenSpaceMatrix(outputMatrix, filterArea, textureSize) {
// let worldTransform = sprite.worldTransform.copy(Matrix.TEMP_MATRIX),
// let texture = {width:1136, height:700};//sprite._texture.baseTexture;
// TODO unwrap?
var mappedMatrix = outputMatrix.identity();
mappedMatrix.translate(filterArea.x / textureSize.width, filterArea.y / textureSize.height);
mappedMatrix.scale(textureSize.width, textureSize.height);
return mappedMatrix;
}
function calculateNormalizedScreenSpaceMatrix(outputMatrix, filterArea, textureSize) {
var mappedMatrix = outputMatrix.identity();
mappedMatrix.translate(filterArea.x / textureSize.width, filterArea.y / textureSize.height);
var translateScaleX = textureSize.width / filterArea.width;
var translateScaleY = textureSize.height / filterArea.height;
mappedMatrix.scale(translateScaleX, translateScaleY);
return mappedMatrix;
}
// this will map the filter coord so that a texture can be used based on the transform of a sprite
function calculateSpriteMatrix(outputMatrix, filterArea, textureSize, sprite) {
var orig = sprite._texture.orig;
var mappedMatrix = outputMatrix.set(textureSize.width, 0, 0, textureSize.height, filterArea.x, filterArea.y);
var worldTransform = sprite.worldTransform.copy(_math.Matrix.TEMP_MATRIX);
worldTransform.invert();
mappedMatrix.prepend(worldTransform);
mappedMatrix.scale(1.0 / orig.width, 1.0 / orig.height);
mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y);
return mappedMatrix;
}
//# sourceMappingURL=filterTransforms.js.map
/***/ }),
/* 475 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _pixiGlCore = __webpack_require__(23);
var _const = __webpack_require__(3);
var _RenderTarget = __webpack_require__(87);
var _RenderTarget2 = _interopRequireDefault(_RenderTarget);
var _utils = __webpack_require__(7);
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"); } }
/**
* Helper class to create a webGL Texture
*
* @class
* @memberof PIXI
*/
var TextureManager = function () {
/**
* @param {PIXI.WebGLRenderer} renderer - A reference to the current renderer
*/
function TextureManager(renderer) {
_classCallCheck(this, TextureManager);
/**
* A reference to the current renderer
*
* @member {PIXI.WebGLRenderer}
*/
this.renderer = renderer;
/**
* The current WebGL rendering context
*
* @member {WebGLRenderingContext}
*/
this.gl = renderer.gl;
/**
* Track textures in the renderer so we can no longer listen to them on destruction.
*
* @member {Array<*>}
* @private
*/
this._managedTextures = [];
}
/**
* Binds a texture.
*
*/
TextureManager.prototype.bindTexture = function bindTexture() {}
// empty
/**
* Gets a texture.
*
*/
;
TextureManager.prototype.getTexture = function getTexture() {}
// empty
/**
* Updates and/or Creates a WebGL texture for the renderer's context.
*
* @param {PIXI.BaseTexture|PIXI.Texture} texture - the texture to update
* @param {number} location - the location the texture will be bound to.
* @return {GLTexture} The gl texture.
*/
;
TextureManager.prototype.updateTexture = function updateTexture(texture, location) {
// assume it good!
// texture = texture.baseTexture || texture;
var gl = this.gl;
var isRenderTexture = !!texture._glRenderTargets;
if (!texture.hasLoaded) {
return null;
}
var boundTextures = this.renderer.boundTextures;
// if the location is undefined then this may have been called by n event.
// this being the case the texture may already be bound to a slot. As a texture can only be bound once
// we need to find its current location if it exists.
if (location === undefined) {
location = 0;
// TODO maybe we can use texture bound ids later on...
// check if texture is already bound..
for (var i = 0; i < boundTextures.length; ++i) {
if (boundTextures[i] === texture) {
location = i;
break;
}
}
}
boundTextures[location] = texture;
gl.activeTexture(gl.TEXTURE0 + location);
var glTexture = texture._glTextures[this.renderer.CONTEXT_UID];
if (!glTexture) {
if (isRenderTexture) {
var renderTarget = new _RenderTarget2.default(this.gl, texture.width, texture.height, texture.scaleMode, texture.resolution);
renderTarget.resize(texture.width, texture.height);
texture._glRenderTargets[this.renderer.CONTEXT_UID] = renderTarget;
glTexture = renderTarget.texture;
// framebuffer constructor disactivates current framebuffer
if (!this.renderer._activeRenderTarget.root) {
this.renderer._activeRenderTarget.frameBuffer.bind();
}
} else {
glTexture = new _pixiGlCore.GLTexture(this.gl, null, null, null, null);
glTexture.bind(location);
glTexture.premultiplyAlpha = true;
glTexture.upload(texture.source);
}
texture._glTextures[this.renderer.CONTEXT_UID] = glTexture;
texture.on('update', this.updateTexture, this);
texture.on('dispose', this.destroyTexture, this);
this._managedTextures.push(texture);
if (texture.isPowerOfTwo) {
if (texture.mipmap) {
glTexture.enableMipmap();
}
if (texture.wrapMode === _const.WRAP_MODES.CLAMP) {
glTexture.enableWrapClamp();
} else if (texture.wrapMode === _const.WRAP_MODES.REPEAT) {
glTexture.enableWrapRepeat();
} else {
glTexture.enableWrapMirrorRepeat();
}
} else {
glTexture.enableWrapClamp();
}
if (texture.scaleMode === _const.SCALE_MODES.NEAREST) {
glTexture.enableNearestScaling();
} else {
glTexture.enableLinearScaling();
}
}
// the texture already exists so we only need to update it..
else if (isRenderTexture) {
texture._glRenderTargets[this.renderer.CONTEXT_UID].resize(texture.width, texture.height);
} else {
glTexture.upload(texture.source);
}
return glTexture;
};
/**
* Deletes the texture from WebGL
*
* @param {PIXI.BaseTexture|PIXI.Texture} texture - the texture to destroy
* @param {boolean} [skipRemove=false] - Whether to skip removing the texture from the TextureManager.
*/
TextureManager.prototype.destroyTexture = function destroyTexture(texture, skipRemove) {
texture = texture.baseTexture || texture;
if (!texture.hasLoaded) {
return;
}
var renderer = this.renderer;
var uid = renderer.CONTEXT_UID;
var glTextures = texture._glTextures;
var glRenderTargets = texture._glRenderTargets;
if (glTextures[uid]) {
renderer.unbindTexture(texture);
glTextures[uid].destroy();
texture.off('update', this.updateTexture, this);
texture.off('dispose', this.destroyTexture, this);
delete glTextures[uid];
if (!skipRemove) {
var i = this._managedTextures.indexOf(texture);
if (i !== -1) {
(0, _utils.removeItems)(this._managedTextures, i, 1);
}
}
}
if (glRenderTargets && glRenderTargets[uid]) {
if (renderer._activeRenderTarget === glRenderTargets[uid]) {
renderer.bindRenderTarget(renderer.rootRenderTarget);
}
glRenderTargets[uid].destroy();
delete glRenderTargets[uid];
}
};
/**
* Deletes all the textures from WebGL
*/
TextureManager.prototype.removeAll = function removeAll() {
// empty all the old gl textures as they are useless now
for (var i = 0; i < this._managedTextures.length; ++i) {
var texture = this._managedTextures[i];
if (texture._glTextures[this.renderer.CONTEXT_UID]) {
delete texture._glTextures[this.renderer.CONTEXT_UID];
}
}
};
/**
* Destroys this manager and removes all its textures
*/
TextureManager.prototype.destroy = function destroy() {
// destroy managed textures
for (var i = 0; i < this._managedTextures.length; ++i) {
var texture = this._managedTextures[i];
this.destroyTexture(texture, true);
texture.off('update', this.updateTexture, this);
texture.off('dispose', this.destroyTexture, this);
}
this._managedTextures = null;
};
return TextureManager;
}();
exports.default = TextureManager;
//# sourceMappingURL=TextureManager.js.map
/***/ }),
/* 476 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
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"); } }
/**
* TextureGarbageCollector. This class manages the GPU and ensures that it does not get clogged
* up with textures that are no longer being used.
*
* @class
* @memberof PIXI
*/
var TextureGarbageCollector = function () {
/**
* @param {PIXI.WebGLRenderer} renderer - The renderer this manager works for.
*/
function TextureGarbageCollector(renderer) {
_classCallCheck(this, TextureGarbageCollector);
this.renderer = renderer;
this.count = 0;
this.checkCount = 0;
this.maxIdle = _settings2.default.GC_MAX_IDLE;
this.checkCountMax = _settings2.default.GC_MAX_CHECK_COUNT;
this.mode = _settings2.default.GC_MODE;
}
/**
* Checks to see when the last time a texture was used
* if the texture has not been used for a specified amount of time it will be removed from the GPU
*/
TextureGarbageCollector.prototype.update = function update() {
this.count++;
if (this.mode === _const.GC_MODES.MANUAL) {
return;
}
this.checkCount++;
if (this.checkCount > this.checkCountMax) {
this.checkCount = 0;
this.run();
}
};
/**
* Checks to see when the last time a texture was used
* if the texture has not been used for a specified amount of time it will be removed from the GPU
*/
TextureGarbageCollector.prototype.run = function run() {
var tm = this.renderer.textureManager;
var managedTextures = tm._managedTextures;
var wasRemoved = false;
for (var i = 0; i < managedTextures.length; i++) {
var texture = managedTextures[i];
// only supports non generated textures at the moment!
if (!texture._glRenderTargets && this.count - texture.touched > this.maxIdle) {
tm.destroyTexture(texture, true);
managedTextures[i] = null;
wasRemoved = true;
}
}
if (wasRemoved) {
var j = 0;
for (var _i = 0; _i < managedTextures.length; _i++) {
if (managedTextures[_i] !== null) {
managedTextures[j++] = managedTextures[_i];
}
}
managedTextures.length = j;
}
};
/**
* Removes all the textures within the specified displayObject and its children from the GPU
*
* @param {PIXI.DisplayObject} displayObject - the displayObject to remove the textures from.
*/
TextureGarbageCollector.prototype.unload = function unload(displayObject) {
var tm = this.renderer.textureManager;
// only destroy non generated textures
if (displayObject._texture && displayObject._texture._glRenderTargets) {
tm.destroyTexture(displayObject._texture, true);
}
for (var i = displayObject.children.length - 1; i >= 0; i--) {
this.unload(displayObject.children[i]);
}
};
return TextureGarbageCollector;
}();
exports.default = TextureGarbageCollector;
//# sourceMappingURL=TextureGarbageCollector.js.map
/***/ }),
/* 477 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _mapWebGLBlendModesToPixi = __webpack_require__(478);
var _mapWebGLBlendModesToPixi2 = _interopRequireDefault(_mapWebGLBlendModesToPixi);
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"); } }
var BLEND = 0;
var DEPTH_TEST = 1;
var FRONT_FACE = 2;
var CULL_FACE = 3;
var BLEND_FUNC = 4;
/**
* A WebGL state machines
*
* @memberof PIXI
* @class
*/
var WebGLState = function () {
/**
* @param {WebGLRenderingContext} gl - The current WebGL rendering context
*/
function WebGLState(gl) {
_classCallCheck(this, WebGLState);
/**
* The current active state
*
* @member {Uint8Array}
*/
this.activeState = new Uint8Array(16);
/**
* The default state
*
* @member {Uint8Array}
*/
this.defaultState = new Uint8Array(16);
// default blend mode..
this.defaultState[0] = 1;
/**
* The current state index in the stack
*
* @member {number}
* @private
*/
this.stackIndex = 0;
/**
* The stack holding all the different states
*
* @member {Array<*>}
* @private
*/
this.stack = [];
/**
* The current WebGL rendering context
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
this.maxAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
this.attribState = {
tempAttribState: new Array(this.maxAttribs),
attribState: new Array(this.maxAttribs)
};
this.blendModes = (0, _mapWebGLBlendModesToPixi2.default)(gl);
// check we have vao..
this.nativeVaoExtension = gl.getExtension('OES_vertex_array_object') || gl.getExtension('MOZ_OES_vertex_array_object') || gl.getExtension('WEBKIT_OES_vertex_array_object');
}
/**
* Pushes a new active state
*/
WebGLState.prototype.push = function push() {
// next state..
var state = this.stack[this.stackIndex];
if (!state) {
state = this.stack[this.stackIndex] = new Uint8Array(16);
}
++this.stackIndex;
// copy state..
// set active state so we can force overrides of gl state
for (var i = 0; i < this.activeState.length; i++) {
state[i] = this.activeState[i];
}
};
/**
* Pops a state out
*/
WebGLState.prototype.pop = function pop() {
var state = this.stack[--this.stackIndex];
this.setState(state);
};
/**
* Sets the current state
*
* @param {*} state - The state to set.
*/
WebGLState.prototype.setState = function setState(state) {
this.setBlend(state[BLEND]);
this.setDepthTest(state[DEPTH_TEST]);
this.setFrontFace(state[FRONT_FACE]);
this.setCullFace(state[CULL_FACE]);
this.setBlendMode(state[BLEND_FUNC]);
};
/**
* Enables or disabled blending.
*
* @param {boolean} value - Turn on or off webgl blending.
*/
WebGLState.prototype.setBlend = function setBlend(value) {
value = value ? 1 : 0;
if (this.activeState[BLEND] === value) {
return;
}
this.activeState[BLEND] = value;
this.gl[value ? 'enable' : 'disable'](this.gl.BLEND);
};
/**
* Sets the blend mode.
*
* @param {number} value - The blend mode to set to.
*/
WebGLState.prototype.setBlendMode = function setBlendMode(value) {
if (value === this.activeState[BLEND_FUNC]) {
return;
}
this.activeState[BLEND_FUNC] = value;
var mode = this.blendModes[value];
if (mode.length === 2) {
this.gl.blendFunc(mode[0], mode[1]);
} else {
this.gl.blendFuncSeparate(mode[0], mode[1], mode[2], mode[3]);
}
};
/**
* Sets whether to enable or disable depth test.
*
* @param {boolean} value - Turn on or off webgl depth testing.
*/
WebGLState.prototype.setDepthTest = function setDepthTest(value) {
value = value ? 1 : 0;
if (this.activeState[DEPTH_TEST] === value) {
return;
}
this.activeState[DEPTH_TEST] = value;
this.gl[value ? 'enable' : 'disable'](this.gl.DEPTH_TEST);
};
/**
* Sets whether to enable or disable cull face.
*
* @param {boolean} value - Turn on or off webgl cull face.
*/
WebGLState.prototype.setCullFace = function setCullFace(value) {
value = value ? 1 : 0;
if (this.activeState[CULL_FACE] === value) {
return;
}
this.activeState[CULL_FACE] = value;
this.gl[value ? 'enable' : 'disable'](this.gl.CULL_FACE);
};
/**
* Sets the gl front face.
*
* @param {boolean} value - true is clockwise and false is counter-clockwise
*/
WebGLState.prototype.setFrontFace = function setFrontFace(value) {
value = value ? 1 : 0;
if (this.activeState[FRONT_FACE] === value) {
return;
}
this.activeState[FRONT_FACE] = value;
this.gl.frontFace(this.gl[value ? 'CW' : 'CCW']);
};
/**
* Disables all the vaos in use
*
*/
WebGLState.prototype.resetAttributes = function resetAttributes() {
for (var i = 0; i < this.attribState.tempAttribState.length; i++) {
this.attribState.tempAttribState[i] = 0;
}
for (var _i = 0; _i < this.attribState.attribState.length; _i++) {
this.attribState.attribState[_i] = 0;
}
// im going to assume one is always active for performance reasons.
for (var _i2 = 1; _i2 < this.maxAttribs; _i2++) {
this.gl.disableVertexAttribArray(_i2);
}
};
// used
/**
* Resets all the logic and disables the vaos
*/
WebGLState.prototype.resetToDefault = function resetToDefault() {
// unbind any VAO if they exist..
if (this.nativeVaoExtension) {
this.nativeVaoExtension.bindVertexArrayOES(null);
}
// reset all attributes..
this.resetAttributes();
// set active state so we can force overrides of gl state
for (var i = 0; i < this.activeState.length; ++i) {
this.activeState[i] = 32;
}
this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, false);
this.setState(this.defaultState);
};
return WebGLState;
}();
exports.default = WebGLState;
//# sourceMappingURL=WebGLState.js.map
/***/ }),
/* 478 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = mapWebGLBlendModesToPixi;
var _const = __webpack_require__(3);
/**
* Maps gl blend combinations to WebGL.
*
* @memberof PIXI
* @function mapWebGLBlendModesToPixi
* @private
* @param {WebGLRenderingContext} gl - The rendering context.
* @param {string[]} [array=[]] - The array to output into.
* @return {string[]} Mapped modes.
*/
function mapWebGLBlendModesToPixi(gl) {
var array = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
// TODO - premultiply alpha would be different.
// add a boolean for that!
array[_const.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.ADD] = [gl.ONE, gl.DST_ALPHA];
array[_const.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.SCREEN] = [gl.ONE, gl.ONE_MINUS_SRC_COLOR];
array[_const.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
// not-premultiplied blend modes
array[_const.BLEND_MODES.NORMAL_NPM] = [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[_const.BLEND_MODES.ADD_NPM] = [gl.SRC_ALPHA, gl.DST_ALPHA, gl.ONE, gl.DST_ALPHA];
array[_const.BLEND_MODES.SCREEN_NPM] = [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_COLOR, gl.ONE, gl.ONE_MINUS_SRC_COLOR];
return array;
}
//# sourceMappingURL=mapWebGLBlendModesToPixi.js.map
/***/ }),
/* 479 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = mapWebGLDrawModesToPixi;
var _const = __webpack_require__(3);
/**
* Generic Mask Stack data structure.
*
* @memberof PIXI
* @function mapWebGLDrawModesToPixi
* @private
* @param {WebGLRenderingContext} gl - The current WebGL drawing context
* @param {object} [object={}] - The object to map into
* @return {object} The mapped draw modes.
*/
function mapWebGLDrawModesToPixi(gl) {
var object = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
object[_const.DRAW_MODES.POINTS] = gl.POINTS;
object[_const.DRAW_MODES.LINES] = gl.LINES;
object[_const.DRAW_MODES.LINE_LOOP] = gl.LINE_LOOP;
object[_const.DRAW_MODES.LINE_STRIP] = gl.LINE_STRIP;
object[_const.DRAW_MODES.TRIANGLES] = gl.TRIANGLES;
object[_const.DRAW_MODES.TRIANGLE_STRIP] = gl.TRIANGLE_STRIP;
object[_const.DRAW_MODES.TRIANGLE_FAN] = gl.TRIANGLE_FAN;
return object;
}
//# sourceMappingURL=mapWebGLDrawModesToPixi.js.map
/***/ }),
/* 480 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = validateContext;
function validateContext(gl) {
var attributes = gl.getContextAttributes();
// this is going to be fairly simple for now.. but at least we have room to grow!
if (!attributes.stencil) {
/* eslint-disable no-console */
console.warn('Provided WebGL context does not have a stencil buffer, masks may not render correctly');
/* eslint-enable no-console */
}
}
//# sourceMappingURL=validateContext.js.map
/***/ }),
/* 481 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = generateMultiTextureShader;
var _Shader = __webpack_require__(67);
var _Shader2 = _interopRequireDefault(_Shader);
var _path = __webpack_require__(34);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var fragTemplate = ['varying vec2 vTextureCoord;', 'varying vec4 vColor;', 'varying float vTextureId;', 'uniform sampler2D uSamplers[%count%];', 'void main(void){', 'vec4 color;', '%forloop%', 'gl_FragColor = color * vColor;', '}'].join('\n');
function generateMultiTextureShader(gl, maxTextures) {
var vertexSrc = 'precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor;\n}\n';
var fragmentSrc = fragTemplate;
fragmentSrc = fragmentSrc.replace(/%count%/gi, maxTextures);
fragmentSrc = fragmentSrc.replace(/%forloop%/gi, generateSampleSrc(maxTextures));
var shader = new _Shader2.default(gl, vertexSrc, fragmentSrc);
var sampleValues = [];
for (var i = 0; i < maxTextures; i++) {
sampleValues[i] = i;
}
shader.bind();
shader.uniforms.uSamplers = sampleValues;
return shader;
}
function generateSampleSrc(maxTextures) {
var src = '';
src += '\n';
src += '\n';
for (var i = 0; i < maxTextures; i++) {
if (i > 0) {
src += '\nelse ';
}
if (i < maxTextures - 1) {
src += 'if(vTextureId < ' + i + '.5)';
}
src += '\n{';
src += '\n\tcolor = texture2D(uSamplers[' + i + '], vTextureCoord);';
src += '\n}';
}
src += '\n';
src += '\n';
return src;
}
//# sourceMappingURL=generateMultiTextureShader.js.map
/***/ }),
/* 482 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = checkMaxIfStatmentsInShader;
var _pixiGlCore = __webpack_require__(23);
var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var fragTemplate = ['precision mediump float;', 'void main(void){', 'float test = 0.1;', '%forloop%', 'gl_FragColor = vec4(0.0);', '}'].join('\n');
function checkMaxIfStatmentsInShader(maxIfs, gl) {
var createTempContext = !gl;
// @if DEBUG
if (maxIfs === 0) {
throw new Error('Invalid value of `0` passed to `checkMaxIfStatementsInShader`');
}
// @endif
if (createTempContext) {
var tinyCanvas = document.createElement('canvas');
tinyCanvas.width = 1;
tinyCanvas.height = 1;
gl = _pixiGlCore2.default.createContext(tinyCanvas);
}
var shader = gl.createShader(gl.FRAGMENT_SHADER);
while (true) // eslint-disable-line no-constant-condition
{
var fragmentSrc = fragTemplate.replace(/%forloop%/gi, generateIfTestSrc(maxIfs));
gl.shaderSource(shader, fragmentSrc);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
maxIfs = maxIfs / 2 | 0;
} else {
// valid!
break;
}
}
if (createTempContext) {
// get rid of context
if (gl.getExtension('WEBGL_lose_context')) {
gl.getExtension('WEBGL_lose_context').loseContext();
}
}
return maxIfs;
}
function generateIfTestSrc(maxIfs) {
var src = '';
for (var i = 0; i < maxIfs; ++i) {
if (i > 0) {
src += '\nelse ';
}
if (i < maxIfs - 1) {
src += 'if(test == ' + i + '.0){}';
}
}
return src;
}
//# sourceMappingURL=checkMaxIfStatmentsInShader.js.map
/***/ }),
/* 483 */
/***/ (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 Buffer = function () {
/**
* @param {number} size - The size of the buffer in bytes.
*/
function Buffer(size) {
_classCallCheck(this, Buffer);
this.vertices = new ArrayBuffer(size);
/**
* View on the vertices as a Float32Array for positions
*
* @member {Float32Array}
*/
this.float32View = new Float32Array(this.vertices);
/**
* View on the vertices as a Uint32Array for uvs
*
* @member {Float32Array}
*/
this.uint32View = new Uint32Array(this.vertices);
}
/**
* Destroys the buffer.
*
*/
Buffer.prototype.destroy = function destroy() {
this.vertices = null;
this.positions = null;
this.uvs = null;
this.colors = null;
};
return Buffer;
}();
exports.default = Buffer;
//# sourceMappingURL=BatchBuffer.js.map
/***/ }),
/* 484 */
/***/ (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 _Sprite2 = __webpack_require__(125);
var _Sprite3 = _interopRequireDefault(_Sprite2);
var _Texture = __webpack_require__(40);
var _Texture2 = _interopRequireDefault(_Texture);
var _math = __webpack_require__(14);
var _utils = __webpack_require__(7);
var _const = __webpack_require__(3);
var _settings = __webpack_require__(13);
var _settings2 = _interopRequireDefault(_settings);
var _TextStyle = __webpack_require__(196);
var _TextStyle2 = _interopRequireDefault(_TextStyle);
var _TextMetrics = __webpack_require__(197);
var _TextMetrics2 = _interopRequireDefault(_TextMetrics);
var _trimCanvas = __webpack_require__(485);
var _trimCanvas2 = _interopRequireDefault(_trimCanvas);
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; } /* eslint max-depth: [2, 8] */
var defaultDestroyOptions = {
texture: true,
children: false,
baseTexture: true
};
/**
* A Text Object will create a line or multiple lines of text. To split a line you can use '\n' in your text string,
* or add a wordWrap property set to true and and wordWrapWidth property with a value in the style object.
*
* A Text can be created directly from a string and a style object,
* which can be generated [here](https://pixijs.io/pixi-text-style).
*
* ```js
* let text = new PIXI.Text('This is a PixiJS text',{fontFamily : 'Arial', fontSize: 24, fill : 0xff1010, align : 'center'});
* ```
*
* @class
* @extends PIXI.Sprite
* @memberof PIXI
*/
var Text = function (_Sprite) {
_inherits(Text, _Sprite);
/**
* @param {string} text - The string that you would like the text to display
* @param {object|PIXI.TextStyle} [style] - The style parameters
* @param {HTMLCanvasElement} [canvas] - The canvas element for drawing text
*/
function Text(text, style, canvas) {
_classCallCheck(this, Text);
canvas = canvas || document.createElement('canvas');
canvas.width = 3;
canvas.height = 3;
var texture = _Texture2.default.fromCanvas(canvas, _settings2.default.SCALE_MODE, 'text');
texture.orig = new _math.Rectangle();
texture.trim = new _math.Rectangle();
// base texture is already automatically added to the cache, now adding the actual texture
var _this = _possibleConstructorReturn(this, _Sprite.call(this, texture));
_Texture2.default.addToCache(_this._texture, _this._texture.baseTexture.textureCacheIds[0]);
/**
* The canvas element that everything is drawn to
*
* @member {HTMLCanvasElement}
*/
_this.canvas = canvas;
/**
* The canvas 2d context that everything is drawn with
* @member {CanvasRenderingContext2D}
*/
_this.context = _this.canvas.getContext('2d');
/**
* The resolution / device pixel ratio of the canvas. This is set automatically by the renderer.
* @member {number}
* @default 1
*/
_this.resolution = _settings2.default.RESOLUTION;
/**
* Private tracker for the current text.
*
* @member {string}
* @private
*/
_this._text = null;
/**
* Private tracker for the current style.
*
* @member {object}
* @private
*/
_this._style = null;
/**
* Private listener to track style changes.
*
* @member {Function}
* @private
*/
_this._styleListener = null;
/**
* Private tracker for the current font.
*
* @member {string}
* @private
*/
_this._font = '';
_this.text = text;
_this.style = style;
_this.localStyleID = -1;
return _this;
}
/**
* Renders text and updates it when needed.
*
* @private
* @param {boolean} respectDirty - Whether to abort updating the text if the Text isn't dirty and the function is called.
*/
Text.prototype.updateText = function updateText(respectDirty) {
var style = this._style;
// check if style has changed..
if (this.localStyleID !== style.styleID) {
this.dirty = true;
this.localStyleID = style.styleID;
}
if (!this.dirty && respectDirty) {
return;
}
this._font = this._style.toFontString();
var context = this.context;
var measured = _TextMetrics2.default.measureText(this._text, this._style, this._style.wordWrap, this.canvas);
var width = measured.width;
var height = measured.height;
var lines = measured.lines;
var lineHeight = measured.lineHeight;
var lineWidths = measured.lineWidths;
var maxLineWidth = measured.maxLineWidth;
var fontProperties = measured.fontProperties;
this.canvas.width = Math.ceil((Math.max(1, width) + style.padding * 2) * this.resolution);
this.canvas.height = Math.ceil((Math.max(1, height) + style.padding * 2) * this.resolution);
context.scale(this.resolution, this.resolution);
context.clearRect(0, 0, this.canvas.width, this.canvas.height);
context.font = this._font;
context.strokeStyle = style.stroke;
context.lineWidth = style.strokeThickness;
context.textBaseline = style.textBaseline;
context.lineJoin = style.lineJoin;
context.miterLimit = style.miterLimit;
var linePositionX = void 0;
var linePositionY = void 0;
if (style.dropShadow) {
context.fillStyle = style.dropShadowColor;
context.globalAlpha = style.dropShadowAlpha;
context.shadowBlur = style.dropShadowBlur;
if (style.dropShadowBlur > 0) {
context.shadowColor = style.dropShadowColor;
}
var xShadowOffset = Math.cos(style.dropShadowAngle) * style.dropShadowDistance;
var yShadowOffset = Math.sin(style.dropShadowAngle) * style.dropShadowDistance;
for (var i = 0; i < lines.length; i++) {
linePositionX = style.strokeThickness / 2;
linePositionY = style.strokeThickness / 2 + i * lineHeight + fontProperties.ascent;
if (style.align === 'right') {
linePositionX += maxLineWidth - lineWidths[i];
} else if (style.align === 'center') {
linePositionX += (maxLineWidth - lineWidths[i]) / 2;
}
if (style.fill) {
this.drawLetterSpacing(lines[i], linePositionX + xShadowOffset + style.padding, linePositionY + yShadowOffset + style.padding);
if (style.stroke && style.strokeThickness) {
context.strokeStyle = style.dropShadowColor;
this.drawLetterSpacing(lines[i], linePositionX + xShadowOffset + style.padding, linePositionY + yShadowOffset + style.padding, true);
context.strokeStyle = style.stroke;
}
}
}
}
// reset the shadow blur and alpha that was set by the drop shadow, for the regular text
context.shadowBlur = 0;
context.globalAlpha = 1;
// set canvas text styles
context.fillStyle = this._generateFillStyle(style, lines);
// draw lines line by line
for (var _i = 0; _i < lines.length; _i++) {
linePositionX = style.strokeThickness / 2;
linePositionY = style.strokeThickness / 2 + _i * lineHeight + fontProperties.ascent;
if (style.align === 'right') {
linePositionX += maxLineWidth - lineWidths[_i];
} else if (style.align === 'center') {
linePositionX += (maxLineWidth - lineWidths[_i]) / 2;
}
if (style.stroke && style.strokeThickness) {
this.drawLetterSpacing(lines[_i], linePositionX + style.padding, linePositionY + style.padding, true);
}
if (style.fill) {
this.drawLetterSpacing(lines[_i], linePositionX + style.padding, linePositionY + style.padding);
}
}
this.updateTexture();
};
/**
* Render the text with letter-spacing.
* @param {string} text - The text to draw
* @param {number} x - Horizontal position to draw the text
* @param {number} y - Vertical position to draw the text
* @param {boolean} [isStroke=false] - Is this drawing for the outside stroke of the
* text? If not, it's for the inside fill
* @private
*/
Text.prototype.drawLetterSpacing = function drawLetterSpacing(text, x, y) {
var isStroke = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var style = this._style;
// letterSpacing of 0 means normal
var letterSpacing = style.letterSpacing;
if (letterSpacing === 0) {
if (isStroke) {
this.context.strokeText(text, x, y);
} else {
this.context.fillText(text, x, y);
}
return;
}
var characters = String.prototype.split.call(text, '');
var currentPosition = x;
var index = 0;
var current = '';
while (index < text.length) {
current = characters[index++];
if (isStroke) {
this.context.strokeText(current, currentPosition, y);
} else {
this.context.fillText(current, currentPosition, y);
}
currentPosition += this.context.measureText(current).width + letterSpacing;
}
};
/**
* Updates texture size based on canvas size
*
* @private
*/
Text.prototype.updateTexture = function updateTexture() {
var canvas = this.canvas;
if (this._style.trim) {
var trimmed = (0, _trimCanvas2.default)(canvas);
if (trimmed.data) {
canvas.width = trimmed.width;
canvas.height = trimmed.height;
this.context.putImageData(trimmed.data, 0, 0);
}
}
var texture = this._texture;
var style = this._style;
var padding = style.trim ? 0 : style.padding;
var baseTexture = texture.baseTexture;
baseTexture.hasLoaded = true;
baseTexture.resolution = this.resolution;
baseTexture.realWidth = canvas.width;
baseTexture.realHeight = canvas.height;
baseTexture.width = canvas.width / this.resolution;
baseTexture.height = canvas.height / this.resolution;
texture.trim.width = texture._frame.width = canvas.width / this.resolution;
texture.trim.height = texture._frame.height = canvas.height / this.resolution;
texture.trim.x = -padding;
texture.trim.y = -padding;
texture.orig.width = texture._frame.width - padding * 2;
texture.orig.height = texture._frame.height - padding * 2;
// call sprite onTextureUpdate to update scale if _width or _height were set
this._onTextureUpdate();
baseTexture.emit('update', baseTexture);
this.dirty = false;
};
/**
* Renders the object using the WebGL renderer
*
* @param {PIXI.WebGLRenderer} renderer - The renderer
*/
Text.prototype.renderWebGL = function renderWebGL(renderer) {
if (this.resolution !== renderer.resolution) {
this.resolution = renderer.resolution;
this.dirty = true;
}
this.updateText(true);
_Sprite.prototype.renderWebGL.call(this, renderer);
};
/**
* Renders the object using the Canvas renderer
*
* @private
* @param {PIXI.CanvasRenderer} renderer - The renderer
*/
Text.prototype._renderCanvas = function _renderCanvas(renderer) {
if (this.resolution !== renderer.resolution) {
this.resolution = renderer.resolution;
this.dirty = true;
}
this.updateText(true);
_Sprite.prototype._renderCanvas.call(this, renderer);
};
/**
* Gets the local bounds of the text object.
*
* @param {Rectangle} rect - The output rectangle.
* @return {Rectangle} The bounds.
*/
Text.prototype.getLocalBounds = function getLocalBounds(rect) {
this.updateText(true);
return _Sprite.prototype.getLocalBounds.call(this, rect);
};
/**
* calculates the bounds of the Text as a rectangle. The bounds calculation takes the worldTransform into account.
*/
Text.prototype._calculateBounds = function _calculateBounds() {
this.updateText(true);
this.calculateVertices();
// if we have already done this on THIS frame.
this._bounds.addQuad(this.vertexData);
};
/**
* Method to be called upon a TextStyle change.
* @private
*/
Text.prototype._onStyleChange = function _onStyleChange() {
this.dirty = true;
};
/**
* Generates the fill style. Can automatically generate a gradient based on the fill style being an array
*
* @private
* @param {object} style - The style.
* @param {string[]} lines - The lines of text.
* @return {string|number|CanvasGradient} The fill style
*/
Text.prototype._generateFillStyle = function _generateFillStyle(style, lines) {
if (!Array.isArray(style.fill)) {
return style.fill;
}
// cocoon on canvas+ cannot generate textures, so use the first colour instead
if (navigator.isCocoonJS) {
return style.fill[0];
}
// the gradient will be evenly spaced out according to how large the array is.
// ['#FF0000', '#00FF00', '#0000FF'] would created stops at 0.25, 0.5 and 0.75
var gradient = void 0;
var totalIterations = void 0;
var currentIteration = void 0;
var stop = void 0;
var width = this.canvas.width / this.resolution;
var height = this.canvas.height / this.resolution;
// make a copy of the style settings, so we can manipulate them later
var fill = style.fill.slice();
var fillGradientStops = style.fillGradientStops.slice();
// wanting to evenly distribute the fills. So an array of 4 colours should give fills of 0.25, 0.5 and 0.75
if (!fillGradientStops.length) {
var lengthPlus1 = fill.length + 1;
for (var i = 1; i < lengthPlus1; ++i) {
fillGradientStops.push(i / lengthPlus1);
}
}
// stop the bleeding of the last gradient on the line above to the top gradient of the this line
// by hard defining the first gradient colour at point 0, and last gradient colour at point 1
fill.unshift(style.fill[0]);
fillGradientStops.unshift(0);
fill.push(style.fill[style.fill.length - 1]);
fillGradientStops.push(1);
if (style.fillGradientType === _const.TEXT_GRADIENT.LINEAR_VERTICAL) {
// start the gradient at the top center of the canvas, and end at the bottom middle of the canvas
gradient = this.context.createLinearGradient(width / 2, 0, width / 2, height);
// we need to repeat the gradient so that each individual line of text has the same vertical gradient effect
// ['#FF0000', '#00FF00', '#0000FF'] over 2 lines would create stops at 0.125, 0.25, 0.375, 0.625, 0.75, 0.875
totalIterations = (fill.length + 1) * lines.length;
currentIteration = 0;
for (var _i2 = 0; _i2 < lines.length; _i2++) {
currentIteration += 1;
for (var j = 0; j < fill.length; j++) {
if (typeof fillGradientStops[j] === 'number') {
stop = fillGradientStops[j] / lines.length + _i2 / lines.length;
} else {
stop = currentIteration / totalIterations;
}
gradient.addColorStop(stop, fill[j]);
currentIteration++;
}
}
} else {
// start the gradient at the center left of the canvas, and end at the center right of the canvas
gradient = this.context.createLinearGradient(0, height / 2, width, height / 2);
// can just evenly space out the gradients in this case, as multiple lines makes no difference
// to an even left to right gradient
totalIterations = fill.length + 1;
currentIteration = 1;
for (var _i3 = 0; _i3 < fill.length; _i3++) {
if (typeof fillGradientStops[_i3] === 'number') {
stop = fillGradientStops[_i3];
} else {
stop = currentIteration / totalIterations;
}
gradient.addColorStop(stop, fill[_i3]);
currentIteration++;
}
}
return gradient;
};
/**
* Destroys this text object.
* Note* Unlike a Sprite, a Text object will automatically destroy its baseTexture and texture as
* the majority of the time the texture will not be shared with any other Sprites.
*
* @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=true] - Should it destroy the current texture of the sprite as well
* @param {boolean} [options.baseTexture=true] - Should it destroy the base texture of the sprite as well
*/
Text.prototype.destroy = function destroy(options) {
if (typeof options === 'boolean') {
options = { children: options };
}
options = Object.assign({}, defaultDestroyOptions, options);
_Sprite.prototype.destroy.call(this, options);
// make sure to reset the the context and canvas.. dont want this hanging around in memory!
this.context = null;
this.canvas = null;
this._style = null;
};
/**
* The width of the Text, setting this will actually modify the scale to achieve the value set
*
* @member {number}
*/
_createClass(Text, [{
key: 'width',
get: function get() {
this.updateText(true);
return Math.abs(this.scale.x) * this._texture.orig.width;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.updateText(true);
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 Text, setting this will actually modify the scale to achieve the value set
*
* @member {number}
*/
}, {
key: 'height',
get: function get() {
this.updateText(true);
return Math.abs(this.scale.y) * this._texture.orig.height;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.updateText(true);
var s = (0, _utils.sign)(this.scale.y) || 1;
this.scale.y = s * value / this._texture.orig.height;
this._height = value;
}
/**
* Set the style of the text. Set up an event listener to listen for changes on the style
* object and mark the text as dirty.
*
* @member {object|PIXI.TextStyle}
*/
}, {
key: 'style',
get: function get() {
return this._style;
},
set: function set(style) // eslint-disable-line require-jsdoc
{
style = style || {};
if (style instanceof _TextStyle2.default) {
this._style = style;
} else {
this._style = new _TextStyle2.default(style);
}
this.localStyleID = -1;
this.dirty = true;
}
/**
* Set the copy for the text object. To split a line you can use '\n'.
*
* @member {string}
*/
}, {
key: 'text',
get: function get() {
return this._text;
},
set: function set(text) // eslint-disable-line require-jsdoc
{
text = String(text === '' || text === null || text === undefined ? ' ' : text);
if (this._text === text) {
return;
}
this._text = text;
this.dirty = true;
}
}]);
return Text;
}(_Sprite3.default);
exports.default = Text;
//# sourceMappingURL=Text.js.map
/***/ }),
/* 485 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = trimCanvas;
/**
* Trim transparent borders from a canvas
*
* @memberof PIXI
* @function trimCanvas
* @private
* @param {HTMLCanvasElement} canvas - the canvas to trim
* @returns {object} Trim data
*/
function trimCanvas(canvas) {
// https://gist.github.com/remy/784508
var width = canvas.width;
var height = canvas.height;
var context = canvas.getContext('2d');
var imageData = context.getImageData(0, 0, width, height);
var pixels = imageData.data;
var len = pixels.length;
var bound = {
top: null,
left: null,
right: null,
bottom: null
};
var data = null;
var i = void 0;
var x = void 0;
var y = void 0;
for (i = 0; i < len; i += 4) {
if (pixels[i + 3] !== 0) {
x = i / 4 % width;
y = ~~(i / 4 / width);
if (bound.top === null) {
bound.top = y;
}
if (bound.left === null) {
bound.left = x;
} else if (x < bound.left) {
bound.left = x;
}
if (bound.right === null) {
bound.right = x + 1;
} else if (bound.right < x) {
bound.right = x + 1;
}
if (bound.bottom === null) {
bound.bottom = y;
} else if (bound.bottom < y) {
bound.bottom = y;
}
}
}
if (bound.top !== null) {
width = bound.right - bound.left;
height = bound.bottom - bound.top + 1;
data = context.getImageData(bound.left, bound.top, width, height);
}
return {
height: height,
width: width,
data: data
};
}
//# sourceMappingURL=trimCanvas.js.map
/***/ }),
/* 486 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Container2 = __webpack_require__(64);
var _Container3 = _interopRequireDefault(_Container2);
var _RenderTexture = __webpack_require__(128);
var _RenderTexture2 = _interopRequireDefault(_RenderTexture);
var _Texture = __webpack_require__(40);
var _Texture2 = _interopRequireDefault(_Texture);
var _GraphicsData = __webpack_require__(198);
var _GraphicsData2 = _interopRequireDefault(_GraphicsData);
var _Sprite = __webpack_require__(125);
var _Sprite2 = _interopRequireDefault(_Sprite);
var _math = __webpack_require__(14);
var _utils = __webpack_require__(7);
var _const = __webpack_require__(3);
var _Bounds = __webpack_require__(121);
var _Bounds2 = _interopRequireDefault(_Bounds);
var _bezierCurveTo2 = __webpack_require__(487);
var _bezierCurveTo3 = _interopRequireDefault(_bezierCurveTo2);
var _CanvasRenderer = __webpack_require__(65);
var _CanvasRenderer2 = _interopRequireDefault(_CanvasRenderer);
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 canvasRenderer = void 0;
var tempMatrix = new _math.Matrix();
var tempPoint = new _math.Point();
var tempColor1 = new Float32Array(4);
var tempColor2 = new Float32Array(4);
/**
* The Graphics class contains methods used to draw primitive shapes such as lines, circles and
* rectangles to the display, and to color and fill them.
*
* @class
* @extends PIXI.Container
* @memberof PIXI
*/
var Graphics = function (_Container) {
_inherits(Graphics, _Container);
/**
*
* @param {boolean} [nativeLines=false] - If true the lines will be draw using LINES instead of TRIANGLE_STRIP
*/
function Graphics() {
var nativeLines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
_classCallCheck(this, Graphics);
/**
* The alpha value used when filling the Graphics object.
*
* @member {number}
* @default 1
*/
var _this = _possibleConstructorReturn(this, _Container.call(this));
_this.fillAlpha = 1;
/**
* The width (thickness) of any lines drawn.
*
* @member {number}
* @default 0
*/
_this.lineWidth = 0;
/**
* If true the lines will be draw using LINES instead of TRIANGLE_STRIP
*
* @member {boolean}
*/
_this.nativeLines = nativeLines;
/**
* The color of any lines drawn.
*
* @member {string}
* @default 0
*/
_this.lineColor = 0;
/**
* The alignment of any lines drawn (0.5 = middle, 1 = outter, 0 = inner).
*
* @member {number}
* @default 0.5
*/
_this.lineAlignment = 0.5;
/**
* Graphics data
*
* @member {PIXI.GraphicsData[]}
* @private
*/
_this.graphicsData = [];
/**
* The tint applied to the graphic shape. This is a hex value. Apply a value of 0xFFFFFF to
* reset the tint.
*
* @member {number}
* @default 0xFFFFFF
*/
_this.tint = 0xFFFFFF;
/**
* The previous tint applied to the graphic shape. Used to compare to the current tint and
* check if theres change.
*
* @member {number}
* @private
* @default 0xFFFFFF
*/
_this._prevTint = 0xFFFFFF;
/**
* The blend mode to be applied to the graphic shape. 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;
/**
* Current path
*
* @member {PIXI.GraphicsData}
* @private
*/
_this.currentPath = null;
/**
* Array containing some WebGL-related properties used by the WebGL renderer.
*
* @member {object<number, object>}
* @private
*/
// TODO - _webgl should use a prototype object, not a random undocumented object...
_this._webGL = {};
/**
* Whether this shape is being used as a mask.
*
* @member {boolean}
*/
_this.isMask = false;
/**
* The bounds' padding used for bounds calculation.
*
* @member {number}
*/
_this.boundsPadding = 0;
/**
* A cache of the local bounds to prevent recalculation.
*
* @member {PIXI.Rectangle}
* @private
*/
_this._localBounds = new _Bounds2.default();
/**
* Used to detect if the graphics object has changed. If this is set to true then the graphics
* object will be recalculated.
*
* @member {boolean}
* @private
*/
_this.dirty = 0;
/**
* Used to detect if we need to do a fast rect check using the id compare method
* @type {Number}
*/
_this.fastRectDirty = -1;
/**
* Used to detect if we clear the graphics webGL data
* @type {Number}
*/
_this.clearDirty = 0;
/**
* Used to detect if we we need to recalculate local bounds
* @type {Number}
*/
_this.boundsDirty = -1;
/**
* Used to detect if the cached sprite object needs to be updated.
*
* @member {boolean}
* @private
*/
_this.cachedSpriteDirty = false;
_this._spriteRect = null;
_this._fastRect = false;
_this._prevRectTint = null;
_this._prevRectFillColor = null;
/**
* When cacheAsBitmap is set to true the graphics object will be rendered as if it was a sprite.
* This is useful if your graphics element does not change often, as it will speed up the rendering
* of the object in exchange for taking up texture memory. It is also useful if you need the graphics
* object to be anti-aliased, because it will be rendered using canvas. This is not recommended if
* you are constantly redrawing the graphics element.
*
* @name cacheAsBitmap
* @member {boolean}
* @memberof PIXI.Graphics#
* @default false
*/
return _this;
}
/**
* Creates a new Graphics object with the same values as this one.
* Note that the only the properties of the object are cloned, not its transform (position,scale,etc)
*
* @return {PIXI.Graphics} A clone of the graphics object
*/
Graphics.prototype.clone = function clone() {
var clone = new Graphics();
clone.renderable = this.renderable;
clone.fillAlpha = this.fillAlpha;
clone.lineWidth = this.lineWidth;
clone.lineColor = this.lineColor;
clone.lineAlignment = this.lineAlignment;
clone.tint = this.tint;
clone.blendMode = this.blendMode;
clone.isMask = this.isMask;
clone.boundsPadding = this.boundsPadding;
clone.dirty = 0;
clone.cachedSpriteDirty = this.cachedSpriteDirty;
// copy graphics data
for (var i = 0; i < this.graphicsData.length; ++i) {
clone.graphicsData.push(this.graphicsData[i].clone());
}
clone.currentPath = clone.graphicsData[clone.graphicsData.length - 1];
clone.updateLocalBounds();
return clone;
};
/**
* Calculate length of quadratic curve
* @see {@link http://www.malczak.linuxpl.com/blog/quadratic-bezier-curve-length/}
* for the detailed explanation of math behind this.
*
* @private
* @param {number} fromX - x-coordinate of curve start point
* @param {number} fromY - y-coordinate of curve start point
* @param {number} cpX - x-coordinate of curve control point
* @param {number} cpY - y-coordinate of curve control point
* @param {number} toX - x-coordinate of curve end point
* @param {number} toY - y-coordinate of curve end point
* @return {number} Length of quadratic curve
*/
Graphics.prototype._quadraticCurveLength = function _quadraticCurveLength(fromX, fromY, cpX, cpY, toX, toY) {
var ax = fromX - 2.0 * cpX + toX;
var ay = fromY - 2.0 * cpY + toY;
var bx = 2.0 * cpX - 2.0 * fromX;
var by = 2.0 * cpY - 2.0 * fromY;
var a = 4.0 * (ax * ax + ay * ay);
var b = 4.0 * (ax * bx + ay * by);
var c = bx * bx + by * by;
var s = 2.0 * Math.sqrt(a + b + c);
var a2 = Math.sqrt(a);
var a32 = 2.0 * a * a2;
var c2 = 2.0 * Math.sqrt(c);
var ba = b / a2;
return (a32 * s + a2 * b * (s - c2) + (4.0 * c * a - b * b) * Math.log((2.0 * a2 + ba + s) / (ba + c2))) / (4.0 * a32);
};
/**
* Calculate length of bezier curve.
* Analytical solution is impossible, since it involves an integral that does not integrate in general.
* Therefore numerical solution is used.
*
* @private
* @param {number} fromX - Starting point x
* @param {number} fromY - Starting point y
* @param {number} cpX - Control point x
* @param {number} cpY - Control point y
* @param {number} cpX2 - Second Control point x
* @param {number} cpY2 - Second Control point y
* @param {number} toX - Destination point x
* @param {number} toY - Destination point y
* @return {number} Length of bezier curve
*/
Graphics.prototype._bezierCurveLength = function _bezierCurveLength(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY) {
var n = 10;
var result = 0.0;
var t = 0.0;
var t2 = 0.0;
var t3 = 0.0;
var nt = 0.0;
var nt2 = 0.0;
var nt3 = 0.0;
var x = 0.0;
var y = 0.0;
var dx = 0.0;
var dy = 0.0;
var prevX = fromX;
var prevY = fromY;
for (var i = 1; i <= n; ++i) {
t = i / n;
t2 = t * t;
t3 = t2 * t;
nt = 1.0 - t;
nt2 = nt * nt;
nt3 = nt2 * nt;
x = nt3 * fromX + 3.0 * nt2 * t * cpX + 3.0 * nt * t2 * cpX2 + t3 * toX;
y = nt3 * fromY + 3.0 * nt2 * t * cpY + 3 * nt * t2 * cpY2 + t3 * toY;
dx = prevX - x;
dy = prevY - y;
prevX = x;
prevY = y;
result += Math.sqrt(dx * dx + dy * dy);
}
return result;
};
/**
* Calculate number of segments for the curve based on its length to ensure its smoothness.
*
* @private
* @param {number} length - length of curve
* @return {number} Number of segments
*/
Graphics.prototype._segmentsCount = function _segmentsCount(length) {
var result = Math.ceil(length / Graphics.CURVES.maxLength);
if (result < Graphics.CURVES.minSegments) {
result = Graphics.CURVES.minSegments;
} else if (result > Graphics.CURVES.maxSegments) {
result = Graphics.CURVES.maxSegments;
}
return result;
};
/**
* Specifies the line style used for subsequent calls to Graphics methods such as the lineTo()
* method or the drawCircle() method.
*
* @param {number} [lineWidth=0] - width of the line to draw, will update the objects stored style
* @param {number} [color=0] - color of the line to draw, will update the objects stored style
* @param {number} [alpha=1] - alpha of the line to draw, will update the objects stored style
* @param {number} [alignment=0.5] - alignment of the line to draw, (0 = inner, 0.5 = middle, 1 = outter)
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.lineStyle = function lineStyle() {
var lineWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var alpha = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
var alignment = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.5;
this.lineWidth = lineWidth;
this.lineColor = color;
this.lineAlpha = alpha;
this.lineAlignment = alignment;
if (this.currentPath) {
if (this.currentPath.shape.points.length) {
// halfway through a line? start a new one!
var shape = new _math.Polygon(this.currentPath.shape.points.slice(-2));
shape.closed = false;
this.drawShape(shape);
} else {
// otherwise its empty so lets just set the line properties
this.currentPath.lineWidth = this.lineWidth;
this.currentPath.lineColor = this.lineColor;
this.currentPath.lineAlpha = this.lineAlpha;
this.currentPath.lineAlignment = this.lineAlignment;
}
}
return this;
};
/**
* Moves the current drawing position to x, y.
*
* @param {number} x - the X coordinate to move to
* @param {number} y - the Y coordinate to move to
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.moveTo = function moveTo(x, y) {
var shape = new _math.Polygon([x, y]);
shape.closed = false;
this.drawShape(shape);
return this;
};
/**
* Draws a line using the current line style from the current drawing position to (x, y);
* The current drawing position is then set to (x, y).
*
* @param {number} x - the X coordinate to draw to
* @param {number} y - the Y coordinate to draw to
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.lineTo = function lineTo(x, y) {
var points = this.currentPath.shape.points;
var fromX = points[points.length - 2];
var fromY = points[points.length - 1];
if (fromX !== x || fromY !== y) {
points.push(x, y);
this.dirty++;
}
return this;
};
/**
* Calculate the points for a quadratic bezier curve and then draws it.
* Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c
*
* @param {number} cpX - Control point x
* @param {number} cpY - Control point y
* @param {number} toX - Destination point x
* @param {number} toY - Destination point y
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.quadraticCurveTo = function quadraticCurveTo(cpX, cpY, toX, toY) {
if (this.currentPath) {
if (this.currentPath.shape.points.length === 0) {
this.currentPath.shape.points = [0, 0];
}
} else {
this.moveTo(0, 0);
}
var points = this.currentPath.shape.points;
var xa = 0;
var ya = 0;
if (points.length === 0) {
this.moveTo(0, 0);
}
var fromX = points[points.length - 2];
var fromY = points[points.length - 1];
var n = Graphics.CURVES.adaptive ? this._segmentsCount(this._quadraticCurveLength(fromX, fromY, cpX, cpY, toX, toY)) : 20;
for (var i = 1; i <= n; ++i) {
var j = i / n;
xa = fromX + (cpX - fromX) * j;
ya = fromY + (cpY - fromY) * j;
points.push(xa + (cpX + (toX - cpX) * j - xa) * j, ya + (cpY + (toY - cpY) * j - ya) * j);
}
this.dirty++;
return this;
};
/**
* Calculate the points for a bezier curve and then draws it.
*
* @param {number} cpX - Control point x
* @param {number} cpY - Control point y
* @param {number} cpX2 - Second Control point x
* @param {number} cpY2 - Second Control point y
* @param {number} toX - Destination point x
* @param {number} toY - Destination point y
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.bezierCurveTo = function bezierCurveTo(cpX, cpY, cpX2, cpY2, toX, toY) {
if (this.currentPath) {
if (this.currentPath.shape.points.length === 0) {
this.currentPath.shape.points = [0, 0];
}
} else {
this.moveTo(0, 0);
}
var points = this.currentPath.shape.points;
var fromX = points[points.length - 2];
var fromY = points[points.length - 1];
points.length -= 2;
var n = Graphics.CURVES.adaptive ? this._segmentsCount(this._bezierCurveLength(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY)) : 20;
(0, _bezierCurveTo3.default)(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY, n, points);
this.dirty++;
return this;
};
/**
* The arcTo() method creates an arc/curve between two tangents on the canvas.
*
* "borrowed" from https://code.google.com/p/fxcanvas/ - thanks google!
*
* @param {number} x1 - The x-coordinate of the beginning of the arc
* @param {number} y1 - The y-coordinate of the beginning of the arc
* @param {number} x2 - The x-coordinate of the end of the arc
* @param {number} y2 - The y-coordinate of the end of the arc
* @param {number} radius - The radius of the arc
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.arcTo = function arcTo(x1, y1, x2, y2, radius) {
if (this.currentPath) {
if (this.currentPath.shape.points.length === 0) {
this.currentPath.shape.points.push(x1, y1);
}
} else {
this.moveTo(x1, y1);
}
var points = this.currentPath.shape.points;
var fromX = points[points.length - 2];
var fromY = points[points.length - 1];
var a1 = fromY - y1;
var b1 = fromX - x1;
var a2 = y2 - y1;
var b2 = x2 - x1;
var mm = Math.abs(a1 * b2 - b1 * a2);
if (mm < 1.0e-8 || radius === 0) {
if (points[points.length - 2] !== x1 || points[points.length - 1] !== y1) {
points.push(x1, y1);
}
} else {
var dd = a1 * a1 + b1 * b1;
var cc = a2 * a2 + b2 * b2;
var tt = a1 * a2 + b1 * b2;
var k1 = radius * Math.sqrt(dd) / mm;
var k2 = radius * Math.sqrt(cc) / mm;
var j1 = k1 * tt / dd;
var j2 = k2 * tt / cc;
var cx = k1 * b2 + k2 * b1;
var cy = k1 * a2 + k2 * a1;
var px = b1 * (k2 + j1);
var py = a1 * (k2 + j1);
var qx = b2 * (k1 + j2);
var qy = a2 * (k1 + j2);
var startAngle = Math.atan2(py - cy, px - cx);
var endAngle = Math.atan2(qy - cy, qx - cx);
this.arc(cx + x1, cy + y1, radius, startAngle, endAngle, b1 * a2 > b2 * a1);
}
this.dirty++;
return this;
};
/**
* The arc method creates an arc/curve (used to create circles, or parts of circles).
*
* @param {number} cx - The x-coordinate of the center of the circle
* @param {number} cy - The y-coordinate of the center of the circle
* @param {number} radius - The radius of the circle
* @param {number} startAngle - The starting angle, in radians (0 is at the 3 o'clock position
* of the arc's circle)
* @param {number} endAngle - The ending angle, in radians
* @param {boolean} [anticlockwise=false] - Specifies whether the drawing should be
* counter-clockwise or clockwise. False is default, and indicates clockwise, while true
* indicates counter-clockwise.
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.arc = function arc(cx, cy, radius, startAngle, endAngle) {
var anticlockwise = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
if (startAngle === endAngle) {
return this;
}
if (!anticlockwise && endAngle <= startAngle) {
endAngle += _const.PI_2;
} else if (anticlockwise && startAngle <= endAngle) {
startAngle += _const.PI_2;
}
var sweep = endAngle - startAngle;
var segs = Graphics.CURVES.adaptive ? this._segmentsCount(Math.abs(sweep) * radius) : Math.ceil(Math.abs(sweep) / _const.PI_2) * 40;
if (sweep === 0) {
return this;
}
var startX = cx + Math.cos(startAngle) * radius;
var startY = cy + Math.sin(startAngle) * radius;
// If the currentPath exists, take its points. Otherwise call `moveTo` to start a path.
var points = this.currentPath ? this.currentPath.shape.points : null;
if (points) {
// We check how far our start is from the last existing point
var xDiff = Math.abs(points[points.length - 2] - startX);
var yDiff = Math.abs(points[points.length - 1] - startY);
if (xDiff < 0.001 && yDiff < 0.001) {
// If the point is very close, we don't add it, since this would lead to artifacts
// during tesselation due to floating point imprecision.
} else {
points.push(startX, startY);
}
} else {
this.moveTo(startX, startY);
points = this.currentPath.shape.points;
}
var theta = sweep / (segs * 2);
var theta2 = theta * 2;
var cTheta = Math.cos(theta);
var sTheta = Math.sin(theta);
var segMinus = segs - 1;
var remainder = segMinus % 1 / segMinus;
for (var i = 0; i <= segMinus; ++i) {
var real = i + remainder * i;
var angle = theta + startAngle + theta2 * real;
var c = Math.cos(angle);
var s = -Math.sin(angle);
points.push((cTheta * c + sTheta * s) * radius + cx, (cTheta * -s + sTheta * c) * radius + cy);
}
this.dirty++;
return this;
};
/**
* Specifies a simple one-color fill that subsequent calls to other Graphics methods
* (such as lineTo() or drawCircle()) use when drawing.
*
* @param {number} [color=0] - the color of the fill
* @param {number} [alpha=1] - the alpha of the fill
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.beginFill = function beginFill() {
var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var alpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
this.filling = true;
this.fillColor = color;
this.fillAlpha = alpha;
if (this.currentPath) {
if (this.currentPath.shape.points.length <= 2) {
this.currentPath.fill = this.filling;
this.currentPath.fillColor = this.fillColor;
this.currentPath.fillAlpha = this.fillAlpha;
}
}
return this;
};
/**
* Applies a fill to the lines and shapes that were added since the last call to the beginFill() method.
*
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.endFill = function endFill() {
this.filling = false;
this.fillColor = null;
this.fillAlpha = 1;
return this;
};
/**
*
* @param {number} x - The X coord of the top-left of the rectangle
* @param {number} y - The Y coord of the top-left of the rectangle
* @param {number} width - The width of the rectangle
* @param {number} height - The height of the rectangle
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.drawRect = function drawRect(x, y, width, height) {
this.drawShape(new _math.Rectangle(x, y, width, height));
return this;
};
/**
*
* @param {number} x - The X coord of the top-left of the rectangle
* @param {number} y - The Y coord of the top-left of the rectangle
* @param {number} width - The width of the rectangle
* @param {number} height - The height of the rectangle
* @param {number} radius - Radius of the rectangle corners
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.drawRoundedRect = function drawRoundedRect(x, y, width, height, radius) {
this.drawShape(new _math.RoundedRectangle(x, y, width, height, radius));
return this;
};
/**
* Draws a circle.
*
* @param {number} x - The X coordinate of the center of the circle
* @param {number} y - The Y coordinate of the center of the circle
* @param {number} radius - The radius of the circle
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.drawCircle = function drawCircle(x, y, radius) {
this.drawShape(new _math.Circle(x, y, radius));
return this;
};
/**
* Draws an ellipse.
*
* @param {number} x - The X coordinate of the center of the ellipse
* @param {number} y - The Y coordinate of the center of the ellipse
* @param {number} width - The half width of the ellipse
* @param {number} height - The half height of the ellipse
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.drawEllipse = function drawEllipse(x, y, width, height) {
this.drawShape(new _math.Ellipse(x, y, width, height));
return this;
};
/**
* Draws a polygon using the given path.
*
* @param {number[]|PIXI.Point[]|PIXI.Polygon} path - The path data used to construct the polygon.
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.drawPolygon = function drawPolygon(path) {
// prevents an argument assignment deopt
// see section 3.1: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
var points = path;
var closed = true;
if (points instanceof _math.Polygon) {
closed = points.closed;
points = points.points;
}
if (!Array.isArray(points)) {
// prevents an argument leak deopt
// see section 3.2: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
points = new Array(arguments.length);
for (var i = 0; i < points.length; ++i) {
points[i] = arguments[i]; // eslint-disable-line prefer-rest-params
}
}
var shape = new _math.Polygon(points);
shape.closed = closed;
this.drawShape(shape);
return this;
};
/**
* Draw a star shape with an abitrary number of points.
*
* @param {number} x - Center X position of the star
* @param {number} y - Center Y position of the star
* @param {number} points - The number of points of the star, must be > 1
* @param {number} radius - The outer radius of the star
* @param {number} [innerRadius] - The inner radius between points, default half `radius`
* @param {number} [rotation=0] - The rotation of the star in radians, where 0 is vertical
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.drawStar = function drawStar(x, y, points, radius, innerRadius) {
var rotation = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
innerRadius = innerRadius || radius / 2;
var startAngle = -1 * Math.PI / 2 + rotation;
var len = points * 2;
var delta = _const.PI_2 / len;
var polygon = [];
for (var i = 0; i < len; i++) {
var r = i % 2 ? innerRadius : radius;
var angle = i * delta + startAngle;
polygon.push(x + r * Math.cos(angle), y + r * Math.sin(angle));
}
return this.drawPolygon(polygon);
};
/**
* Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.
*
* @return {PIXI.Graphics} This Graphics object. Good for chaining method calls
*/
Graphics.prototype.clear = function clear() {
if (this.lineWidth || this.filling || this.graphicsData.length > 0) {
this.lineWidth = 0;
this.lineAlignment = 0.5;
this.filling = false;
this.boundsDirty = -1;
this.canvasTintDirty = -1;
this.dirty++;
this.clearDirty++;
this.graphicsData.length = 0;
}
this.currentPath = null;
this._spriteRect = null;
return this;
};
/**
* True if graphics consists of one rectangle, and thus, can be drawn like a Sprite and
* masked with gl.scissor.
*
* @returns {boolean} True if only 1 rect.
*/
Graphics.prototype.isFastRect = function isFastRect() {
return this.graphicsData.length === 1 && this.graphicsData[0].shape.type === _const.SHAPES.RECT && !this.graphicsData[0].lineWidth;
};
/**
* Renders the object using the WebGL renderer
*
* @private
* @param {PIXI.WebGLRenderer} renderer - The renderer
*/
Graphics.prototype._renderWebGL = function _renderWebGL(renderer) {
// if the sprite is not visible or the alpha is 0 then no need to render this element
if (this.dirty !== this.fastRectDirty) {
this.fastRectDirty = this.dirty;
this._fastRect = this.isFastRect();
}
// TODO this check can be moved to dirty?
if (this._fastRect) {
this._renderSpriteRect(renderer);
} else {
renderer.setObjectRenderer(renderer.plugins.graphics);
renderer.plugins.graphics.render(this);
}
};
/**
* Renders a sprite rectangle.
*
* @private
* @param {PIXI.WebGLRenderer} renderer - The renderer
*/
Graphics.prototype._renderSpriteRect = function _renderSpriteRect(renderer) {
var rect = this.graphicsData[0].shape;
if (!this._spriteRect) {
this._spriteRect = new _Sprite2.default(new _Texture2.default(_Texture2.default.WHITE));
}
var sprite = this._spriteRect;
var fillColor = this.graphicsData[0].fillColor;
if (this.tint === 0xffffff) {
sprite.tint = fillColor;
} else if (this.tint !== this._prevRectTint || fillColor !== this._prevRectFillColor) {
var t1 = tempColor1;
var t2 = tempColor2;
(0, _utils.hex2rgb)(fillColor, t1);
(0, _utils.hex2rgb)(this.tint, t2);
t1[0] *= t2[0];
t1[1] *= t2[1];
t1[2] *= t2[2];
sprite.tint = (0, _utils.rgb2hex)(t1);
this._prevRectTint = this.tint;
this._prevRectFillColor = fillColor;
}
sprite.alpha = this.graphicsData[0].fillAlpha;
sprite.worldAlpha = this.worldAlpha * sprite.alpha;
sprite.blendMode = this.blendMode;
sprite._texture._frame.width = rect.width;
sprite._texture._frame.height = rect.height;
sprite.transform.worldTransform = this.transform.worldTransform;
sprite.anchor.set(-rect.x / rect.width, -rect.y / rect.height);
sprite._onAnchorUpdate();
sprite._renderWebGL(renderer);
};
/**
* Renders the object using the Canvas renderer
*
* @private
* @param {PIXI.CanvasRenderer} renderer - The renderer
*/
Graphics.prototype._renderCanvas = function _renderCanvas(renderer) {
if (this.isMask === true) {
return;
}
renderer.plugins.graphics.render(this);
};
/**
* Retrieves the bounds of the graphic shape as a rectangle object
*
* @private
*/
Graphics.prototype._calculateBounds = function _calculateBounds() {
if (this.boundsDirty !== this.dirty) {
this.boundsDirty = this.dirty;
this.updateLocalBounds();
this.cachedSpriteDirty = true;
}
var lb = this._localBounds;
this._bounds.addFrame(this.transform, lb.minX, lb.minY, lb.maxX, lb.maxY);
};
/**
* Tests if a point is inside this graphics object
*
* @param {PIXI.Point} point - the point to test
* @return {boolean} the result of the test
*/
Graphics.prototype.containsPoint = function containsPoint(point) {
this.worldTransform.applyInverse(point, tempPoint);
var graphicsData = this.graphicsData;
for (var i = 0; i < graphicsData.length; ++i) {
var data = graphicsData[i];
if (!data.fill) {
continue;
}
// only deal with fills..
if (data.shape) {
if (data.shape.contains(tempPoint.x, tempPoint.y)) {
if (data.holes) {
for (var _i = 0; _i < data.holes.length; _i++) {
var hole = data.holes[_i];
if (hole.contains(tempPoint.x, tempPoint.y)) {
return false;
}
}
}
return true;
}
}
}
return false;
};
/**
* Update the bounds of the object
*
*/
Graphics.prototype.updateLocalBounds = function updateLocalBounds() {
var minX = Infinity;
var maxX = -Infinity;
var minY = Infinity;
var maxY = -Infinity;
if (this.graphicsData.length) {
var shape = 0;
var x = 0;
var y = 0;
var w = 0;
var h = 0;
for (var i = 0; i < this.graphicsData.length; i++) {
var data = this.graphicsData[i];
var type = data.type;
var lineWidth = data.lineWidth;
var lineAlignment = data.lineAlignment;
var lineOffset = lineWidth * lineAlignment;
shape = data.shape;
if (type === _const.SHAPES.RECT || type === _const.SHAPES.RREC) {
x = shape.x - lineOffset;
y = shape.y - lineOffset;
w = shape.width + lineOffset * 2;
h = shape.height + lineOffset * 2;
minX = x < minX ? x : minX;
maxX = x + w > maxX ? x + w : maxX;
minY = y < minY ? y : minY;
maxY = y + h > maxY ? y + h : maxY;
} else if (type === _const.SHAPES.CIRC) {
x = shape.x;
y = shape.y;
w = shape.radius + lineOffset;
h = shape.radius + lineOffset;
minX = x - w < minX ? x - w : minX;
maxX = x + w > maxX ? x + w : maxX;
minY = y - h < minY ? y - h : minY;
maxY = y + h > maxY ? y + h : maxY;
} else if (type === _const.SHAPES.ELIP) {
x = shape.x;
y = shape.y;
w = shape.width + lineOffset;
h = shape.height + lineOffset;
minX = x - w < minX ? x - w : minX;
maxX = x + w > maxX ? x + w : maxX;
minY = y - h < minY ? y - h : minY;
maxY = y + h > maxY ? y + h : maxY;
} else {
// POLY
var points = shape.points;
var x2 = 0;
var y2 = 0;
var dx = 0;
var dy = 0;
var rw = 0;
var rh = 0;
var cx = 0;
var cy = 0;
for (var j = 0; j + 2 < points.length; j += 2) {
x = points[j];
y = points[j + 1];
x2 = points[j + 2];
y2 = points[j + 3];
dx = Math.abs(x2 - x);
dy = Math.abs(y2 - y);
h = lineOffset * 2;
w = Math.sqrt(dx * dx + dy * dy);
if (w < 1e-9) {
continue;
}
rw = (h / w * dy + dx) / 2;
rh = (h / w * dx + dy) / 2;
cx = (x2 + x) / 2;
cy = (y2 + y) / 2;
minX = cx - rw < minX ? cx - rw : minX;
maxX = cx + rw > maxX ? cx + rw : maxX;
minY = cy - rh < minY ? cy - rh : minY;
maxY = cy + rh > maxY ? cy + rh : maxY;
}
}
}
} else {
minX = 0;
maxX = 0;
minY = 0;
maxY = 0;
}
var padding = this.boundsPadding;
this._localBounds.minX = minX - padding;
this._localBounds.maxX = maxX + padding;
this._localBounds.minY = minY - padding;
this._localBounds.maxY = maxY + padding;
};
/**
* Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.
*
* @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw.
* @return {PIXI.GraphicsData} The generated GraphicsData object.
*/
Graphics.prototype.drawShape = function drawShape(shape) {
if (this.currentPath) {
// check current path!
if (this.currentPath.shape.points.length <= 2) {
this.graphicsData.pop();
}
}
this.currentPath = null;
var data = new _GraphicsData2.default(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.filling, this.nativeLines, shape, this.lineAlignment);
this.graphicsData.push(data);
if (data.type === _const.SHAPES.POLY) {
data.shape.closed = data.shape.closed;
this.currentPath = data;
}
this.dirty++;
return data;
};
/**
* Generates a canvas texture.
*
* @param {number} scaleMode - The scale mode of the texture.
* @param {number} resolution - The resolution of the texture.
* @return {PIXI.Texture} The new texture.
*/
Graphics.prototype.generateCanvasTexture = function generateCanvasTexture(scaleMode) {
var resolution = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var bounds = this.getLocalBounds();
var canvasBuffer = _RenderTexture2.default.create(bounds.width, bounds.height, scaleMode, resolution);
if (!canvasRenderer) {
canvasRenderer = new _CanvasRenderer2.default();
}
this.transform.updateLocalTransform();
this.transform.localTransform.copy(tempMatrix);
tempMatrix.invert();
tempMatrix.tx -= bounds.x;
tempMatrix.ty -= bounds.y;
canvasRenderer.render(this, canvasBuffer, true, tempMatrix);
var texture = _Texture2.default.fromCanvas(canvasBuffer.baseTexture._canvasRenderTarget.canvas, scaleMode, 'graphics');
texture.baseTexture.resolution = resolution;
texture.baseTexture.update();
return texture;
};
/**
* Closes the current path.
*
* @return {PIXI.Graphics} Returns itself.
*/
Graphics.prototype.closePath = function closePath() {
// ok so close path assumes next one is a hole!
var currentPath = this.currentPath;
if (currentPath && currentPath.shape) {
currentPath.shape.close();
}
return this;
};
/**
* Adds a hole in the current path.
*
* @return {PIXI.Graphics} Returns itself.
*/
Graphics.prototype.addHole = function addHole() {
// this is a hole!
var hole = this.graphicsData.pop();
this.currentPath = this.graphicsData[this.graphicsData.length - 1];
this.currentPath.addHole(hole.shape);
this.currentPath = null;
return this;
};
/**
* Destroys the Graphics 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
*/
Graphics.prototype.destroy = function destroy(options) {
_Container.prototype.destroy.call(this, options);
// destroy each of the GraphicsData objects
for (var i = 0; i < this.graphicsData.length; ++i) {
this.graphicsData[i].destroy();
}
// for each webgl data entry, destroy the WebGLGraphicsData
for (var id in this._webGL) {
for (var j = 0; j < this._webGL[id].data.length; ++j) {
this._webGL[id].data[j].destroy();
}
}
if (this._spriteRect) {
this._spriteRect.destroy();
}
this.graphicsData = null;
this.currentPath = null;
this._webGL = null;
this._localBounds = null;
};
return Graphics;
}(_Container3.default);
exports.default = Graphics;
Graphics._SPRITE_TEXTURE = null;
/**
* Graphics curves resolution settings. If `adaptive` flag is set to `true`,
* the resolution is calculated based on the curve's length to ensure better visual quality.
* Adaptive draw works with `bezierCurveTo` and `quadraticCurveTo`.
*
* @static
* @constant
* @memberof PIXI.Graphics
* @name CURVES
* @type {object}
* @property {boolean} adaptive=false - flag indicating if the resolution should be adaptive
* @property {number} maxLength=10 - maximal length of a single segment of the curve (if adaptive = false, ignored)
* @property {number} minSegments=8 - minimal number of segments in the curve (if adaptive = false, ignored)
* @property {number} maxSegments=2048 - maximal number of segments in the curve (if adaptive = false, ignored)
*/
Graphics.CURVES = {
adaptive: false,
maxLength: 10,
minSegments: 8,
maxSegments: 2048
};
//# sourceMappingURL=Graphics.js.map
/***/ }),
/* 487 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = bezierCurveTo;
/**
* Calculate the points for a bezier curve and then draws it.
*
* Ignored from docs since it is not directly exposed.
*
* @ignore
* @param {number} fromX - Starting point x
* @param {number} fromY - Starting point y
* @param {number} cpX - Control point x
* @param {number} cpY - Control point y
* @param {number} cpX2 - Second Control point x
* @param {number} cpY2 - Second Control point y
* @param {number} toX - Destination point x
* @param {number} toY - Destination point y
* @param {number} n - Number of segments approximating the bezier curve
* @param {number[]} [path=[]] - Path array to push points into
* @return {number[]} Array of points of the curve
*/
function bezierCurveTo(fromX, fromY, cpX, cpY, cpX2, cpY2, toX, toY, n) {
var path = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : [];
var dt = 0;
var dt2 = 0;
var dt3 = 0;
var t2 = 0;
var t3 = 0;
path.push(fromX, fromY);
for (var i = 1, j = 0; i <= n; ++i) {
j = i / n;
dt = 1 - j;
dt2 = dt * dt;
dt3 = dt2 * dt;
t2 = j * j;
t3 = t2 * j;
path.push(dt3 * fromX + 3 * dt2 * j * cpX + 3 * dt * t2 * cpX2 + t3 * toX, dt3 * fromY + 3 * dt2 * j * cpY + 3 * dt * t2 * cpY2 + t3 * toY);
}
return path;
}
//# sourceMappingURL=bezierCurveTo.js.map
/***/ }),
/* 488 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _utils = __webpack_require__(7);
var _const = __webpack_require__(3);
var _ObjectRenderer2 = __webpack_require__(85);
var _ObjectRenderer3 = _interopRequireDefault(_ObjectRenderer2);
var _WebGLRenderer = __webpack_require__(86);
var _WebGLRenderer2 = _interopRequireDefault(_WebGLRenderer);
var _WebGLGraphicsData = __webpack_require__(489);
var _WebGLGraphicsData2 = _interopRequireDefault(_WebGLGraphicsData);
var _PrimitiveShader = __webpack_require__(490);
var _PrimitiveShader2 = _interopRequireDefault(_PrimitiveShader);
var _buildPoly = __webpack_require__(491);
var _buildPoly2 = _interopRequireDefault(_buildPoly);
var _buildRectangle = __webpack_require__(492);
var _buildRectangle2 = _interopRequireDefault(_buildRectangle);
var _buildRoundedRectangle = __webpack_require__(493);
var _buildRoundedRectangle2 = _interopRequireDefault(_buildRoundedRectangle);
var _buildCircle = __webpack_require__(494);
var _buildCircle2 = _interopRequireDefault(_buildCircle);
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; }
/**
* Renders the graphics object.
*
* @class
* @memberof PIXI
* @extends PIXI.ObjectRenderer
*/
var GraphicsRenderer = function (_ObjectRenderer) {
_inherits(GraphicsRenderer, _ObjectRenderer);
/**
* @param {PIXI.WebGLRenderer} renderer - The renderer this object renderer works for.
*/
function GraphicsRenderer(renderer) {
_classCallCheck(this, GraphicsRenderer);
var _this = _possibleConstructorReturn(this, _ObjectRenderer.call(this, renderer));
_this.graphicsDataPool = [];
_this.primitiveShader = null;
_this.gl = renderer.gl;
// easy access!
_this.CONTEXT_UID = 0;
return _this;
}
/**
* Called when there is a WebGL context change
*
* @private
*
*/
GraphicsRenderer.prototype.onContextChange = function onContextChange() {
this.gl = this.renderer.gl;
this.CONTEXT_UID = this.renderer.CONTEXT_UID;
this.primitiveShader = new _PrimitiveShader2.default(this.gl);
};
/**
* Destroys this renderer.
*
*/
GraphicsRenderer.prototype.destroy = function destroy() {
_ObjectRenderer3.default.prototype.destroy.call(this);
for (var i = 0; i < this.graphicsDataPool.length; ++i) {
this.graphicsDataPool[i].destroy();
}
this.graphicsDataPool = null;
};
/**
* Renders a graphics object.
*
* @param {PIXI.Graphics} graphics - The graphics object to render.
*/
GraphicsRenderer.prototype.render = function render(graphics) {
var renderer = this.renderer;
var gl = renderer.gl;
var webGLData = void 0;
var webGL = graphics._webGL[this.CONTEXT_UID];
if (!webGL || graphics.dirty !== webGL.dirty) {
this.updateGraphics(graphics);
webGL = graphics._webGL[this.CONTEXT_UID];
}
// This could be speeded up for sure!
var shader = this.primitiveShader;
renderer.bindShader(shader);
renderer.state.setBlendMode(graphics.blendMode);
for (var i = 0, n = webGL.data.length; i < n; i++) {
webGLData = webGL.data[i];
var shaderTemp = webGLData.shader;
renderer.bindShader(shaderTemp);
shaderTemp.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true);
shaderTemp.uniforms.tint = (0, _utils.hex2rgb)(graphics.tint);
shaderTemp.uniforms.alpha = graphics.worldAlpha;
renderer.bindVao(webGLData.vao);
if (webGLData.nativeLines) {
gl.drawArrays(gl.LINES, 0, webGLData.points.length / 6);
} else {
webGLData.vao.draw(gl.TRIANGLE_STRIP, webGLData.indices.length);
}
}
};
/**
* Updates the graphics object
*
* @private
* @param {PIXI.Graphics} graphics - The graphics object to update
*/
GraphicsRenderer.prototype.updateGraphics = function updateGraphics(graphics) {
var gl = this.renderer.gl;
// get the contexts graphics object
var webGL = graphics._webGL[this.CONTEXT_UID];
// if the graphics object does not exist in the webGL context time to create it!
if (!webGL) {
webGL = graphics._webGL[this.CONTEXT_UID] = { lastIndex: 0, data: [], gl: gl, clearDirty: -1, dirty: -1 };
}
// flag the graphics as not dirty as we are about to update it...
webGL.dirty = graphics.dirty;
// if the user cleared the graphics object we will need to clear every object
if (graphics.clearDirty !== webGL.clearDirty) {
webGL.clearDirty = graphics.clearDirty;
// loop through and return all the webGLDatas to the object pool so than can be reused later on
for (var i = 0; i < webGL.data.length; i++) {
this.graphicsDataPool.push(webGL.data[i]);
}
// clear the array and reset the index..
webGL.data.length = 0;
webGL.lastIndex = 0;
}
var webGLData = void 0;
var webGLDataNativeLines = void 0;
// loop through the graphics datas and construct each one..
// if the object is a complex fill then the new stencil buffer technique will be used
// other wise graphics objects will be pushed into a batch..
for (var _i = webGL.lastIndex; _i < graphics.graphicsData.length; _i++) {
var data = graphics.graphicsData[_i];
// TODO - this can be simplified
webGLData = this.getWebGLData(webGL, 0);
if (data.nativeLines && data.lineWidth) {
webGLDataNativeLines = this.getWebGLData(webGL, 0, true);
webGL.lastIndex++;
}
if (data.type === _const.SHAPES.POLY) {
(0, _buildPoly2.default)(data, webGLData, webGLDataNativeLines);
}
if (data.type === _const.SHAPES.RECT) {
(0, _buildRectangle2.default)(data, webGLData, webGLDataNativeLines);
} else if (data.type === _const.SHAPES.CIRC || data.type === _const.SHAPES.ELIP) {
(0, _buildCircle2.default)(data, webGLData, webGLDataNativeLines);
} else if (data.type === _const.SHAPES.RREC) {
(0, _buildRoundedRectangle2.default)(data, webGLData, webGLDataNativeLines);
}
webGL.lastIndex++;
}
this.renderer.bindVao(null);
// upload all the dirty data...
for (var _i2 = 0; _i2 < webGL.data.length; _i2++) {
webGLData = webGL.data[_i2];
if (webGLData.dirty) {
webGLData.upload();
}
}
};
/**
*
* @private
* @param {WebGLRenderingContext} gl - the current WebGL drawing context
* @param {number} type - TODO @Alvin
* @param {number} nativeLines - indicate whether the webGLData use for nativeLines.
* @return {*} TODO
*/
GraphicsRenderer.prototype.getWebGLData = function getWebGLData(gl, type, nativeLines) {
var webGLData = gl.data[gl.data.length - 1];
if (!webGLData || webGLData.nativeLines !== nativeLines || webGLData.points.length > 320000) {
webGLData = this.graphicsDataPool.pop() || new _WebGLGraphicsData2.default(this.renderer.gl, this.primitiveShader, this.renderer.state.attribsState);
webGLData.nativeLines = nativeLines;
webGLData.reset(type);
gl.data.push(webGLData);
}
webGLData.dirty = true;
return webGLData;
};
return GraphicsRenderer;
}(_ObjectRenderer3.default);
exports.default = GraphicsRenderer;
_WebGLRenderer2.default.registerPlugin('graphics', GraphicsRenderer);
//# sourceMappingURL=GraphicsRenderer.js.map
/***/ }),
/* 489 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _pixiGlCore = __webpack_require__(23);
var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore);
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"); } }
/**
* An object containing WebGL specific properties to be used by the WebGL renderer
*
* @class
* @private
* @memberof PIXI
*/
var WebGLGraphicsData = function () {
/**
* @param {WebGLRenderingContext} gl - The current WebGL drawing context
* @param {PIXI.Shader} shader - The shader
* @param {object} attribsState - The state for the VAO
*/
function WebGLGraphicsData(gl, shader, attribsState) {
_classCallCheck(this, WebGLGraphicsData);
/**
* The current WebGL drawing context
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
// TODO does this need to be split before uploading??
/**
* An array of color components (r,g,b)
* @member {number[]}
*/
this.color = [0, 0, 0]; // color split!
/**
* An array of points to draw
* @member {PIXI.Point[]}
*/
this.points = [];
/**
* The indices of the vertices
* @member {number[]}
*/
this.indices = [];
/**
* The main buffer
* @member {WebGLBuffer}
*/
this.buffer = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl);
/**
* The index buffer
* @member {WebGLBuffer}
*/
this.indexBuffer = _pixiGlCore2.default.GLBuffer.createIndexBuffer(gl);
/**
* Whether this graphics is dirty or not
* @member {boolean}
*/
this.dirty = true;
/**
* Whether this graphics is nativeLines or not
* @member {boolean}
*/
this.nativeLines = false;
this.glPoints = null;
this.glIndices = null;
/**
*
* @member {PIXI.Shader}
*/
this.shader = shader;
this.vao = new _pixiGlCore2.default.VertexArrayObject(gl, attribsState).addIndex(this.indexBuffer).addAttribute(this.buffer, shader.attributes.aVertexPosition, gl.FLOAT, false, 4 * 6, 0).addAttribute(this.buffer, shader.attributes.aColor, gl.FLOAT, false, 4 * 6, 2 * 4);
}
/**
* Resets the vertices and the indices
*/
WebGLGraphicsData.prototype.reset = function reset() {
this.points.length = 0;
this.indices.length = 0;
};
/**
* Binds the buffers and uploads the data
*/
WebGLGraphicsData.prototype.upload = function upload() {
this.glPoints = new Float32Array(this.points);
this.buffer.upload(this.glPoints);
this.glIndices = new Uint16Array(this.indices);
this.indexBuffer.upload(this.glIndices);
this.dirty = false;
};
/**
* Empties all the data
*/
WebGLGraphicsData.prototype.destroy = function destroy() {
this.color = null;
this.points = null;
this.indices = null;
this.vao.destroy();
this.buffer.destroy();
this.indexBuffer.destroy();
this.gl = null;
this.buffer = null;
this.indexBuffer = null;
this.glPoints = null;
this.glIndices = null;
};
return WebGLGraphicsData;
}();
exports.default = WebGLGraphicsData;
//# sourceMappingURL=WebGLGraphicsData.js.map
/***/ }),
/* 490 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Shader2 = __webpack_require__(67);
var _Shader3 = _interopRequireDefault(_Shader2);
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; }
/**
* This shader is used to draw simple primitive shapes for {@link PIXI.Graphics}.
*
* @class
* @memberof PIXI
* @extends PIXI.Shader
*/
var PrimitiveShader = function (_Shader) {
_inherits(PrimitiveShader, _Shader);
/**
* @param {WebGLRenderingContext} gl - The webgl shader manager this shader works for.
*/
function PrimitiveShader(gl) {
_classCallCheck(this, PrimitiveShader);
return _possibleConstructorReturn(this, _Shader.call(this, gl,
// vertex shader
['attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', 'uniform mat3 translationMatrix;', 'uniform mat3 projectionMatrix;', 'uniform float alpha;', 'uniform vec3 tint;', 'varying vec4 vColor;', 'void main(void){', ' gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);', ' vColor = aColor * vec4(tint * alpha, alpha);', '}'].join('\n'),
// fragment shader
['varying vec4 vColor;', 'void main(void){', ' gl_FragColor = vColor;', '}'].join('\n')));
}
return PrimitiveShader;
}(_Shader3.default);
exports.default = PrimitiveShader;
//# sourceMappingURL=PrimitiveShader.js.map
/***/ }),
/* 491 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = buildPoly;
var _buildLine = __webpack_require__(88);
var _buildLine2 = _interopRequireDefault(_buildLine);
var _utils = __webpack_require__(7);
var _earcut = __webpack_require__(124);
var _earcut2 = _interopRequireDefault(_earcut);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Builds a polygon 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 buildPoly(graphicsData, webGLData, webGLDataNativeLines) {
graphicsData.points = graphicsData.shape.points.slice();
var points = graphicsData.points;
if (graphicsData.fill && points.length >= 6) {
var holeArray = [];
// Process holes..
var holes = graphicsData.holes;
for (var i = 0; i < holes.length; i++) {
var hole = holes[i];
holeArray.push(points.length / 2);
points = points.concat(hole.points);
}
// get first and last point.. figure out the middle!
var verts = webGLData.points;
var indices = webGLData.indices;
var length = points.length / 2;
// sort color
var color = (0, _utils.hex2rgb)(graphicsData.fillColor);
var alpha = graphicsData.fillAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
var triangles = (0, _earcut2.default)(points, holeArray, 2);
if (!triangles) {
return;
}
var vertPos = verts.length / 6;
for (var _i = 0; _i < triangles.length; _i += 3) {
indices.push(triangles[_i] + vertPos);
indices.push(triangles[_i] + vertPos);
indices.push(triangles[_i + 1] + vertPos);
indices.push(triangles[_i + 2] + vertPos);
indices.push(triangles[_i + 2] + vertPos);
}
for (var _i2 = 0; _i2 < length; _i2++) {
verts.push(points[_i2 * 2], points[_i2 * 2 + 1], r, g, b, alpha);
}
}
if (graphicsData.lineWidth > 0) {
(0, _buildLine2.default)(graphicsData, webGLData, webGLDataNativeLines);
}
}
//# sourceMappingURL=buildPoly.js.map
/***/ }),
/* 492 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = buildRectangle;
var _buildLine = __webpack_require__(88);
var _buildLine2 = _interopRequireDefault(_buildLine);
var _utils = __webpack_require__(7);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Builds a rectangle 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 buildRectangle(graphicsData, webGLData, webGLDataNativeLines) {
// --- //
// need to convert points to a nice regular data
//
var rectData = graphicsData.shape;
var x = rectData.x;
var y = rectData.y;
var width = rectData.width;
var height = rectData.height;
if (graphicsData.fill) {
var color = (0, _utils.hex2rgb)(graphicsData.fillColor);
var alpha = graphicsData.fillAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
var verts = webGLData.points;
var indices = webGLData.indices;
var vertPos = verts.length / 6;
// start
verts.push(x, y);
verts.push(r, g, b, alpha);
verts.push(x + width, y);
verts.push(r, g, b, alpha);
verts.push(x, y + height);
verts.push(r, g, b, alpha);
verts.push(x + width, y + height);
verts.push(r, g, b, alpha);
// insert 2 dead triangles..
indices.push(vertPos, vertPos, vertPos + 1, vertPos + 2, vertPos + 3, vertPos + 3);
}
if (graphicsData.lineWidth) {
var tempPoints = graphicsData.points;
graphicsData.points = [x, y, x + width, y, x + width, y + height, x, y + height, x, y];
(0, _buildLine2.default)(graphicsData, webGLData, webGLDataNativeLines);
graphicsData.points = tempPoints;
}
}
//# sourceMappingURL=buildRectangle.js.map
/***/ }),
/* 493 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = buildRoundedRectangle;
var _earcut = __webpack_require__(124);
var _earcut2 = _interopRequireDefault(_earcut);
var _buildLine = __webpack_require__(88);
var _buildLine2 = _interopRequireDefault(_buildLine);
var _utils = __webpack_require__(7);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Builds a rounded rectangle 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 buildRoundedRectangle(graphicsData, webGLData, webGLDataNativeLines) {
var rrectData = graphicsData.shape;
var x = rrectData.x;
var y = rrectData.y;
var width = rrectData.width;
var height = rrectData.height;
var radius = rrectData.radius;
var recPoints = [];
recPoints.push(x + radius, y);
quadraticBezierCurve(x + width - radius, y, x + width, y, x + width, y + radius, recPoints);
quadraticBezierCurve(x + width, y + height - radius, x + width, y + height, x + width - radius, y + height, recPoints);
quadraticBezierCurve(x + radius, y + height, x, y + height, x, y + height - radius, recPoints);
quadraticBezierCurve(x, y + radius, x, y, x + radius + 0.0000000001, y, recPoints);
// this tiny number deals with the issue that occurs when points overlap and earcut fails to triangulate the item.
// TODO - fix this properly, this is not very elegant.. but it works for now.
if (graphicsData.fill) {
var color = (0, _utils.hex2rgb)(graphicsData.fillColor);
var alpha = graphicsData.fillAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
var verts = webGLData.points;
var indices = webGLData.indices;
var vecPos = verts.length / 6;
var triangles = (0, _earcut2.default)(recPoints, null, 2);
for (var i = 0, j = triangles.length; i < j; i += 3) {
indices.push(triangles[i] + vecPos);
indices.push(triangles[i] + vecPos);
indices.push(triangles[i + 1] + vecPos);
indices.push(triangles[i + 2] + vecPos);
indices.push(triangles[i + 2] + vecPos);
}
for (var _i = 0, _j = recPoints.length; _i < _j; _i++) {
verts.push(recPoints[_i], recPoints[++_i], r, g, b, alpha);
}
}
if (graphicsData.lineWidth) {
var tempPoints = graphicsData.points;
graphicsData.points = recPoints;
(0, _buildLine2.default)(graphicsData, webGLData, webGLDataNativeLines);
graphicsData.points = tempPoints;
}
}
/**
* Calculate a single point for a quadratic bezier curve.
* Utility function used by quadraticBezierCurve.
* Ignored from docs since it is not directly exposed.
*
* @ignore
* @private
* @param {number} n1 - first number
* @param {number} n2 - second number
* @param {number} perc - percentage
* @return {number} the result
*
*/
function getPt(n1, n2, perc) {
var diff = n2 - n1;
return n1 + diff * perc;
}
/**
* Calculate the points for a quadratic bezier curve. (helper function..)
* Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c
*
* Ignored from docs since it is not directly exposed.
*
* @ignore
* @private
* @param {number} fromX - Origin point x
* @param {number} fromY - Origin point x
* @param {number} cpX - Control point x
* @param {number} cpY - Control point y
* @param {number} toX - Destination point x
* @param {number} toY - Destination point y
* @param {number[]} [out=[]] - The output array to add points into. If not passed, a new array is created.
* @return {number[]} an array of points
*/
function quadraticBezierCurve(fromX, fromY, cpX, cpY, toX, toY) {
var out = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [];
var n = 20;
var points = out;
var xa = 0;
var ya = 0;
var xb = 0;
var yb = 0;
var x = 0;
var y = 0;
for (var i = 0, j = 0; i <= n; ++i) {
j = i / n;
// The Green Line
xa = getPt(fromX, cpX, j);
ya = getPt(fromY, cpY, j);
xb = getPt(cpX, toX, j);
yb = getPt(cpY, toY, j);
// The Black Dot
x = getPt(xa, xb, j);
y = getPt(ya, yb, j);
points.push(x, y);
}
return points;
}
//# sourceMappingURL=buildRoundedRectangle.js.map
/***/ }),
/* 494 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = buildCircle;
var _buildLine = __webpack_require__(88);
var _buildLine2 = _interopRequireDefault(_buildLine);
var _const = __webpack_require__(3);
var _utils = __webpack_require__(7);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Builds a circle to draw
*
* Ignored from docs since it is not directly exposed.
*
* @ignore
* @private
* @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object to draw
* @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 buildCircle(graphicsData, webGLData, webGLDataNativeLines) {
// need to convert points to a nice regular data
var circleData = graphicsData.shape;
var x = circleData.x;
var y = circleData.y;
var width = void 0;
var height = void 0;
// TODO - bit hacky??
if (graphicsData.type === _const.SHAPES.CIRC) {
width = circleData.radius;
height = circleData.radius;
} else {
width = circleData.width;
height = circleData.height;
}
if (width === 0 || height === 0) {
return;
}
var totalSegs = Math.floor(30 * Math.sqrt(circleData.radius)) || Math.floor(15 * Math.sqrt(circleData.width + circleData.height));
var seg = Math.PI * 2 / totalSegs;
if (graphicsData.fill) {
var color = (0, _utils.hex2rgb)(graphicsData.fillColor);
var alpha = graphicsData.fillAlpha;
var r = color[0] * alpha;
var g = color[1] * alpha;
var b = color[2] * alpha;
var verts = webGLData.points;
var indices = webGLData.indices;
var vecPos = verts.length / 6;
indices.push(vecPos);
for (var i = 0; i < totalSegs + 1; i++) {
verts.push(x, y, r, g, b, alpha);
verts.push(x + Math.sin(seg * i) * width, y + Math.cos(seg * i) * height, r, g, b, alpha);
indices.push(vecPos++, vecPos++);
}
indices.push(vecPos - 1);
}
if (graphicsData.lineWidth) {
var tempPoints = graphicsData.points;
graphicsData.points = [];
for (var _i = 0; _i < totalSegs; _i++) {
graphicsData.points.push(x + Math.sin(seg * -_i) * width, y + Math.cos(seg * -_i) * height);
}
graphicsData.points.push(graphicsData.points[0], graphicsData.points[1]);
(0, _buildLine2.default)(graphicsData, webGLData, webGLDataNativeLines);
graphicsData.points = tempPoints;
}
}
//# sourceMappingURL=buildCircle.js.map
/***/ }),
/* 495 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _CanvasRenderer = __webpack_require__(65);
var _CanvasRenderer2 = _interopRequireDefault(_CanvasRenderer);
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"); } }
/**
* @author Mat Groves
*
* Big thanks to the very clever Matt DesLauriers <mattdesl> https://github.com/mattdesl/
* for creating the original PixiJS version!
* Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that they
* now share 4 bytes on the vertex buffer
*
* Heavily inspired by LibGDX's CanvasGraphicsRenderer:
* https://github.com/libgdx/libgdx/blob/1.0.0/gdx/src/com/badlogic/gdx/graphics/glutils/ShapeRenderer.java
*/
/**
* Renderer dedicated to drawing and batching graphics objects.
*
* @class
* @private
* @memberof PIXI
*/
var CanvasGraphicsRenderer = function () {
/**
* @param {PIXI.CanvasRenderer} renderer - The current PIXI renderer.
*/
function CanvasGraphicsRenderer(renderer) {
_classCallCheck(this, CanvasGraphicsRenderer);
this.renderer = renderer;
}
/**
* Renders a Graphics object to a canvas.
*
* @param {PIXI.Graphics} graphics - the actual graphics object to render
*/
CanvasGraphicsRenderer.prototype.render = function render(graphics) {
var renderer = this.renderer;
var context = renderer.context;
var worldAlpha = graphics.worldAlpha;
var transform = graphics.transform.worldTransform;
var resolution = renderer.resolution;
context.setTransform(transform.a * resolution, transform.b * resolution, transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution);
// update tint if graphics was dirty
if (graphics.canvasTintDirty !== graphics.dirty || graphics._prevTint !== graphics.tint) {
this.updateGraphicsTint(graphics);
}
renderer.setBlendMode(graphics.blendMode);
for (var i = 0; i < graphics.graphicsData.length; i++) {
var data = graphics.graphicsData[i];
var shape = data.shape;
var fillColor = data._fillTint;
var lineColor = data._lineTint;
context.lineWidth = data.lineWidth;
if (data.type === _const.SHAPES.POLY) {
context.beginPath();
var points = shape.points;
var holes = data.holes;
var outerArea = void 0;
var innerArea = void 0;
context.moveTo(points[0], points[1]);
for (var j = 2; j < points.length; j += 2) {
context.lineTo(points[j], points[j + 1]);
}
// if the first and last point are the same close the path - much neater :)
if (shape.closed) {
context.closePath();
}
if (holes.length > 0) {
outerArea = 0;
for (var _j = 0; _j < points.length; _j += 2) {
outerArea += points[_j] * points[_j + 3] - points[_j + 1] * points[_j + 2];
}
for (var k = 0; k < holes.length; k++) {
points = holes[k].points;
innerArea = 0;
for (var _j2 = 0; _j2 < points.length; _j2 += 2) {
innerArea += points[_j2] * points[_j2 + 3] - points[_j2 + 1] * points[_j2 + 2];
}
context.moveTo(points[0], points[1]);
if (innerArea * outerArea < 0) {
for (var _j3 = 2; _j3 < points.length; _j3 += 2) {
context.lineTo(points[_j3], points[_j3 + 1]);
}
} else {
for (var _j4 = points.length - 2; _j4 >= 2; _j4 -= 2) {
context.lineTo(points[_j4], points[_j4 + 1]);
}
}
if (holes[k].closed) {
context.closePath();
}
}
}
if (data.fill) {
context.globalAlpha = data.fillAlpha * worldAlpha;
context.fillStyle = '#' + ('00000' + (fillColor | 0).toString(16)).substr(-6);
context.fill();
}
if (data.lineWidth) {
context.globalAlpha = data.lineAlpha * worldAlpha;
context.strokeStyle = '#' + ('00000' + (lineColor | 0).toString(16)).substr(-6);
context.stroke();
}
} else if (data.type === _const.SHAPES.RECT) {
if (data.fillColor || data.fillColor === 0) {
context.globalAlpha = data.fillAlpha * worldAlpha;
context.fillStyle = '#' + ('00000' + (fillColor | 0).toString(16)).substr(-6);
context.fillRect(shape.x, shape.y, shape.width, shape.height);
}
if (data.lineWidth) {
context.globalAlpha = data.lineAlpha * worldAlpha;
context.strokeStyle = '#' + ('00000' + (lineColor | 0).toString(16)).substr(-6);
context.strokeRect(shape.x, shape.y, shape.width, shape.height);
}
} else if (data.type === _const.SHAPES.CIRC) {
// TODO - need to be Undefined!
context.beginPath();
context.arc(shape.x, shape.y, shape.radius, 0, 2 * Math.PI);
context.closePath();
if (data.fill) {
context.globalAlpha = data.fillAlpha * worldAlpha;
context.fillStyle = '#' + ('00000' + (fillColor | 0).toString(16)).substr(-6);
context.fill();
}
if (data.lineWidth) {
context.globalAlpha = data.lineAlpha * worldAlpha;
context.strokeStyle = '#' + ('00000' + (lineColor | 0).toString(16)).substr(-6);
context.stroke();
}
} else if (data.type === _const.SHAPES.ELIP) {
// ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
var w = shape.width * 2;
var h = shape.height * 2;
var x = shape.x - w / 2;
var y = shape.y - h / 2;
context.beginPath();
var kappa = 0.5522848;
var ox = w / 2 * kappa; // control point offset horizontal
var oy = h / 2 * kappa; // control point offset vertical
var xe = x + w; // x-end
var ye = y + h; // y-end
var xm = x + w / 2; // x-middle
var ym = y + h / 2; // y-middle
context.moveTo(x, ym);
context.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
context.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
context.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
context.closePath();
if (data.fill) {
context.globalAlpha = data.fillAlpha * worldAlpha;
context.fillStyle = '#' + ('00000' + (fillColor | 0).toString(16)).substr(-6);
context.fill();
}
if (data.lineWidth) {
context.globalAlpha = data.lineAlpha * worldAlpha;
context.strokeStyle = '#' + ('00000' + (lineColor | 0).toString(16)).substr(-6);
context.stroke();
}
} else if (data.type === _const.SHAPES.RREC) {
var rx = shape.x;
var ry = shape.y;
var width = shape.width;
var height = shape.height;
var radius = shape.radius;
var maxRadius = Math.min(width, height) / 2 | 0;
radius = radius > maxRadius ? maxRadius : radius;
context.beginPath();
context.moveTo(rx, ry + radius);
context.lineTo(rx, ry + height - radius);
context.quadraticCurveTo(rx, ry + height, rx + radius, ry + height);
context.lineTo(rx + width - radius, ry + height);
context.quadraticCurveTo(rx + width, ry + height, rx + width, ry + height - radius);
context.lineTo(rx + width, ry + radius);
context.quadraticCurveTo(rx + width, ry, rx + width - radius, ry);
context.lineTo(rx + radius, ry);
context.quadraticCurveTo(rx, ry, rx, ry + radius);
context.closePath();
if (data.fillColor || data.fillColor === 0) {
context.globalAlpha = data.fillAlpha * worldAlpha;
context.fillStyle = '#' + ('00000' + (fillColor | 0).toString(16)).substr(-6);
context.fill();
}
if (data.lineWidth) {
context.globalAlpha = data.lineAlpha * worldAlpha;
context.strokeStyle = '#' + ('00000' + (lineColor | 0).toString(16)).substr(-6);
context.stroke();
}
}
}
};
/**
* Updates the tint of a graphics object
*
* @private
* @param {PIXI.Graphics} graphics - the graphics that will have its tint updated
*/
CanvasGraphicsRenderer.prototype.updateGraphicsTint = function updateGraphicsTint(graphics) {
graphics._prevTint = graphics.tint;
graphics.canvasTintDirty = graphics.dirty;
var tintR = (graphics.tint >> 16 & 0xFF) / 255;
var tintG = (graphics.tint >> 8 & 0xFF) / 255;
var tintB = (graphics.tint & 0xFF) / 255;
for (var i = 0; i < graphics.graphicsData.length; ++i) {
var data = graphics.graphicsData[i];
var fillColor = data.fillColor | 0;
var lineColor = data.lineColor | 0;
// super inline, cos optimization :)
data._fillTint = ((fillColor >> 16 & 0xFF) / 255 * tintR * 255 << 16) + ((fillColor >> 8 & 0xFF) / 255 * tintG * 255 << 8) + (fillColor & 0xFF) / 255 * tintB * 255;
data._lineTint = ((lineColor >> 16 & 0xFF) / 255 * tintR * 255 << 16) + ((lineColor >> 8 & 0xFF) / 255 * tintG * 255 << 8) + (lineColor & 0xFF) / 255 * tintB * 255;
}
};
/**
* Renders a polygon.
*
* @param {PIXI.Point[]} points - The points to render
* @param {boolean} close - Should the polygon be closed
* @param {CanvasRenderingContext2D} context - The rendering context to use
*/
CanvasGraphicsRenderer.prototype.renderPolygon = function renderPolygon(points, close, context) {
context.moveTo(points[0], points[1]);
for (var j = 1; j < points.length / 2; ++j) {
context.lineTo(points[j * 2], points[j * 2 + 1]);
}
if (close) {
context.closePath();
}
};
/**
* destroy graphics object
*
*/
CanvasGraphicsRenderer.prototype.destroy = function destroy() {
this.renderer = null;
};
return CanvasGraphicsRenderer;
}();
exports.default = CanvasGraphicsRenderer;
_CanvasRenderer2.default.registerPlugin('graphics', CanvasGraphicsRenderer);
//# sourceMappingURL=CanvasGraphicsRenderer.js.map
/***/ }),
/* 496 */
/***/ (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 _ = __webpack_require__(5);
var _utils = __webpack_require__(7);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Utility class for maintaining reference to a collection
* of Textures on a single Spritesheet.
*
* To access a sprite sheet from your code pass its JSON data file to Pixi's loader:
*
* ```js
* PIXI.loader.add("images/spritesheet.json").load(setup);
*
* function setup() {
* let sheet = PIXI.loader.resources["images/spritesheet.json"].spritesheet;
* ...
* }
* ```
* With the `sheet.textures` you can create Sprite objects,`sheet.animations` can be used to create an AnimatedSprite.
*
* Sprite sheets can be packed using tools like {@link https://codeandweb.com/texturepacker|TexturePacker},
* {@link https://renderhjs.net/shoebox/|Shoebox} or {@link https://github.com/krzysztof-o/spritesheet.js|Spritesheet.js}.
* Default anchor points (see {@link PIXI.Texture#defaultAnchor}) and grouping of animation sprites are currently only
* supported by TexturePacker.
*
* @class
* @memberof PIXI
*/
var Spritesheet = function () {
_createClass(Spritesheet, null, [{
key: 'BATCH_SIZE',
/**
* The maximum number of Textures to build per process.
*
* @type {number}
* @default 1000
*/
get: function get() {
return 1000;
}
/**
* @param {PIXI.BaseTexture} baseTexture Reference to the source BaseTexture object.
* @param {Object} data - Spritesheet image data.
* @param {string} [resolutionFilename] - The filename to consider when determining
* the resolution of the spritesheet. If not provided, the imageUrl will
* be used on the BaseTexture.
*/
}]);
function Spritesheet(baseTexture, data) {
var resolutionFilename = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
_classCallCheck(this, Spritesheet);
/**
* Reference to ths source texture
* @type {PIXI.BaseTexture}
*/
this.baseTexture = baseTexture;
/**
* A map containing all textures of the sprite sheet.
* Can be used to create a {@link PIXI.Sprite|Sprite}:
* ```js
* new PIXI.Sprite(sheet.textures["image.png"]);
* ```
* @member {Object}
*/
this.textures = {};
/**
* A map containing the textures for each animation.
* Can be used to create an {@link PIXI.extras.AnimatedSprite|AnimatedSprite}:
* ```js
* new PIXI.extras.AnimatedSprite(sheet.animations["anim_name"])
* ```
* @member {Object}
*/
this.animations = {};
/**
* Reference to the original JSON data.
* @type {Object}
*/
this.data = data;
/**
* The resolution of the spritesheet.
* @type {number}
*/
this.resolution = this._updateResolution(resolutionFilename || this.baseTexture.imageUrl);
/**
* Map of spritesheet frames.
* @type {Object}
* @private
*/
this._frames = this.data.frames;
/**
* Collection of frame names.
* @type {string[]}
* @private
*/
this._frameKeys = Object.keys(this._frames);
/**
* Current batch index being processed.
* @type {number}
* @private
*/
this._batchIndex = 0;
/**
* Callback when parse is completed.
* @type {Function}
* @private
*/
this._callback = null;
}
/**
* Generate the resolution from the filename or fallback
* to the meta.scale field of the JSON data.
*
* @private
* @param {string} resolutionFilename - The filename to use for resolving
* the default resolution.
* @return {number} Resolution to use for spritesheet.
*/
Spritesheet.prototype._updateResolution = function _updateResolution(resolutionFilename) {
var scale = this.data.meta.scale;
// Use a defaultValue of `null` to check if a url-based resolution is set
var resolution = (0, _utils.getResolutionOfUrl)(resolutionFilename, null);
// No resolution found via URL
if (resolution === null) {
// Use the scale value or default to 1
resolution = scale !== undefined ? parseFloat(scale) : 1;
}
// For non-1 resolutions, update baseTexture
if (resolution !== 1) {
this.baseTexture.resolution = resolution;
this.baseTexture.update();
}
return resolution;
};
/**
* Parser spritesheet from loaded data. This is done asynchronously
* to prevent creating too many Texture within a single process.
*
* @param {Function} callback - Callback when complete returns
* a map of the Textures for this spritesheet.
*/
Spritesheet.prototype.parse = function parse(callback) {
this._batchIndex = 0;
this._callback = callback;
if (this._frameKeys.length <= Spritesheet.BATCH_SIZE) {
this._processFrames(0);
this._processAnimations();
this._parseComplete();
} else {
this._nextBatch();
}
};
/**
* Process a batch of frames
*
* @private
* @param {number} initialFrameIndex - The index of frame to start.
*/
Spritesheet.prototype._processFrames = function _processFrames(initialFrameIndex) {
var frameIndex = initialFrameIndex;
var maxFrames = Spritesheet.BATCH_SIZE;
var sourceScale = this.baseTexture.sourceScale;
while (frameIndex - initialFrameIndex < maxFrames && frameIndex < this._frameKeys.length) {
var i = this._frameKeys[frameIndex];
var data = this._frames[i];
var rect = data.frame;
if (rect) {
var frame = null;
var trim = null;
var sourceSize = data.trimmed !== false && data.sourceSize ? data.sourceSize : data.frame;
var orig = new _.Rectangle(0, 0, Math.floor(sourceSize.w * sourceScale) / this.resolution, Math.floor(sourceSize.h * sourceScale) / this.resolution);
if (data.rotated) {
frame = new _.Rectangle(Math.floor(rect.x * sourceScale) / this.resolution, Math.floor(rect.y * sourceScale) / this.resolution, Math.floor(rect.h * sourceScale) / this.resolution, Math.floor(rect.w * sourceScale) / this.resolution);
} else {
frame = new _.Rectangle(Math.floor(rect.x * sourceScale) / this.resolution, Math.floor(rect.y * sourceScale) / this.resolution, Math.floor(rect.w * sourceScale) / this.resolution, Math.floor(rect.h * sourceScale) / this.resolution);
}
// Check to see if the sprite is trimmed
if (data.trimmed !== false && data.spriteSourceSize) {
trim = new _.Rectangle(Math.floor(data.spriteSourceSize.x * sourceScale) / this.resolution, Math.floor(data.spriteSourceSize.y * sourceScale) / this.resolution, Math.floor(rect.w * sourceScale) / this.resolution, Math.floor(rect.h * sourceScale) / this.resolution);
}
this.textures[i] = new _.Texture(this.baseTexture, frame, orig, trim, data.rotated ? 2 : 0, data.anchor);
// lets also add the frame to pixi's global cache for fromFrame and fromImage functions
_.Texture.addToCache(this.textures[i], i);
}
frameIndex++;
}
};
/**
* Parse animations config
*
* @private
*/
Spritesheet.prototype._processAnimations = function _processAnimations() {
var animations = this.data.animations || {};
for (var animName in animations) {
this.animations[animName] = [];
for (var _iterator = animations[animName], _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var frameName = _ref;
this.animations[animName].push(this.textures[frameName]);
}
}
};
/**
* The parse has completed.
*
* @private
*/
Spritesheet.prototype._parseComplete = function _parseComplete() {
var callback = this._callback;
this._callback = null;
this._batchIndex = 0;
callback.call(this, this.textures);
};
/**
* Begin the next batch of textures.
*
* @private
*/
Spritesheet.prototype._nextBatch = function _nextBatch() {
var _this = this;
this._processFrames(this._batchIndex * Spritesheet.BATCH_SIZE);
this._batchIndex++;
setTimeout(function () {
if (_this._batchIndex * Spritesheet.BATCH_SIZE < _this._frameKeys.length) {
_this._nextBatch();
} else {
_this._processAnimations();
_this._parseComplete();
}
}, 0);
};
/**
* Destroy Spritesheet and don't use after this.
*
* @param {boolean} [destroyBase=false] Whether to destroy the base texture as well
*/
Spritesheet.prototype.destroy = function destroy() {
var destroyBase = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
for (var i in this.textures) {
this.textures[i].destroy();
}
this._frames = null;
this._frameKeys = null;
this.data = null;
this.textures = null;
if (destroyBase) {
this.baseTexture.destroy();
}
this.baseTexture = null;
};
return Spritesheet;
}();
exports.default = Spritesheet;
//# sourceMappingURL=Spritesheet.js.map
/***/ }),
/* 497 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.default = deprecation;
// provide method to give a stack track for warnings
// useful for tracking-down where deprecated methods/properties/classes
// are being used within the code
// A map of warning messages already fired
var warnings = {};
// provide method to give a stack track for warnings
// useful for tracking-down where deprecated methods/properties/classes
// are being used within the code
function warn(msg) {
// Ignore duplicat
if (warnings[msg]) {
return;
}
/* eslint-disable no-console */
var stack = new Error().stack;
// Handle IE < 10 and Safari < 6
if (typeof stack === 'undefined') {
console.warn('Deprecation Warning: ', msg);
} else {
// chop off the stack trace which includes pixi.js internal calls
stack = stack.split('\n').splice(3).join('\n');
if (console.groupCollapsed) {
console.groupCollapsed('%cDeprecation Warning: %c%s', 'color:#614108;background:#fffbe6', 'font-weight:normal;color:#614108;background:#fffbe6', msg);
console.warn(stack);
console.groupEnd();
} else {
console.warn('Deprecation Warning: ', msg);
console.warn(stack);
}
}
/* eslint-enable no-console */
warnings[msg] = true;
}
function deprecation(core) {
var mesh = core.mesh,
particles = core.particles,
extras = core.extras,
filters = core.filters,
prepare = core.prepare,
loaders = core.loaders,
interaction = core.interaction;
Object.defineProperties(core, {
/**
* @class
* @private
* @name SpriteBatch
* @memberof PIXI
* @see PIXI.ParticleContainer
* @throws {ReferenceError} SpriteBatch does not exist any more, please use the new ParticleContainer instead.
* @deprecated since version 3.0.0
*/
SpriteBatch: {
get: function get() {
throw new ReferenceError('SpriteBatch does not exist any more, ' + 'please use the new ParticleContainer instead.');
}
},
/**
* @class
* @private
* @name AssetLoader
* @memberof PIXI
* @see PIXI.loaders.Loader
* @throws {ReferenceError} The loader system was overhauled in PixiJS v3,
* please see the new PIXI.loaders.Loader class.
* @deprecated since version 3.0.0
*/
AssetLoader: {
get: function get() {
throw new ReferenceError('The loader system was overhauled in PixiJS v3, ' + 'please see the new PIXI.loaders.Loader class.');
}
},
/**
* @class
* @private
* @name Stage
* @memberof PIXI
* @see PIXI.Container
* @deprecated since version 3.0.0
*/
Stage: {
get: function get() {
warn('You do not need to use a PIXI Stage any more, you can simply render any container.');
return core.Container;
}
},
/**
* @class
* @private
* @name DisplayObjectContainer
* @memberof PIXI
* @see PIXI.Container
* @deprecated since version 3.0.0
*/
DisplayObjectContainer: {
get: function get() {
warn('DisplayObjectContainer has been shortened to Container, please use Container from now on.');
return core.Container;
}
},
/**
* @class
* @private
* @name Strip
* @memberof PIXI
* @see PIXI.mesh.Mesh
* @deprecated since version 3.0.0
*/
Strip: {
get: function get() {
warn('The Strip class has been renamed to Mesh and moved to mesh.Mesh, please use mesh.Mesh from now on.');
return mesh.Mesh;
}
},
/**
* @class
* @private
* @name Rope
* @memberof PIXI
* @see PIXI.mesh.Rope
* @deprecated since version 3.0.0
*/
Rope: {
get: function get() {
warn('The Rope class has been moved to mesh.Rope, please use mesh.Rope from now on.');
return mesh.Rope;
}
},
/**
* @class
* @private
* @name ParticleContainer
* @memberof PIXI
* @see PIXI.particles.ParticleContainer
* @deprecated since version 4.0.0
*/
ParticleContainer: {
get: function get() {
warn('The ParticleContainer class has been moved to particles.ParticleContainer, ' + 'please use particles.ParticleContainer from now on.');
return particles.ParticleContainer;
}
},
/**
* @class
* @private
* @name MovieClip
* @memberof PIXI
* @see PIXI.extras.MovieClip
* @deprecated since version 3.0.0
*/
MovieClip: {
get: function get() {
warn('The MovieClip class has been moved to extras.AnimatedSprite, please use extras.AnimatedSprite.');
return extras.AnimatedSprite;
}
},
/**
* @class
* @private
* @name TilingSprite
* @memberof PIXI
* @see PIXI.extras.TilingSprite
* @deprecated since version 3.0.0
*/
TilingSprite: {
get: function get() {
warn('The TilingSprite class has been moved to extras.TilingSprite, ' + 'please use extras.TilingSprite from now on.');
return extras.TilingSprite;
}
},
/**
* @class
* @private
* @name BitmapText
* @memberof PIXI
* @see PIXI.extras.BitmapText
* @deprecated since version 3.0.0
*/
BitmapText: {
get: function get() {
warn('The BitmapText class has been moved to extras.BitmapText, ' + 'please use extras.BitmapText from now on.');
return extras.BitmapText;
}
},
/**
* @class
* @private
* @name blendModes
* @memberof PIXI
* @see PIXI.BLEND_MODES
* @deprecated since version 3.0.0
*/
blendModes: {
get: function get() {
warn('The blendModes has been moved to BLEND_MODES, please use BLEND_MODES from now on.');
return core.BLEND_MODES;
}
},
/**
* @class
* @private
* @name scaleModes
* @memberof PIXI
* @see PIXI.SCALE_MODES
* @deprecated since version 3.0.0
*/
scaleModes: {
get: function get() {
warn('The scaleModes has been moved to SCALE_MODES, please use SCALE_MODES from now on.');
return core.SCALE_MODES;
}
},
/**
* @class
* @private
* @name BaseTextureCache
* @memberof PIXI
* @see PIXI.utils.BaseTextureCache
* @deprecated since version 3.0.0
*/
BaseTextureCache: {
get: function get() {
warn('The BaseTextureCache class has been moved to utils.BaseTextureCache, ' + 'please use utils.BaseTextureCache from now on.');
return core.utils.BaseTextureCache;
}
},
/**
* @class
* @private
* @name TextureCache
* @memberof PIXI
* @see PIXI.utils.TextureCache
* @deprecated since version 3.0.0
*/
TextureCache: {
get: function get() {
warn('The TextureCache class has been moved to utils.TextureCache, ' + 'please use utils.TextureCache from now on.');
return core.utils.TextureCache;
}
},
/**
* @namespace
* @private
* @name math
* @memberof PIXI
* @see PIXI
* @deprecated since version 3.0.6
*/
math: {
get: function get() {
warn('The math namespace is deprecated, please access members already accessible on PIXI.');
return core;
}
},
/**
* @class
* @private
* @name PIXI.AbstractFilter
* @see PIXI.Filter
* @deprecated since version 3.0.6
*/
AbstractFilter: {
get: function get() {
warn('AstractFilter has been renamed to Filter, please use PIXI.Filter');
return core.Filter;
}
},
/**
* @class
* @private
* @name PIXI.TransformManual
* @see PIXI.TransformBase
* @deprecated since version 4.0.0
*/
TransformManual: {
get: function get() {
warn('TransformManual has been renamed to TransformBase, please update your pixi-spine');
return core.TransformBase;
}
},
/**
* @static
* @constant
* @name PIXI.TARGET_FPMS
* @see PIXI.settings.TARGET_FPMS
* @deprecated since version 4.2.0
*/
TARGET_FPMS: {
get: function get() {
warn('PIXI.TARGET_FPMS has been deprecated, please use PIXI.settings.TARGET_FPMS');
return core.settings.TARGET_FPMS;
},
set: function set(value) {
warn('PIXI.TARGET_FPMS has been deprecated, please use PIXI.settings.TARGET_FPMS');
core.settings.TARGET_FPMS = value;
}
},
/**
* @static
* @constant
* @name PIXI.FILTER_RESOLUTION
* @see PIXI.settings.FILTER_RESOLUTION
* @deprecated since version 4.2.0
*/
FILTER_RESOLUTION: {
get: function get() {
warn('PIXI.FILTER_RESOLUTION has been deprecated, please use PIXI.settings.FILTER_RESOLUTION');
return core.settings.FILTER_RESOLUTION;
},
set: function set(value) {
warn('PIXI.FILTER_RESOLUTION has been deprecated, please use PIXI.settings.FILTER_RESOLUTION');
core.settings.FILTER_RESOLUTION = value;
}
},
/**
* @static
* @constant
* @name PIXI.RESOLUTION
* @see PIXI.settings.RESOLUTION
* @deprecated since version 4.2.0
*/
RESOLUTION: {
get: function get() {
warn('PIXI.RESOLUTION has been deprecated, please use PIXI.settings.RESOLUTION');
return core.settings.RESOLUTION;
},
set: function set(value) {
warn('PIXI.RESOLUTION has been deprecated, please use PIXI.settings.RESOLUTION');
core.settings.RESOLUTION = value;
}
},
/**
* @static
* @constant
* @name PIXI.MIPMAP_TEXTURES
* @see PIXI.settings.MIPMAP_TEXTURES
* @deprecated since version 4.2.0
*/
MIPMAP_TEXTURES: {
get: function get() {
warn('PIXI.MIPMAP_TEXTURES has been deprecated, please use PIXI.settings.MIPMAP_TEXTURES');
return core.settings.MIPMAP_TEXTURES;
},
set: function set(value) {
warn('PIXI.MIPMAP_TEXTURES has been deprecated, please use PIXI.settings.MIPMAP_TEXTURES');
core.settings.MIPMAP_TEXTURES = value;
}
},
/**
* @static
* @constant
* @name PIXI.SPRITE_BATCH_SIZE
* @see PIXI.settings.SPRITE_BATCH_SIZE
* @deprecated since version 4.2.0
*/
SPRITE_BATCH_SIZE: {
get: function get() {
warn('PIXI.SPRITE_BATCH_SIZE has been deprecated, please use PIXI.settings.SPRITE_BATCH_SIZE');
return core.settings.SPRITE_BATCH_SIZE;
},
set: function set(value) {
warn('PIXI.SPRITE_BATCH_SIZE has been deprecated, please use PIXI.settings.SPRITE_BATCH_SIZE');
core.settings.SPRITE_BATCH_SIZE = value;
}
},
/**
* @static
* @constant
* @name PIXI.SPRITE_MAX_TEXTURES
* @see PIXI.settings.SPRITE_MAX_TEXTURES
* @deprecated since version 4.2.0
*/
SPRITE_MAX_TEXTURES: {
get: function get() {
warn('PIXI.SPRITE_MAX_TEXTURES has been deprecated, please use PIXI.settings.SPRITE_MAX_TEXTURES');
return core.settings.SPRITE_MAX_TEXTURES;
},
set: function set(value) {
warn('PIXI.SPRITE_MAX_TEXTURES has been deprecated, please use PIXI.settings.SPRITE_MAX_TEXTURES');
core.settings.SPRITE_MAX_TEXTURES = value;
}
},
/**
* @static
* @constant
* @name PIXI.RETINA_PREFIX
* @see PIXI.settings.RETINA_PREFIX
* @deprecated since version 4.2.0
*/
RETINA_PREFIX: {
get: function get() {
warn('PIXI.RETINA_PREFIX has been deprecated, please use PIXI.settings.RETINA_PREFIX');
return core.settings.RETINA_PREFIX;
},
set: function set(value) {
warn('PIXI.RETINA_PREFIX has been deprecated, please use PIXI.settings.RETINA_PREFIX');
core.settings.RETINA_PREFIX = value;
}
},
/**
* @static
* @constant
* @name PIXI.DEFAULT_RENDER_OPTIONS
* @see PIXI.settings.RENDER_OPTIONS
* @deprecated since version 4.2.0
*/
DEFAULT_RENDER_OPTIONS: {
get: function get() {
warn('PIXI.DEFAULT_RENDER_OPTIONS has been deprecated, please use PIXI.settings.DEFAULT_RENDER_OPTIONS');
return core.settings.RENDER_OPTIONS;
}
}
});
// Move the default properties to settings
var defaults = [{ parent: 'TRANSFORM_MODE', target: 'TRANSFORM_MODE' }, { parent: 'GC_MODES', target: 'GC_MODE' }, { parent: 'WRAP_MODES', target: 'WRAP_MODE' }, { parent: 'SCALE_MODES', target: 'SCALE_MODE' }, { parent: 'PRECISION', target: 'PRECISION_FRAGMENT' }];
var _loop = function _loop(i) {
var deprecation = defaults[i];
Object.defineProperty(core[deprecation.parent], 'DEFAULT', {
get: function get() {
warn('PIXI.' + deprecation.parent + '.DEFAULT has been deprecated, ' + ('please use PIXI.settings.' + deprecation.target));
return core.settings[deprecation.target];
},
set: function set(value) {
warn('PIXI.' + deprecation.parent + '.DEFAULT has been deprecated, ' + ('please use PIXI.settings.' + deprecation.target));
core.settings[deprecation.target] = value;
}
});
};
for (var i = 0; i < defaults.length; i++) {
_loop(i);
}
Object.defineProperties(core.settings, {
/**
* @static
* @name PRECISION
* @memberof PIXI.settings
* @see PIXI.PRECISION
* @deprecated since version 4.4.0
*/
PRECISION: {
get: function get() {
warn('PIXI.settings.PRECISION has been deprecated, please use PIXI.settings.PRECISION_FRAGMENT');
return core.settings.PRECISION_FRAGMENT;
},
set: function set(value) {
warn('PIXI.settings.PRECISION has been deprecated, please use PIXI.settings.PRECISION_FRAGMENT');
core.settings.PRECISION_FRAGMENT = value;
}
}
});
if (extras.AnimatedSprite) {
Object.defineProperties(extras, {
/**
* @class
* @name MovieClip
* @memberof PIXI.extras
* @see PIXI.extras.AnimatedSprite
* @deprecated since version 4.2.0
*/
MovieClip: {
get: function get() {
warn('The MovieClip class has been renamed to AnimatedSprite, please use AnimatedSprite from now on.');
return extras.AnimatedSprite;
}
}
});
}
if (extras) {
Object.defineProperties(extras, {
/**
* @class
* @name TextureTransform
* @memberof PIXI.extras
* @see PIXI.TextureMatrix
* @deprecated since version 4.6.0
*/
TextureTransform: {
get: function get() {
warn('The TextureTransform class has been renamed to TextureMatrix, ' + 'please use PIXI.TextureMatrix from now on.');
return core.TextureMatrix;
}
}
});
}
core.DisplayObject.prototype.generateTexture = function generateTexture(renderer, scaleMode, resolution) {
warn('generateTexture has moved to the renderer, please use renderer.generateTexture(displayObject)');
return renderer.generateTexture(this, scaleMode, resolution);
};
core.Graphics.prototype.generateTexture = function generateTexture(scaleMode, resolution) {
warn('graphics generate texture has moved to the renderer. ' + 'Or to render a graphics to a texture using canvas please use generateCanvasTexture');
return this.generateCanvasTexture(scaleMode, resolution);
};
/**
* @method
* @name PIXI.GroupD8.isSwapWidthHeight
* @see PIXI.GroupD8.isVertical
* @param {number} rotation - The number to check.
* @returns {boolean} Whether or not the direction is vertical
* @deprecated since version 4.6.0
*/
core.GroupD8.isSwapWidthHeight = function isSwapWidthHeight(rotation) {
warn('GroupD8.isSwapWidthHeight was renamed to GroupD8.isVertical');
return core.GroupD8.isVertical(rotation);
};
core.RenderTexture.prototype.render = function render(displayObject, matrix, clear, updateTransform) {
this.legacyRenderer.render(displayObject, this, clear, matrix, !updateTransform);
warn('RenderTexture.render is now deprecated, please use renderer.render(displayObject, renderTexture)');
};
core.RenderTexture.prototype.getImage = function getImage(target) {
warn('RenderTexture.getImage is now deprecated, please use renderer.extract.image(target)');
return this.legacyRenderer.extract.image(target);
};
core.RenderTexture.prototype.getBase64 = function getBase64(target) {
warn('RenderTexture.getBase64 is now deprecated, please use renderer.extract.base64(target)');
return this.legacyRenderer.extract.base64(target);
};
core.RenderTexture.prototype.getCanvas = function getCanvas(target) {
warn('RenderTexture.getCanvas is now deprecated, please use renderer.extract.canvas(target)');
return this.legacyRenderer.extract.canvas(target);
};
core.RenderTexture.prototype.getPixels = function getPixels(target) {
warn('RenderTexture.getPixels is now deprecated, please use renderer.extract.pixels(target)');
return this.legacyRenderer.pixels(target);
};
/**
* @method
* @private
* @name PIXI.Sprite#setTexture
* @see PIXI.Sprite#texture
* @deprecated since version 3.0.0
* @param {PIXI.Texture} texture - The texture to set to.
*/
core.Sprite.prototype.setTexture = function setTexture(texture) {
this.texture = texture;
warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;');
};
if (extras.BitmapText) {
/**
* @method
* @name PIXI.extras.BitmapText#setText
* @see PIXI.extras.BitmapText#text
* @deprecated since version 3.0.0
* @param {string} text - The text to set to.
*/
extras.BitmapText.prototype.setText = function setText(text) {
this.text = text;
warn('setText is now deprecated, please use the text property, e.g : myBitmapText.text = \'my text\';');
};
}
/**
* @method
* @name PIXI.Text#setText
* @see PIXI.Text#text
* @deprecated since version 3.0.0
* @param {string} text - The text to set to.
*/
core.Text.prototype.setText = function setText(text) {
this.text = text;
warn('setText is now deprecated, please use the text property, e.g : myText.text = \'my text\';');
};
/**
* Calculates the ascent, descent and fontSize of a given fontStyle
*
* @name PIXI.Text.calculateFontProperties
* @see PIXI.TextMetrics.measureFont
* @deprecated since version 4.5.0
* @param {string} font - String representing the style of the font
* @return {Object} Font properties object
*/
core.Text.calculateFontProperties = function calculateFontProperties(font) {
warn('Text.calculateFontProperties is now deprecated, please use the TextMetrics.measureFont');
return core.TextMetrics.measureFont(font);
};
Object.defineProperties(core.Text, {
fontPropertiesCache: {
get: function get() {
warn('Text.fontPropertiesCache is deprecated');
return core.TextMetrics._fonts;
}
},
fontPropertiesCanvas: {
get: function get() {
warn('Text.fontPropertiesCanvas is deprecated');
return core.TextMetrics._canvas;
}
},
fontPropertiesContext: {
get: function get() {
warn('Text.fontPropertiesContext is deprecated');
return core.TextMetrics._context;
}
}
});
/**
* @method
* @name PIXI.Text#setStyle
* @see PIXI.Text#style
* @deprecated since version 3.0.0
* @param {*} style - The style to set to.
*/
core.Text.prototype.setStyle = function setStyle(style) {
this.style = style;
warn('setStyle is now deprecated, please use the style property, e.g : myText.style = style;');
};
/**
* @method
* @name PIXI.Text#determineFontProperties
* @see PIXI.Text#measureFontProperties
* @deprecated since version 4.2.0
* @private
* @param {string} fontStyle - String representing the style of the font
* @return {Object} Font properties object
*/
core.Text.prototype.determineFontProperties = function determineFontProperties(fontStyle) {
warn('determineFontProperties is now deprecated, please use TextMetrics.measureFont method');
return core.TextMetrics.measureFont(fontStyle);
};
/**
* @method
* @name PIXI.Text.getFontStyle
* @see PIXI.TextMetrics.getFontStyle
* @deprecated since version 4.5.0
* @param {PIXI.TextStyle} style - The style to use.
* @return {string} Font string
*/
core.Text.getFontStyle = function getFontStyle(style) {
warn('getFontStyle is now deprecated, please use TextStyle.toFontString() instead');
style = style || {};
if (!(style instanceof core.TextStyle)) {
style = new core.TextStyle(style);
}
return style.toFontString();
};
Object.defineProperties(core.TextStyle.prototype, {
/**
* Set all properties of a font as a single string
*
* @name PIXI.TextStyle#font
* @deprecated since version 4.0.0
*/
font: {
get: function get() {
warn('text style property \'font\' is now deprecated, please use the ' + '\'fontFamily\', \'fontSize\', \'fontStyle\', \'fontVariant\' and \'fontWeight\' properties from now on');
var fontSizeString = typeof this._fontSize === 'number' ? this._fontSize + 'px' : this._fontSize;
return this._fontStyle + ' ' + this._fontVariant + ' ' + this._fontWeight + ' ' + fontSizeString + ' ' + this._fontFamily;
},
set: function set(font) {
warn('text style property \'font\' is now deprecated, please use the ' + '\'fontFamily\',\'fontSize\',fontStyle\',\'fontVariant\' and \'fontWeight\' properties from now on');
// can work out fontStyle from search of whole string
if (font.indexOf('italic') > 1) {
this._fontStyle = 'italic';
} else if (font.indexOf('oblique') > -1) {
this._fontStyle = 'oblique';
} else {
this._fontStyle = 'normal';
}
// can work out fontVariant from search of whole string
if (font.indexOf('small-caps') > -1) {
this._fontVariant = 'small-caps';
} else {
this._fontVariant = 'normal';
}
// fontWeight and fontFamily are tricker to find, but it's easier to find the fontSize due to it's units
var splits = font.split(' ');
var fontSizeIndex = -1;
this._fontSize = 26;
for (var i = 0; i < splits.length; ++i) {
if (splits[i].match(/(px|pt|em|%)/)) {
fontSizeIndex = i;
this._fontSize = splits[i];
break;
}
}
// we can now search for fontWeight as we know it must occur before the fontSize
this._fontWeight = 'normal';
for (var _i = 0; _i < fontSizeIndex; ++_i) {
if (splits[_i].match(/(bold|bolder|lighter|100|200|300|400|500|600|700|800|900)/)) {
this._fontWeight = splits[_i];
break;
}
}
// and finally join everything together after the fontSize in case the font family has multiple words
if (fontSizeIndex > -1 && fontSizeIndex < splits.length - 1) {
this._fontFamily = '';
for (var _i2 = fontSizeIndex + 1; _i2 < splits.length; ++_i2) {
this._fontFamily += splits[_i2] + ' ';
}
this._fontFamily = this._fontFamily.slice(0, -1);
} else {
this._fontFamily = 'Arial';
}
this.styleID++;
}
}
});
/**
* @method
* @name PIXI.Texture#setFrame
* @see PIXI.Texture#setFrame
* @deprecated since version 3.0.0
* @param {PIXI.Rectangle} frame - The frame to set.
*/
core.Texture.prototype.setFrame = function setFrame(frame) {
this.frame = frame;
warn('setFrame is now deprecated, please use the frame property, e.g: myTexture.frame = frame;');
};
/**
* @static
* @function
* @name PIXI.Texture.addTextureToCache
* @see PIXI.Texture.addToCache
* @deprecated since 4.5.0
* @param {PIXI.Texture} texture - The Texture to add to the cache.
* @param {string} id - The id that the texture will be stored against.
*/
core.Texture.addTextureToCache = function addTextureToCache(texture, id) {
core.Texture.addToCache(texture, id);
warn('Texture.addTextureToCache is deprecated, please use Texture.addToCache from now on.');
};
/**
* @static
* @function
* @name PIXI.Texture.removeTextureFromCache
* @see PIXI.Texture.removeFromCache
* @deprecated since 4.5.0
* @param {string} id - The id of the texture to be removed
* @return {PIXI.Texture|null} The texture that was removed
*/
core.Texture.removeTextureFromCache = function removeTextureFromCache(id) {
warn('Texture.removeTextureFromCache is deprecated, please use Texture.removeFromCache from now on. ' + 'Be aware that Texture.removeFromCache does not automatically its BaseTexture from the BaseTextureCache. ' + 'For that, use BaseTexture.removeFromCache');
core.BaseTexture.removeFromCache(id);
return core.Texture.removeFromCache(id);
};
Object.defineProperties(filters, {
/**
* @class
* @private
* @name PIXI.filters.AbstractFilter
* @see PIXI.AbstractFilter
* @deprecated since version 3.0.6
*/
AbstractFilter: {
get: function get() {
warn('AstractFilter has been renamed to Filter, please use PIXI.Filter');
return core.AbstractFilter;
}
},
/**
* @class
* @private
* @name PIXI.filters.SpriteMaskFilter
* @see PIXI.SpriteMaskFilter
* @deprecated since version 3.0.6
*/
SpriteMaskFilter: {
get: function get() {
warn('filters.SpriteMaskFilter is an undocumented alias, please use SpriteMaskFilter from now on.');
return core.SpriteMaskFilter;
}
},
/**
* @class
* @private
* @name PIXI.filters.VoidFilter
* @see PIXI.filters.AlphaFilter
* @deprecated since version 4.5.7
*/
VoidFilter: {
get: function get() {
warn('VoidFilter has been renamed to AlphaFilter, please use PIXI.filters.AlphaFilter');
return filters.AlphaFilter;
}
}
});
/**
* @method
* @name PIXI.utils.uuid
* @see PIXI.utils.uid
* @deprecated since version 3.0.6
* @return {number} The uid
*/
core.utils.uuid = function () {
warn('utils.uuid() is deprecated, please use utils.uid() from now on.');
return core.utils.uid();
};
/**
* @method
* @name PIXI.utils.canUseNewCanvasBlendModes
* @see PIXI.CanvasTinter
* @deprecated
* @return {boolean} Can use blend modes.
*/
core.utils.canUseNewCanvasBlendModes = function () {
warn('utils.canUseNewCanvasBlendModes() is deprecated, please use CanvasTinter.canUseMultiply from now on');
return core.CanvasTinter.canUseMultiply;
};
var saidHello = true;
/**
* @name PIXI.utils._saidHello
* @type {boolean}
* @see PIXI.utils.skipHello
* @deprecated since 4.1.0
*/
Object.defineProperty(core.utils, '_saidHello', {
set: function set(bool) {
if (bool) {
warn('PIXI.utils._saidHello is deprecated, please use PIXI.utils.skipHello()');
this.skipHello();
}
saidHello = bool;
},
get: function get() {
return saidHello;
}
});
if (prepare.BasePrepare) {
/**
* @method
* @name PIXI.prepare.BasePrepare#register
* @see PIXI.prepare.BasePrepare#registerFindHook
* @deprecated since version 4.4.2
* @param {Function} [addHook] - Function call that takes two parameters: `item:*, queue:Array`
* function must return `true` if it was able to add item to the queue.
* @param {Function} [uploadHook] - Function call that takes two parameters: `prepare:CanvasPrepare, item:*` and
* function must return `true` if it was able to handle upload of item.
* @return {PIXI.BasePrepare} Instance of plugin for chaining.
*/
prepare.BasePrepare.prototype.register = function register(addHook, uploadHook) {
warn('renderer.plugins.prepare.register is now deprecated, ' + 'please use renderer.plugins.prepare.registerFindHook & renderer.plugins.prepare.registerUploadHook');
if (addHook) {
this.registerFindHook(addHook);
}
if (uploadHook) {
this.registerUploadHook(uploadHook);
}
return this;
};
}
if (prepare.canvas) {
/**
* The number of graphics or textures to upload to the GPU.
*
* @name PIXI.prepare.canvas.UPLOADS_PER_FRAME
* @static
* @type {number}
* @see PIXI.prepare.BasePrepare.limiter
* @deprecated since 4.2.0
*/
Object.defineProperty(prepare.canvas, 'UPLOADS_PER_FRAME', {
set: function set() {
warn('PIXI.CanvasPrepare.UPLOADS_PER_FRAME has been removed. Please set ' + 'renderer.plugins.prepare.limiter.maxItemsPerFrame on your renderer');
// because we don't have a reference to the renderer, we can't actually set
// the uploads per frame, so we'll have to stick with the warning.
},
get: function get() {
warn('PIXI.CanvasPrepare.UPLOADS_PER_FRAME has been removed. Please use ' + 'renderer.plugins.prepare.limiter');
return NaN;
}
});
}
if (prepare.webgl) {
/**
* The number of graphics or textures to upload to the GPU.
*
* @name PIXI.prepare.webgl.UPLOADS_PER_FRAME
* @static
* @type {number}
* @see PIXI.prepare.BasePrepare.limiter
* @deprecated since 4.2.0
*/
Object.defineProperty(prepare.webgl, 'UPLOADS_PER_FRAME', {
set: function set() {
warn('PIXI.WebGLPrepare.UPLOADS_PER_FRAME has been removed. Please set ' + 'renderer.plugins.prepare.limiter.maxItemsPerFrame on your renderer');
// because we don't have a reference to the renderer, we can't actually set
// the uploads per frame, so we'll have to stick with the warning.
},
get: function get() {
warn('PIXI.WebGLPrepare.UPLOADS_PER_FRAME has been removed. Please use ' + 'renderer.plugins.prepare.limiter');
return NaN;
}
});
}
if (loaders.Loader) {
var Resource = loaders.Resource;
var Loader = loaders.Loader;
Object.defineProperties(Resource.prototype, {
isJson: {
get: function get() {
warn('The isJson property is deprecated, please use `resource.type === Resource.TYPE.JSON`.');
return this.type === Resource.TYPE.JSON;
}
},
isXml: {
get: function get() {
warn('The isXml property is deprecated, please use `resource.type === Resource.TYPE.XML`.');
return this.type === Resource.TYPE.XML;
}
},
isImage: {
get: function get() {
warn('The isImage property is deprecated, please use `resource.type === Resource.TYPE.IMAGE`.');
return this.type === Resource.TYPE.IMAGE;
}
},
isAudio: {
get: function get() {
warn('The isAudio property is deprecated, please use `resource.type === Resource.TYPE.AUDIO`.');
return this.type === Resource.TYPE.AUDIO;
}
},
isVideo: {
get: function get() {
warn('The isVideo property is deprecated, please use `resource.type === Resource.TYPE.VIDEO`.');
return this.type === Resource.TYPE.VIDEO;
}
}
});
Object.defineProperties(Loader.prototype, {
before: {
get: function get() {
warn('The before() method is deprecated, please use pre().');
return this.pre;
}
},
after: {
get: function get() {
warn('The after() method is deprecated, please use use().');
return this.use;
}
}
});
}
if (interaction.interactiveTarget) {
/**
* @name PIXI.interaction.interactiveTarget#defaultCursor
* @static
* @type {number}
* @see PIXI.interaction.interactiveTarget#cursor
* @deprecated since 4.3.0
*/
Object.defineProperty(interaction.interactiveTarget, 'defaultCursor', {
set: function set(value) {
warn('Property defaultCursor has been replaced with \'cursor\'. ');
this.cursor = value;
},
get: function get() {
warn('Property defaultCursor has been replaced with \'cursor\'. ');
return this.cursor;
}
});
}
if (interaction.InteractionManager) {
/**
* @name PIXI.interaction.InteractionManager#defaultCursorStyle
* @static
* @type {string}
* @see PIXI.interaction.InteractionManager#cursorStyles
* @deprecated since 4.3.0
*/
Object.defineProperty(interaction.InteractionManager, 'defaultCursorStyle', {
set: function set(value) {
warn('Property defaultCursorStyle has been replaced with \'cursorStyles.default\'. ');
this.cursorStyles.default = value;
},
get: function get() {
warn('Property defaultCursorStyle has been replaced with \'cursorStyles.default\'. ');
return this.cursorStyles.default;
}
});
/**
* @name PIXI.interaction.InteractionManager#currentCursorStyle
* @static
* @type {string}
* @see PIXI.interaction.InteractionManager#cursorStyles
* @deprecated since 4.3.0
*/
Object.defineProperty(interaction.InteractionManager, 'currentCursorStyle', {
set: function set(value) {
warn('Property currentCursorStyle has been removed.' + 'See the currentCursorMode property, which works differently.');
this.currentCursorMode = value;
},
get: function get() {
warn('Property currentCursorStyle has been removed.' + 'See the currentCursorMode property, which works differently.');
return this.currentCursorMode;
}
});
}
}
//# sourceMappingURL=deprecation.js.map
/***/ }),
/* 498 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _accessibleTarget = __webpack_require__(201);
Object.defineProperty(exports, 'accessibleTarget', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_accessibleTarget).default;
}
});
var _AccessibilityManager = __webpack_require__(499);
Object.defineProperty(exports, 'AccessibilityManager', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_AccessibilityManager).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map
/***/ }),
/* 499 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _ismobilejs = __webpack_require__(122);
var _ismobilejs2 = _interopRequireDefault(_ismobilejs);
var _accessibleTarget = __webpack_require__(201);
var _accessibleTarget2 = _interopRequireDefault(_accessibleTarget);
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"); } }
// add some extra variables to the container..
core.utils.mixins.delayMixin(core.DisplayObject.prototype, _accessibleTarget2.default);
var KEY_CODE_TAB = 9;
var DIV_TOUCH_SIZE = 100;
var DIV_TOUCH_POS_X = 0;
var DIV_TOUCH_POS_Y = 0;
var DIV_TOUCH_ZINDEX = 2;
var DIV_HOOK_SIZE = 1;
var DIV_HOOK_POS_X = -1000;
var DIV_HOOK_POS_Y = -1000;
var DIV_HOOK_ZINDEX = 2;
/**
* The Accessibility manager recreates the ability to tab and have content read by screen
* readers. This is very important as it can possibly help people with disabilities access pixi
* content.
*
* Much like interaction any DisplayObject can be made accessible. This manager will map the
* events as if the mouse was being used, minimizing the effort required to implement.
*
* An instance of this class is automatically created by default, and can be found at renderer.plugins.accessibility
*
* @class
* @memberof PIXI.accessibility
*/
var AccessibilityManager = function () {
/**
* @param {PIXI.CanvasRenderer|PIXI.WebGLRenderer} renderer - A reference to the current renderer
*/
function AccessibilityManager(renderer) {
_classCallCheck(this, AccessibilityManager);
if ((_ismobilejs2.default.tablet || _ismobilejs2.default.phone) && !navigator.isCocoonJS) {
this.createTouchHook();
}
// first we create a div that will sit over the PixiJS element. This is where the div overlays will go.
var div = document.createElement('div');
div.style.width = DIV_TOUCH_SIZE + 'px';
div.style.height = DIV_TOUCH_SIZE + 'px';
div.style.position = 'absolute';
div.style.top = DIV_TOUCH_POS_X + 'px';
div.style.left = DIV_TOUCH_POS_Y + 'px';
div.style.zIndex = DIV_TOUCH_ZINDEX;
/**
* This is the dom element that will sit over the PixiJS element. This is where the div overlays will go.
*
* @type {HTMLElement}
* @private
*/
this.div = div;
/**
* A simple pool for storing divs.
*
* @type {*}
* @private
*/
this.pool = [];
/**
* This is a tick used to check if an object is no longer being rendered.
*
* @type {Number}
* @private
*/
this.renderId = 0;
/**
* Setting this to true will visually show the divs.
*
* @type {boolean}
*/
this.debug = false;
/**
* The renderer this accessibility manager works for.
*
* @member {PIXI.SystemRenderer}
*/
this.renderer = renderer;
/**
* The array of currently active accessible items.
*
* @member {Array<*>}
* @private
*/
this.children = [];
/**
* pre-bind the functions
*
* @private
*/
this._onKeyDown = this._onKeyDown.bind(this);
this._onMouseMove = this._onMouseMove.bind(this);
/**
* stores the state of the manager. If there are no accessible objects or the mouse is moving, this will be false.
*
* @member {Array<*>}
* @private
*/
this.isActive = false;
this.isMobileAccessabillity = false;
// let listen for tab.. once pressed we can fire up and show the accessibility layer
window.addEventListener('keydown', this._onKeyDown, false);
}
/**
* Creates the touch hooks.
*
*/
AccessibilityManager.prototype.createTouchHook = function createTouchHook() {
var _this = this;
var hookDiv = document.createElement('button');
hookDiv.style.width = DIV_HOOK_SIZE + 'px';
hookDiv.style.height = DIV_HOOK_SIZE + 'px';
hookDiv.style.position = 'absolute';
hookDiv.style.top = DIV_HOOK_POS_X + 'px';
hookDiv.style.left = DIV_HOOK_POS_Y + 'px';
hookDiv.style.zIndex = DIV_HOOK_ZINDEX;
hookDiv.style.backgroundColor = '#FF0000';
hookDiv.title = 'HOOK DIV';
hookDiv.addEventListener('focus', function () {
_this.isMobileAccessabillity = true;
_this.activate();
document.body.removeChild(hookDiv);
});
document.body.appendChild(hookDiv);
};
/**
* Activating will cause the Accessibility layer to be shown. This is called when a user
* preses the tab key.
*
* @private
*/
AccessibilityManager.prototype.activate = function activate() {
if (this.isActive) {
return;
}
this.isActive = true;
window.document.addEventListener('mousemove', this._onMouseMove, true);
window.removeEventListener('keydown', this._onKeyDown, false);
this.renderer.on('postrender', this.update, this);
if (this.renderer.view.parentNode) {
this.renderer.view.parentNode.appendChild(this.div);
}
};
/**
* Deactivating will cause the Accessibility layer to be hidden. This is called when a user moves
* the mouse.
*
* @private
*/
AccessibilityManager.prototype.deactivate = function deactivate() {
if (!this.isActive || this.isMobileAccessabillity) {
return;
}
this.isActive = false;
window.document.removeEventListener('mousemove', this._onMouseMove, true);
window.addEventListener('keydown', this._onKeyDown, false);
this.renderer.off('postrender', this.update);
if (this.div.parentNode) {
this.div.parentNode.removeChild(this.div);
}
};
/**
* This recursive function will run through the scene graph and add any new accessible objects to the DOM layer.
*
* @private
* @param {PIXI.Container} displayObject - The DisplayObject to check.
*/
AccessibilityManager.prototype.updateAccessibleObjects = function updateAccessibleObjects(displayObject) {
if (!displayObject.visible) {
return;
}
if (displayObject.accessible && displayObject.interactive) {
if (!displayObject._accessibleActive) {
this.addChild(displayObject);
}
displayObject.renderId = this.renderId;
}
var children = displayObject.children;
for (var i = 0; i < children.length; i++) {
this.updateAccessibleObjects(children[i]);
}
};
/**
* Before each render this function will ensure that all divs are mapped correctly to their DisplayObjects.
*
* @private
*/
AccessibilityManager.prototype.update = function update() {
if (!this.renderer.renderingToScreen) {
return;
}
// update children...
this.updateAccessibleObjects(this.renderer._lastObjectRendered);
var rect = this.renderer.view.getBoundingClientRect();
var sx = rect.width / this.renderer.width;
var sy = rect.height / this.renderer.height;
var div = this.div;
div.style.left = rect.left + 'px';
div.style.top = rect.top + 'px';
div.style.width = this.renderer.width + 'px';
div.style.height = this.renderer.height + 'px';
for (var i = 0; i < this.children.length; i++) {
var child = this.children[i];
if (child.renderId !== this.renderId) {
child._accessibleActive = false;
core.utils.removeItems(this.children, i, 1);
this.div.removeChild(child._accessibleDiv);
this.pool.push(child._accessibleDiv);
child._accessibleDiv = null;
i--;
if (this.children.length === 0) {
this.deactivate();
}
} else {
// map div to display..
div = child._accessibleDiv;
var hitArea = child.hitArea;
var wt = child.worldTransform;
if (child.hitArea) {
div.style.left = (wt.tx + hitArea.x * wt.a) * sx + 'px';
div.style.top = (wt.ty + hitArea.y * wt.d) * sy + 'px';
div.style.width = hitArea.width * wt.a * sx + 'px';
div.style.height = hitArea.height * wt.d * sy + 'px';
} else {
hitArea = child.getBounds();
this.capHitArea(hitArea);
div.style.left = hitArea.x * sx + 'px';
div.style.top = hitArea.y * sy + 'px';
div.style.width = hitArea.width * sx + 'px';
div.style.height = hitArea.height * sy + 'px';
// update button titles and hints if they exist and they've changed
if (div.title !== child.accessibleTitle && child.accessibleTitle !== null) {
div.title = child.accessibleTitle;
}
if (div.getAttribute('aria-label') !== child.accessibleHint && child.accessibleHint !== null) {
div.setAttribute('aria-label', child.accessibleHint);
}
}
}
}
// increment the render id..
this.renderId++;
};
/**
* TODO: docs.
*
* @param {Rectangle} hitArea - TODO docs
*/
AccessibilityManager.prototype.capHitArea = function capHitArea(hitArea) {
if (hitArea.x < 0) {
hitArea.width += hitArea.x;
hitArea.x = 0;
}
if (hitArea.y < 0) {
hitArea.height += hitArea.y;
hitArea.y = 0;
}
if (hitArea.x + hitArea.width > this.renderer.width) {
hitArea.width = this.renderer.width - hitArea.x;
}
if (hitArea.y + hitArea.height > this.renderer.height) {
hitArea.height = this.renderer.height - hitArea.y;
}
};
/**
* Adds a DisplayObject to the accessibility manager
*
* @private
* @param {DisplayObject} displayObject - The child to make accessible.
*/
AccessibilityManager.prototype.addChild = function addChild(displayObject) {
// this.activate();
var div = this.pool.pop();
if (!div) {
div = document.createElement('button');
div.style.width = DIV_TOUCH_SIZE + 'px';
div.style.height = DIV_TOUCH_SIZE + 'px';
div.style.backgroundColor = this.debug ? 'rgba(255,0,0,0.5)' : 'transparent';
div.style.position = 'absolute';
div.style.zIndex = DIV_TOUCH_ZINDEX;
div.style.borderStyle = 'none';
// ARIA attributes ensure that button title and hint updates are announced properly
if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
// Chrome doesn't need aria-live to work as intended; in fact it just gets more confused.
div.setAttribute('aria-live', 'off');
} else {
div.setAttribute('aria-live', 'polite');
}
if (navigator.userAgent.match(/rv:.*Gecko\//)) {
// FireFox needs this to announce only the new button name
div.setAttribute('aria-relevant', 'additions');
} else {
// required by IE, other browsers don't much care
div.setAttribute('aria-relevant', 'text');
}
div.addEventListener('click', this._onClick.bind(this));
div.addEventListener('focus', this._onFocus.bind(this));
div.addEventListener('focusout', this._onFocusOut.bind(this));
}
if (displayObject.accessibleTitle && displayObject.accessibleTitle !== null) {
div.title = displayObject.accessibleTitle;
} else if (!displayObject.accessibleHint || displayObject.accessibleHint === null) {
div.title = 'displayObject ' + displayObject.tabIndex;
}
if (displayObject.accessibleHint && displayObject.accessibleHint !== null) {
div.setAttribute('aria-label', displayObject.accessibleHint);
}
//
displayObject._accessibleActive = true;
displayObject._accessibleDiv = div;
div.displayObject = displayObject;
this.children.push(displayObject);
this.div.appendChild(displayObject._accessibleDiv);
displayObject._accessibleDiv.tabIndex = displayObject.tabIndex;
};
/**
* Maps the div button press to pixi's InteractionManager (click)
*
* @private
* @param {MouseEvent} e - The click event.
*/
AccessibilityManager.prototype._onClick = function _onClick(e) {
var interactionManager = this.renderer.plugins.interaction;
interactionManager.dispatchEvent(e.target.displayObject, 'click', interactionManager.eventData);
};
/**
* Maps the div focus events to pixi's InteractionManager (mouseover)
*
* @private
* @param {FocusEvent} e - The focus event.
*/
AccessibilityManager.prototype._onFocus = function _onFocus(e) {
if (!e.target.getAttribute('aria-live', 'off')) {
e.target.setAttribute('aria-live', 'assertive');
}
var interactionManager = this.renderer.plugins.interaction;
interactionManager.dispatchEvent(e.target.displayObject, 'mouseover', interactionManager.eventData);
};
/**
* Maps the div focus events to pixi's InteractionManager (mouseout)
*
* @private
* @param {FocusEvent} e - The focusout event.
*/
AccessibilityManager.prototype._onFocusOut = function _onFocusOut(e) {
if (!e.target.getAttribute('aria-live', 'off')) {
e.target.setAttribute('aria-live', 'polite');
}
var interactionManager = this.renderer.plugins.interaction;
interactionManager.dispatchEvent(e.target.displayObject, 'mouseout', interactionManager.eventData);
};
/**
* Is called when a key is pressed
*
* @private
* @param {KeyboardEvent} e - The keydown event.
*/
AccessibilityManager.prototype._onKeyDown = function _onKeyDown(e) {
if (e.keyCode !== KEY_CODE_TAB) {
return;
}
this.activate();
};
/**
* Is called when the mouse moves across the renderer element
*
* @private
* @param {MouseEvent} e - The mouse event.
*/
AccessibilityManager.prototype._onMouseMove = function _onMouseMove(e) {
if (e.movementX === 0 && e.movementY === 0) {
return;
}
this.deactivate();
};
/**
* Destroys the accessibility manager
*
*/
AccessibilityManager.prototype.destroy = function destroy() {
this.div = null;
for (var i = 0; i < this.children.length; i++) {
this.children[i].div = null;
}
window.document.removeEventListener('mousemove', this._onMouseMove, true);
window.removeEventListener('keydown', this._onKeyDown);
this.pool = null;
this.children = null;
this.renderer = null;
};
return AccessibilityManager;
}();
exports.default = AccessibilityManager;
core.WebGLRenderer.registerPlugin('accessibility', AccessibilityManager);
core.CanvasRenderer.registerPlugin('accessibility', AccessibilityManager);
//# sourceMappingURL=AccessibilityManager.js.map
/***/ }),
/* 500 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _WebGLExtract = __webpack_require__(501);
Object.defineProperty(exports, 'webgl', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_WebGLExtract).default;
}
});
var _CanvasExtract = __webpack_require__(502);
Object.defineProperty(exports, 'canvas', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_CanvasExtract).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map
/***/ }),
/* 501 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
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"); } }
var TEMP_RECT = new core.Rectangle();
var BYTES_PER_PIXEL = 4;
/**
* The extract manager provides functionality to export content from the renderers.
*
* An instance of this class is automatically created by default, and can be found at renderer.plugins.extract
*
* @class
* @memberof PIXI.extract
*/
var WebGLExtract = function () {
/**
* @param {PIXI.WebGLRenderer} renderer - A reference to the current renderer
*/
function WebGLExtract(renderer) {
_classCallCheck(this, WebGLExtract);
this.renderer = renderer;
/**
* Collection of methods for extracting data (image, pixels, etc.) from a display object or render texture
*
* @member {PIXI.extract.WebGLExtract} extract
* @memberof PIXI.WebGLRenderer#
* @see PIXI.extract.WebGLExtract
*/
renderer.extract = this;
}
/**
* Will return a HTML Image of the target
*
* @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture
* to convert. If left empty will use use the main renderer
* @return {HTMLImageElement} HTML Image of the target
*/
WebGLExtract.prototype.image = function image(target) {
var image = new Image();
image.src = this.base64(target);
return image;
};
/**
* Will return a a base64 encoded string of this target. It works by calling
* `WebGLExtract.getCanvas` and then running toDataURL on that.
*
* @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture
* to convert. If left empty will use use the main renderer
* @return {string} A base64 encoded string of the texture.
*/
WebGLExtract.prototype.base64 = function base64(target) {
return this.canvas(target).toDataURL();
};
/**
* Creates a Canvas element, renders this target to it and then returns it.
*
* @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture
* to convert. If left empty will use use the main renderer
* @return {HTMLCanvasElement} A Canvas element with the texture rendered on.
*/
WebGLExtract.prototype.canvas = function canvas(target) {
var renderer = this.renderer;
var textureBuffer = void 0;
var resolution = void 0;
var frame = void 0;
var flipY = false;
var renderTexture = void 0;
var generated = false;
if (target) {
if (target instanceof core.RenderTexture) {
renderTexture = target;
} else {
renderTexture = this.renderer.generateTexture(target);
generated = true;
}
}
if (renderTexture) {
textureBuffer = renderTexture.baseTexture._glRenderTargets[this.renderer.CONTEXT_UID];
resolution = textureBuffer.resolution;
frame = renderTexture.frame;
flipY = false;
} else {
textureBuffer = this.renderer.rootRenderTarget;
resolution = textureBuffer.resolution;
flipY = true;
frame = TEMP_RECT;
frame.width = textureBuffer.size.width;
frame.height = textureBuffer.size.height;
}
var width = frame.width * resolution;
var height = frame.height * resolution;
var canvasBuffer = new core.CanvasRenderTarget(width, height, 1);
if (textureBuffer) {
// bind the buffer
renderer.bindRenderTarget(textureBuffer);
// set up an array of pixels
var webglPixels = new Uint8Array(BYTES_PER_PIXEL * width * height);
// read pixels to the array
var gl = renderer.gl;
gl.readPixels(frame.x * resolution, frame.y * resolution, width, height, gl.RGBA, gl.UNSIGNED_BYTE, webglPixels);
// add the pixels to the canvas
var canvasData = canvasBuffer.context.getImageData(0, 0, width, height);
canvasData.data.set(webglPixels);
canvasBuffer.context.putImageData(canvasData, 0, 0);
// pulling pixels
if (flipY) {
canvasBuffer.context.scale(1, -1);
canvasBuffer.context.drawImage(canvasBuffer.canvas, 0, -height);
}
}
if (generated) {
renderTexture.destroy(true);
}
// send the canvas back..
return canvasBuffer.canvas;
};
/**
* Will return a one-dimensional array containing the pixel data of the entire texture in RGBA
* order, with integer values between 0 and 255 (included).
*
* @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture
* to convert. If left empty will use use the main renderer
* @return {Uint8ClampedArray} One-dimensional array containing the pixel data of the entire texture
*/
WebGLExtract.prototype.pixels = function pixels(target) {
var renderer = this.renderer;
var textureBuffer = void 0;
var resolution = void 0;
var frame = void 0;
var renderTexture = void 0;
var generated = false;
if (target) {
if (target instanceof core.RenderTexture) {
renderTexture = target;
} else {
renderTexture = this.renderer.generateTexture(target);
generated = true;
}
}
if (renderTexture) {
textureBuffer = renderTexture.baseTexture._glRenderTargets[this.renderer.CONTEXT_UID];
resolution = textureBuffer.resolution;
frame = renderTexture.frame;
} else {
textureBuffer = this.renderer.rootRenderTarget;
resolution = textureBuffer.resolution;
frame = TEMP_RECT;
frame.width = textureBuffer.size.width;
frame.height = textureBuffer.size.height;
}
var width = frame.width * resolution;
var height = frame.height * resolution;
var webglPixels = new Uint8Array(BYTES_PER_PIXEL * width * height);
if (textureBuffer) {
// bind the buffer
renderer.bindRenderTarget(textureBuffer);
// read pixels to the array
var gl = renderer.gl;
gl.readPixels(frame.x * resolution, frame.y * resolution, width, height, gl.RGBA, gl.UNSIGNED_BYTE, webglPixels);
}
if (generated) {
renderTexture.destroy(true);
}
return webglPixels;
};
/**
* Destroys the extract
*
*/
WebGLExtract.prototype.destroy = function destroy() {
this.renderer.extract = null;
this.renderer = null;
};
return WebGLExtract;
}();
exports.default = WebGLExtract;
core.WebGLRenderer.registerPlugin('extract', WebGLExtract);
//# sourceMappingURL=WebGLExtract.js.map
/***/ }),
/* 502 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
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"); } }
var TEMP_RECT = new core.Rectangle();
/**
* The extract manager provides functionality to export content from the renderers.
*
* An instance of this class is automatically created by default, and can be found at renderer.plugins.extract
*
* @class
* @memberof PIXI.extract
*/
var CanvasExtract = function () {
/**
* @param {PIXI.CanvasRenderer} renderer - A reference to the current renderer
*/
function CanvasExtract(renderer) {
_classCallCheck(this, CanvasExtract);
this.renderer = renderer;
/**
* Collection of methods for extracting data (image, pixels, etc.) from a display object or render texture
*
* @member {PIXI.extract.CanvasExtract} extract
* @memberof PIXI.CanvasRenderer#
* @see PIXI.extract.CanvasExtract
*/
renderer.extract = this;
}
/**
* Will return a HTML Image of the target
*
* @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture
* to convert. If left empty will use use the main renderer
* @return {HTMLImageElement} HTML Image of the target
*/
CanvasExtract.prototype.image = function image(target) {
var image = new Image();
image.src = this.base64(target);
return image;
};
/**
* Will return a a base64 encoded string of this target. It works by calling
* `CanvasExtract.getCanvas` and then running toDataURL on that.
*
* @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture
* to convert. If left empty will use use the main renderer
* @return {string} A base64 encoded string of the texture.
*/
CanvasExtract.prototype.base64 = function base64(target) {
return this.canvas(target).toDataURL();
};
/**
* Creates a Canvas element, renders this target to it and then returns it.
*
* @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture
* to convert. If left empty will use use the main renderer
* @return {HTMLCanvasElement} A Canvas element with the texture rendered on.
*/
CanvasExtract.prototype.canvas = function canvas(target) {
var renderer = this.renderer;
var context = void 0;
var resolution = void 0;
var frame = void 0;
var renderTexture = void 0;
if (target) {
if (target instanceof core.RenderTexture) {
renderTexture = target;
} else {
renderTexture = renderer.generateTexture(target);
}
}
if (renderTexture) {
context = renderTexture.baseTexture._canvasRenderTarget.context;
resolution = renderTexture.baseTexture._canvasRenderTarget.resolution;
frame = renderTexture.frame;
} else {
context = renderer.rootContext;
resolution = renderer.resolution;
frame = TEMP_RECT;
frame.width = this.renderer.width;
frame.height = this.renderer.height;
}
var width = frame.width * resolution;
var height = frame.height * resolution;
var canvasBuffer = new core.CanvasRenderTarget(width, height, 1);
var canvasData = context.getImageData(frame.x * resolution, frame.y * resolution, width, height);
canvasBuffer.context.putImageData(canvasData, 0, 0);
// send the canvas back..
return canvasBuffer.canvas;
};
/**
* Will return a one-dimensional array containing the pixel data of the entire texture in RGBA
* order, with integer values between 0 and 255 (included).
*
* @param {PIXI.DisplayObject|PIXI.RenderTexture} target - A displayObject or renderTexture
* to convert. If left empty will use use the main renderer
* @return {Uint8ClampedArray} One-dimensional array containing the pixel data of the entire texture
*/
CanvasExtract.prototype.pixels = function pixels(target) {
var renderer = this.renderer;
var context = void 0;
var resolution = void 0;
var frame = void 0;
var renderTexture = void 0;
if (target) {
if (target instanceof core.RenderTexture) {
renderTexture = target;
} else {
renderTexture = renderer.generateTexture(target);
}
}
if (renderTexture) {
context = renderTexture.baseTexture._canvasRenderTarget.context;
resolution = renderTexture.baseTexture._canvasRenderTarget.resolution;
frame = renderTexture.frame;
} else {
context = renderer.rootContext;
frame = TEMP_RECT;
frame.width = renderer.width;
frame.height = renderer.height;
}
return context.getImageData(0, 0, frame.width * resolution, frame.height * resolution).data;
};
/**
* Destroys the extract
*
*/
CanvasExtract.prototype.destroy = function destroy() {
this.renderer.extract = null;
this.renderer = null;
};
return CanvasExtract;
}();
exports.default = CanvasExtract;
core.CanvasRenderer.registerPlugin('extract', CanvasExtract);
//# sourceMappingURL=CanvasExtract.js.map
/***/ }),
/* 503 */
/***/ (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);
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; }
/**
* @typedef PIXI.extras.AnimatedSprite~FrameObject
* @type {object}
* @property {PIXI.Texture} texture - The {@link PIXI.Texture} of the frame
* @property {number} time - the duration of the frame in ms
*/
/**
* An AnimatedSprite is a simple way to display an animation depicted by a list of textures.
*
* ```js
* let alienImages = ["image_sequence_01.png","image_sequence_02.png","image_sequence_03.png","image_sequence_04.png"];
* let textureArray = [];
*
* for (let i=0; i < 4; i++)
* {
* let texture = PIXI.Texture.fromImage(alienImages[i]);
* textureArray.push(texture);
* };
*
* let animatedSprite = new PIXI.extras.AnimatedSprite(textureArray);
* ```
*
* The more efficient and simpler way to create an animated sprite is using a {@link PIXI.Spritesheet}
* containing the animation definitions:
*
* ```js
* PIXI.loader.add("assets/spritesheet.json").load(setup);
*
* function setup() {
* let sheet = PIXI.loader.resources["assets/spritesheet.json"].spritesheet;
* animatedSprite = new PIXI.extras.AnimatedSprite(sheet.animations["image_sequence"]);
* ...
* }
* ```
*
* @class
* @extends PIXI.Sprite
* @memberof PIXI.extras
*/
var AnimatedSprite = function (_core$Sprite) {
_inherits(AnimatedSprite, _core$Sprite);
/**
* @param {PIXI.Texture[]|PIXI.extras.AnimatedSprite~FrameObject[]} textures - an array of {@link PIXI.Texture} or frame
* objects that make up the animation
* @param {boolean} [autoUpdate=true] - Whether to use PIXI.ticker.shared to auto update animation time.
*/
function AnimatedSprite(textures, autoUpdate) {
_classCallCheck(this, AnimatedSprite);
/**
* @private
*/
var _this = _possibleConstructorReturn(this, _core$Sprite.call(this, textures[0] instanceof core.Texture ? textures[0] : textures[0].texture));
_this._textures = null;
/**
* @private
*/
_this._durations = null;
_this.textures = textures;
/**
* `true` uses PIXI.ticker.shared to auto update animation time.
* @type {boolean}
* @default true
* @private
*/
_this._autoUpdate = autoUpdate !== false;
/**
* The speed that the AnimatedSprite will play at. Higher is faster, lower is slower
*
* @member {number}
* @default 1
*/
_this.animationSpeed = 1;
/**
* Whether or not the animate sprite repeats after playing.
*
* @member {boolean}
* @default true
*/
_this.loop = true;
/**
* Update anchor to [Texture's defaultAnchor]{@link PIXI.Texture#defaultAnchor} when frame changes.
*
* Useful with [sprite sheet animations]{@link PIXI.Spritesheet#animations} created with tools.
* Changing anchor for each frame allows to pin sprite origin to certain moving feature
* of the frame (e.g. left foot).
*
* Note: Enabling this will override any previously set `anchor` on each frame change.
*
* @member {boolean}
* @default false
*/
_this.updateAnchor = false;
/**
* Function to call when a AnimatedSprite finishes playing
*
* @member {Function}
*/
_this.onComplete = null;
/**
* Function to call when a AnimatedSprite changes which texture is being rendered
*
* @member {Function}
*/
_this.onFrameChange = null;
/**
* Function to call when 'loop' is true, and an AnimatedSprite is played and loops around to start again
*
* @member {Function}
*/
_this.onLoop = null;
/**
* Elapsed time since animation has been started, used internally to display current texture
*
* @member {number}
* @private
*/
_this._currentTime = 0;
/**
* Indicates if the AnimatedSprite is currently playing
*
* @member {boolean}
* @readonly
*/
_this.playing = false;
return _this;
}
/**
* Stops the AnimatedSprite
*
*/
AnimatedSprite.prototype.stop = function stop() {
if (!this.playing) {
return;
}
this.playing = false;
if (this._autoUpdate) {
core.ticker.shared.remove(this.update, this);
}
};
/**
* Plays the AnimatedSprite
*
*/
AnimatedSprite.prototype.play = function play() {
if (this.playing) {
return;
}
this.playing = true;
if (this._autoUpdate) {
core.ticker.shared.add(this.update, this, core.UPDATE_PRIORITY.HIGH);
}
};
/**
* Stops the AnimatedSprite and goes to a specific frame
*
* @param {number} frameNumber - frame index to stop at
*/
AnimatedSprite.prototype.gotoAndStop = function gotoAndStop(frameNumber) {
this.stop();
var previousFrame = this.currentFrame;
this._currentTime = frameNumber;
if (previousFrame !== this.currentFrame) {
this.updateTexture();
}
};
/**
* Goes to a specific frame and begins playing the AnimatedSprite
*
* @param {number} frameNumber - frame index to start at
*/
AnimatedSprite.prototype.gotoAndPlay = function gotoAndPlay(frameNumber) {
var previousFrame = this.currentFrame;
this._currentTime = frameNumber;
if (previousFrame !== this.currentFrame) {
this.updateTexture();
}
this.play();
};
/**
* Updates the object transform for rendering.
*
* @private
* @param {number} deltaTime - Time since last tick.
*/
AnimatedSprite.prototype.update = function update(deltaTime) {
var elapsed = this.animationSpeed * deltaTime;
var previousFrame = this.currentFrame;
if (this._durations !== null) {
var lag = this._currentTime % 1 * this._durations[this.currentFrame];
lag += elapsed / 60 * 1000;
while (lag < 0) {
this._currentTime--;
lag += this._durations[this.currentFrame];
}
var sign = Math.sign(this.animationSpeed * deltaTime);
this._currentTime = Math.floor(this._currentTime);
while (lag >= this._durations[this.currentFrame]) {
lag -= this._durations[this.currentFrame] * sign;
this._currentTime += sign;
}
this._currentTime += lag / this._durations[this.currentFrame];
} else {
this._currentTime += elapsed;
}
if (this._currentTime < 0 && !this.loop) {
this.gotoAndStop(0);
if (this.onComplete) {
this.onComplete();
}
} else if (this._currentTime >= this._textures.length && !this.loop) {
this.gotoAndStop(this._textures.length - 1);
if (this.onComplete) {
this.onComplete();
}
} else if (previousFrame !== this.currentFrame) {
if (this.loop && this.onLoop) {
if (this.animationSpeed > 0 && this.currentFrame < previousFrame) {
this.onLoop();
} else if (this.animationSpeed < 0 && this.currentFrame > previousFrame) {
this.onLoop();
}
}
this.updateTexture();
}
};
/**
* Updates the displayed texture to match the current frame index
*
* @private
*/
AnimatedSprite.prototype.updateTexture = function updateTexture() {
this._texture = this._textures[this.currentFrame];
this._textureID = -1;
this.cachedTint = 0xFFFFFF;
if (this.updateAnchor) {
this._anchor.copy(this._texture.defaultAnchor);
}
if (this.onFrameChange) {
this.onFrameChange(this.currentFrame);
}
};
/**
* Stops the AnimatedSprite and destroys it
*
* @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
*/
AnimatedSprite.prototype.destroy = function destroy(options) {
this.stop();
_core$Sprite.prototype.destroy.call(this, options);
};
/**
* A short hand way of creating a movieclip from an array of frame ids
*
* @static
* @param {string[]} frames - The array of frames ids the movieclip will use as its texture frames
* @return {AnimatedSprite} The new animated sprite with the specified frames.
*/
AnimatedSprite.fromFrames = function fromFrames(frames) {
var textures = [];
for (var i = 0; i < frames.length; ++i) {
textures.push(core.Texture.fromFrame(frames[i]));
}
return new AnimatedSprite(textures);
};
/**
* A short hand way of creating a movieclip from an array of image ids
*
* @static
* @param {string[]} images - the array of image urls the movieclip will use as its texture frames
* @return {AnimatedSprite} The new animate sprite with the specified images as frames.
*/
AnimatedSprite.fromImages = function fromImages(images) {
var textures = [];
for (var i = 0; i < images.length; ++i) {
textures.push(core.Texture.fromImage(images[i]));
}
return new AnimatedSprite(textures);
};
/**
* totalFrames is the total number of frames in the AnimatedSprite. This is the same as number of textures
* assigned to the AnimatedSprite.
*
* @readonly
* @member {number}
* @default 0
*/
_createClass(AnimatedSprite, [{
key: 'totalFrames',
get: function get() {
return this._textures.length;
}
/**
* The array of textures used for this AnimatedSprite
*
* @member {PIXI.Texture[]}
*/
}, {
key: 'textures',
get: function get() {
return this._textures;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (value[0] instanceof core.Texture) {
this._textures = value;
this._durations = null;
} else {
this._textures = [];
this._durations = [];
for (var i = 0; i < value.length; i++) {
this._textures.push(value[i].texture);
this._durations.push(value[i].time);
}
}
this.gotoAndStop(0);
this.updateTexture();
}
/**
* The AnimatedSprites current frame index
*
* @member {number}
* @readonly
*/
}, {
key: 'currentFrame',
get: function get() {
var currentFrame = Math.floor(this._currentTime) % this._textures.length;
if (currentFrame < 0) {
currentFrame += this._textures.length;
}
return currentFrame;
}
}]);
return AnimatedSprite;
}(core.Sprite);
exports.default = AnimatedSprite;
//# sourceMappingURL=AnimatedSprite.js.map
/***/ }),
/* 504 */
/***/ (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 _CanvasTinter = __webpack_require__(84);
var _CanvasTinter2 = _interopRequireDefault(_CanvasTinter);
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();
/**
* A tiling sprite is a fast way of rendering a tiling image
*
* @class
* @extends PIXI.Sprite
* @memberof PIXI.extras
*/
var TilingSprite = function (_core$Sprite) {
_inherits(TilingSprite, _core$Sprite);
/**
* @param {PIXI.Texture} texture - the texture of the tiling sprite
* @param {number} [width=100] - the width of the tiling sprite
* @param {number} [height=100] - the height of the tiling sprite
*/
function TilingSprite(texture) {
var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
_classCallCheck(this, TilingSprite);
/**
* Tile transform
*
* @member {PIXI.TransformStatic}
*/
var _this = _possibleConstructorReturn(this, _core$Sprite.call(this, texture));
_this.tileTransform = new core.TransformStatic();
// /// private
/**
* The with of the tiling sprite
*
* @member {number}
* @private
*/
_this._width = width;
/**
* The height of the tiling sprite
*
* @member {number}
* @private
*/
_this._height = height;
/**
* Canvas pattern
*
* @type {CanvasPattern}
* @private
*/
_this._canvasPattern = null;
/**
* transform that is applied to UV to get the texture coords
*
* @member {PIXI.TextureMatrix}
*/
_this.uvTransform = texture.transform || new core.TextureMatrix(texture);
/**
* Plugin that is responsible for rendering this element.
* Allows to customize the rendering process without overriding '_renderWebGL' method.
*
* @member {string}
* @default 'tilingSprite'
*/
_this.pluginName = 'tilingSprite';
/**
* Whether or not anchor affects uvs
*
* @member {boolean}
* @default false
*/
_this.uvRespectAnchor = false;
return _this;
}
/**
* Changes frame clamping in corresponding textureTransform, shortcut
* Change to -0.5 to add a pixel to the edge, recommended for transparent trimmed textures in atlas
*
* @default 0.5
* @member {number}
*/
/**
* @private
*/
TilingSprite.prototype._onTextureUpdate = function _onTextureUpdate() {
if (this.uvTransform) {
this.uvTransform.texture = this._texture;
}
this.cachedTint = 0xFFFFFF;
};
/**
* Renders the object using the WebGL renderer
*
* @private
* @param {PIXI.WebGLRenderer} renderer - The renderer
*/
TilingSprite.prototype._renderWebGL = function _renderWebGL(renderer) {
// tweak our texture temporarily..
var texture = this._texture;
if (!texture || !texture.valid) {
return;
}
this.tileTransform.updateLocalTransform();
this.uvTransform.update();
renderer.setObjectRenderer(renderer.plugins[this.pluginName]);
renderer.plugins[this.pluginName].render(this);
};
/**
* Renders the object using the Canvas renderer
*
* @private
* @param {PIXI.CanvasRenderer} renderer - a reference to the canvas renderer
*/
TilingSprite.prototype._renderCanvas = function _renderCanvas(renderer) {
var texture = this._texture;
if (!texture.baseTexture.hasLoaded) {
return;
}
var context = renderer.context;
var transform = this.worldTransform;
var resolution = renderer.resolution;
var isTextureRotated = texture.rotate === 2;
var baseTexture = texture.baseTexture;
var baseTextureResolution = baseTexture.resolution;
var modX = this.tilePosition.x / this.tileScale.x % texture.orig.width * baseTextureResolution;
var modY = this.tilePosition.y / this.tileScale.y % texture.orig.height * baseTextureResolution;
// create a nice shiny pattern!
if (this._textureID !== this._texture._updateID || this.cachedTint !== this.tint) {
this._textureID = this._texture._updateID;
// cut an object from a spritesheet..
var tempCanvas = new core.CanvasRenderTarget(texture.orig.width, texture.orig.height, baseTextureResolution);
// Tint the tiling sprite
if (this.tint !== 0xFFFFFF) {
this.tintedTexture = _CanvasTinter2.default.getTintedTexture(this, this.tint);
tempCanvas.context.drawImage(this.tintedTexture, 0, 0);
} else {
var sx = texture._frame.x * baseTextureResolution;
var sy = texture._frame.y * baseTextureResolution;
var sWidth = texture._frame.width * baseTextureResolution;
var sHeight = texture._frame.height * baseTextureResolution;
var dWidth = (texture.trim ? texture.trim.width : texture.orig.width) * baseTextureResolution;
var dHeight = (texture.trim ? texture.trim.height : texture.orig.height) * baseTextureResolution;
var dx = (texture.trim ? texture.trim.x : 0) * baseTextureResolution;
var dy = (texture.trim ? texture.trim.y : 0) * baseTextureResolution;
if (isTextureRotated) {
// Apply rotation and transform
tempCanvas.context.rotate(-Math.PI / 2);
tempCanvas.context.translate(-dHeight, 0);
tempCanvas.context.drawImage(baseTexture.source, sx, sy, sWidth, sHeight, -dy, dx, dHeight, dWidth);
} else {
tempCanvas.context.drawImage(baseTexture.source, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
}
}
this.cachedTint = this.tint;
this._canvasPattern = tempCanvas.context.createPattern(tempCanvas.canvas, 'repeat');
}
// set context state..
context.globalAlpha = this.worldAlpha;
context.setTransform(transform.a * resolution, transform.b * resolution, transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution);
renderer.setBlendMode(this.blendMode);
// fill the pattern!
context.fillStyle = this._canvasPattern;
// TODO - this should be rolled into the setTransform above..
context.scale(this.tileScale.x / baseTextureResolution, this.tileScale.y / baseTextureResolution);
var anchorX = this.anchor.x * -this._width * baseTextureResolution;
var anchorY = this.anchor.y * -this._height * baseTextureResolution;
if (this.uvRespectAnchor) {
context.translate(modX, modY);
context.fillRect(-modX + anchorX, -modY + anchorY, this._width / this.tileScale.x * baseTextureResolution, this._height / this.tileScale.y * baseTextureResolution);
} else {
context.translate(modX + anchorX, modY + anchorY);
context.fillRect(-modX, -modY, this._width / this.tileScale.x * baseTextureResolution, this._height / this.tileScale.y * baseTextureResolution);
}
};
/**
* Updates the bounds of the tiling sprite.
*
* @private
*/
TilingSprite.prototype._calculateBounds = function _calculateBounds() {
var minX = this._width * -this._anchor._x;
var minY = this._height * -this._anchor._y;
var maxX = this._width * (1 - this._anchor._x);
var maxY = this._height * (1 - this._anchor._y);
this._bounds.addFrame(this.transform, minX, minY, maxX, maxY);
};
/**
* Gets the local bounds of the sprite object.
*
* @param {PIXI.Rectangle} rect - The output rectangle.
* @return {PIXI.Rectangle} The bounds.
*/
TilingSprite.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._width * -this._anchor._x;
this._bounds.minY = this._height * -this._anchor._y;
this._bounds.maxX = this._width * (1 - this._anchor._x);
this._bounds.maxY = this._height * (1 - this._anchor._y);
if (!rect) {
if (!this._localBoundsRect) {
this._localBoundsRect = new core.Rectangle();
}
rect = this._localBoundsRect;
}
return this._bounds.getRectangle(rect);
}
return _core$Sprite.prototype.getLocalBounds.call(this, rect);
};
/**
* Checks if a point is inside this tiling sprite.
*
* @param {PIXI.Point} point - the point to check
* @return {boolean} Whether or not the sprite contains the point.
*/
TilingSprite.prototype.containsPoint = function containsPoint(point) {
this.worldTransform.applyInverse(point, tempPoint);
var width = this._width;
var height = this._height;
var x1 = -width * this.anchor._x;
if (tempPoint.x >= x1 && tempPoint.x < x1 + width) {
var 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
*/
TilingSprite.prototype.destroy = function destroy(options) {
_core$Sprite.prototype.destroy.call(this, options);
this.tileTransform = null;
this.uvTransform = null;
};
/**
* Helper function that creates a new tiling 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
* @param {number} width - the width of the tiling sprite
* @param {number} height - the height of the tiling sprite
* @return {PIXI.Texture} The newly created texture
*/
TilingSprite.from = function from(source, width, height) {
return new TilingSprite(core.Texture.from(source), width, height);
};
/**
* Helper function that creates a tiling sprite that will use 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
* @param {number} width - the width of the tiling sprite
* @param {number} height - the height of the tiling sprite
* @return {PIXI.extras.TilingSprite} A new TilingSprite using a texture from the texture cache matching the frameId
*/
TilingSprite.fromFrame = function fromFrame(frameId, width, height) {
var texture = core.utils.TextureCache[frameId];
if (!texture) {
throw new Error('The frameId "' + frameId + '" does not exist in the texture cache ' + this);
}
return new TilingSprite(texture, width, height);
};
/**
* 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 {number} width - the width of the tiling sprite
* @param {number} height - the height of the tiling sprite
* @param {boolean} [crossorigin] - 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.extras.TilingSprite} A new TilingSprite using a texture from the texture cache matching the image id
*/
TilingSprite.fromImage = function fromImage(imageId, width, height, crossorigin, scaleMode) {
return new TilingSprite(core.Texture.fromImage(imageId, crossorigin, scaleMode), width, height);
};
/**
* The width of the sprite, setting this will actually modify the scale to achieve the value set
*
* @member {number}
*/
_createClass(TilingSprite, [{
key: 'clampMargin',
get: function get() {
return this.uvTransform.clampMargin;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.uvTransform.clampMargin = value;
this.uvTransform.update(true);
}
/**
* The scaling of the image that is being tiled
*
* @member {PIXI.ObservablePoint}
*/
}, {
key: 'tileScale',
get: function get() {
return this.tileTransform.scale;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.tileTransform.scale.copy(value);
}
/**
* The offset of the image that is being tiled
*
* @member {PIXI.ObservablePoint}
*/
}, {
key: 'tilePosition',
get: function get() {
return this.tileTransform.position;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.tileTransform.position.copy(value);
}
}, {
key: 'width',
get: function get() {
return this._width;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._width = value;
}
/**
* The height of the TilingSprite, setting this will actually modify the scale to achieve the value set
*
* @member {number}
*/
}, {
key: 'height',
get: function get() {
return this._height;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._height = value;
}
}]);
return TilingSprite;
}(core.Sprite);
exports.default = TilingSprite;
//# sourceMappingURL=TilingSprite.js.map
/***/ }),
/* 505 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _const = __webpack_require__(3);
var _path = __webpack_require__(34);
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 tempMat = new core.Matrix();
/**
* WebGL renderer plugin for tiling sprites
*
* @class
* @memberof PIXI.extras
* @extends PIXI.ObjectRenderer
*/
var TilingSpriteRenderer = function (_core$ObjectRenderer) {
_inherits(TilingSpriteRenderer, _core$ObjectRenderer);
/**
* constructor for renderer
*
* @param {WebGLRenderer} renderer The renderer this tiling awesomeness works for.
*/
function TilingSpriteRenderer(renderer) {
_classCallCheck(this, TilingSpriteRenderer);
var _this = _possibleConstructorReturn(this, _core$ObjectRenderer.call(this, renderer));
_this.shader = null;
_this.simpleShader = null;
_this.quad = null;
return _this;
}
/**
* Sets up the renderer context and necessary buffers.
*
* @private
*/
TilingSpriteRenderer.prototype.onContextChange = function onContextChange() {
var gl = this.renderer.gl;
this.shader = new core.Shader(gl, 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n', 'varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\nuniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;\n\nvoid main(void)\n{\n vec2 coord = mod(vTextureCoord - uClampOffset, vec2(1.0, 1.0)) + uClampOffset;\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n vec4 sample = texture2D(uSampler, coord);\n gl_FragColor = sample * uColor;\n}\n');
this.simpleShader = new core.Shader(gl, 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n', 'varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\n\nvoid main(void)\n{\n vec4 sample = texture2D(uSampler, vTextureCoord);\n gl_FragColor = sample * uColor;\n}\n');
this.renderer.bindVao(null);
this.quad = new core.Quad(gl, this.renderer.state.attribState);
this.quad.initVao(this.shader);
};
/**
*
* @param {PIXI.extras.TilingSprite} ts tilingSprite to be rendered
*/
TilingSpriteRenderer.prototype.render = function render(ts) {
var renderer = this.renderer;
var quad = this.quad;
renderer.bindVao(quad.vao);
var vertices = quad.vertices;
vertices[0] = vertices[6] = ts._width * -ts.anchor.x;
vertices[1] = vertices[3] = ts._height * -ts.anchor.y;
vertices[2] = vertices[4] = ts._width * (1.0 - ts.anchor.x);
vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y);
if (ts.uvRespectAnchor) {
vertices = quad.uvs;
vertices[0] = vertices[6] = -ts.anchor.x;
vertices[1] = vertices[3] = -ts.anchor.y;
vertices[2] = vertices[4] = 1.0 - ts.anchor.x;
vertices[5] = vertices[7] = 1.0 - ts.anchor.y;
}
quad.upload();
var tex = ts._texture;
var baseTex = tex.baseTexture;
var lt = ts.tileTransform.localTransform;
var uv = ts.uvTransform;
var isSimple = baseTex.isPowerOfTwo && tex.frame.width === baseTex.width && tex.frame.height === baseTex.height;
// auto, force repeat wrapMode for big tiling textures
if (isSimple) {
if (!baseTex._glTextures[renderer.CONTEXT_UID]) {
if (baseTex.wrapMode === _const.WRAP_MODES.CLAMP) {
baseTex.wrapMode = _const.WRAP_MODES.REPEAT;
}
} else {
isSimple = baseTex.wrapMode !== _const.WRAP_MODES.CLAMP;
}
}
var shader = isSimple ? this.simpleShader : this.shader;
renderer.bindShader(shader);
var w = tex.width;
var h = tex.height;
var W = ts._width;
var H = ts._height;
tempMat.set(lt.a * w / W, lt.b * w / H, lt.c * h / W, lt.d * h / H, lt.tx / W, lt.ty / H);
// that part is the same as above:
// tempMat.identity();
// tempMat.scale(tex.width, tex.height);
// tempMat.prepend(lt);
// tempMat.scale(1.0 / ts._width, 1.0 / ts._height);
tempMat.invert();
if (isSimple) {
tempMat.prepend(uv.mapCoord);
} else {
shader.uniforms.uMapCoord = uv.mapCoord.toArray(true);
shader.uniforms.uClampFrame = uv.uClampFrame;
shader.uniforms.uClampOffset = uv.uClampOffset;
}
shader.uniforms.uTransform = tempMat.toArray(true);
shader.uniforms.uColor = core.utils.premultiplyTintToRgba(ts.tint, ts.worldAlpha, shader.uniforms.uColor, baseTex.premultipliedAlpha);
shader.uniforms.translationMatrix = ts.transform.worldTransform.toArray(true);
shader.uniforms.uSampler = renderer.bindTexture(tex);
renderer.setBlendMode(core.utils.correctBlendMode(ts.blendMode, baseTex.premultipliedAlpha));
quad.vao.draw(this.renderer.gl.TRIANGLES, 6, 0);
};
return TilingSpriteRenderer;
}(core.ObjectRenderer);
exports.default = TilingSpriteRenderer;
core.WebGLRenderer.registerPlugin('tilingSprite', TilingSpriteRenderer);
//# sourceMappingURL=TilingSpriteRenderer.js.map
/***/ }),
/* 506 */
/***/ (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 _ObservablePoint = __webpack_require__(170);
var _ObservablePoint2 = _interopRequireDefault(_ObservablePoint);
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 _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; }
/**
* A BitmapText object will create a line or multiple lines of text using bitmap font. To
* split a line you can use '\n', '\r' or '\r\n' in your string. You can generate the fnt files using:
*
* A BitmapText can only be created when the font is loaded
*
* ```js
* // in this case the font is in a file called 'desyrel.fnt'
* let bitmapText = new PIXI.extras.BitmapText("text using a fancy font!", {font: "35px Desyrel", align: "right"});
* ```
*
* http://www.angelcode.com/products/bmfont/ for windows or
* http://www.bmglyph.com/ for mac.
*
* @class
* @extends PIXI.Container
* @memberof PIXI.extras
*/
var BitmapText = function (_core$Container) {
_inherits(BitmapText, _core$Container);
/**
* @param {string} text - The copy that you would like the text to display
* @param {object} style - The style parameters
* @param {string|object} style.font - The font descriptor for the object, can be passed as a string of form
* "24px FontName" or "FontName" or as an object with explicit name/size properties.
* @param {string} [style.font.name] - The bitmap font id
* @param {number} [style.font.size] - The size of the font in pixels, e.g. 24
* @param {string} [style.align='left'] - Alignment for multiline text ('left', 'center' or 'right'), does not affect
* single line text
* @param {number} [style.tint=0xFFFFFF] - The tint color
*/
function BitmapText(text) {
var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, BitmapText);
/**
* Private tracker for the width of the overall text
*
* @member {number}
* @private
*/
var _this = _possibleConstructorReturn(this, _core$Container.call(this));
_this._textWidth = 0;
/**
* Private tracker for the height of the overall text
*
* @member {number}
* @private
*/
_this._textHeight = 0;
/**
* Private tracker for the letter sprite pool.
*
* @member {PIXI.Sprite[]}
* @private
*/
_this._glyphs = [];
/**
* Private tracker for the current style.
*
* @member {object}
* @private
*/
_this._font = {
tint: style.tint !== undefined ? style.tint : 0xFFFFFF,
align: style.align || 'left',
name: null,
size: 0
};
/**
* Private tracker for the current font.
*
* @member {object}
* @private
*/
_this.font = style.font; // run font setter
/**
* Private tracker for the current text.
*
* @member {string}
* @private
*/
_this._text = text;
/**
* The max width of this bitmap text in pixels. If the text provided is longer than the
* value provided, line breaks will be automatically inserted in the last whitespace.
* Disable by setting value to 0
*
* @member {number}
* @private
*/
_this._maxWidth = 0;
/**
* The max line height. This is useful when trying to use the total height of the Text,
* ie: when trying to vertically align.
*
* @member {number}
* @private
*/
_this._maxLineHeight = 0;
/**
* Letter spacing. This is useful for setting the space between characters.
* @member {number}
* @private
*/
_this._letterSpacing = 0;
/**
* Text anchor. read-only
*
* @member {PIXI.ObservablePoint}
* @private
*/
_this._anchor = new _ObservablePoint2.default(function () {
_this.dirty = true;
}, _this, 0, 0);
/**
* The dirty state of this object.
*
* @member {boolean}
*/
_this.dirty = false;
_this.updateText();
return _this;
}
/**
* Renders text and updates it when needed
*
* @private
*/
BitmapText.prototype.updateText = function updateText() {
var data = BitmapText.fonts[this._font.name];
var scale = this._font.size / data.size;
var pos = new core.Point();
var chars = [];
var lineWidths = [];
var text = this.text.replace(/(?:\r\n|\r)/g, '\n');
var textLength = text.length;
var maxWidth = this._maxWidth * data.size / this._font.size;
var prevCharCode = null;
var lastLineWidth = 0;
var maxLineWidth = 0;
var line = 0;
var lastBreakPos = -1;
var lastBreakWidth = 0;
var spacesRemoved = 0;
var maxLineHeight = 0;
for (var i = 0; i < textLength; i++) {
var charCode = text.charCodeAt(i);
var char = text.charAt(i);
if (/(?:\s)/.test(char)) {
lastBreakPos = i;
lastBreakWidth = lastLineWidth;
}
if (char === '\r' || char === '\n') {
lineWidths.push(lastLineWidth);
maxLineWidth = Math.max(maxLineWidth, lastLineWidth);
++line;
++spacesRemoved;
pos.x = 0;
pos.y += data.lineHeight;
prevCharCode = null;
continue;
}
var charData = data.chars[charCode];
if (!charData) {
continue;
}
if (prevCharCode && charData.kerning[prevCharCode]) {
pos.x += charData.kerning[prevCharCode];
}
chars.push({
texture: charData.texture,
line: line,
charCode: charCode,
position: new core.Point(pos.x + charData.xOffset + this._letterSpacing / 2, pos.y + charData.yOffset)
});
pos.x += charData.xAdvance + this._letterSpacing;
lastLineWidth = pos.x;
maxLineHeight = Math.max(maxLineHeight, charData.yOffset + charData.texture.height);
prevCharCode = charCode;
if (lastBreakPos !== -1 && maxWidth > 0 && pos.x > maxWidth) {
++spacesRemoved;
core.utils.removeItems(chars, 1 + lastBreakPos - spacesRemoved, 1 + i - lastBreakPos);
i = lastBreakPos;
lastBreakPos = -1;
lineWidths.push(lastBreakWidth);
maxLineWidth = Math.max(maxLineWidth, lastBreakWidth);
line++;
pos.x = 0;
pos.y += data.lineHeight;
prevCharCode = null;
}
}
var lastChar = text.charAt(text.length - 1);
if (lastChar !== '\r' && lastChar !== '\n') {
if (/(?:\s)/.test(lastChar)) {
lastLineWidth = lastBreakWidth;
}
lineWidths.push(lastLineWidth);
maxLineWidth = Math.max(maxLineWidth, lastLineWidth);
}
var lineAlignOffsets = [];
for (var _i = 0; _i <= line; _i++) {
var alignOffset = 0;
if (this._font.align === 'right') {
alignOffset = maxLineWidth - lineWidths[_i];
} else if (this._font.align === 'center') {
alignOffset = (maxLineWidth - lineWidths[_i]) / 2;
}
lineAlignOffsets.push(alignOffset);
}
var lenChars = chars.length;
var tint = this.tint;
for (var _i2 = 0; _i2 < lenChars; _i2++) {
var c = this._glyphs[_i2]; // get the next glyph sprite
if (c) {
c.texture = chars[_i2].texture;
} else {
c = new core.Sprite(chars[_i2].texture);
this._glyphs.push(c);
}
c.position.x = (chars[_i2].position.x + lineAlignOffsets[chars[_i2].line]) * scale;
c.position.y = chars[_i2].position.y * scale;
c.scale.x = c.scale.y = scale;
c.tint = tint;
if (!c.parent) {
this.addChild(c);
}
}
// remove unnecessary children.
for (var _i3 = lenChars; _i3 < this._glyphs.length; ++_i3) {
this.removeChild(this._glyphs[_i3]);
}
this._textWidth = maxLineWidth * scale;
this._textHeight = (pos.y + data.lineHeight) * scale;
// apply anchor
if (this.anchor.x !== 0 || this.anchor.y !== 0) {
for (var _i4 = 0; _i4 < lenChars; _i4++) {
this._glyphs[_i4].x -= this._textWidth * this.anchor.x;
this._glyphs[_i4].y -= this._textHeight * this.anchor.y;
}
}
this._maxLineHeight = maxLineHeight * scale;
};
/**
* Updates the transform of this object
*
* @private
*/
BitmapText.prototype.updateTransform = function updateTransform() {
this.validate();
this.containerUpdateTransform();
};
/**
* Validates text before calling parent's getLocalBounds
*
* @return {PIXI.Rectangle} The rectangular bounding area
*/
BitmapText.prototype.getLocalBounds = function getLocalBounds() {
this.validate();
return _core$Container.prototype.getLocalBounds.call(this);
};
/**
* Updates text when needed
*
* @private
*/
BitmapText.prototype.validate = function validate() {
if (this.dirty) {
this.updateText();
this.dirty = false;
}
};
/**
* The tint of the BitmapText object
*
* @member {number}
*/
/**
* Register a bitmap font with data and a texture.
*
* @static
* @param {XMLDocument} xml - The XML document data.
* @param {Object.<string, PIXI.Texture>|PIXI.Texture|PIXI.Texture[]} textures - List of textures for each page.
* If providing an object, the key is the `<page>` element's `file` attribute in the FNT file.
* @return {Object} Result font object with font, size, lineHeight and char fields.
*/
BitmapText.registerFont = function registerFont(xml, textures) {
var data = {};
var info = xml.getElementsByTagName('info')[0];
var common = xml.getElementsByTagName('common')[0];
var pages = xml.getElementsByTagName('page');
var res = (0, _utils.getResolutionOfUrl)(pages[0].getAttribute('file'), _settings2.default.RESOLUTION);
var pagesTextures = {};
data.font = info.getAttribute('face');
data.size = parseInt(info.getAttribute('size'), 10);
data.lineHeight = parseInt(common.getAttribute('lineHeight'), 10) / res;
data.chars = {};
// Single texture, convert to list
if (textures instanceof core.Texture) {
textures = [textures];
}
// Convert the input Texture, Textures or object
// into a page Texture lookup by "id"
for (var i = 0; i < pages.length; i++) {
var id = pages[i].getAttribute('id');
var file = pages[i].getAttribute('file');
pagesTextures[id] = textures instanceof Array ? textures[i] : textures[file];
}
// parse letters
var letters = xml.getElementsByTagName('char');
for (var _i5 = 0; _i5 < letters.length; _i5++) {
var letter = letters[_i5];
var charCode = parseInt(letter.getAttribute('id'), 10);
var page = letter.getAttribute('page') || 0;
var textureRect = new core.Rectangle(parseInt(letter.getAttribute('x'), 10) / res + pagesTextures[page].frame.x / res, parseInt(letter.getAttribute('y'), 10) / res + pagesTextures[page].frame.y / res, parseInt(letter.getAttribute('width'), 10) / res, parseInt(letter.getAttribute('height'), 10) / res);
data.chars[charCode] = {
xOffset: parseInt(letter.getAttribute('xoffset'), 10) / res,
yOffset: parseInt(letter.getAttribute('yoffset'), 10) / res,
xAdvance: parseInt(letter.getAttribute('xadvance'), 10) / res,
kerning: {},
texture: new core.Texture(pagesTextures[page].baseTexture, textureRect),
page: page
};
}
// parse kernings
var kernings = xml.getElementsByTagName('kerning');
for (var _i6 = 0; _i6 < kernings.length; _i6++) {
var kerning = kernings[_i6];
var first = parseInt(kerning.getAttribute('first'), 10) / res;
var second = parseInt(kerning.getAttribute('second'), 10) / res;
var amount = parseInt(kerning.getAttribute('amount'), 10) / res;
if (data.chars[second]) {
data.chars[second].kerning[first] = amount;
}
}
// I'm leaving this as a temporary fix so we can test the bitmap fonts in v3
// but it's very likely to change
BitmapText.fonts[data.font] = data;
return data;
};
_createClass(BitmapText, [{
key: 'tint',
get: function get() {
return this._font.tint;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._font.tint = typeof value === 'number' && value >= 0 ? value : 0xFFFFFF;
this.dirty = true;
}
/**
* The alignment of the BitmapText object
*
* @member {string}
* @default 'left'
*/
}, {
key: 'align',
get: function get() {
return this._font.align;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._font.align = value || 'left';
this.dirty = true;
}
/**
* The anchor sets the origin point of the text.
* The default is 0,0 this means the text's origin is the top left
* Setting the anchor to 0.5,0.5 means the text's origin is centered
* Setting the anchor to 1,1 would mean the text's origin point will be the bottom right corner
*
* @member {PIXI.Point | number}
*/
}, {
key: 'anchor',
get: function get() {
return this._anchor;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (typeof value === 'number') {
this._anchor.set(value);
} else {
this._anchor.copy(value);
}
}
/**
* The font descriptor of the BitmapText object
*
* @member {string|object}
*/
}, {
key: 'font',
get: function get() {
return this._font;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (!value) {
return;
}
if (typeof value === 'string') {
value = value.split(' ');
this._font.name = value.length === 1 ? value[0] : value.slice(1).join(' ');
this._font.size = value.length >= 2 ? parseInt(value[0], 10) : BitmapText.fonts[this._font.name].size;
} else {
this._font.name = value.name;
this._font.size = typeof value.size === 'number' ? value.size : parseInt(value.size, 10);
}
this.dirty = true;
}
/**
* The text of the BitmapText object
*
* @member {string}
*/
}, {
key: 'text',
get: function get() {
return this._text;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
value = value.toString() || ' ';
if (this._text === value) {
return;
}
this._text = value;
this.dirty = true;
}
/**
* The max width of this bitmap text in pixels. If the text provided is longer than the
* value provided, line breaks will be automatically inserted in the last whitespace.
* Disable by setting value to 0
*
* @member {number}
*/
}, {
key: 'maxWidth',
get: function get() {
return this._maxWidth;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (this._maxWidth === value) {
return;
}
this._maxWidth = value;
this.dirty = true;
}
/**
* The max line height. This is useful when trying to use the total height of the Text,
* ie: when trying to vertically align.
*
* @member {number}
* @readonly
*/
}, {
key: 'maxLineHeight',
get: function get() {
this.validate();
return this._maxLineHeight;
}
/**
* The width of the overall text, different from fontSize,
* which is defined in the style object
*
* @member {number}
* @readonly
*/
}, {
key: 'textWidth',
get: function get() {
this.validate();
return this._textWidth;
}
/**
* Additional space between characters.
*
* @member {number}
*/
}, {
key: 'letterSpacing',
get: function get() {
return this._letterSpacing;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
if (this._letterSpacing !== value) {
this._letterSpacing = value;
this.dirty = true;
}
}
/**
* The height of the overall text, different from fontSize,
* which is defined in the style object
*
* @member {number}
* @readonly
*/
}, {
key: 'textHeight',
get: function get() {
this.validate();
return this._textHeight;
}
}]);
return BitmapText;
}(core.Container);
exports.default = BitmapText;
BitmapText.fonts = {};
//# sourceMappingURL=BitmapText.js.map
/***/ }),
/* 507 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _Texture = __webpack_require__(40);
var _Texture2 = _interopRequireDefault(_Texture);
var _BaseTexture = __webpack_require__(58);
var _BaseTexture2 = _interopRequireDefault(_BaseTexture);
var _utils = __webpack_require__(7);
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"); } }
var DisplayObject = core.DisplayObject;
var _tempMatrix = new core.Matrix();
DisplayObject.prototype._cacheAsBitmap = false;
DisplayObject.prototype._cacheData = false;
// figured theres no point adding ALL the extra variables to prototype.
// this model can hold the information needed. This can also be generated on demand as
// most objects are not cached as bitmaps.
/**
* @class
* @ignore
*/
var CacheData =
/**
*
*/
function CacheData() {
_classCallCheck(this, CacheData);
this.textureCacheId = null;
this.originalRenderWebGL = null;
this.originalRenderCanvas = null;
this.originalCalculateBounds = null;
this.originalGetLocalBounds = null;
this.originalUpdateTransform = null;
this.originalHitTest = null;
this.originalDestroy = null;
this.originalMask = null;
this.originalFilterArea = null;
this.sprite = null;
};
Object.defineProperties(DisplayObject.prototype, {
/**
* Set this to true if you want this display object to be cached as a bitmap.
* This basically takes a snap shot of the display object as it is at that moment. It can
* provide a performance benefit for complex static displayObjects.
* To remove simply set this property to 'false'
*
* IMPORTANT GOTCHA - make sure that all your textures are preloaded BEFORE setting this property to true
* as it will take a snapshot of what is currently there. If the textures have not loaded then they will not appear.
*
* @member {boolean}
* @memberof PIXI.DisplayObject#
*/
cacheAsBitmap: {
get: function get() {
return this._cacheAsBitmap;
},
set: function set(value) {
if (this._cacheAsBitmap === value) {
return;
}
this._cacheAsBitmap = value;
var data = void 0;
if (value) {
if (!this._cacheData) {
this._cacheData = new CacheData();
}
data = this._cacheData;
data.originalRenderWebGL = this.renderWebGL;
data.originalRenderCanvas = this.renderCanvas;
data.originalUpdateTransform = this.updateTransform;
data.originalCalculateBounds = this.calculateBounds;
data.originalGetLocalBounds = this.getLocalBounds;
data.originalDestroy = this.destroy;
data.originalContainsPoint = this.containsPoint;
data.originalMask = this._mask;
data.originalFilterArea = this.filterArea;
this.renderWebGL = this._renderCachedWebGL;
this.renderCanvas = this._renderCachedCanvas;
this.destroy = this._cacheAsBitmapDestroy;
} else {
data = this._cacheData;
if (data.sprite) {
this._destroyCachedDisplayObject();
}
this.renderWebGL = data.originalRenderWebGL;
this.renderCanvas = data.originalRenderCanvas;
this.calculateBounds = data.originalCalculateBounds;
this.getLocalBounds = data.originalGetLocalBounds;
this.destroy = data.originalDestroy;
this.updateTransform = data.originalUpdateTransform;
this.containsPoint = data.originalContainsPoint;
this._mask = data.originalMask;
this.filterArea = data.originalFilterArea;
}
}
}
});
/**
* Renders a cached version of the sprite with WebGL
*
* @private
* @memberof PIXI.DisplayObject#
* @param {PIXI.WebGLRenderer} renderer - the WebGL renderer
*/
DisplayObject.prototype._renderCachedWebGL = function _renderCachedWebGL(renderer) {
if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {
return;
}
this._initCachedDisplayObject(renderer);
this._cacheData.sprite.transform._worldID = this.transform._worldID;
this._cacheData.sprite.worldAlpha = this.worldAlpha;
this._cacheData.sprite._renderWebGL(renderer);
};
/**
* Prepares the WebGL renderer to cache the sprite
*
* @private
* @memberof PIXI.DisplayObject#
* @param {PIXI.WebGLRenderer} renderer - the WebGL renderer
*/
DisplayObject.prototype._initCachedDisplayObject = function _initCachedDisplayObject(renderer) {
if (this._cacheData && this._cacheData.sprite) {
return;
}
// make sure alpha is set to 1 otherwise it will get rendered as invisible!
var cacheAlpha = this.alpha;
this.alpha = 1;
// first we flush anything left in the renderer (otherwise it would get rendered to the cached texture)
renderer.currentRenderer.flush();
// this.filters= [];
// next we find the dimensions of the untransformed object
// this function also calls updatetransform on all its children as part of the measuring.
// This means we don't need to update the transform again in this function
// TODO pass an object to clone too? saves having to create a new one each time!
var bounds = this.getLocalBounds().clone();
// add some padding!
if (this._filters && this._filters.length) {
var padding = this._filters[0].padding;
bounds.pad(padding);
}
bounds.ceil(core.settings.RESOLUTION);
// for now we cache the current renderTarget that the webGL renderer is currently using.
// this could be more elegent..
var cachedRenderTarget = renderer._activeRenderTarget;
// We also store the filter stack - I will definitely look to change how this works a little later down the line.
var stack = renderer.filterManager.filterStack;
// this renderTexture will be used to store the cached DisplayObject
var renderTexture = core.RenderTexture.create(bounds.width, bounds.height);
var textureCacheId = 'cacheAsBitmap_' + (0, _utils.uid)();
this._cacheData.textureCacheId = textureCacheId;
_BaseTexture2.default.addToCache(renderTexture.baseTexture, textureCacheId);
_Texture2.default.addToCache(renderTexture, textureCacheId);
// need to set //
var m = _tempMatrix;
m.tx = -bounds.x;
m.ty = -bounds.y;
// reset
this.transform.worldTransform.identity();
// set all properties to there original so we can render to a texture
this.renderWebGL = this._cacheData.originalRenderWebGL;
renderer.render(this, renderTexture, true, m, true);
// now restore the state be setting the new properties
renderer.bindRenderTarget(cachedRenderTarget);
renderer.filterManager.filterStack = stack;
this.renderWebGL = this._renderCachedWebGL;
// the rest is the same as for Canvas
this.updateTransform = this.displayObjectUpdateTransform;
this.calculateBounds = this._calculateCachedBounds;
this.getLocalBounds = this._getCachedLocalBounds;
this._mask = null;
this.filterArea = null;
// create our cached sprite
var cachedSprite = new core.Sprite(renderTexture);
cachedSprite.transform.worldTransform = this.transform.worldTransform;
cachedSprite.anchor.x = -(bounds.x / bounds.width);
cachedSprite.anchor.y = -(bounds.y / bounds.height);
cachedSprite.alpha = cacheAlpha;
cachedSprite._bounds = this._bounds;
this._cacheData.sprite = cachedSprite;
this.transform._parentID = -1;
// restore the transform of the cached sprite to avoid the nasty flicker..
if (!this.parent) {
this.parent = renderer._tempDisplayObjectParent;
this.updateTransform();
this.parent = null;
} else {
this.updateTransform();
}
// map the hit test..
this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite);
};
/**
* Renders a cached version of the sprite with canvas
*
* @private
* @memberof PIXI.DisplayObject#
* @param {PIXI.WebGLRenderer} renderer - the WebGL renderer
*/
DisplayObject.prototype._renderCachedCanvas = function _renderCachedCanvas(renderer) {
if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {
return;
}
this._initCachedDisplayObjectCanvas(renderer);
this._cacheData.sprite.worldAlpha = this.worldAlpha;
this._cacheData.sprite._renderCanvas(renderer);
};
// TODO this can be the same as the webGL verison.. will need to do a little tweaking first though..
/**
* Prepares the Canvas renderer to cache the sprite
*
* @private
* @memberof PIXI.DisplayObject#
* @param {PIXI.WebGLRenderer} renderer - the WebGL renderer
*/
DisplayObject.prototype._initCachedDisplayObjectCanvas = function _initCachedDisplayObjectCanvas(renderer) {
if (this._cacheData && this._cacheData.sprite) {
return;
}
// get bounds actually transforms the object for us already!
var bounds = this.getLocalBounds();
var cacheAlpha = this.alpha;
this.alpha = 1;
var cachedRenderTarget = renderer.context;
bounds.ceil(core.settings.RESOLUTION);
var renderTexture = core.RenderTexture.create(bounds.width, bounds.height);
var textureCacheId = 'cacheAsBitmap_' + (0, _utils.uid)();
this._cacheData.textureCacheId = textureCacheId;
_BaseTexture2.default.addToCache(renderTexture.baseTexture, textureCacheId);
_Texture2.default.addToCache(renderTexture, textureCacheId);
// need to set //
var m = _tempMatrix;
this.transform.localTransform.copy(m);
m.invert();
m.tx -= bounds.x;
m.ty -= bounds.y;
// m.append(this.transform.worldTransform.)
// set all properties to there original so we can render to a texture
this.renderCanvas = this._cacheData.originalRenderCanvas;
// renderTexture.render(this, m, true);
renderer.render(this, renderTexture, true, m, false);
// now restore the state be setting the new properties
renderer.context = cachedRenderTarget;
this.renderCanvas = this._renderCachedCanvas;
// the rest is the same as for WebGL
this.updateTransform = this.displayObjectUpdateTransform;
this.calculateBounds = this._calculateCachedBounds;
this.getLocalBounds = this._getCachedLocalBounds;
this._mask = null;
this.filterArea = null;
// create our cached sprite
var cachedSprite = new core.Sprite(renderTexture);
cachedSprite.transform.worldTransform = this.transform.worldTransform;
cachedSprite.anchor.x = -(bounds.x / bounds.width);
cachedSprite.anchor.y = -(bounds.y / bounds.height);
cachedSprite.alpha = cacheAlpha;
cachedSprite._bounds = this._bounds;
this._cacheData.sprite = cachedSprite;
this.transform._parentID = -1;
// restore the transform of the cached sprite to avoid the nasty flicker..
if (!this.parent) {
this.parent = renderer._tempDisplayObjectParent;
this.updateTransform();
this.parent = null;
} else {
this.updateTransform();
}
// map the hit test..
this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite);
};
/**
* Calculates the bounds of the cached sprite
*
* @private
*/
DisplayObject.prototype._calculateCachedBounds = function _calculateCachedBounds() {
this._bounds.clear();
this._cacheData.sprite.transform._worldID = this.transform._worldID;
this._cacheData.sprite._calculateBounds();
this._lastBoundsID = this._boundsID;
};
/**
* Gets the bounds of the cached sprite.
*
* @private
* @return {Rectangle} The local bounds.
*/
DisplayObject.prototype._getCachedLocalBounds = function _getCachedLocalBounds() {
return this._cacheData.sprite.getLocalBounds();
};
/**
* Destroys the cached sprite.
*
* @private
*/
DisplayObject.prototype._destroyCachedDisplayObject = function _destroyCachedDisplayObject() {
this._cacheData.sprite._texture.destroy(true);
this._cacheData.sprite = null;
_BaseTexture2.default.removeFromCache(this._cacheData.textureCacheId);
_Texture2.default.removeFromCache(this._cacheData.textureCacheId);
this._cacheData.textureCacheId = null;
};
/**
* Destroys the cached object.
*
* @private
* @param {object|boolean} [options] - Options parameter. A boolean will act as if all options
* have been set to that value.
* Used when destroying containers, see the Container.destroy method.
*/
DisplayObject.prototype._cacheAsBitmapDestroy = function _cacheAsBitmapDestroy(options) {
this.cacheAsBitmap = false;
this.destroy(options);
};
//# sourceMappingURL=cacheAsBitmap.js.map
/***/ }),
/* 508 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
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; } }
/**
* The instance name of the object.
*
* @memberof PIXI.DisplayObject#
* @member {string} name
*/
core.DisplayObject.prototype.name = null;
/**
* Returns the display object in the container
*
* @method getChildByName
* @memberof PIXI.Container#
* @param {string} name - instance name
* @return {PIXI.DisplayObject} The child with the specified name.
*/
core.Container.prototype.getChildByName = function getChildByName(name) {
for (var i = 0; i < this.children.length; i++) {
if (this.children[i].name === name) {
return this.children[i];
}
}
return null;
};
//# sourceMappingURL=getChildByName.js.map
/***/ }),
/* 509 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
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; } }
/**
* Returns the global position of the displayObject. Does not depend on object scale, rotation and pivot.
*
* @method getGlobalPosition
* @memberof PIXI.DisplayObject#
* @param {Point} point - the point to write the global value to. If null a new point will be returned
* @param {boolean} skipUpdate - setting to true will stop the transforms of the scene graph from
* being updated. This means the calculation returned MAY be out of date BUT will give you a
* nice performance boost
* @return {Point} The updated point
*/
core.DisplayObject.prototype.getGlobalPosition = function getGlobalPosition() {
var point = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new core.Point();
var skipUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
if (this.parent) {
this.parent.toGlobal(this.position, point, skipUpdate);
} else {
point.x = this.position.x;
point.y = this.position.y;
}
return point;
};
//# sourceMappingURL=getGlobalPosition.js.map
/***/ }),
/* 510 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _FXAAFilter = __webpack_require__(511);
Object.defineProperty(exports, 'FXAAFilter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_FXAAFilter).default;
}
});
var _NoiseFilter = __webpack_require__(512);
Object.defineProperty(exports, 'NoiseFilter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_NoiseFilter).default;
}
});
var _DisplacementFilter = __webpack_require__(513);
Object.defineProperty(exports, 'DisplacementFilter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_DisplacementFilter).default;
}
});
var _BlurFilter = __webpack_require__(514);
Object.defineProperty(exports, 'BlurFilter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_BlurFilter).default;
}
});
var _BlurXFilter = __webpack_require__(203);
Object.defineProperty(exports, 'BlurXFilter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_BlurXFilter).default;
}
});
var _BlurYFilter = __webpack_require__(207);
Object.defineProperty(exports, 'BlurYFilter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_BlurYFilter).default;
}
});
var _ColorMatrixFilter = __webpack_require__(515);
Object.defineProperty(exports, 'ColorMatrixFilter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_ColorMatrixFilter).default;
}
});
var _AlphaFilter = __webpack_require__(516);
Object.defineProperty(exports, 'AlphaFilter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_AlphaFilter).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map
/***/ }),
/* 511 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _path = __webpack_require__(34);
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; }
/**
*
* Basic FXAA implementation based on the code on geeks3d.com with the
* modification that the texture2DLod stuff was removed since it's
* unsupported by WebGL.
*
* @see https://github.com/mitsuhiko/webgl-meincraft
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
*
*/
var FXAAFilter = function (_core$Filter) {
_inherits(FXAAFilter, _core$Filter);
/**
*
*/
function FXAAFilter() {
_classCallCheck(this, FXAAFilter);
// TODO - needs work
return _possibleConstructorReturn(this, _core$Filter.call(this,
// vertex shader
'\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nuniform vec4 filterArea;\n\nvarying vec2 vTextureCoord;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvoid texcoords(vec2 fragCoord, vec2 resolution,\n out vec2 v_rgbNW, out vec2 v_rgbNE,\n out vec2 v_rgbSW, out vec2 v_rgbSE,\n out vec2 v_rgbM) {\n vec2 inverseVP = 1.0 / resolution.xy;\n v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\n v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\n v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\n v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\n v_rgbM = vec2(fragCoord * inverseVP);\n}\n\nvoid main(void) {\n\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n\n vec2 fragCoord = vTextureCoord * filterArea.xy;\n\n texcoords(fragCoord, filterArea.xy, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}',
// fragment shader
'varying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\n/**\n Basic FXAA implementation based on the code on geeks3d.com with the\n modification that the texture2DLod stuff was removed since it\'s\n unsupported by WebGL.\n \n --\n \n From:\n https://github.com/mitsuhiko/webgl-meincraft\n \n Copyright (c) 2011 by Armin Ronacher.\n \n Some rights reserved.\n \n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are\n met:\n \n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n \n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials provided\n with the distribution.\n \n * The names of the contributors may not be used to endorse or\n promote products derived from this software without specific\n prior written permission.\n \n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef FXAA_REDUCE_MIN\n#define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n#define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n#define FXAA_SPAN_MAX 8.0\n#endif\n\n//optimized version for mobile, where dependent\n//texture reads can be a bottleneck\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\n vec2 v_rgbNW, vec2 v_rgbNE,\n vec2 v_rgbSW, vec2 v_rgbSE,\n vec2 v_rgbM) {\n vec4 color;\n mediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n \n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n \n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n \n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n \n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n \n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\n\nvoid main() {\n\n vec2 fragCoord = vTextureCoord * filterArea.xy;\n\n vec4 color;\n\n color = fxaa(uSampler, fragCoord, filterArea.xy, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n\n gl_FragColor = color;\n}\n'));
}
return FXAAFilter;
}(core.Filter);
exports.default = FXAAFilter;
//# sourceMappingURL=FXAAFilter.js.map
/***/ }),
/* 512 */
/***/ (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 _path = __webpack_require__(34);
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; }
/**
* @author Vico @vicocotea
* original filter: https://github.com/evanw/glfx.js/blob/master/src/filters/adjust/noise.js
*/
/**
* A Noise effect filter.
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
*/
var NoiseFilter = function (_core$Filter) {
_inherits(NoiseFilter, _core$Filter);
/**
* @param {number} noise - The noise intensity, should be a normalized value in the range [0, 1].
* @param {number} seed - A random seed for the noise generation. Default is `Math.random()`.
*/
function NoiseFilter() {
var noise = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.5;
var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.random();
_classCallCheck(this, NoiseFilter);
var _this = _possibleConstructorReturn(this, _core$Filter.call(this,
// vertex shader
'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}',
// fragment shader
'precision highp float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform float uNoise;\nuniform float uSeed;\nuniform sampler2D uSampler;\n\nfloat rand(vec2 co)\n{\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n float randomValue = rand(gl_FragCoord.xy * uSeed);\n float diff = (randomValue - 0.5) * uNoise;\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (color.a > 0.0) {\n color.rgb /= color.a;\n }\n\n color.r += diff;\n color.g += diff;\n color.b += diff;\n\n // Premultiply alpha again.\n color.rgb *= color.a;\n\n gl_FragColor = color;\n}\n'));
_this.noise = noise;
_this.seed = seed;
return _this;
}
/**
* The amount of noise to apply, this value should be in the range (0, 1].
*
* @member {number}
* @default 0.5
*/
_createClass(NoiseFilter, [{
key: 'noise',
get: function get() {
return this.uniforms.uNoise;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.uniforms.uNoise = value;
}
/**
* A seed value to apply to the random noise generation. `Math.random()` is a good value to use.
*
* @member {number}
*/
}, {
key: 'seed',
get: function get() {
return this.uniforms.uSeed;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.uniforms.uSeed = value;
}
}]);
return NoiseFilter;
}(core.Filter);
exports.default = NoiseFilter;
//# sourceMappingURL=NoiseFilter.js.map
/***/ }),
/* 513 */
/***/ (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 _path = __webpack_require__(34);
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; }
/**
* The DisplacementFilter class uses the pixel values from the specified texture
* (called the displacement map) to perform a displacement of an object. You can
* use this filter to apply all manor of crazy warping effects. Currently the r
* property of the texture is used to offset the x and the g property of the texture
* is used to offset the y.
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
*/
var DisplacementFilter = function (_core$Filter) {
_inherits(DisplacementFilter, _core$Filter);
/**
* @param {PIXI.Sprite} sprite - The sprite used for the displacement map. (make sure its added to the scene!)
* @param {number} scale - The scale of the displacement
*/
function DisplacementFilter(sprite, scale) {
_classCallCheck(this, DisplacementFilter);
var maskMatrix = new core.Matrix();
sprite.renderable = false;
var _this = _possibleConstructorReturn(this, _core$Filter.call(this,
// vertex shader
'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 filterMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vFilterCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vFilterCoord = ( filterMatrix * vec3( aTextureCoord, 1.0) ).xy;\n vTextureCoord = aTextureCoord;\n}',
// fragment shader
'varying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\n\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform vec4 filterArea;\nuniform vec4 filterClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy *= scale / filterArea.xy;\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), filterClamp.xy, filterClamp.zw));\n}\n'));
_this.maskSprite = sprite;
_this.maskMatrix = maskMatrix;
_this.uniforms.mapSampler = sprite._texture;
_this.uniforms.filterMatrix = maskMatrix;
_this.uniforms.scale = { x: 1, y: 1 };
if (scale === null || scale === undefined) {
scale = 20;
}
_this.scale = new core.Point(scale, scale);
return _this;
}
/**
* Applies the filter.
*
* @param {PIXI.FilterManager} filterManager - The manager.
* @param {PIXI.RenderTarget} input - The input target.
* @param {PIXI.RenderTarget} output - The output target.
*/
DisplacementFilter.prototype.apply = function apply(filterManager, input, output) {
this.uniforms.filterMatrix = filterManager.calculateSpriteMatrix(this.maskMatrix, this.maskSprite);
this.uniforms.scale.x = this.scale.x;
this.uniforms.scale.y = this.scale.y;
// draw the filter...
filterManager.applyFilter(this, input, output);
};
/**
* The texture used for the displacement map. Must be power of 2 sized texture.
*
* @member {PIXI.Texture}
*/
_createClass(DisplacementFilter, [{
key: 'map',
get: function get() {
return this.uniforms.mapSampler;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.uniforms.mapSampler = value;
}
}]);
return DisplacementFilter;
}(core.Filter);
exports.default = DisplacementFilter;
//# sourceMappingURL=DisplacementFilter.js.map
/***/ }),
/* 514 */
/***/ (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 _BlurXFilter = __webpack_require__(203);
var _BlurXFilter2 = _interopRequireDefault(_BlurXFilter);
var _BlurYFilter = __webpack_require__(207);
var _BlurYFilter2 = _interopRequireDefault(_BlurYFilter);
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; }
/**
* The BlurFilter applies a Gaussian blur to an object.
* The strength of the blur can be set for x- and y-axis separately.
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
*/
var BlurFilter = function (_core$Filter) {
_inherits(BlurFilter, _core$Filter);
/**
* @param {number} strength - The strength of the blur filter.
* @param {number} quality - The quality of the blur filter.
* @param {number} resolution - The resolution of the blur filter.
* @param {number} [kernelSize=5] - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15.
*/
function BlurFilter(strength, quality, resolution, kernelSize) {
_classCallCheck(this, BlurFilter);
var _this = _possibleConstructorReturn(this, _core$Filter.call(this));
_this.blurXFilter = new _BlurXFilter2.default(strength, quality, resolution, kernelSize);
_this.blurYFilter = new _BlurYFilter2.default(strength, quality, resolution, kernelSize);
_this.padding = 0;
_this.resolution = resolution || core.settings.RESOLUTION;
_this.quality = quality || 4;
_this.blur = strength || 8;
return _this;
}
/**
* Applies the filter.
*
* @param {PIXI.FilterManager} filterManager - The manager.
* @param {PIXI.RenderTarget} input - The input target.
* @param {PIXI.RenderTarget} output - The output target.
*/
BlurFilter.prototype.apply = function apply(filterManager, input, output) {
var renderTarget = filterManager.getRenderTarget(true);
this.blurXFilter.apply(filterManager, input, renderTarget, true);
this.blurYFilter.apply(filterManager, renderTarget, output, false);
filterManager.returnRenderTarget(renderTarget);
};
/**
* Sets the strength of both the blurX and blurY properties simultaneously
*
* @member {number}
* @default 2
*/
_createClass(BlurFilter, [{
key: 'blur',
get: function get() {
return this.blurXFilter.blur;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.blurXFilter.blur = this.blurYFilter.blur = value;
this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2;
}
/**
* Sets the number of passes for blur. More passes means higher quaility bluring.
*
* @member {number}
* @default 1
*/
}, {
key: 'quality',
get: function get() {
return this.blurXFilter.quality;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.blurXFilter.quality = this.blurYFilter.quality = value;
}
/**
* Sets the strength of the blurX property
*
* @member {number}
* @default 2
*/
}, {
key: 'blurX',
get: function get() {
return this.blurXFilter.blur;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.blurXFilter.blur = value;
this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2;
}
/**
* Sets the strength of the blurY property
*
* @member {number}
* @default 2
*/
}, {
key: 'blurY',
get: function get() {
return this.blurYFilter.blur;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.blurYFilter.blur = value;
this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2;
}
/**
* Sets the blendmode of the filter
*
* @member {number}
* @default PIXI.BLEND_MODES.NORMAL
*/
}, {
key: 'blendMode',
get: function get() {
return this.blurYFilter._blendMode;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.blurYFilter._blendMode = value;
}
}]);
return BlurFilter;
}(core.Filter);
exports.default = BlurFilter;
//# sourceMappingURL=BlurFilter.js.map
/***/ }),
/* 515 */
/***/ (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 _path = __webpack_require__(34);
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; }
/**
* The ColorMatrixFilter class lets you apply a 5x4 matrix transformation on the RGBA
* color and alpha values of every pixel on your displayObject to produce a result
* with a new set of RGBA color and alpha values. It's pretty powerful!
*
* ```js
* let colorMatrix = new PIXI.filters.ColorMatrixFilter();
* container.filters = [colorMatrix];
* colorMatrix.contrast(2);
* ```
* @author Clément Chenebault <clement@goodboydigital.com>
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
*/
var ColorMatrixFilter = function (_core$Filter) {
_inherits(ColorMatrixFilter, _core$Filter);
/**
*
*/
function ColorMatrixFilter() {
_classCallCheck(this, ColorMatrixFilter);
var _this = _possibleConstructorReturn(this, _core$Filter.call(this,
// vertex shader
'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}',
// fragment shader
'varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\nuniform float uAlpha;\n\nvoid main(void)\n{\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n if (uAlpha == 0.0) {\n gl_FragColor = c;\n return;\n }\n\n // Un-premultiply alpha before applying the color matrix. See issue #3539.\n if (c.a > 0.0) {\n c.rgb /= c.a;\n }\n\n vec4 result;\n\n result.r = (m[0] * c.r);\n result.r += (m[1] * c.g);\n result.r += (m[2] * c.b);\n result.r += (m[3] * c.a);\n result.r += m[4];\n\n result.g = (m[5] * c.r);\n result.g += (m[6] * c.g);\n result.g += (m[7] * c.b);\n result.g += (m[8] * c.a);\n result.g += m[9];\n\n result.b = (m[10] * c.r);\n result.b += (m[11] * c.g);\n result.b += (m[12] * c.b);\n result.b += (m[13] * c.a);\n result.b += m[14];\n\n result.a = (m[15] * c.r);\n result.a += (m[16] * c.g);\n result.a += (m[17] * c.b);\n result.a += (m[18] * c.a);\n result.a += m[19];\n\n vec3 rgb = mix(c.rgb, result.rgb, uAlpha);\n\n // Premultiply alpha again.\n rgb *= result.a;\n\n gl_FragColor = vec4(rgb, result.a);\n}\n'));
_this.uniforms.m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
_this.alpha = 1;
return _this;
}
/**
* Transforms current matrix and set the new one
*
* @param {number[]} matrix - 5x4 matrix
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype._loadMatrix = function _loadMatrix(matrix) {
var multiply = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var newMatrix = matrix;
if (multiply) {
this._multiply(newMatrix, this.uniforms.m, matrix);
newMatrix = this._colorMatrix(newMatrix);
}
// set the new matrix
this.uniforms.m = newMatrix;
};
/**
* Multiplies two mat5's
*
* @private
* @param {number[]} out - 5x4 matrix the receiving matrix
* @param {number[]} a - 5x4 matrix the first operand
* @param {number[]} b - 5x4 matrix the second operand
* @returns {number[]} 5x4 matrix
*/
ColorMatrixFilter.prototype._multiply = function _multiply(out, a, b) {
// Red Channel
out[0] = a[0] * b[0] + a[1] * b[5] + a[2] * b[10] + a[3] * b[15];
out[1] = a[0] * b[1] + a[1] * b[6] + a[2] * b[11] + a[3] * b[16];
out[2] = a[0] * b[2] + a[1] * b[7] + a[2] * b[12] + a[3] * b[17];
out[3] = a[0] * b[3] + a[1] * b[8] + a[2] * b[13] + a[3] * b[18];
out[4] = a[0] * b[4] + a[1] * b[9] + a[2] * b[14] + a[3] * b[19] + a[4];
// Green Channel
out[5] = a[5] * b[0] + a[6] * b[5] + a[7] * b[10] + a[8] * b[15];
out[6] = a[5] * b[1] + a[6] * b[6] + a[7] * b[11] + a[8] * b[16];
out[7] = a[5] * b[2] + a[6] * b[7] + a[7] * b[12] + a[8] * b[17];
out[8] = a[5] * b[3] + a[6] * b[8] + a[7] * b[13] + a[8] * b[18];
out[9] = a[5] * b[4] + a[6] * b[9] + a[7] * b[14] + a[8] * b[19] + a[9];
// Blue Channel
out[10] = a[10] * b[0] + a[11] * b[5] + a[12] * b[10] + a[13] * b[15];
out[11] = a[10] * b[1] + a[11] * b[6] + a[12] * b[11] + a[13] * b[16];
out[12] = a[10] * b[2] + a[11] * b[7] + a[12] * b[12] + a[13] * b[17];
out[13] = a[10] * b[3] + a[11] * b[8] + a[12] * b[13] + a[13] * b[18];
out[14] = a[10] * b[4] + a[11] * b[9] + a[12] * b[14] + a[13] * b[19] + a[14];
// Alpha Channel
out[15] = a[15] * b[0] + a[16] * b[5] + a[17] * b[10] + a[18] * b[15];
out[16] = a[15] * b[1] + a[16] * b[6] + a[17] * b[11] + a[18] * b[16];
out[17] = a[15] * b[2] + a[16] * b[7] + a[17] * b[12] + a[18] * b[17];
out[18] = a[15] * b[3] + a[16] * b[8] + a[17] * b[13] + a[18] * b[18];
out[19] = a[15] * b[4] + a[16] * b[9] + a[17] * b[14] + a[18] * b[19] + a[19];
return out;
};
/**
* Create a Float32 Array and normalize the offset component to 0-1
*
* @private
* @param {number[]} matrix - 5x4 matrix
* @return {number[]} 5x4 matrix with all values between 0-1
*/
ColorMatrixFilter.prototype._colorMatrix = function _colorMatrix(matrix) {
// Create a Float32 Array and normalize the offset component to 0-1
var m = new Float32Array(matrix);
m[4] /= 255;
m[9] /= 255;
m[14] /= 255;
m[19] /= 255;
return m;
};
/**
* Adjusts brightness
*
* @param {number} b - value of the brigthness (0-1, where 0 is black)
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.brightness = function brightness(b, multiply) {
var matrix = [b, 0, 0, 0, 0, 0, b, 0, 0, 0, 0, 0, b, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Set the matrices in grey scales
*
* @param {number} scale - value of the grey (0-1, where 0 is black)
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.greyscale = function greyscale(scale, multiply) {
var matrix = [scale, scale, scale, 0, 0, scale, scale, scale, 0, 0, scale, scale, scale, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Set the black and white matrice.
*
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.blackAndWhite = function blackAndWhite(multiply) {
var matrix = [0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0.3, 0.6, 0.1, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Set the hue property of the color
*
* @param {number} rotation - in degrees
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.hue = function hue(rotation, multiply) {
rotation = (rotation || 0) / 180 * Math.PI;
var cosR = Math.cos(rotation);
var sinR = Math.sin(rotation);
var sqrt = Math.sqrt;
/* a good approximation for hue rotation
This matrix is far better than the versions with magic luminance constants
formerly used here, but also used in the starling framework (flash) and known from this
old part of the internet: quasimondo.com/archives/000565.php
This new matrix is based on rgb cube rotation in space. Look here for a more descriptive
implementation as a shader not a general matrix:
https://github.com/evanw/glfx.js/blob/58841c23919bd59787effc0333a4897b43835412/src/filters/adjust/huesaturation.js
This is the source for the code:
see http://stackoverflow.com/questions/8507885/shift-hue-of-an-rgb-color/8510751#8510751
*/
var w = 1 / 3;
var sqrW = sqrt(w); // weight is
var a00 = cosR + (1.0 - cosR) * w;
var a01 = w * (1.0 - cosR) - sqrW * sinR;
var a02 = w * (1.0 - cosR) + sqrW * sinR;
var a10 = w * (1.0 - cosR) + sqrW * sinR;
var a11 = cosR + w * (1.0 - cosR);
var a12 = w * (1.0 - cosR) - sqrW * sinR;
var a20 = w * (1.0 - cosR) - sqrW * sinR;
var a21 = w * (1.0 - cosR) + sqrW * sinR;
var a22 = cosR + w * (1.0 - cosR);
var matrix = [a00, a01, a02, 0, 0, a10, a11, a12, 0, 0, a20, a21, a22, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Set the contrast matrix, increase the separation between dark and bright
* Increase contrast : shadows darker and highlights brighter
* Decrease contrast : bring the shadows up and the highlights down
*
* @param {number} amount - value of the contrast (0-1)
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.contrast = function contrast(amount, multiply) {
var v = (amount || 0) + 1;
var o = -0.5 * (v - 1);
var matrix = [v, 0, 0, 0, o, 0, v, 0, 0, o, 0, 0, v, 0, o, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Set the saturation matrix, increase the separation between colors
* Increase saturation : increase contrast, brightness, and sharpness
*
* @param {number} amount - The saturation amount (0-1)
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.saturate = function saturate() {
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var multiply = arguments[1];
var x = amount * 2 / 3 + 1;
var y = (x - 1) * -0.5;
var matrix = [x, y, y, 0, 0, y, x, y, 0, 0, y, y, x, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Desaturate image (remove color)
*
* Call the saturate function
*
*/
ColorMatrixFilter.prototype.desaturate = function desaturate() // eslint-disable-line no-unused-vars
{
this.saturate(-1);
};
/**
* Negative image (inverse of classic rgb matrix)
*
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.negative = function negative(multiply) {
var matrix = [-1, 0, 0, 1, 0, 0, -1, 0, 1, 0, 0, 0, -1, 1, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Sepia image
*
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.sepia = function sepia(multiply) {
var matrix = [0.393, 0.7689999, 0.18899999, 0, 0, 0.349, 0.6859999, 0.16799999, 0, 0, 0.272, 0.5339999, 0.13099999, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Color motion picture process invented in 1916 (thanks Dominic Szablewski)
*
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.technicolor = function technicolor(multiply) {
var matrix = [1.9125277891456083, -0.8545344976951645, -0.09155508482755585, 0, 11.793603434377337, -0.3087833385928097, 1.7658908555458428, -0.10601743074722245, 0, -70.35205161461398, -0.231103377548616, -0.7501899197440212, 1.847597816108189, 0, 30.950940869491138, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Polaroid filter
*
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.polaroid = function polaroid(multiply) {
var matrix = [1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016, 1.483, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Filter who transforms : Red -> Blue and Blue -> Red
*
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.toBGR = function toBGR(multiply) {
var matrix = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Color reversal film introduced by Eastman Kodak in 1935. (thanks Dominic Szablewski)
*
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.kodachrome = function kodachrome(multiply) {
var matrix = [1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502, -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203, -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Brown delicious browni filter (thanks Dominic Szablewski)
*
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.browni = function browni(multiply) {
var matrix = [0.5997023498159715, 0.34553243048391263, -0.2708298674538042, 0, 47.43192855600873, -0.037703249837783157, 0.8609577587992641, 0.15059552388459913, 0, -36.96841498319127, 0.24113635128153335, -0.07441037908422492, 0.44972182064877153, 0, -7.562075277591283, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Vintage filter (thanks Dominic Szablewski)
*
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.vintage = function vintage(multiply) {
var matrix = [0.6279345635605994, 0.3202183420819367, -0.03965408211312453, 0, 9.651285835294123, 0.02578397704808868, 0.6441188644374771, 0.03259127616149294, 0, 7.462829176470591, 0.0466055556782719, -0.0851232987247891, 0.5241648018700465, 0, 5.159190588235296, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* We don't know exactly what it does, kind of gradient map, but funny to play with!
*
* @param {number} desaturation - Tone values.
* @param {number} toned - Tone values.
* @param {string} lightColor - Tone values, example: `0xFFE580`
* @param {string} darkColor - Tone values, example: `0xFFE580`
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.colorTone = function colorTone(desaturation, toned, lightColor, darkColor, multiply) {
desaturation = desaturation || 0.2;
toned = toned || 0.15;
lightColor = lightColor || 0xFFE580;
darkColor = darkColor || 0x338000;
var lR = (lightColor >> 16 & 0xFF) / 255;
var lG = (lightColor >> 8 & 0xFF) / 255;
var lB = (lightColor & 0xFF) / 255;
var dR = (darkColor >> 16 & 0xFF) / 255;
var dG = (darkColor >> 8 & 0xFF) / 255;
var dB = (darkColor & 0xFF) / 255;
var matrix = [0.3, 0.59, 0.11, 0, 0, lR, lG, lB, desaturation, 0, dR, dG, dB, toned, 0, lR - dR, lG - dG, lB - dB, 0, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Night effect
*
* @param {number} intensity - The intensity of the night effect.
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.night = function night(intensity, multiply) {
intensity = intensity || 0.1;
var matrix = [intensity * -2.0, -intensity, 0, 0, 0, -intensity, 0, intensity, 0, 0, 0, intensity, intensity * 2.0, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Predator effect
*
* Erase the current matrix by setting a new indepent one
*
* @param {number} amount - how much the predator feels his future victim
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.predator = function predator(amount, multiply) {
var matrix = [
// row 1
11.224130630493164 * amount, -4.794486999511719 * amount, -2.8746118545532227 * amount, 0 * amount, 0.40342438220977783 * amount,
// row 2
-3.6330697536468506 * amount, 9.193157196044922 * amount, -2.951810836791992 * amount, 0 * amount, -1.316135048866272 * amount,
// row 3
-3.2184197902679443 * amount, -4.2375030517578125 * amount, 7.476448059082031 * amount, 0 * amount, 0.8044459223747253 * amount,
// row 4
0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* LSD effect
*
* Multiply the current matrix
*
* @param {boolean} multiply - if true, current matrix and matrix are multiplied. If false,
* just set the current matrix with @param matrix
*/
ColorMatrixFilter.prototype.lsd = function lsd(multiply) {
var matrix = [2, -0.4, 0.5, 0, 0, -0.5, 2, -0.4, 0, 0, -0.4, -0.5, 3, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, multiply);
};
/**
* Erase the current matrix by setting the default one
*
*/
ColorMatrixFilter.prototype.reset = function reset() {
var matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
this._loadMatrix(matrix, false);
};
/**
* The matrix of the color matrix filter
*
* @member {number[]}
* @default [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]
*/
_createClass(ColorMatrixFilter, [{
key: 'matrix',
get: function get() {
return this.uniforms.m;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.uniforms.m = value;
}
/**
* The opacity value to use when mixing the original and resultant colors.
*
* When the value is 0, the original color is used without modification.
* When the value is 1, the result color is used.
* When in the range (0, 1) the color is interpolated between the original and result by this amount.
*
* @member {number}
* @default 1
*/
}, {
key: 'alpha',
get: function get() {
return this.uniforms.uAlpha;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.uniforms.uAlpha = value;
}
}]);
return ColorMatrixFilter;
}(core.Filter);
// Americanized alias
exports.default = ColorMatrixFilter;
ColorMatrixFilter.prototype.grayscale = ColorMatrixFilter.prototype.greyscale;
//# sourceMappingURL=ColorMatrixFilter.js.map
/***/ }),
/* 516 */
/***/ (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 _path = __webpack_require__(34);
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; }
/**
* Simplest filter - applies alpha
*
* Use this instead of Container's alpha property to avoid visual layering of individual elements.
* AlphaFilter applies alpha evenly across the entire display object and any opaque elements it contains.
* If elements are not opaque, they will blend with each other anyway.
*
* Very handy if you want to use common features of all filters:
*
* 1. Assign a blendMode to this filter, blend all elements inside display object with background.
*
* 2. To use clipping in display coordinates, assign a filterArea to the same container that has this filter.
*
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
*/
var AlphaFilter = function (_core$Filter) {
_inherits(AlphaFilter, _core$Filter);
/**
* @param {number} [alpha=1] Amount of alpha from 0 to 1, where 0 is transparent
*/
function AlphaFilter() {
var alpha = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1.0;
_classCallCheck(this, AlphaFilter);
var _this = _possibleConstructorReturn(this, _core$Filter.call(this,
// vertex shader
'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}',
// fragment shader
'varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float uAlpha;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;\n}\n'));
_this.alpha = alpha;
_this.glShaderKey = 'alpha';
return _this;
}
/**
* Coefficient for alpha multiplication
*
* @member {number}
* @default 1
*/
_createClass(AlphaFilter, [{
key: 'alpha',
get: function get() {
return this.uniforms.uAlpha;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this.uniforms.uAlpha = value;
}
}]);
return AlphaFilter;
}(core.Filter);
exports.default = AlphaFilter;
//# sourceMappingURL=AlphaFilter.js.map
/***/ }),
/* 517 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _InteractionData = __webpack_require__(208);
Object.defineProperty(exports, 'InteractionData', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_InteractionData).default;
}
});
var _InteractionManager = __webpack_require__(518);
Object.defineProperty(exports, 'InteractionManager', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_InteractionManager).default;
}
});
var _interactiveTarget = __webpack_require__(211);
Object.defineProperty(exports, 'interactiveTarget', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_interactiveTarget).default;
}
});
var _InteractionTrackingData = __webpack_require__(210);
Object.defineProperty(exports, 'InteractionTrackingData', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_InteractionTrackingData).default;
}
});
var _InteractionEvent = __webpack_require__(209);
Object.defineProperty(exports, 'InteractionEvent', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_InteractionEvent).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map
/***/ }),
/* 518 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _InteractionData = __webpack_require__(208);
var _InteractionData2 = _interopRequireDefault(_InteractionData);
var _InteractionEvent = __webpack_require__(209);
var _InteractionEvent2 = _interopRequireDefault(_InteractionEvent);
var _InteractionTrackingData = __webpack_require__(210);
var _InteractionTrackingData2 = _interopRequireDefault(_InteractionTrackingData);
var _eventemitter = __webpack_require__(52);
var _eventemitter2 = _interopRequireDefault(_eventemitter);
var _interactiveTarget = __webpack_require__(211);
var _interactiveTarget2 = _interopRequireDefault(_interactiveTarget);
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; }
// Mix interactiveTarget into core.DisplayObject.prototype, after deprecation has been handled
core.utils.mixins.delayMixin(core.DisplayObject.prototype, _interactiveTarget2.default);
var MOUSE_POINTER_ID = 1;
// helpers for hitTest() - only used inside hitTest()
var hitTestEvent = {
target: null,
data: {
global: null
}
};
/**
* The interaction manager deals with mouse, touch and pointer events. Any DisplayObject can be interactive
* if its interactive parameter is set to true
* This manager also supports multitouch.
*
* An instance of this class is automatically created by default, and can be found at renderer.plugins.interaction
*
* @class
* @extends EventEmitter
* @memberof PIXI.interaction
*/
var InteractionManager = function (_EventEmitter) {
_inherits(InteractionManager, _EventEmitter);
/**
* @param {PIXI.CanvasRenderer|PIXI.WebGLRenderer} renderer - A reference to the current renderer
* @param {object} [options] - The options for the manager.
* @param {boolean} [options.autoPreventDefault=true] - Should the manager automatically prevent default browser actions.
* @param {number} [options.interactionFrequency=10] - Frequency increases the interaction events will be checked.
*/
function InteractionManager(renderer, options) {
_classCallCheck(this, InteractionManager);
var _this = _possibleConstructorReturn(this, _EventEmitter.call(this));
options = options || {};
/**
* The renderer this interaction manager works for.
*
* @member {PIXI.SystemRenderer}
*/
_this.renderer = renderer;
/**
* Should default browser actions automatically be prevented.
* Does not apply to pointer events for backwards compatibility
* preventDefault on pointer events stops mouse events from firing
* Thus, for every pointer event, there will always be either a mouse of touch event alongside it.
*
* @member {boolean}
* @default true
*/
_this.autoPreventDefault = options.autoPreventDefault !== undefined ? options.autoPreventDefault : true;
/**
* Frequency in milliseconds that the mousemove, moveover & mouseout interaction events will be checked.
*
* @member {number}
* @default 10
*/
_this.interactionFrequency = options.interactionFrequency || 10;
/**
* The mouse data
*
* @member {PIXI.interaction.InteractionData}
*/
_this.mouse = new _InteractionData2.default();
_this.mouse.identifier = MOUSE_POINTER_ID;
// setting the mouse to start off far off screen will mean that mouse over does
// not get called before we even move the mouse.
_this.mouse.global.set(-999999);
/**
* Actively tracked InteractionData
*
* @private
* @member {Object.<number,PIXI.interation.InteractionData>}
*/
_this.activeInteractionData = {};
_this.activeInteractionData[MOUSE_POINTER_ID] = _this.mouse;
/**
* Pool of unused InteractionData
*
* @private
* @member {PIXI.interation.InteractionData[]}
*/
_this.interactionDataPool = [];
/**
* An event data object to handle all the event tracking/dispatching
*
* @member {object}
*/
_this.eventData = new _InteractionEvent2.default();
/**
* The DOM element to bind to.
*
* @private
* @member {HTMLElement}
*/
_this.interactionDOMElement = null;
/**
* This property determines if mousemove and touchmove events are fired only when the cursor
* is over the object.
* Setting to true will make things work more in line with how the DOM verison works.
* Setting to false can make things easier for things like dragging
* It is currently set to false as this is how PixiJS used to work. This will be set to true in
* future versions of pixi.
*
* @member {boolean}
* @default false
*/
_this.moveWhenInside = false;
/**
* Have events been attached to the dom element?
*
* @private
* @member {boolean}
*/
_this.eventsAdded = false;
/**
* Is the mouse hovering over the renderer?
*
* @private
* @member {boolean}
*/
_this.mouseOverRenderer = false;
/**
* Does the device support touch events
* https://www.w3.org/TR/touch-events/
*
* @readonly
* @member {boolean}
*/
_this.supportsTouchEvents = 'ontouchstart' in window;
/**
* Does the device support pointer events
* https://www.w3.org/Submission/pointer-events/
*
* @readonly
* @member {boolean}
*/
_this.supportsPointerEvents = !!window.PointerEvent;
// this will make it so that you don't have to call bind all the time
/**
* @private
* @member {Function}
*/
_this.onPointerUp = _this.onPointerUp.bind(_this);
_this.processPointerUp = _this.processPointerUp.bind(_this);
/**
* @private
* @member {Function}
*/
_this.onPointerCancel = _this.onPointerCancel.bind(_this);
_this.processPointerCancel = _this.processPointerCancel.bind(_this);
/**
* @private
* @member {Function}
*/
_this.onPointerDown = _this.onPointerDown.bind(_this);
_this.processPointerDown = _this.processPointerDown.bind(_this);
/**
* @private
* @member {Function}
*/
_this.onPointerMove = _this.onPointerMove.bind(_this);
_this.processPointerMove = _this.processPointerMove.bind(_this);
/**
* @private
* @member {Function}
*/
_this.onPointerOut = _this.onPointerOut.bind(_this);
_this.processPointerOverOut = _this.processPointerOverOut.bind(_this);
/**
* @private
* @member {Function}
*/
_this.onPointerOver = _this.onPointerOver.bind(_this);
/**
* Dictionary of how different cursor modes are handled. Strings are handled as CSS cursor
* values, objects are handled as dictionaries of CSS values for interactionDOMElement,
* and functions are called instead of changing the CSS.
* Default CSS cursor values are provided for 'default' and 'pointer' modes.
* @member {Object.<string, (string|Function|Object.<string, string>)>}
*/
_this.cursorStyles = {
default: 'inherit',
pointer: 'pointer'
};
/**
* The mode of the cursor that is being used.
* The value of this is a key from the cursorStyles dictionary.
*
* @member {string}
*/
_this.currentCursorMode = null;
/**
* Internal cached let.
*
* @private
* @member {string}
*/
_this.cursor = null;
/**
* Internal cached let.
*
* @private
* @member {PIXI.Point}
*/
_this._tempPoint = new core.Point();
/**
* The current resolution / device pixel ratio.
*
* @member {number}
* @default 1
*/
_this.resolution = 1;
_this.setTargetElement(_this.renderer.view, _this.renderer.resolution);
/**
* Fired when a pointer device button (usually a mouse left-button) is pressed on the display
* object.
*
* @event PIXI.interaction.InteractionManager#mousedown
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is pressed
* on the display object.
*
* @event PIXI.interaction.InteractionManager#rightdown
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button (usually a mouse left-button) is released over the display
* object.
*
* @event PIXI.interaction.InteractionManager#mouseup
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is released
* over the display object.
*
* @event PIXI.interaction.InteractionManager#rightup
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button (usually a mouse left-button) is pressed and released on
* the display object.
*
* @event PIXI.interaction.InteractionManager#click
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is pressed
* and released on the display object.
*
* @event PIXI.interaction.InteractionManager#rightclick
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button (usually a mouse left-button) is released outside the
* display object that initially registered a
* [mousedown]{@link PIXI.interaction.InteractionManager#event:mousedown}.
*
* @event PIXI.interaction.InteractionManager#mouseupoutside
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is released
* outside the display object that initially registered a
* [rightdown]{@link PIXI.interaction.InteractionManager#event:rightdown}.
*
* @event PIXI.interaction.InteractionManager#rightupoutside
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device (usually a mouse) is moved while over the display object
*
* @event PIXI.interaction.InteractionManager#mousemove
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device (usually a mouse) is moved onto the display object
*
* @event PIXI.interaction.InteractionManager#mouseover
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device (usually a mouse) is moved off the display object
*
* @event PIXI.interaction.InteractionManager#mouseout
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button is pressed on the display object.
*
* @event PIXI.interaction.InteractionManager#pointerdown
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button is released over the display object.
* Not always fired when some buttons are held down while others are released. In those cases,
* use [mousedown]{@link PIXI.interaction.InteractionManager#event:mousedown} and
* [mouseup]{@link PIXI.interaction.InteractionManager#event:mouseup} instead.
*
* @event PIXI.interaction.InteractionManager#pointerup
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when the operating system cancels a pointer event
*
* @event PIXI.interaction.InteractionManager#pointercancel
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button is pressed and released on the display object.
*
* @event PIXI.interaction.InteractionManager#pointertap
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button is released outside the display object that initially
* registered a [pointerdown]{@link PIXI.interaction.InteractionManager#event:pointerdown}.
*
* @event PIXI.interaction.InteractionManager#pointerupoutside
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device is moved while over the display object
*
* @event PIXI.interaction.InteractionManager#pointermove
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device is moved onto the display object
*
* @event PIXI.interaction.InteractionManager#pointerover
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device is moved off the display object
*
* @event PIXI.interaction.InteractionManager#pointerout
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a touch point is placed on the display object.
*
* @event PIXI.interaction.InteractionManager#touchstart
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a touch point is removed from the display object.
*
* @event PIXI.interaction.InteractionManager#touchend
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when the operating system cancels a touch
*
* @event PIXI.interaction.InteractionManager#touchcancel
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a touch point is placed and removed from the display object.
*
* @event PIXI.interaction.InteractionManager#tap
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a touch point is removed outside of the display object that initially
* registered a [touchstart]{@link PIXI.interaction.InteractionManager#event:touchstart}.
*
* @event PIXI.interaction.InteractionManager#touchendoutside
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a touch point is moved along the display object.
*
* @event PIXI.interaction.InteractionManager#touchmove
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button (usually a mouse left-button) is pressed on the display.
* object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#mousedown
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is pressed
* on the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#rightdown
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button (usually a mouse left-button) is released over the display
* object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#mouseup
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is released
* over the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#rightup
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button (usually a mouse left-button) is pressed and released on
* the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#click
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is pressed
* and released on the display object. DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#rightclick
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button (usually a mouse left-button) is released outside the
* display object that initially registered a
* [mousedown]{@link PIXI.DisplayObject#event:mousedown}.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#mouseupoutside
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device secondary button (usually a mouse right-button) is released
* outside the display object that initially registered a
* [rightdown]{@link PIXI.DisplayObject#event:rightdown}.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#rightupoutside
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device (usually a mouse) is moved while over the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#mousemove
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device (usually a mouse) is moved onto the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#mouseover
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device (usually a mouse) is moved off the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#mouseout
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button is pressed on the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#pointerdown
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button is released over the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#pointerup
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when the operating system cancels a pointer event.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#pointercancel
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button is pressed and released on the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#pointertap
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device button is released outside the display object that initially
* registered a [pointerdown]{@link PIXI.DisplayObject#event:pointerdown}.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#pointerupoutside
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device is moved while over the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#pointermove
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device is moved onto the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#pointerover
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a pointer device is moved off the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#pointerout
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a touch point is placed on the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#touchstart
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a touch point is removed from the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#touchend
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when the operating system cancels a touch.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#touchcancel
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a touch point is placed and removed from the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#tap
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a touch point is removed outside of the display object that initially
* registered a [touchstart]{@link PIXI.DisplayObject#event:touchstart}.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#touchendoutside
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
/**
* Fired when a touch point is moved along the display object.
* DisplayObject's `interactive` property must be set to `true` to fire event.
*
* @event PIXI.DisplayObject#touchmove
* @param {PIXI.interaction.InteractionEvent} event - Interaction event
*/
return _this;
}
/**
* Hit tests a point against the display tree, returning the first interactive object that is hit.
*
* @param {PIXI.Point} globalPoint - A point to hit test with, in global space.
* @param {PIXI.Container} [root] - The root display object to start from. If omitted, defaults
* to the last rendered root of the associated renderer.
* @return {PIXI.DisplayObject} The hit display object, if any.
*/
InteractionManager.prototype.hitTest = function hitTest(globalPoint, root) {
// clear the target for our hit test
hitTestEvent.target = null;
// assign the global point
hitTestEvent.data.global = globalPoint;
// ensure safety of the root
if (!root) {
root = this.renderer._lastObjectRendered;
}
// run the hit test
this.processInteractive(hitTestEvent, root, null, true);
// return our found object - it'll be null if we didn't hit anything
return hitTestEvent.target;
};
/**
* Sets the DOM element which will receive mouse/touch events. This is useful for when you have
* other DOM elements on top of the renderers Canvas element. With this you'll be bale to deletegate
* another DOM element to receive those events.
*
* @param {HTMLCanvasElement} element - the DOM element which will receive mouse and touch events.
* @param {number} [resolution=1] - The resolution / device pixel ratio of the new element (relative to the canvas).
*/
InteractionManager.prototype.setTargetElement = function setTargetElement(element) {
var resolution = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
this.removeEvents();
this.interactionDOMElement = element;
this.resolution = resolution;
this.addEvents();
};
/**
* Registers all the DOM events
*
* @private
*/
InteractionManager.prototype.addEvents = function addEvents() {
if (!this.interactionDOMElement) {
return;
}
core.ticker.shared.add(this.update, this, core.UPDATE_PRIORITY.INTERACTION);
if (window.navigator.msPointerEnabled) {
this.interactionDOMElement.style['-ms-content-zooming'] = 'none';
this.interactionDOMElement.style['-ms-touch-action'] = 'none';
} else if (this.supportsPointerEvents) {
this.interactionDOMElement.style['touch-action'] = 'none';
}
/**
* These events are added first, so that if pointer events are normalised, they are fired
* in the same order as non-normalised events. ie. pointer event 1st, mouse / touch 2nd
*/
if (this.supportsPointerEvents) {
window.document.addEventListener('pointermove', this.onPointerMove, true);
this.interactionDOMElement.addEventListener('pointerdown', this.onPointerDown, true);
// pointerout is fired in addition to pointerup (for touch events) and pointercancel
// we already handle those, so for the purposes of what we do in onPointerOut, we only
// care about the pointerleave event
this.interactionDOMElement.addEventListener('pointerleave', this.onPointerOut, true);
this.interactionDOMElement.addEventListener('pointerover', this.onPointerOver, true);
window.addEventListener('pointercancel', this.onPointerCancel, true);
window.addEventListener('pointerup', this.onPointerUp, true);
} else {
window.document.addEventListener('mousemove', this.onPointerMove, true);
this.interactionDOMElement.addEventListener('mousedown', this.onPointerDown, true);
this.interactionDOMElement.addEventListener('mouseout', this.onPointerOut, true);
this.interactionDOMElement.addEventListener('mouseover', this.onPointerOver, true);
window.addEventListener('mouseup', this.onPointerUp, true);
}
// always look directly for touch events so that we can provide original data
// In a future version we should change this to being just a fallback and rely solely on
// PointerEvents whenever available
if (this.supportsTouchEvents) {
this.interactionDOMElement.addEventListener('touchstart', this.onPointerDown, true);
this.interactionDOMElement.addEventListener('touchcancel', this.onPointerCancel, true);
this.interactionDOMElement.addEventListener('touchend', this.onPointerUp, true);
this.interactionDOMElement.addEventListener('touchmove', this.onPointerMove, true);
}
this.eventsAdded = true;
};
/**
* Removes all the DOM events that were previously registered
*
* @private
*/
InteractionManager.prototype.removeEvents = function removeEvents() {
if (!this.interactionDOMElement) {
return;
}
core.ticker.shared.remove(this.update, this);
if (window.navigator.msPointerEnabled) {
this.interactionDOMElement.style['-ms-content-zooming'] = '';
this.interactionDOMElement.style['-ms-touch-action'] = '';
} else if (this.supportsPointerEvents) {
this.interactionDOMElement.style['touch-action'] = '';
}
if (this.supportsPointerEvents) {
window.document.removeEventListener('pointermove', this.onPointerMove, true);
this.interactionDOMElement.removeEventListener('pointerdown', this.onPointerDown, true);
this.interactionDOMElement.removeEventListener('pointerleave', this.onPointerOut, true);
this.interactionDOMElement.removeEventListener('pointerover', this.onPointerOver, true);
window.removeEventListener('pointercancel', this.onPointerCancel, true);
window.removeEventListener('pointerup', this.onPointerUp, true);
} else {
window.document.removeEventListener('mousemove', this.onPointerMove, true);
this.interactionDOMElement.removeEventListener('mousedown', this.onPointerDown, true);
this.interactionDOMElement.removeEventListener('mouseout', this.onPointerOut, true);
this.interactionDOMElement.removeEventListener('mouseover', this.onPointerOver, true);
window.removeEventListener('mouseup', this.onPointerUp, true);
}
if (this.supportsTouchEvents) {
this.interactionDOMElement.removeEventListener('touchstart', this.onPointerDown, true);
this.interactionDOMElement.removeEventListener('touchcancel', this.onPointerCancel, true);
this.interactionDOMElement.removeEventListener('touchend', this.onPointerUp, true);
this.interactionDOMElement.removeEventListener('touchmove', this.onPointerMove, true);
}
this.interactionDOMElement = null;
this.eventsAdded = false;
};
/**
* Updates the state of interactive objects.
* Invoked by a throttled ticker update from {@link PIXI.ticker.shared}.
*
* @param {number} deltaTime - time delta since last tick
*/
InteractionManager.prototype.update = function update(deltaTime) {
this._deltaTime += deltaTime;
if (this._deltaTime < this.interactionFrequency) {
return;
}
this._deltaTime = 0;
if (!this.interactionDOMElement) {
return;
}
// if the user move the mouse this check has already been done using the mouse move!
if (this.didMove) {
this.didMove = false;
return;
}
this.cursor = null;
// Resets the flag as set by a stopPropagation call. This flag is usually reset by a user interaction of any kind,
// but there was a scenario of a display object moving under a static mouse cursor.
// In this case, mouseover and mouseevents would not pass the flag test in dispatchEvent function
for (var k in this.activeInteractionData) {
// eslint-disable-next-line no-prototype-builtins
if (this.activeInteractionData.hasOwnProperty(k)) {
var interactionData = this.activeInteractionData[k];
if (interactionData.originalEvent && interactionData.pointerType !== 'touch') {
var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, interactionData.originalEvent, interactionData);
this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, this.processPointerOverOut, true);
}
}
}
this.setCursorMode(this.cursor);
// TODO
};
/**
* Sets the current cursor mode, handling any callbacks or CSS style changes.
*
* @param {string} mode - cursor mode, a key from the cursorStyles dictionary
*/
InteractionManager.prototype.setCursorMode = function setCursorMode(mode) {
mode = mode || 'default';
// if the mode didn't actually change, bail early
if (this.currentCursorMode === mode) {
return;
}
this.currentCursorMode = mode;
var style = this.cursorStyles[mode];
// only do things if there is a cursor style for it
if (style) {
switch (typeof style === 'undefined' ? 'undefined' : _typeof(style)) {
case 'string':
// string styles are handled as cursor CSS
this.interactionDOMElement.style.cursor = style;
break;
case 'function':
// functions are just called, and passed the cursor mode
style(mode);
break;
case 'object':
// if it is an object, assume that it is a dictionary of CSS styles,
// apply it to the interactionDOMElement
Object.assign(this.interactionDOMElement.style, style);
break;
}
} else if (typeof mode === 'string' && !Object.prototype.hasOwnProperty.call(this.cursorStyles, mode)) {
// if it mode is a string (not a Symbol) and cursorStyles doesn't have any entry
// for the mode, then assume that the dev wants it to be CSS for the cursor.
this.interactionDOMElement.style.cursor = mode;
}
};
/**
* Dispatches an event on the display object that was interacted with
*
* @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - the display object in question
* @param {string} eventString - the name of the event (e.g, mousedown)
* @param {object} eventData - the event data object
* @private
*/
InteractionManager.prototype.dispatchEvent = function dispatchEvent(displayObject, eventString, eventData) {
if (!eventData.stopped) {
eventData.currentTarget = displayObject;
eventData.type = eventString;
displayObject.emit(eventString, eventData);
if (displayObject[eventString]) {
displayObject[eventString](eventData);
}
}
};
/**
* Maps x and y coords from a DOM object and maps them correctly to the PixiJS view. The
* resulting value is stored in the point. This takes into account the fact that the DOM
* element could be scaled and positioned anywhere on the screen.
*
* @param {PIXI.Point} point - the point that the result will be stored in
* @param {number} x - the x coord of the position to map
* @param {number} y - the y coord of the position to map
*/
InteractionManager.prototype.mapPositionToPoint = function mapPositionToPoint(point, x, y) {
var rect = void 0;
// IE 11 fix
if (!this.interactionDOMElement.parentElement) {
rect = { x: 0, y: 0, width: 0, height: 0 };
} else {
rect = this.interactionDOMElement.getBoundingClientRect();
}
var resolutionMultiplier = navigator.isCocoonJS ? this.resolution : 1.0 / this.resolution;
point.x = (x - rect.left) * (this.interactionDOMElement.width / rect.width) * resolutionMultiplier;
point.y = (y - rect.top) * (this.interactionDOMElement.height / rect.height) * resolutionMultiplier;
};
/**
* This function is provides a neat way of crawling through the scene graph and running a
* specified function on all interactive objects it finds. It will also take care of hit
* testing the interactive objects and passes the hit across in the function.
*
* @private
* @param {PIXI.interaction.InteractionEvent} interactionEvent - event containing the point that
* is tested for collision
* @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - the displayObject
* that will be hit test (recursively crawls its children)
* @param {Function} [func] - the function that will be called on each interactive object. The
* interactionEvent, displayObject and hit will be passed to the function
* @param {boolean} [hitTest] - this indicates if the objects inside should be hit test against the point
* @param {boolean} [interactive] - Whether the displayObject is interactive
* @return {boolean} returns true if the displayObject hit the point
*/
InteractionManager.prototype.processInteractive = function processInteractive(interactionEvent, displayObject, func, hitTest, interactive) {
if (!displayObject || !displayObject.visible) {
return false;
}
var point = interactionEvent.data.global;
// Took a little while to rework this function correctly! But now it is done and nice and optimised. ^_^
//
// This function will now loop through all objects and then only hit test the objects it HAS
// to, not all of them. MUCH faster..
// An object will be hit test if the following is true:
//
// 1: It is interactive.
// 2: It belongs to a parent that is interactive AND one of the parents children have not already been hit.
//
// As another little optimisation once an interactive object has been hit we can carry on
// through the scenegraph, but we know that there will be no more hits! So we can avoid extra hit tests
// A final optimisation is that an object is not hit test directly if a child has already been hit.
interactive = displayObject.interactive || interactive;
var hit = false;
var interactiveParent = interactive;
// Flag here can set to false if the event is outside the parents hitArea or mask
var hitTestChildren = true;
// If there is a hitArea, no need to test against anything else if the pointer is not within the hitArea
// There is also no longer a need to hitTest children.
if (displayObject.hitArea) {
if (hitTest) {
displayObject.worldTransform.applyInverse(point, this._tempPoint);
if (!displayObject.hitArea.contains(this._tempPoint.x, this._tempPoint.y)) {
hitTest = false;
hitTestChildren = false;
} else {
hit = true;
}
}
interactiveParent = false;
}
// If there is a mask, no need to test against anything else if the pointer is not within the mask
else if (displayObject._mask) {
if (hitTest) {
if (!displayObject._mask.containsPoint(point)) {
hitTest = false;
hitTestChildren = false;
}
}
}
// ** FREE TIP **! If an object is not interactive or has no buttons in it
// (such as a game scene!) set interactiveChildren to false for that displayObject.
// This will allow PixiJS to completely ignore and bypass checking the displayObjects children.
if (hitTestChildren && displayObject.interactiveChildren && displayObject.children) {
var children = displayObject.children;
for (var i = children.length - 1; i >= 0; i--) {
var child = children[i];
// time to get recursive.. if this function will return if something is hit..
var childHit = this.processInteractive(interactionEvent, child, func, hitTest, interactiveParent);
if (childHit) {
// its a good idea to check if a child has lost its parent.
// this means it has been removed whilst looping so its best
if (!child.parent) {
continue;
}
// we no longer need to hit test any more objects in this container as we we
// now know the parent has been hit
interactiveParent = false;
// If the child is interactive , that means that the object hit was actually
// interactive and not just the child of an interactive object.
// This means we no longer need to hit test anything else. We still need to run
// through all objects, but we don't need to perform any hit tests.
if (childHit) {
if (interactionEvent.target) {
hitTest = false;
}
hit = true;
}
}
}
}
// no point running this if the item is not interactive or does not have an interactive parent.
if (interactive) {
// if we are hit testing (as in we have no hit any objects yet)
// We also don't need to worry about hit testing if once of the displayObjects children
// has already been hit - but only if it was interactive, otherwise we need to keep
// looking for an interactive child, just in case we hit one
if (hitTest && !interactionEvent.target) {
// already tested against hitArea if it is defined
if (!displayObject.hitArea && displayObject.containsPoint) {
if (displayObject.containsPoint(point)) {
hit = true;
}
}
}
if (displayObject.interactive) {
if (hit && !interactionEvent.target) {
interactionEvent.target = displayObject;
}
if (func) {
func(interactionEvent, displayObject, !!hit);
}
}
}
return hit;
};
/**
* Is called when the pointer button is pressed down on the renderer element
*
* @private
* @param {PointerEvent} originalEvent - The DOM event of a pointer button being pressed down
*/
InteractionManager.prototype.onPointerDown = function onPointerDown(originalEvent) {
// if we support touch events, then only use those for touch events, not pointer events
if (this.supportsTouchEvents && originalEvent.pointerType === 'touch') return;
var events = this.normalizeToPointerData(originalEvent);
/**
* No need to prevent default on natural pointer events, as there are no side effects
* Normalized events, however, may have the double mousedown/touchstart issue on the native android browser,
* so still need to be prevented.
*/
// Guaranteed that there will be at least one event in events, and all events must have the same pointer type
if (this.autoPreventDefault && events[0].isNormalized) {
originalEvent.preventDefault();
}
var eventLen = events.length;
for (var i = 0; i < eventLen; i++) {
var event = events[i];
var interactionData = this.getInteractionDataForPointerId(event);
var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);
interactionEvent.data.originalEvent = originalEvent;
this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, this.processPointerDown, true);
this.emit('pointerdown', interactionEvent);
if (event.pointerType === 'touch') {
this.emit('touchstart', interactionEvent);
}
// emit a mouse event for "pen" pointers, the way a browser would emit a fallback event
else if (event.pointerType === 'mouse' || event.pointerType === 'pen') {
var isRightButton = event.button === 2;
this.emit(isRightButton ? 'rightdown' : 'mousedown', this.eventData);
}
}
};
/**
* Processes the result of the pointer down check and dispatches the event if need be
*
* @private
* @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event
* @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - The display object that was tested
* @param {boolean} hit - the result of the hit test on the display object
*/
InteractionManager.prototype.processPointerDown = function processPointerDown(interactionEvent, displayObject, hit) {
var data = interactionEvent.data;
var id = interactionEvent.data.identifier;
if (hit) {
if (!displayObject.trackedPointers[id]) {
displayObject.trackedPointers[id] = new _InteractionTrackingData2.default(id);
}
this.dispatchEvent(displayObject, 'pointerdown', interactionEvent);
if (data.pointerType === 'touch') {
this.dispatchEvent(displayObject, 'touchstart', interactionEvent);
} else if (data.pointerType === 'mouse' || data.pointerType === 'pen') {
var isRightButton = data.button === 2;
if (isRightButton) {
displayObject.trackedPointers[id].rightDown = true;
} else {
displayObject.trackedPointers[id].leftDown = true;
}
this.dispatchEvent(displayObject, isRightButton ? 'rightdown' : 'mousedown', interactionEvent);
}
}
};
/**
* Is called when the pointer button is released on the renderer element
*
* @private
* @param {PointerEvent} originalEvent - The DOM event of a pointer button being released
* @param {boolean} cancelled - true if the pointer is cancelled
* @param {Function} func - Function passed to {@link processInteractive}
*/
InteractionManager.prototype.onPointerComplete = function onPointerComplete(originalEvent, cancelled, func) {
var events = this.normalizeToPointerData(originalEvent);
var eventLen = events.length;
// if the event wasn't targeting our canvas, then consider it to be pointerupoutside
// in all cases (unless it was a pointercancel)
var eventAppend = originalEvent.target !== this.interactionDOMElement ? 'outside' : '';
for (var i = 0; i < eventLen; i++) {
var event = events[i];
var interactionData = this.getInteractionDataForPointerId(event);
var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);
interactionEvent.data.originalEvent = originalEvent;
// perform hit testing for events targeting our canvas or cancel events
this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, func, cancelled || !eventAppend);
this.emit(cancelled ? 'pointercancel' : 'pointerup' + eventAppend, interactionEvent);
if (event.pointerType === 'mouse' || event.pointerType === 'pen') {
var isRightButton = event.button === 2;
this.emit(isRightButton ? 'rightup' + eventAppend : 'mouseup' + eventAppend, interactionEvent);
} else if (event.pointerType === 'touch') {
this.emit(cancelled ? 'touchcancel' : 'touchend' + eventAppend, interactionEvent);
this.releaseInteractionDataForPointerId(event.pointerId, interactionData);
}
}
};
/**
* Is called when the pointer button is cancelled
*
* @private
* @param {PointerEvent} event - The DOM event of a pointer button being released
*/
InteractionManager.prototype.onPointerCancel = function onPointerCancel(event) {
// if we support touch events, then only use those for touch events, not pointer events
if (this.supportsTouchEvents && event.pointerType === 'touch') return;
this.onPointerComplete(event, true, this.processPointerCancel);
};
/**
* Processes the result of the pointer cancel check and dispatches the event if need be
*
* @private
* @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event
* @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - The display object that was tested
*/
InteractionManager.prototype.processPointerCancel = function processPointerCancel(interactionEvent, displayObject) {
var data = interactionEvent.data;
var id = interactionEvent.data.identifier;
if (displayObject.trackedPointers[id] !== undefined) {
delete displayObject.trackedPointers[id];
this.dispatchEvent(displayObject, 'pointercancel', interactionEvent);
if (data.pointerType === 'touch') {
this.dispatchEvent(displayObject, 'touchcancel', interactionEvent);
}
}
};
/**
* Is called when the pointer button is released on the renderer element
*
* @private
* @param {PointerEvent} event - The DOM event of a pointer button being released
*/
InteractionManager.prototype.onPointerUp = function onPointerUp(event) {
// if we support touch events, then only use those for touch events, not pointer events
if (this.supportsTouchEvents && event.pointerType === 'touch') return;
this.onPointerComplete(event, false, this.processPointerUp);
};
/**
* Processes the result of the pointer up check and dispatches the event if need be
*
* @private
* @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event
* @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - The display object that was tested
* @param {boolean} hit - the result of the hit test on the display object
*/
InteractionManager.prototype.processPointerUp = function processPointerUp(interactionEvent, displayObject, hit) {
var data = interactionEvent.data;
var id = interactionEvent.data.identifier;
var trackingData = displayObject.trackedPointers[id];
var isTouch = data.pointerType === 'touch';
var isMouse = data.pointerType === 'mouse' || data.pointerType === 'pen';
// need to track mouse down status in the mouse block so that we can emit
// event in a later block
var isMouseTap = false;
// Mouse only
if (isMouse) {
var isRightButton = data.button === 2;
var flags = _InteractionTrackingData2.default.FLAGS;
var test = isRightButton ? flags.RIGHT_DOWN : flags.LEFT_DOWN;
var isDown = trackingData !== undefined && trackingData.flags & test;
if (hit) {
this.dispatchEvent(displayObject, isRightButton ? 'rightup' : 'mouseup', interactionEvent);
if (isDown) {
this.dispatchEvent(displayObject, isRightButton ? 'rightclick' : 'click', interactionEvent);
// because we can confirm that the mousedown happened on this object, flag for later emit of pointertap
isMouseTap = true;
}
} else if (isDown) {
this.dispatchEvent(displayObject, isRightButton ? 'rightupoutside' : 'mouseupoutside', interactionEvent);
}
// update the down state of the tracking data
if (trackingData) {
if (isRightButton) {
trackingData.rightDown = false;
} else {
trackingData.leftDown = false;
}
}
}
// Pointers and Touches, and Mouse
if (hit) {
this.dispatchEvent(displayObject, 'pointerup', interactionEvent);
if (isTouch) this.dispatchEvent(displayObject, 'touchend', interactionEvent);
if (trackingData) {
// emit pointertap if not a mouse, or if the mouse block decided it was a tap
if (!isMouse || isMouseTap) {
this.dispatchEvent(displayObject, 'pointertap', interactionEvent);
}
if (isTouch) {
this.dispatchEvent(displayObject, 'tap', interactionEvent);
// touches are no longer over (if they ever were) when we get the touchend
// so we should ensure that we don't keep pretending that they are
trackingData.over = false;
}
}
} else if (trackingData) {
this.dispatchEvent(displayObject, 'pointerupoutside', interactionEvent);
if (isTouch) this.dispatchEvent(displayObject, 'touchendoutside', interactionEvent);
}
// Only remove the tracking data if there is no over/down state still associated with it
if (trackingData && trackingData.none) {
delete displayObject.trackedPointers[id];
}
};
/**
* Is called when the pointer moves across the renderer element
*
* @private
* @param {PointerEvent} originalEvent - The DOM event of a pointer moving
*/
InteractionManager.prototype.onPointerMove = function onPointerMove(originalEvent) {
// if we support touch events, then only use those for touch events, not pointer events
if (this.supportsTouchEvents && originalEvent.pointerType === 'touch') return;
var events = this.normalizeToPointerData(originalEvent);
if (events[0].pointerType === 'mouse' || events[0].pointerType === 'pen') {
this.didMove = true;
this.cursor = null;
}
var eventLen = events.length;
for (var i = 0; i < eventLen; i++) {
var event = events[i];
var interactionData = this.getInteractionDataForPointerId(event);
var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);
interactionEvent.data.originalEvent = originalEvent;
var interactive = event.pointerType === 'touch' ? this.moveWhenInside : true;
this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, this.processPointerMove, interactive);
this.emit('pointermove', interactionEvent);
if (event.pointerType === 'touch') this.emit('touchmove', interactionEvent);
if (event.pointerType === 'mouse' || event.pointerType === 'pen') this.emit('mousemove', interactionEvent);
}
if (events[0].pointerType === 'mouse') {
this.setCursorMode(this.cursor);
// TODO BUG for parents interactive object (border order issue)
}
};
/**
* Processes the result of the pointer move check and dispatches the event if need be
*
* @private
* @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event
* @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - The display object that was tested
* @param {boolean} hit - the result of the hit test on the display object
*/
InteractionManager.prototype.processPointerMove = function processPointerMove(interactionEvent, displayObject, hit) {
var data = interactionEvent.data;
var isTouch = data.pointerType === 'touch';
var isMouse = data.pointerType === 'mouse' || data.pointerType === 'pen';
if (isMouse) {
this.processPointerOverOut(interactionEvent, displayObject, hit);
}
if (!this.moveWhenInside || hit) {
this.dispatchEvent(displayObject, 'pointermove', interactionEvent);
if (isTouch) this.dispatchEvent(displayObject, 'touchmove', interactionEvent);
if (isMouse) this.dispatchEvent(displayObject, 'mousemove', interactionEvent);
}
};
/**
* Is called when the pointer is moved out of the renderer element
*
* @private
* @param {PointerEvent} originalEvent - The DOM event of a pointer being moved out
*/
InteractionManager.prototype.onPointerOut = function onPointerOut(originalEvent) {
// if we support touch events, then only use those for touch events, not pointer events
if (this.supportsTouchEvents && originalEvent.pointerType === 'touch') return;
var events = this.normalizeToPointerData(originalEvent);
// Only mouse and pointer can call onPointerOut, so events will always be length 1
var event = events[0];
if (event.pointerType === 'mouse') {
this.mouseOverRenderer = false;
this.setCursorMode(null);
}
var interactionData = this.getInteractionDataForPointerId(event);
var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);
interactionEvent.data.originalEvent = event;
this.processInteractive(interactionEvent, this.renderer._lastObjectRendered, this.processPointerOverOut, false);
this.emit('pointerout', interactionEvent);
if (event.pointerType === 'mouse' || event.pointerType === 'pen') {
this.emit('mouseout', interactionEvent);
} else {
// we can get touchleave events after touchend, so we want to make sure we don't
// introduce memory leaks
this.releaseInteractionDataForPointerId(interactionData.identifier);
}
};
/**
* Processes the result of the pointer over/out check and dispatches the event if need be
*
* @private
* @param {PIXI.interaction.InteractionEvent} interactionEvent - The interaction event wrapping the DOM event
* @param {PIXI.Container|PIXI.Sprite|PIXI.extras.TilingSprite} displayObject - The display object that was tested
* @param {boolean} hit - the result of the hit test on the display object
*/
InteractionManager.prototype.processPointerOverOut = function processPointerOverOut(interactionEvent, displayObject, hit) {
var data = interactionEvent.data;
var id = interactionEvent.data.identifier;
var isMouse = data.pointerType === 'mouse' || data.pointerType === 'pen';
var trackingData = displayObject.trackedPointers[id];
// if we just moused over the display object, then we need to track that state
if (hit && !trackingData) {
trackingData = displayObject.trackedPointers[id] = new _InteractionTrackingData2.default(id);
}
if (trackingData === undefined) return;
if (hit && this.mouseOverRenderer) {
if (!trackingData.over) {
trackingData.over = true;
this.dispatchEvent(displayObject, 'pointerover', interactionEvent);
if (isMouse) {
this.dispatchEvent(displayObject, 'mouseover', interactionEvent);
}
}
// only change the cursor if it has not already been changed (by something deeper in the
// display tree)
if (isMouse && this.cursor === null) {
this.cursor = displayObject.cursor;
}
} else if (trackingData.over) {
trackingData.over = false;
this.dispatchEvent(displayObject, 'pointerout', this.eventData);
if (isMouse) {
this.dispatchEvent(displayObject, 'mouseout', interactionEvent);
}
// if there is no mouse down information for the pointer, then it is safe to delete
if (trackingData.none) {
delete displayObject.trackedPointers[id];
}
}
};
/**
* Is called when the pointer is moved into the renderer element
*
* @private
* @param {PointerEvent} originalEvent - The DOM event of a pointer button being moved into the renderer view
*/
InteractionManager.prototype.onPointerOver = function onPointerOver(originalEvent) {
var events = this.normalizeToPointerData(originalEvent);
// Only mouse and pointer can call onPointerOver, so events will always be length 1
var event = events[0];
var interactionData = this.getInteractionDataForPointerId(event);
var interactionEvent = this.configureInteractionEventForDOMEvent(this.eventData, event, interactionData);
interactionEvent.data.originalEvent = event;
if (event.pointerType === 'mouse') {
this.mouseOverRenderer = true;
}
this.emit('pointerover', interactionEvent);
if (event.pointerType === 'mouse' || event.pointerType === 'pen') {
this.emit('mouseover', interactionEvent);
}
};
/**
* Get InteractionData for a given pointerId. Store that data as well
*
* @private
* @param {PointerEvent} event - Normalized pointer event, output from normalizeToPointerData
* @return {PIXI.interaction.InteractionData} - Interaction data for the given pointer identifier
*/
InteractionManager.prototype.getInteractionDataForPointerId = function getInteractionDataForPointerId(event) {
var pointerId = event.pointerId;
var interactionData = void 0;
if (pointerId === MOUSE_POINTER_ID || event.pointerType === 'mouse') {
interactionData = this.mouse;
} else if (this.activeInteractionData[pointerId]) {
interactionData = this.activeInteractionData[pointerId];
} else {
interactionData = this.interactionDataPool.pop() || new _InteractionData2.default();
interactionData.identifier = pointerId;
this.activeInteractionData[pointerId] = interactionData;
}
// copy properties from the event, so that we can make sure that touch/pointer specific
// data is available
interactionData.copyEvent(event);
return interactionData;
};
/**
* Return unused InteractionData to the pool, for a given pointerId
*
* @private
* @param {number} pointerId - Identifier from a pointer event
*/
InteractionManager.prototype.releaseInteractionDataForPointerId = function releaseInteractionDataForPointerId(pointerId) {
var interactionData = this.activeInteractionData[pointerId];
if (interactionData) {
delete this.activeInteractionData[pointerId];
interactionData.reset();
this.interactionDataPool.push(interactionData);
}
};
/**
* Configure an InteractionEvent to wrap a DOM PointerEvent and InteractionData
*
* @private
* @param {PIXI.interaction.InteractionEvent} interactionEvent - The event to be configured
* @param {PointerEvent} pointerEvent - The DOM event that will be paired with the InteractionEvent
* @param {PIXI.interaction.InteractionData} interactionData - The InteractionData that will be paired
* with the InteractionEvent
* @return {PIXI.interaction.InteractionEvent} the interaction event that was passed in
*/
InteractionManager.prototype.configureInteractionEventForDOMEvent = function configureInteractionEventForDOMEvent(interactionEvent, pointerEvent, interactionData) {
interactionEvent.data = interactionData;
this.mapPositionToPoint(interactionData.global, pointerEvent.clientX, pointerEvent.clientY);
// This is the way InteractionManager processed touch events before the refactoring, so I've kept
// it here. But it doesn't make that much sense to me, since mapPositionToPoint already factors
// in this.resolution, so this just divides by this.resolution twice for touch events...
if (navigator.isCocoonJS && pointerEvent.pointerType === 'touch') {
interactionData.global.x = interactionData.global.x / this.resolution;
interactionData.global.y = interactionData.global.y / this.resolution;
}
// Not really sure why this is happening, but it's how a previous version handled things
if (pointerEvent.pointerType === 'touch') {
pointerEvent.globalX = interactionData.global.x;
pointerEvent.globalY = interactionData.global.y;
}
interactionData.originalEvent = pointerEvent;
interactionEvent.reset();
return interactionEvent;
};
/**
* Ensures that the original event object contains all data that a regular pointer event would have
*
* @private
* @param {TouchEvent|MouseEvent|PointerEvent} event - The original event data from a touch or mouse event
* @return {PointerEvent[]} An array containing a single normalized pointer event, in the case of a pointer
* or mouse event, or a multiple normalized pointer events if there are multiple changed touches
*/
InteractionManager.prototype.normalizeToPointerData = function normalizeToPointerData(event) {
var normalizedEvents = [];
if (this.supportsTouchEvents && event instanceof TouchEvent) {
for (var i = 0, li = event.changedTouches.length; i < li; i++) {
var touch = event.changedTouches[i];
if (typeof touch.button === 'undefined') touch.button = event.touches.length ? 1 : 0;
if (typeof touch.buttons === 'undefined') touch.buttons = event.touches.length ? 1 : 0;
if (typeof touch.isPrimary === 'undefined') {
touch.isPrimary = event.touches.length === 1 && event.type === 'touchstart';
}
if (typeof touch.width === 'undefined') touch.width = touch.radiusX || 1;
if (typeof touch.height === 'undefined') touch.height = touch.radiusY || 1;
if (typeof touch.tiltX === 'undefined') touch.tiltX = 0;
if (typeof touch.tiltY === 'undefined') touch.tiltY = 0;
if (typeof touch.pointerType === 'undefined') touch.pointerType = 'touch';
if (typeof touch.pointerId === 'undefined') touch.pointerId = touch.identifier || 0;
if (typeof touch.pressure === 'undefined') touch.pressure = touch.force || 0.5;
if (typeof touch.twist === 'undefined') touch.twist = 0;
if (typeof touch.tangentialPressure === 'undefined') touch.tangentialPressure = 0;
// TODO: Remove these, as layerX/Y is not a standard, is deprecated, has uneven
// support, and the fill ins are not quite the same
// offsetX/Y might be okay, but is not the same as clientX/Y when the canvas's top
// left is not 0,0 on the page
if (typeof touch.layerX === 'undefined') touch.layerX = touch.offsetX = touch.clientX;
if (typeof touch.layerY === 'undefined') touch.layerY = touch.offsetY = touch.clientY;
// mark the touch as normalized, just so that we know we did it
touch.isNormalized = true;
normalizedEvents.push(touch);
}
}
// apparently PointerEvent subclasses MouseEvent, so yay
else if (event instanceof MouseEvent && (!this.supportsPointerEvents || !(event instanceof window.PointerEvent))) {
if (typeof event.isPrimary === 'undefined') event.isPrimary = true;
if (typeof event.width === 'undefined') event.width = 1;
if (typeof event.height === 'undefined') event.height = 1;
if (typeof event.tiltX === 'undefined') event.tiltX = 0;
if (typeof event.tiltY === 'undefined') event.tiltY = 0;
if (typeof event.pointerType === 'undefined') event.pointerType = 'mouse';
if (typeof event.pointerId === 'undefined') event.pointerId = MOUSE_POINTER_ID;
if (typeof event.pressure === 'undefined') event.pressure = 0.5;
if (typeof event.twist === 'undefined') event.twist = 0;
if (typeof event.tangentialPressure === 'undefined') event.tangentialPressure = 0;
// mark the mouse event as normalized, just so that we know we did it
event.isNormalized = true;
normalizedEvents.push(event);
} else {
normalizedEvents.push(event);
}
return normalizedEvents;
};
/**
* Destroys the interaction manager
*
*/
InteractionManager.prototype.destroy = function destroy() {
this.removeEvents();
this.removeAllListeners();
this.renderer = null;
this.mouse = null;
this.eventData = null;
this.interactionDOMElement = null;
this.onPointerDown = null;
this.processPointerDown = null;
this.onPointerUp = null;
this.processPointerUp = null;
this.onPointerCancel = null;
this.processPointerCancel = null;
this.onPointerMove = null;
this.processPointerMove = null;
this.onPointerOut = null;
this.processPointerOverOut = null;
this.onPointerOver = null;
this._tempPoint = null;
};
return InteractionManager;
}(_eventemitter2.default);
exports.default = InteractionManager;
core.WebGLRenderer.registerPlugin('interaction', InteractionManager);
core.CanvasRenderer.registerPlugin('interaction', InteractionManager);
//# sourceMappingURL=InteractionManager.js.map
/***/ }),
/* 519 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.shared = exports.Resource = exports.textureParser = exports.getResourcePath = exports.spritesheetParser = exports.parseBitmapFontData = exports.bitmapFontParser = exports.Loader = undefined;
var _bitmapFontParser = __webpack_require__(212);
Object.defineProperty(exports, 'bitmapFontParser', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_bitmapFontParser).default;
}
});
Object.defineProperty(exports, 'parseBitmapFontData', {
enumerable: true,
get: function get() {
return _bitmapFontParser.parse;
}
});
var _spritesheetParser = __webpack_require__(217);
Object.defineProperty(exports, 'spritesheetParser', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_spritesheetParser).default;
}
});
Object.defineProperty(exports, 'getResourcePath', {
enumerable: true,
get: function get() {
return _spritesheetParser.getResourcePath;
}
});
var _textureParser = __webpack_require__(218);
Object.defineProperty(exports, 'textureParser', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_textureParser).default;
}
});
var _resourceLoader = __webpack_require__(68);
Object.defineProperty(exports, 'Resource', {
enumerable: true,
get: function get() {
return _resourceLoader.Resource;
}
});
var _Application = __webpack_require__(199);
var _Application2 = _interopRequireDefault(_Application);
var _loader = __webpack_require__(521);
var _loader2 = _interopRequireDefault(_loader);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* This namespace contains APIs which extends the {@link https://github.com/englercj/resource-loader resource-loader} module
* for loading assets, data, and other resources dynamically.
* @example
* const loader = new PIXI.loaders.Loader();
* loader.add('bunny', 'data/bunny.png')
* .add('spaceship', 'assets/spritesheet.json');
* loader.load((loader, resources) => {
* // resources.bunny
* // resources.spaceship
* });
* @namespace PIXI.loaders
*/
exports.Loader = _loader2.default;
/**
* A premade instance of the loader that can be used to load resources.
* @name shared
* @memberof PIXI.loaders
* @type {PIXI.loaders.Loader}
*/
var shared = new _loader2.default();
shared.destroy = function () {
// protect destroying shared loader
};
exports.shared = shared;
// Mixin the loader construction
var AppPrototype = _Application2.default.prototype;
AppPrototype._loader = null;
/**
* Loader instance to help with asset loading.
* @name PIXI.Application#loader
* @type {PIXI.loaders.Loader}
*/
Object.defineProperty(AppPrototype, 'loader', {
get: function get() {
if (!this._loader) {
var sharedLoader = this._options.sharedLoader;
this._loader = sharedLoader ? shared : new _loader2.default();
}
return this._loader;
}
});
// Override the destroy function
// making sure to destroy the current Loader
AppPrototype._parentDestroy = AppPrototype.destroy;
AppPrototype.destroy = function destroy(removeView, stageOptions) {
if (this._loader) {
this._loader.destroy();
this._loader = null;
}
this._parentDestroy(removeView, stageOptions);
};
//# sourceMappingURL=index.js.map
/***/ }),
/* 520 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.Loader = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
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 _miniSignals = __webpack_require__(213);
var _miniSignals2 = _interopRequireDefault(_miniSignals);
var _parseUri = __webpack_require__(214);
var _parseUri2 = _interopRequireDefault(_parseUri);
var _async = __webpack_require__(215);
var async = _interopRequireWildcard(_async);
var _Resource = __webpack_require__(130);
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 }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// some constants
var MAX_PROGRESS = 100;
var rgxExtractUrlHash = /(#[\w-]+)?$/;
/**
* Manages the state and loading of multiple resources to load.
*
* @class
*/
var Loader = exports.Loader = function () {
/**
* @param {string} [baseUrl=''] - The base url for all resources loaded by this loader.
* @param {number} [concurrency=10] - The number of resources to load concurrently.
*/
function Loader() {
var _this = this;
var baseUrl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var concurrency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
_classCallCheck(this, Loader);
/**
* The base url for all resources loaded by this loader.
*
* @member {string}
*/
this.baseUrl = baseUrl;
/**
* The progress percent of the loader going through the queue.
*
* @member {number}
*/
this.progress = 0;
/**
* Loading state of the loader, true if it is currently loading resources.
*
* @member {boolean}
*/
this.loading = false;
/**
* A querystring to append to every URL added to the loader.
*
* This should be a valid query string *without* the question-mark (`?`). The loader will
* also *not* escape values for you. Make sure to escape your parameters with
* [`encodeURIComponent`](https://mdn.io/encodeURIComponent) before assigning this property.
*
* @example
* const loader = new Loader();
*
* loader.defaultQueryString = 'user=me&password=secret';
*
* // This will request 'image.png?user=me&password=secret'
* loader.add('image.png').load();
*
* loader.reset();
*
* // This will request 'image.png?v=1&user=me&password=secret'
* loader.add('iamge.png?v=1').load();
*
* @member {string}
*/
this.defaultQueryString = '';
/**
* The middleware to run before loading each resource.
*
* @private
* @member {function[]}
*/
this._beforeMiddleware = [];
/**
* The middleware to run after loading each resource.
*
* @private
* @member {function[]}
*/
this._afterMiddleware = [];
/**
* The tracks the resources we are currently completing parsing for.
*
* @private
* @member {Resource[]}
*/
this._resourcesParsing = [];
/**
* The `_loadResource` function bound with this object context.
*
* @private
* @member {function}
* @param {Resource} r - The resource to load
* @param {Function} d - The dequeue function
* @return {undefined}
*/
this._boundLoadResource = function (r, d) {
return _this._loadResource(r, d);
};
/**
* The resources waiting to be loaded.
*
* @private
* @member {Resource[]}
*/
this._queue = async.queue(this._boundLoadResource, concurrency);
this._queue.pause();
/**
* All the resources for this loader keyed by name.
*
* @member {object<string, Resource>}
*/
this.resources = {};
/**
* Dispatched once per loaded or errored resource.
*
* The callback looks like {@link Loader.OnProgressSignal}.
*
* @member {Signal<Loader.OnProgressSignal>}
*/
this.onProgress = new _miniSignals2.default();
/**
* Dispatched once per errored resource.
*
* The callback looks like {@link Loader.OnErrorSignal}.
*
* @member {Signal<Loader.OnErrorSignal>}
*/
this.onError = new _miniSignals2.default();
/**
* Dispatched once per loaded resource.
*
* The callback looks like {@link Loader.OnLoadSignal}.
*
* @member {Signal<Loader.OnLoadSignal>}
*/
this.onLoad = new _miniSignals2.default();
/**
* Dispatched when the loader begins to process the queue.
*
* The callback looks like {@link Loader.OnStartSignal}.
*
* @member {Signal<Loader.OnStartSignal>}
*/
this.onStart = new _miniSignals2.default();
/**
* Dispatched when the queued resources all load.
*
* The callback looks like {@link Loader.OnCompleteSignal}.
*
* @member {Signal<Loader.OnCompleteSignal>}
*/
this.onComplete = new _miniSignals2.default();
// Add default before middleware
for (var i = 0; i < Loader._defaultBeforeMiddleware.length; ++i) {
this.pre(Loader._defaultBeforeMiddleware[i]);
}
// Add default after middleware
for (var _i = 0; _i < Loader._defaultAfterMiddleware.length; ++_i) {
this.use(Loader._defaultAfterMiddleware[_i]);
}
}
/**
* When the progress changes the loader and resource are disaptched.
*
* @memberof Loader
* @callback OnProgressSignal
* @param {Loader} loader - The loader the progress is advancing on.
* @param {Resource} resource - The resource that has completed or failed to cause the progress to advance.
*/
/**
* When an error occurrs the loader and resource are disaptched.
*
* @memberof Loader
* @callback OnErrorSignal
* @param {Loader} loader - The loader the error happened in.
* @param {Resource} resource - The resource that caused the error.
*/
/**
* When a load completes the loader and resource are disaptched.
*
* @memberof Loader
* @callback OnLoadSignal
* @param {Loader} loader - The loader that laoded the resource.
* @param {Resource} resource - The resource that has completed loading.
*/
/**
* When the loader starts loading resources it dispatches this callback.
*
* @memberof Loader
* @callback OnStartSignal
* @param {Loader} loader - The loader that has started loading resources.
*/
/**
* When the loader completes loading resources it dispatches this callback.
*
* @memberof Loader
* @callback OnCompleteSignal
* @param {Loader} loader - The loader that has finished loading resources.
*/
/**
* Options for a call to `.add()`.
*
* @see Loader#add
*
* @typedef {object} IAddOptions
* @property {string} [name] - The name of the resource to load, if not passed the url is used.
* @property {string} [key] - Alias for `name`.
* @property {string} [url] - The url for this resource, relative to the baseUrl of this loader.
* @property {string|boolean} [crossOrigin] - Is this request cross-origin? Default is to
* determine automatically.
* @property {number} [timeout=0] - A timeout in milliseconds for the load. If the load takes
* longer than this time it is cancelled and the load is considered a failure. If this value is
* set to `0` then there is no explicit timeout.
* @property {Resource.LOAD_TYPE} [loadType=Resource.LOAD_TYPE.XHR] - How should this resource
* be loaded?
* @property {Resource.XHR_RESPONSE_TYPE} [xhrType=Resource.XHR_RESPONSE_TYPE.DEFAULT] - How
* should the data being loaded be interpreted when using XHR?
* @property {Resource.OnCompleteSignal} [onComplete] - Callback to add an an onComplete signal istener.
* @property {Resource.OnCompleteSignal} [callback] - Alias for `onComplete`.
* @property {Resource.IMetadata} [metadata] - Extra configuration for middleware and the Resource object.
*/
/* eslint-disable require-jsdoc,valid-jsdoc */
/**
* Adds a resource (or multiple resources) to the loader queue.
*
* This function can take a wide variety of different parameters. The only thing that is always
* required the url to load. All the following will work:
*
* ```js
* loader
* // normal param syntax
* .add('key', 'http://...', function () {})
* .add('http://...', function () {})
* .add('http://...')
*
* // object syntax
* .add({
* name: 'key2',
* url: 'http://...'
* }, function () {})
* .add({
* url: 'http://...'
* }, function () {})
* .add({
* name: 'key3',
* url: 'http://...'
* onComplete: function () {}
* })
* .add({
* url: 'https://...',
* onComplete: function () {},
* crossOrigin: true
* })
*
* // you can also pass an array of objects or urls or both
* .add([
* { name: 'key4', url: 'http://...', onComplete: function () {} },
* { url: 'http://...', onComplete: function () {} },
* 'http://...'
* ])
*
* // and you can use both params and options
* .add('key', 'http://...', { crossOrigin: true }, function () {})
* .add('http://...', { crossOrigin: true }, function () {});
* ```
*
* @function
* @variation 1
* @param {string} name - The name of the resource to load.
* @param {string} url - The url for this resource, relative to the baseUrl of this loader.
* @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading.
* @return {this} Returns itself.
*/ /**
* @function
* @variation 2
* @param {string} name - The name of the resource to load.
* @param {string} url - The url for this resource, relative to the baseUrl of this loader.
* @param {IAddOptions} [options] - The options for the load.
* @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading.
* @return {this} Returns itself.
*/ /**
* @function
* @variation 3
* @param {string} url - The url for this resource, relative to the baseUrl of this loader.
* @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading.
* @return {this} Returns itself.
*/ /**
* @function
* @variation 4
* @param {string} url - The url for this resource, relative to the baseUrl of this loader.
* @param {IAddOptions} [options] - The options for the load.
* @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading.
* @return {this} Returns itself.
*/ /**
* @function
* @variation 5
* @param {IAddOptions} options - The options for the load. This object must contain a `url` property.
* @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading.
* @return {this} Returns itself.
*/ /**
* @function
* @variation 6
* @param {Array<IAddOptions|string>} resources - An array of resources to load, where each is
* either an object with the options or a string url. If you pass an object, it must contain a `url` property.
* @param {Resource.OnCompleteSignal} [callback] - Function to call when this specific resource completes loading.
* @return {this} Returns itself.
*/
Loader.prototype.add = function add(name, url, options, cb) {
// special case of an array of objects or urls
if (Array.isArray(name)) {
for (var i = 0; i < name.length; ++i) {
this.add(name[i]);
}
return this;
}
// if an object is passed instead of params
if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
cb = url || name.callback || name.onComplete;
options = name;
url = name.url;
name = name.name || name.key || name.url;
}
// case where no name is passed shift all args over by one.
if (typeof url !== 'string') {
cb = options;
options = url;
url = name;
}
// now that we shifted make sure we have a proper url.
if (typeof url !== 'string') {
throw new Error('No url passed to add resource to loader.');
}
// options are optional so people might pass a function and no options
if (typeof options === 'function') {
cb = options;
options = null;
}
// if loading already you can only add resources that have a parent.
if (this.loading && (!options || !options.parentResource)) {
throw new Error('Cannot add resources while the loader is running.');
}
// check if resource already exists.
if (this.resources[name]) {
throw new Error('Resource named "' + name + '" already exists.');
}
// add base url if this isn't an absolute url
url = this._prepareUrl(url);
// create the store the resource
this.resources[name] = new _Resource.Resource(name, url, options);
if (typeof cb === 'function') {
this.resources[name].onAfterMiddleware.once(cb);
}
// if actively loading, make sure to adjust progress chunks for that parent and its children
if (this.loading) {
var parent = options.parentResource;
var incompleteChildren = [];
for (var _i2 = 0; _i2 < parent.children.length; ++_i2) {
if (!parent.children[_i2].isComplete) {
incompleteChildren.push(parent.children[_i2]);
}
}
var fullChunk = parent.progressChunk * (incompleteChildren.length + 1); // +1 for parent
var eachChunk = fullChunk / (incompleteChildren.length + 2); // +2 for parent & new child
parent.children.push(this.resources[name]);
parent.progressChunk = eachChunk;
for (var _i3 = 0; _i3 < incompleteChildren.length; ++_i3) {
incompleteChildren[_i3].progressChunk = eachChunk;
}
this.resources[name].progressChunk = eachChunk;
}
// add the resource to the queue
this._queue.push(this.resources[name]);
return this;
};
/* eslint-enable require-jsdoc,valid-jsdoc */
/**
* Sets up a middleware function that will run *before* the
* resource is loaded.
*
* @param {function} fn - The middleware function to register.
* @return {this} Returns itself.
*/
Loader.prototype.pre = function pre(fn) {
this._beforeMiddleware.push(fn);
return this;
};
/**
* Sets up a middleware function that will run *after* the
* resource is loaded.
*
* @param {function} fn - The middleware function to register.
* @return {this} Returns itself.
*/
Loader.prototype.use = function use(fn) {
this._afterMiddleware.push(fn);
return this;
};
/**
* Resets the queue of the loader to prepare for a new load.
*
* @return {this} Returns itself.
*/
Loader.prototype.reset = function reset() {
this.progress = 0;
this.loading = false;
this._queue.kill();
this._queue.pause();
// abort all resource loads
for (var k in this.resources) {
var res = this.resources[k];
if (res._onLoadBinding) {
res._onLoadBinding.detach();
}
if (res.isLoading) {
res.abort();
}
}
this.resources = {};
return this;
};
/**
* Starts loading the queued resources.
*
* @param {function} [cb] - Optional callback that will be bound to the `complete` event.
* @return {this} Returns itself.
*/
Loader.prototype.load = function load(cb) {
// register complete callback if they pass one
if (typeof cb === 'function') {
this.onComplete.once(cb);
}
// if the queue has already started we are done here
if (this.loading) {
return this;
}
if (this._queue.idle()) {
this._onStart();
this._onComplete();
} else {
// distribute progress chunks
var numTasks = this._queue._tasks.length;
var chunk = MAX_PROGRESS / numTasks;
for (var i = 0; i < this._queue._tasks.length; ++i) {
this._queue._tasks[i].data.progressChunk = chunk;
}
// notify we are starting
this._onStart();
// start loading
this._queue.resume();
}
return this;
};
/**
* The number of resources to load concurrently.
*
* @member {number}
* @default 10
*/
/**
* Prepares a url for usage based on the configuration of this object
*
* @private
* @param {string} url - The url to prepare.
* @return {string} The prepared url.
*/
Loader.prototype._prepareUrl = function _prepareUrl(url) {
var parsedUrl = (0, _parseUri2.default)(url, { strictMode: true });
var result = void 0;
// absolute url, just use it as is.
if (parsedUrl.protocol || !parsedUrl.path || url.indexOf('//') === 0) {
result = url;
}
// if baseUrl doesn't end in slash and url doesn't start with slash, then add a slash inbetween
else if (this.baseUrl.length && this.baseUrl.lastIndexOf('/') !== this.baseUrl.length - 1 && url.charAt(0) !== '/') {
result = this.baseUrl + '/' + url;
} else {
result = this.baseUrl + url;
}
// if we need to add a default querystring, there is a bit more work
if (this.defaultQueryString) {
var hash = rgxExtractUrlHash.exec(result)[0];
result = result.substr(0, result.length - hash.length);
if (result.indexOf('?') !== -1) {
result += '&' + this.defaultQueryString;
} else {
result += '?' + this.defaultQueryString;
}
result += hash;
}
return result;
};
/**
* Loads a single resource.
*
* @private
* @param {Resource} resource - The resource to load.
* @param {function} dequeue - The function to call when we need to dequeue this item.
*/
Loader.prototype._loadResource = function _loadResource(resource, dequeue) {
var _this2 = this;
resource._dequeue = dequeue;
// run before middleware
async.eachSeries(this._beforeMiddleware, function (fn, next) {
fn.call(_this2, resource, function () {
// if the before middleware marks the resource as complete,
// break and don't process any more before middleware
next(resource.isComplete ? {} : null);
});
}, function () {
if (resource.isComplete) {
_this2._onLoad(resource);
} else {
resource._onLoadBinding = resource.onComplete.once(_this2._onLoad, _this2);
resource.load();
}
}, true);
};
/**
* Called once loading has started.
*
* @private
*/
Loader.prototype._onStart = function _onStart() {
this.progress = 0;
this.loading = true;
this.onStart.dispatch(this);
};
/**
* Called once each resource has loaded.
*
* @private
*/
Loader.prototype._onComplete = function _onComplete() {
this.progress = MAX_PROGRESS;
this.loading = false;
this.onComplete.dispatch(this, this.resources);
};
/**
* Called each time a resources is loaded.
*
* @private
* @param {Resource} resource - The resource that was loaded
*/
Loader.prototype._onLoad = function _onLoad(resource) {
var _this3 = this;
resource._onLoadBinding = null;
// remove this resource from the async queue, and add it to our list of resources that are being parsed
this._resourcesParsing.push(resource);
resource._dequeue();
// run all the after middleware for this resource
async.eachSeries(this._afterMiddleware, function (fn, next) {
fn.call(_this3, resource, next);
}, function () {
resource.onAfterMiddleware.dispatch(resource);
_this3.progress = Math.min(MAX_PROGRESS, _this3.progress + resource.progressChunk);
_this3.onProgress.dispatch(_this3, resource);
if (resource.error) {
_this3.onError.dispatch(resource.error, _this3, resource);
} else {
_this3.onLoad.dispatch(_this3, resource);
}
_this3._resourcesParsing.splice(_this3._resourcesParsing.indexOf(resource), 1);
// do completion check
if (_this3._queue.idle() && _this3._resourcesParsing.length === 0) {
_this3._onComplete();
}
}, true);
};
_createClass(Loader, [{
key: 'concurrency',
get: function get() {
return this._queue.concurrency;
}
// eslint-disable-next-line require-jsdoc
,
set: function set(concurrency) {
this._queue.concurrency = concurrency;
}
}]);
return Loader;
}();
/**
* A default array of middleware to run before loading each resource.
* Each of these middlewares are added to any new Loader instances when they are created.
*
* @private
* @member {function[]}
*/
Loader._defaultBeforeMiddleware = [];
/**
* A default array of middleware to run after loading each resource.
* Each of these middlewares are added to any new Loader instances when they are created.
*
* @private
* @member {function[]}
*/
Loader._defaultAfterMiddleware = [];
/**
* Sets up a middleware function that will run *before* the
* resource is loaded.
*
* @static
* @param {function} fn - The middleware function to register.
* @return {Loader} Returns itself.
*/
Loader.pre = function LoaderPreStatic(fn) {
Loader._defaultBeforeMiddleware.push(fn);
return Loader;
};
/**
* Sets up a middleware function that will run *after* the
* resource is loaded.
*
* @static
* @param {function} fn - The middleware function to register.
* @return {Loader} Returns itself.
*/
Loader.use = function LoaderUseStatic(fn) {
Loader._defaultAfterMiddleware.push(fn);
return Loader;
};
//# sourceMappingURL=Loader.js.map
/***/ }),
/* 521 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _resourceLoader = __webpack_require__(68);
var _resourceLoader2 = _interopRequireDefault(_resourceLoader);
var _blob = __webpack_require__(522);
var _eventemitter = __webpack_require__(52);
var _eventemitter2 = _interopRequireDefault(_eventemitter);
var _textureParser = __webpack_require__(218);
var _textureParser2 = _interopRequireDefault(_textureParser);
var _spritesheetParser = __webpack_require__(217);
var _spritesheetParser2 = _interopRequireDefault(_spritesheetParser);
var _bitmapFontParser = __webpack_require__(212);
var _bitmapFontParser2 = _interopRequireDefault(_bitmapFontParser);
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 new loader, extends Resource Loader by Chad Engler: https://github.com/englercj/resource-loader
*
* ```js
* const loader = PIXI.loader; // PixiJS exposes a premade instance for you to use.
* //or
* const loader = new PIXI.loaders.Loader(); // you can also create your own if you want
*
* const sprites = {};
*
* // Chainable `add` to enqueue a resource
* loader.add('bunny', 'data/bunny.png')
* .add('spaceship', 'assets/spritesheet.json');
* loader.add('scoreFont', 'assets/score.fnt');
*
* // Chainable `pre` to add a middleware that runs for each resource, *before* loading that resource.
* // This is useful to implement custom caching modules (using filesystem, indexeddb, memory, etc).
* loader.pre(cachingMiddleware);
*
* // Chainable `use` to add a middleware that runs for each resource, *after* loading that resource.
* // This is useful to implement custom parsing modules (like spritesheet parsers, spine parser, etc).
* loader.use(parsingMiddleware);
*
* // The `load` method loads the queue of resources, and calls the passed in callback called once all
* // resources have loaded.
* loader.load((loader, resources) => {
* // resources is an object where the key is the name of the resource loaded and the value is the resource object.
* // They have a couple default properties:
* // - `url`: The URL that the resource was loaded from
* // - `error`: The error that happened when trying to load (if any)
* // - `data`: The raw data that was loaded
* // also may contain other properties based on the middleware that runs.
* sprites.bunny = new PIXI.TilingSprite(resources.bunny.texture);
* sprites.spaceship = new PIXI.TilingSprite(resources.spaceship.texture);
* sprites.scoreFont = new PIXI.TilingSprite(resources.scoreFont.texture);
* });
*
* // throughout the process multiple signals can be dispatched.
* loader.onProgress.add(() => {}); // called once per loaded/errored file
* loader.onError.add(() => {}); // called once per errored file
* loader.onLoad.add(() => {}); // called once per loaded file
* loader.onComplete.add(() => {}); // called once when the queued resources all load.
* ```
*
* @see https://github.com/englercj/resource-loader
*
* @class
* @extends module:resource-loader.ResourceLoader
* @memberof PIXI.loaders
*/
var Loader = function (_ResourceLoader) {
_inherits(Loader, _ResourceLoader);
/**
* @param {string} [baseUrl=''] - The base url for all resources loaded by this loader.
* @param {number} [concurrency=10] - The number of resources to load concurrently.
*/
function Loader(baseUrl, concurrency) {
_classCallCheck(this, Loader);
var _this = _possibleConstructorReturn(this, _ResourceLoader.call(this, baseUrl, concurrency));
_eventemitter2.default.call(_this);
for (var i = 0; i < Loader._pixiMiddleware.length; ++i) {
_this.use(Loader._pixiMiddleware[i]());
}
// Compat layer, translate the new v2 signals into old v1 events.
_this.onStart.add(function (l) {
return _this.emit('start', l);
});
_this.onProgress.add(function (l, r) {
return _this.emit('progress', l, r);
});
_this.onError.add(function (e, l, r) {
return _this.emit('error', e, l, r);
});
_this.onLoad.add(function (l, r) {
return _this.emit('load', l, r);
});
_this.onComplete.add(function (l, r) {
return _this.emit('complete', l, r);
});
return _this;
}
/**
* Adds a default middleware to the PixiJS loader.
*
* @static
* @param {Function} fn - The middleware to add.
*/
Loader.addPixiMiddleware = function addPixiMiddleware(fn) {
Loader._pixiMiddleware.push(fn);
};
/**
* Destroy the loader, removes references.
*/
Loader.prototype.destroy = function destroy() {
this.removeAllListeners();
this.reset();
};
return Loader;
}(_resourceLoader2.default);
// Copy EE3 prototype (mixin)
exports.default = Loader;
for (var k in _eventemitter2.default.prototype) {
Loader.prototype[k] = _eventemitter2.default.prototype[k];
}
Loader._pixiMiddleware = [
// parse any blob into more usable objects (e.g. Image)
_blob.blobMiddlewareFactory,
// parse any Image objects into textures
_textureParser2.default,
// parse any spritesheet data into multiple textures
_spritesheetParser2.default,
// parse bitmap font data into multiple textures
_bitmapFontParser2.default];
// Add custom extentions
var Resource = _resourceLoader2.default.Resource;
Resource.setExtensionXhrType('fnt', Resource.XHR_RESPONSE_TYPE.DOCUMENT);
//# sourceMappingURL=loader.js.map
/***/ }),
/* 522 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
exports.blobMiddlewareFactory = blobMiddlewareFactory;
var _Resource = __webpack_require__(130);
var _b = __webpack_require__(216);
var Url = window.URL || window.webkitURL;
// a middleware for transforming XHR loaded Blobs into more useful objects
function blobMiddlewareFactory() {
return function blobMiddleware(resource, next) {
if (!resource.data) {
next();
return;
}
// if this was an XHR load of a blob
if (resource.xhr && resource.xhrType === _Resource.Resource.XHR_RESPONSE_TYPE.BLOB) {
// if there is no blob support we probably got a binary string back
if (!window.Blob || typeof resource.data === 'string') {
var type = resource.xhr.getResponseHeader('content-type');
// this is an image, convert the binary string into a data url
if (type && type.indexOf('image') === 0) {
resource.data = new Image();
resource.data.src = 'data:' + type + ';base64,' + (0, _b.encodeBinary)(resource.xhr.responseText);
resource.type = _Resource.Resource.TYPE.IMAGE;
// wait until the image loads and then callback
resource.data.onload = function () {
resource.data.onload = null;
next();
};
// next will be called on load
return;
}
}
// if content type says this is an image, then we should transform the blob into an Image object
else if (resource.data.type.indexOf('image') === 0) {
var src = Url.createObjectURL(resource.data);
resource.blob = resource.data;
resource.data = new Image();
resource.data.src = src;
resource.type = _Resource.Resource.TYPE.IMAGE;
// cleanup the no longer used blob after the image loads
// TODO: Is this correct? Will the image be invalid after revoking?
resource.data.onload = function () {
Url.revokeObjectURL(src);
resource.data.onload = null;
next();
};
// next will be called on load.
return;
}
}
next();
};
}
//# sourceMappingURL=blob.js.map
/***/ }),
/* 523 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Mesh = __webpack_require__(69);
Object.defineProperty(exports, 'Mesh', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Mesh).default;
}
});
var _MeshRenderer = __webpack_require__(524);
Object.defineProperty(exports, 'MeshRenderer', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_MeshRenderer).default;
}
});
var _CanvasMeshRenderer = __webpack_require__(525);
Object.defineProperty(exports, 'CanvasMeshRenderer', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_CanvasMeshRenderer).default;
}
});
var _Plane = __webpack_require__(219);
Object.defineProperty(exports, 'Plane', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Plane).default;
}
});
var _NineSlicePlane = __webpack_require__(526);
Object.defineProperty(exports, 'NineSlicePlane', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_NineSlicePlane).default;
}
});
var _Rope = __webpack_require__(527);
Object.defineProperty(exports, 'Rope', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_Rope).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map
/***/ }),
/* 524 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _pixiGlCore = __webpack_require__(23);
var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore);
var _Mesh = __webpack_require__(69);
var _Mesh2 = _interopRequireDefault(_Mesh);
var _path = __webpack_require__(34);
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 matrixIdentity = core.Matrix.IDENTITY;
/**
* WebGL renderer plugin for tiling sprites
*
* @class
* @memberof PIXI
* @extends PIXI.ObjectRenderer
*/
var MeshRenderer = function (_core$ObjectRenderer) {
_inherits(MeshRenderer, _core$ObjectRenderer);
/**
* constructor for renderer
*
* @param {WebGLRenderer} renderer The renderer this tiling awesomeness works for.
*/
function MeshRenderer(renderer) {
_classCallCheck(this, MeshRenderer);
var _this = _possibleConstructorReturn(this, _core$ObjectRenderer.call(this, renderer));
_this.shader = null;
return _this;
}
/**
* Sets up the renderer context and necessary buffers.
*
* @private
*/
MeshRenderer.prototype.onContextChange = function onContextChange() {
var gl = this.renderer.gl;
this.shader = new core.Shader(gl, 'attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n', 'varying vec2 vTextureCoord;\nuniform vec4 uColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;\n}\n');
};
/**
* renders mesh
*
* @param {PIXI.mesh.Mesh} mesh mesh instance
*/
MeshRenderer.prototype.render = function render(mesh) {
var renderer = this.renderer;
var gl = renderer.gl;
var texture = mesh._texture;
if (!texture.valid) {
return;
}
var glData = mesh._glDatas[renderer.CONTEXT_UID];
if (!glData) {
renderer.bindVao(null);
glData = {
shader: this.shader,
vertexBuffer: _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, mesh.vertices, gl.STREAM_DRAW),
uvBuffer: _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, mesh.uvs, gl.STREAM_DRAW),
indexBuffer: _pixiGlCore2.default.GLBuffer.createIndexBuffer(gl, mesh.indices, gl.STATIC_DRAW),
// build the vao object that will render..
vao: null,
dirty: mesh.dirty,
indexDirty: mesh.indexDirty,
vertexDirty: mesh.vertexDirty
};
// build the vao object that will render..
glData.vao = new _pixiGlCore2.default.VertexArrayObject(gl).addIndex(glData.indexBuffer).addAttribute(glData.vertexBuffer, glData.shader.attributes.aVertexPosition, gl.FLOAT, false, 2 * 4, 0).addAttribute(glData.uvBuffer, glData.shader.attributes.aTextureCoord, gl.FLOAT, false, 2 * 4, 0);
mesh._glDatas[renderer.CONTEXT_UID] = glData;
}
renderer.bindVao(glData.vao);
if (mesh.dirty !== glData.dirty) {
glData.dirty = mesh.dirty;
glData.uvBuffer.upload(mesh.uvs);
}
if (mesh.indexDirty !== glData.indexDirty) {
glData.indexDirty = mesh.indexDirty;
glData.indexBuffer.upload(mesh.indices);
}
if (mesh.vertexDirty !== glData.vertexDirty) {
glData.vertexDirty = mesh.vertexDirty;
glData.vertexBuffer.upload(mesh.vertices);
}
renderer.bindShader(glData.shader);
glData.shader.uniforms.uSampler = renderer.bindTexture(texture);
renderer.state.setBlendMode(core.utils.correctBlendMode(mesh.blendMode, texture.baseTexture.premultipliedAlpha));
if (glData.shader.uniforms.uTransform) {
if (mesh.uploadUvTransform) {
glData.shader.uniforms.uTransform = mesh._uvTransform.mapCoord.toArray(true);
} else {
glData.shader.uniforms.uTransform = matrixIdentity.toArray(true);
}
}
glData.shader.uniforms.translationMatrix = mesh.worldTransform.toArray(true);
glData.shader.uniforms.uColor = core.utils.premultiplyRgba(mesh.tintRgb, mesh.worldAlpha, glData.shader.uniforms.uColor, texture.baseTexture.premultipliedAlpha);
var drawMode = mesh.drawMode === _Mesh2.default.DRAW_MODES.TRIANGLE_MESH ? gl.TRIANGLE_STRIP : gl.TRIANGLES;
glData.vao.draw(drawMode, mesh.indices.length, 0);
};
return MeshRenderer;
}(core.ObjectRenderer);
exports.default = MeshRenderer;
core.WebGLRenderer.registerPlugin('mesh', MeshRenderer);
//# sourceMappingURL=MeshRenderer.js.map
/***/ }),
/* 525 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _Mesh = __webpack_require__(69);
var _Mesh2 = _interopRequireDefault(_Mesh);
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"); } }
/**
* Renderer dedicated to meshes.
*
* @class
* @private
* @memberof PIXI
*/
var MeshSpriteRenderer = function () {
/**
* @param {PIXI.CanvasRenderer} renderer - The renderer this downport works for
*/
function MeshSpriteRenderer(renderer) {
_classCallCheck(this, MeshSpriteRenderer);
this.renderer = renderer;
}
/**
* Renders the Mesh
*
* @param {PIXI.mesh.Mesh} mesh - the Mesh to render
*/
MeshSpriteRenderer.prototype.render = function render(mesh) {
var renderer = this.renderer;
var context = renderer.context;
var transform = mesh.worldTransform;
var res = renderer.resolution;
if (renderer.roundPixels) {
context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, transform.tx * res | 0, transform.ty * res | 0);
} else {
context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, transform.tx * res, transform.ty * res);
}
renderer.context.globalAlpha = mesh.worldAlpha;
renderer.setBlendMode(mesh.blendMode);
if (mesh.drawMode === _Mesh2.default.DRAW_MODES.TRIANGLE_MESH) {
this._renderTriangleMesh(mesh);
} else {
this._renderTriangles(mesh);
}
};
/**
* Draws the object in Triangle Mesh mode
*
* @private
* @param {PIXI.mesh.Mesh} mesh - the Mesh to render
*/
MeshSpriteRenderer.prototype._renderTriangleMesh = function _renderTriangleMesh(mesh) {
// draw triangles!!
var length = mesh.vertices.length / 2;
for (var i = 0; i < length - 2; i++) {
// draw some triangles!
var index = i * 2;
this._renderDrawTriangle(mesh, index, index + 2, index + 4);
}
};
/**
* Draws the object in triangle mode using canvas
*
* @private
* @param {PIXI.mesh.Mesh} mesh - the current mesh
*/
MeshSpriteRenderer.prototype._renderTriangles = function _renderTriangles(mesh) {
// draw triangles!!
var indices = mesh.indices;
var length = indices.length;
for (var i = 0; i < length; i += 3) {
// draw some triangles!
var index0 = indices[i] * 2;
var index1 = indices[i + 1] * 2;
var index2 = indices[i + 2] * 2;
this._renderDrawTriangle(mesh, index0, index1, index2);
}
};
/**
* Draws one of the triangles that from the Mesh
*
* @private
* @param {PIXI.mesh.Mesh} mesh - the current mesh
* @param {number} index0 - the index of the first vertex
* @param {number} index1 - the index of the second vertex
* @param {number} index2 - the index of the third vertex
*/
MeshSpriteRenderer.prototype._renderDrawTriangle = function _renderDrawTriangle(mesh, index0, index1, index2) {
var context = this.renderer.context;
var uvs = mesh.uvs;
var vertices = mesh.vertices;
var texture = mesh._texture;
if (!texture.valid) {
return;
}
var base = texture.baseTexture;
var textureSource = base.source;
var textureWidth = base.width;
var textureHeight = base.height;
var u0 = void 0;
var u1 = void 0;
var u2 = void 0;
var v0 = void 0;
var v1 = void 0;
var v2 = void 0;
if (mesh.uploadUvTransform) {
var ut = mesh._uvTransform.mapCoord;
u0 = (uvs[index0] * ut.a + uvs[index0 + 1] * ut.c + ut.tx) * base.width;
u1 = (uvs[index1] * ut.a + uvs[index1 + 1] * ut.c + ut.tx) * base.width;
u2 = (uvs[index2] * ut.a + uvs[index2 + 1] * ut.c + ut.tx) * base.width;
v0 = (uvs[index0] * ut.b + uvs[index0 + 1] * ut.d + ut.ty) * base.height;
v1 = (uvs[index1] * ut.b + uvs[index1 + 1] * ut.d + ut.ty) * base.height;
v2 = (uvs[index2] * ut.b + uvs[index2 + 1] * ut.d + ut.ty) * base.height;
} else {
u0 = uvs[index0] * base.width;
u1 = uvs[index1] * base.width;
u2 = uvs[index2] * base.width;
v0 = uvs[index0 + 1] * base.height;
v1 = uvs[index1 + 1] * base.height;
v2 = uvs[index2 + 1] * base.height;
}
var x0 = vertices[index0];
var x1 = vertices[index1];
var x2 = vertices[index2];
var y0 = vertices[index0 + 1];
var y1 = vertices[index1 + 1];
var y2 = vertices[index2 + 1];
var canvasPadding = mesh.canvasPadding / this.renderer.resolution;
if (canvasPadding > 0) {
var paddingX = canvasPadding / Math.abs(mesh.worldTransform.a);
var paddingY = canvasPadding / Math.abs(mesh.worldTransform.d);
var centerX = (x0 + x1 + x2) / 3;
var centerY = (y0 + y1 + y2) / 3;
var normX = x0 - centerX;
var normY = y0 - centerY;
var dist = Math.sqrt(normX * normX + normY * normY);
x0 = centerX + normX / dist * (dist + paddingX);
y0 = centerY + normY / dist * (dist + paddingY);
//
normX = x1 - centerX;
normY = y1 - centerY;
dist = Math.sqrt(normX * normX + normY * normY);
x1 = centerX + normX / dist * (dist + paddingX);
y1 = centerY + normY / dist * (dist + paddingY);
normX = x2 - centerX;
normY = y2 - centerY;
dist = Math.sqrt(normX * normX + normY * normY);
x2 = centerX + normX / dist * (dist + paddingX);
y2 = centerY + normY / dist * (dist + paddingY);
}
context.save();
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x1, y1);
context.lineTo(x2, y2);
context.closePath();
context.clip();
// Compute matrix transform
var delta = u0 * v1 + v0 * u2 + u1 * v2 - v1 * u2 - v0 * u1 - u0 * v2;
var deltaA = x0 * v1 + v0 * x2 + x1 * v2 - v1 * x2 - v0 * x1 - x0 * v2;
var deltaB = u0 * x1 + x0 * u2 + u1 * x2 - x1 * u2 - x0 * u1 - u0 * x2;
var deltaC = u0 * v1 * x2 + v0 * x1 * u2 + x0 * u1 * v2 - x0 * v1 * u2 - v0 * u1 * x2 - u0 * x1 * v2;
var deltaD = y0 * v1 + v0 * y2 + y1 * v2 - v1 * y2 - v0 * y1 - y0 * v2;
var deltaE = u0 * y1 + y0 * u2 + u1 * y2 - y1 * u2 - y0 * u1 - u0 * y2;
var deltaF = u0 * v1 * y2 + v0 * y1 * u2 + y0 * u1 * v2 - y0 * v1 * u2 - v0 * u1 * y2 - u0 * y1 * v2;
context.transform(deltaA / delta, deltaD / delta, deltaB / delta, deltaE / delta, deltaC / delta, deltaF / delta);
context.drawImage(textureSource, 0, 0, textureWidth * base.resolution, textureHeight * base.resolution, 0, 0, textureWidth, textureHeight);
context.restore();
this.renderer.invalidateBlendMode();
};
/**
* Renders a flat Mesh
*
* @private
* @param {PIXI.mesh.Mesh} mesh - The Mesh to render
*/
MeshSpriteRenderer.prototype.renderMeshFlat = function renderMeshFlat(mesh) {
var context = this.renderer.context;
var vertices = mesh.vertices;
var length = vertices.length / 2;
// this.count++;
context.beginPath();
for (var i = 1; i < length - 2; ++i) {
// draw some triangles!
var index = i * 2;
var x0 = vertices[index];
var y0 = vertices[index + 1];
var x1 = vertices[index + 2];
var y1 = vertices[index + 3];
var x2 = vertices[index + 4];
var y2 = vertices[index + 5];
context.moveTo(x0, y0);
context.lineTo(x1, y1);
context.lineTo(x2, y2);
}
context.fillStyle = '#FF0000';
context.fill();
context.closePath();
};
/**
* destroy the the renderer.
*
*/
MeshSpriteRenderer.prototype.destroy = function destroy() {
this.renderer = null;
};
return MeshSpriteRenderer;
}();
exports.default = MeshSpriteRenderer;
core.CanvasRenderer.registerPlugin('mesh', MeshSpriteRenderer);
//# sourceMappingURL=CanvasMeshRenderer.js.map
/***/ }),
/* 526 */
/***/ (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 _Plane2 = __webpack_require__(219);
var _Plane3 = _interopRequireDefault(_Plane2);
var _CanvasTinter = __webpack_require__(84);
var _CanvasTinter2 = _interopRequireDefault(_CanvasTinter);
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 DEFAULT_BORDER_SIZE = 10;
/**
* The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful
* for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically
*
*```js
* let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.fromImage('BoxWithRoundedCorners.png'), 15, 15, 15, 15);
* ```
* <pre>
* A B
* +---+----------------------+---+
* C | 1 | 2 | 3 |
* +---+----------------------+---+
* | | | |
* | 4 | 5 | 6 |
* | | | |
* +---+----------------------+---+
* D | 7 | 8 | 9 |
* +---+----------------------+---+
* When changing this objects width and/or height:
* areas 1 3 7 and 9 will remain unscaled.
* areas 2 and 8 will be stretched horizontally
* areas 4 and 6 will be stretched vertically
* area 5 will be stretched both horizontally and vertically
* </pre>
*
* @class
* @extends PIXI.mesh.Plane
* @memberof PIXI.mesh
*
*/
var NineSlicePlane = function (_Plane) {
_inherits(NineSlicePlane, _Plane);
/**
* @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane.
* @param {int} [leftWidth=10] size of the left vertical bar (A)
* @param {int} [topHeight=10] size of the top horizontal bar (C)
* @param {int} [rightWidth=10] size of the right vertical bar (B)
* @param {int} [bottomHeight=10] size of the bottom horizontal bar (D)
*/
function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight) {
_classCallCheck(this, NineSlicePlane);
var _this = _possibleConstructorReturn(this, _Plane.call(this, texture, 4, 4));
_this._origWidth = texture.orig.width;
_this._origHeight = texture.orig.height;
/**
* The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
* @memberof PIXI.NineSlicePlane#
* @override
*/
_this._width = _this._origWidth;
/**
* The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
* @memberof PIXI.NineSlicePlane#
* @override
*/
_this._height = _this._origHeight;
/**
* The width of the left column (a)
*
* @member {number}
* @memberof PIXI.NineSlicePlane#
* @override
*/
_this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE;
/**
* The width of the right column (b)
*
* @member {number}
* @memberof PIXI.NineSlicePlane#
* @override
*/
_this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE;
/**
* The height of the top row (c)
*
* @member {number}
* @memberof PIXI.NineSlicePlane#
* @override
*/
_this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE;
/**
* The height of the bottom row (d)
*
* @member {number}
* @memberof PIXI.NineSlicePlane#
* @override
*/
_this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE;
/**
* Cached tint value so we can tell when the tint is changed.
*
* @member {number}
* @protected
*/
_this._cachedTint = 0xFFFFFF;
/**
* Cached tinted texture.
*
* @member {HTMLCanvasElement}
* @protected
*/
_this._tintedTexture = null;
/**
* Temporary storage for canvas source coords
*
* @member {number[]}
* @private
*/
_this._canvasUvs = null;
_this.refresh(true);
return _this;
}
/**
* Updates the horizontal vertices.
*
*/
NineSlicePlane.prototype.updateHorizontalVertices = function updateHorizontalVertices() {
var vertices = this.vertices;
var h = this._topHeight + this._bottomHeight;
var scale = this._height > h ? 1.0 : this._height / h;
vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale;
vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - this._bottomHeight * scale;
vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height;
};
/**
* Updates the vertical vertices.
*
*/
NineSlicePlane.prototype.updateVerticalVertices = function updateVerticalVertices() {
var vertices = this.vertices;
var w = this._leftWidth + this._rightWidth;
var scale = this._width > w ? 1.0 : this._width / w;
vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale;
vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - this._rightWidth * scale;
vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width;
};
/**
* Renders the object using the Canvas renderer
*
* @private
* @param {PIXI.CanvasRenderer} renderer - The canvas renderer to render with.
*/
NineSlicePlane.prototype._renderCanvas = function _renderCanvas(renderer) {
var context = renderer.context;
var transform = this.worldTransform;
var res = renderer.resolution;
var isTinted = this.tint !== 0xFFFFFF;
var texture = this._texture;
// Work out tinting
if (isTinted) {
if (this._cachedTint !== this.tint) {
// Tint has changed, need to update the tinted texture and use that instead
this._cachedTint = this.tint;
this._tintedTexture = _CanvasTinter2.default.getTintedTexture(this, this.tint);
}
}
var textureSource = !isTinted ? texture.baseTexture.source : this._tintedTexture;
if (!this._canvasUvs) {
this._canvasUvs = [0, 0, 0, 0, 0, 0, 0, 0];
}
var vertices = this.vertices;
var uvs = this._canvasUvs;
var u0 = isTinted ? 0 : texture.frame.x;
var v0 = isTinted ? 0 : texture.frame.y;
var u1 = u0 + texture.frame.width;
var v1 = v0 + texture.frame.height;
uvs[0] = u0;
uvs[1] = u0 + this._leftWidth;
uvs[2] = u1 - this._rightWidth;
uvs[3] = u1;
uvs[4] = v0;
uvs[5] = v0 + this._topHeight;
uvs[6] = v1 - this._bottomHeight;
uvs[7] = v1;
for (var i = 0; i < 8; i++) {
uvs[i] *= texture.baseTexture.resolution;
}
context.globalAlpha = this.worldAlpha;
renderer.setBlendMode(this.blendMode);
if (renderer.roundPixels) {
context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, transform.tx * res | 0, transform.ty * res | 0);
} else {
context.setTransform(transform.a * res, transform.b * res, transform.c * res, transform.d * res, transform.tx * res, transform.ty * res);
}
for (var row = 0; row < 3; row++) {
for (var col = 0; col < 3; col++) {
var ind = col * 2 + row * 8;
var sw = Math.max(1, uvs[col + 1] - uvs[col]);
var sh = Math.max(1, uvs[row + 5] - uvs[row + 4]);
var dw = Math.max(1, vertices[ind + 10] - vertices[ind]);
var dh = Math.max(1, vertices[ind + 11] - vertices[ind + 1]);
context.drawImage(textureSource, uvs[col], uvs[row + 4], sw, sh, vertices[ind], vertices[ind + 1], dw, dh);
}
}
};
/**
* The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
/**
* Refreshes NineSlicePlane coords. All of them.
*/
NineSlicePlane.prototype._refresh = function _refresh() {
_Plane.prototype._refresh.call(this);
var uvs = this.uvs;
var texture = this._texture;
this._origWidth = texture.orig.width;
this._origHeight = texture.orig.height;
var _uvw = 1.0 / this._origWidth;
var _uvh = 1.0 / this._origHeight;
uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0;
uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0;
uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1;
uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1;
uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth;
uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - _uvw * this._rightWidth;
uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight;
uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - _uvh * this._bottomHeight;
this.updateHorizontalVertices();
this.updateVerticalVertices();
this.dirty++;
this.multiplyUvs();
};
_createClass(NineSlicePlane, [{
key: 'width',
get: function get() {
return this._width;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._width = value;
this._refresh();
}
/**
* The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
}, {
key: 'height',
get: function get() {
return this._height;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._height = value;
this._refresh();
}
/**
* The width of the left column
*
* @member {number}
*/
}, {
key: 'leftWidth',
get: function get() {
return this._leftWidth;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._leftWidth = value;
this._refresh();
}
/**
* The width of the right column
*
* @member {number}
*/
}, {
key: 'rightWidth',
get: function get() {
return this._rightWidth;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._rightWidth = value;
this._refresh();
}
/**
* The height of the top row
*
* @member {number}
*/
}, {
key: 'topHeight',
get: function get() {
return this._topHeight;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._topHeight = value;
this._refresh();
}
/**
* The height of the bottom row
*
* @member {number}
*/
}, {
key: 'bottomHeight',
get: function get() {
return this._bottomHeight;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._bottomHeight = value;
this._refresh();
}
}]);
return NineSlicePlane;
}(_Plane3.default);
exports.default = NineSlicePlane;
//# sourceMappingURL=NineSlicePlane.js.map
/***/ }),
/* 527 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Mesh2 = __webpack_require__(69);
var _Mesh3 = _interopRequireDefault(_Mesh2);
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 rope allows you to draw a texture across several points and them manipulate these points
*
*```js
* for (let i = 0; i < 20; i++) {
* points.push(new PIXI.Point(i * 50, 0));
* };
* let rope = new PIXI.Rope(PIXI.Texture.fromImage("snake.png"), points);
* ```
*
* @class
* @extends PIXI.mesh.Mesh
* @memberof PIXI.mesh
*
*/
var Rope = function (_Mesh) {
_inherits(Rope, _Mesh);
/**
* @param {PIXI.Texture} texture - The texture to use on the rope.
* @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope.
*/
function Rope(texture, points) {
_classCallCheck(this, Rope);
/**
* An array of points that determine the rope
*
* @member {PIXI.Point[]}
*/
var _this = _possibleConstructorReturn(this, _Mesh.call(this, texture));
_this.points = points;
/**
* An array of vertices used to construct this rope.
*
* @member {Float32Array}
*/
_this.vertices = new Float32Array(points.length * 4);
/**
* The WebGL Uvs of the rope.
*
* @member {Float32Array}
*/
_this.uvs = new Float32Array(points.length * 4);
/**
* An array containing the color components
*
* @member {Float32Array}
*/
_this.colors = new Float32Array(points.length * 2);
/**
* An array containing the indices of the vertices
*
* @member {Uint16Array}
*/
_this.indices = new Uint16Array(points.length * 2);
/**
* refreshes vertices on every updateTransform
* @member {boolean}
* @default true
*/
_this.autoUpdate = true;
_this.refresh();
return _this;
}
/**
* Refreshes
*
*/
Rope.prototype._refresh = function _refresh() {
var points = this.points;
// if too little points, or texture hasn't got UVs set yet just move on.
if (points.length < 1 || !this._texture._uvs) {
return;
}
// if the number of points has changed we will need to recreate the arraybuffers
if (this.vertices.length / 4 !== points.length) {
this.vertices = new Float32Array(points.length * 4);
this.uvs = new Float32Array(points.length * 4);
this.colors = new Float32Array(points.length * 2);
this.indices = new Uint16Array(points.length * 2);
}
var uvs = this.uvs;
var indices = this.indices;
var colors = this.colors;
uvs[0] = 0;
uvs[1] = 0;
uvs[2] = 0;
uvs[3] = 1;
colors[0] = 1;
colors[1] = 1;
indices[0] = 0;
indices[1] = 1;
var total = points.length;
for (var i = 1; i < total; i++) {
// time to do some smart drawing!
var index = i * 4;
var amount = i / (total - 1);
uvs[index] = amount;
uvs[index + 1] = 0;
uvs[index + 2] = amount;
uvs[index + 3] = 1;
index = i * 2;
colors[index] = 1;
colors[index + 1] = 1;
index = i * 2;
indices[index] = index;
indices[index + 1] = index + 1;
}
// ensure that the changes are uploaded
this.dirty++;
this.indexDirty++;
this.multiplyUvs();
this.refreshVertices();
};
/**
* refreshes vertices of Rope mesh
*/
Rope.prototype.refreshVertices = function refreshVertices() {
var points = this.points;
if (points.length < 1) {
return;
}
var lastPoint = points[0];
var nextPoint = void 0;
var perpX = 0;
var perpY = 0;
// this.count -= 0.2;
var vertices = this.vertices;
var total = points.length;
for (var i = 0; i < total; i++) {
var point = points[i];
var index = i * 4;
if (i < points.length - 1) {
nextPoint = points[i + 1];
} else {
nextPoint = point;
}
perpY = -(nextPoint.x - lastPoint.x);
perpX = nextPoint.y - lastPoint.y;
var ratio = (1 - i / (total - 1)) * 10;
if (ratio > 1) {
ratio = 1;
}
var perpLength = Math.sqrt(perpX * perpX + perpY * perpY);
var num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio;
perpX /= perpLength;
perpY /= perpLength;
perpX *= num;
perpY *= num;
vertices[index] = point.x + perpX;
vertices[index + 1] = point.y + perpY;
vertices[index + 2] = point.x - perpX;
vertices[index + 3] = point.y - perpY;
lastPoint = point;
}
};
/**
* Updates the object transform for rendering
*
* @private
*/
Rope.prototype.updateTransform = function updateTransform() {
if (this.autoUpdate) {
this.refreshVertices();
}
this.containerUpdateTransform();
};
return Rope;
}(_Mesh3.default);
exports.default = Rope;
//# sourceMappingURL=Rope.js.map
/***/ }),
/* 528 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _ParticleContainer = __webpack_require__(529);
Object.defineProperty(exports, 'ParticleContainer', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_ParticleContainer).default;
}
});
var _ParticleRenderer = __webpack_require__(530);
Object.defineProperty(exports, 'ParticleRenderer', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_ParticleRenderer).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map
/***/ }),
/* 529 */
/***/ (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 _utils = __webpack_require__(7);
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; }
/**
* The ParticleContainer class is a really fast version of the Container built solely for speed,
* so use when you need a lot of sprites or particles. The tradeoff of the ParticleContainer is that most advanced
* functionality will not work. ParticleContainer implements the basic object transform (position, scale, rotation)
* and some advanced functionality like tint (as of v4.5.6).
* Other more advanced functionality like masking, children, filters, etc will not work on sprites in this batch.
*
* It's extremely easy to use :
*
* ```js
* let container = new ParticleContainer();
*
* for (let i = 0; i < 100; ++i)
* {
* let sprite = new PIXI.Sprite.fromImage("myImage.png");
* container.addChild(sprite);
* }
* ```
*
* And here you have a hundred sprites that will be rendered at the speed of light.
*
* @class
* @extends PIXI.Container
* @memberof PIXI.particles
*/
var ParticleContainer = function (_core$Container) {
_inherits(ParticleContainer, _core$Container);
/**
* @param {number} [maxSize=1500] - The maximum number of particles that can be rendered by the container.
* Affects size of allocated buffers.
* @param {object} [properties] - The properties of children that should be uploaded to the gpu and applied.
* @param {boolean} [properties.vertices=false] - When true, vertices be uploaded and applied.
* if sprite's ` scale/anchor/trim/frame/orig` is dynamic, please set `true`.
* @param {boolean} [properties.position=true] - When true, position be uploaded and applied.
* @param {boolean} [properties.rotation=false] - When true, rotation be uploaded and applied.
* @param {boolean} [properties.uvs=false] - When true, uvs be uploaded and applied.
* @param {boolean} [properties.tint=false] - When true, alpha and tint be uploaded and applied.
* @param {number} [batchSize=16384] - Number of particles per batch. If less than maxSize, it uses maxSize instead.
* @param {boolean} [autoResize=false] If true, container allocates more batches in case
* there are more than `maxSize` particles.
*/
function ParticleContainer() {
var maxSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1500;
var properties = arguments[1];
var batchSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 16384;
var autoResize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
_classCallCheck(this, ParticleContainer);
// Making sure the batch size is valid
// 65535 is max vertex index in the index buffer (see ParticleRenderer)
// so max number of particles is 65536 / 4 = 16384
var _this = _possibleConstructorReturn(this, _core$Container.call(this));
var maxBatchSize = 16384;
if (batchSize > maxBatchSize) {
batchSize = maxBatchSize;
}
if (batchSize > maxSize) {
batchSize = maxSize;
}
/**
* Set properties to be dynamic (true) / static (false)
*
* @member {boolean[]}
* @private
*/
_this._properties = [false, true, false, false, false];
/**
* @member {number}
* @private
*/
_this._maxSize = maxSize;
/**
* @member {number}
* @private
*/
_this._batchSize = batchSize;
/**
* @member {object<number, WebGLBuffer>}
* @private
*/
_this._glBuffers = {};
/**
* for every batch stores _updateID corresponding to the last change in that batch
* @member {number[]}
* @private
*/
_this._bufferUpdateIDs = [];
/**
* when child inserted, removed or changes position this number goes up
* @member {number[]}
* @private
*/
_this._updateID = 0;
/**
* @member {boolean}
*
*/
_this.interactiveChildren = false;
/**
* 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 = core.BLEND_MODES.NORMAL;
/**
* If true, container allocates more batches in case there are more than `maxSize` particles.
* @member {boolean}
* @default false
*/
_this.autoResize = autoResize;
/**
* Used for canvas renderering. If true then the elements will be positioned at the
* nearest pixel. This provides a nice speed boost.
*
* @member {boolean}
* @default true;
*/
_this.roundPixels = true;
/**
* The texture used to render the children.
*
* @readonly
* @member {BaseTexture}
*/
_this.baseTexture = null;
_this.setProperties(properties);
/**
* The tint applied to the container.
* This is a hex value. A value of 0xFFFFFF will remove any tint effect.
*
* @private
* @member {number}
* @default 0xFFFFFF
*/
_this._tint = 0;
_this.tintRgb = new Float32Array(4);
_this.tint = 0xFFFFFF;
return _this;
}
/**
* Sets the private properties array to dynamic / static based on the passed properties object
*
* @param {object} properties - The properties to be uploaded
*/
ParticleContainer.prototype.setProperties = function setProperties(properties) {
if (properties) {
this._properties[0] = 'vertices' in properties || 'scale' in properties ? !!properties.vertices || !!properties.scale : this._properties[0];
this._properties[1] = 'position' in properties ? !!properties.position : this._properties[1];
this._properties[2] = 'rotation' in properties ? !!properties.rotation : this._properties[2];
this._properties[3] = 'uvs' in properties ? !!properties.uvs : this._properties[3];
this._properties[4] = 'tint' in properties || 'alpha' in properties ? !!properties.tint || !!properties.alpha : this._properties[4];
}
};
/**
* Updates the object transform for rendering
*
* @private
*/
ParticleContainer.prototype.updateTransform = function updateTransform() {
// TODO don't need to!
this.displayObjectUpdateTransform();
// PIXI.Container.prototype.updateTransform.call( this );
};
/**
* The tint applied to the container. This is a hex value.
* A value of 0xFFFFFF will remove any tint effect.
** IMPORTANT: This is a webGL only feature and will be ignored by the canvas renderer.
* @member {number}
* @default 0xFFFFFF
*/
/**
* Renders the container using the WebGL renderer
*
* @private
* @param {PIXI.WebGLRenderer} renderer - The webgl renderer
*/
ParticleContainer.prototype.renderWebGL = function renderWebGL(renderer) {
var _this2 = this;
if (!this.visible || this.worldAlpha <= 0 || !this.children.length || !this.renderable) {
return;
}
if (!this.baseTexture) {
this.baseTexture = this.children[0]._texture.baseTexture;
if (!this.baseTexture.hasLoaded) {
this.baseTexture.once('update', function () {
return _this2.onChildrenChange(0);
});
}
}
renderer.setObjectRenderer(renderer.plugins.particle);
renderer.plugins.particle.render(this);
};
/**
* Set the flag that static data should be updated to true
*
* @private
* @param {number} smallestChildIndex - The smallest child index
*/
ParticleContainer.prototype.onChildrenChange = function onChildrenChange(smallestChildIndex) {
var bufferIndex = Math.floor(smallestChildIndex / this._batchSize);
while (this._bufferUpdateIDs.length < bufferIndex) {
this._bufferUpdateIDs.push(0);
}
this._bufferUpdateIDs[bufferIndex] = ++this._updateID;
};
/**
* Renders the object using the Canvas renderer
*
* @private
* @param {PIXI.CanvasRenderer} renderer - The canvas renderer
*/
ParticleContainer.prototype.renderCanvas = function renderCanvas(renderer) {
if (!this.visible || this.worldAlpha <= 0 || !this.children.length || !this.renderable) {
return;
}
var context = renderer.context;
var transform = this.worldTransform;
var isRotated = true;
var positionX = 0;
var positionY = 0;
var finalWidth = 0;
var finalHeight = 0;
renderer.setBlendMode(this.blendMode);
context.globalAlpha = this.worldAlpha;
this.displayObjectUpdateTransform();
for (var i = 0; i < this.children.length; ++i) {
var child = this.children[i];
if (!child.visible) {
continue;
}
var frame = child._texture.frame;
context.globalAlpha = this.worldAlpha * child.alpha;
if (child.rotation % (Math.PI * 2) === 0) {
// this is the fastest way to optimise! - if rotation is 0 then we can avoid any kind of setTransform call
if (isRotated) {
context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx * renderer.resolution, transform.ty * renderer.resolution);
isRotated = false;
}
positionX = child.anchor.x * (-frame.width * child.scale.x) + child.position.x + 0.5;
positionY = child.anchor.y * (-frame.height * child.scale.y) + child.position.y + 0.5;
finalWidth = frame.width * child.scale.x;
finalHeight = frame.height * child.scale.y;
} else {
if (!isRotated) {
isRotated = true;
}
child.displayObjectUpdateTransform();
var childTransform = child.worldTransform;
if (renderer.roundPixels) {
context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx * renderer.resolution | 0, childTransform.ty * renderer.resolution | 0);
} else {
context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx * renderer.resolution, childTransform.ty * renderer.resolution);
}
positionX = child.anchor.x * -frame.width + 0.5;
positionY = child.anchor.y * -frame.height + 0.5;
finalWidth = frame.width;
finalHeight = frame.height;
}
var resolution = child._texture.baseTexture.resolution;
context.drawImage(child._texture.baseTexture.source, frame.x * resolution, frame.y * resolution, frame.width * resolution, frame.height * resolution, positionX * renderer.resolution, positionY * renderer.resolution, finalWidth * renderer.resolution, finalHeight * renderer.resolution);
}
};
/**
* Destroys the container
*
* @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
*/
ParticleContainer.prototype.destroy = function destroy(options) {
_core$Container.prototype.destroy.call(this, options);
if (this._buffers) {
for (var i = 0; i < this._buffers.length; ++i) {
this._buffers[i].destroy();
}
}
this._properties = null;
this._buffers = null;
this._bufferUpdateIDs = null;
};
_createClass(ParticleContainer, [{
key: 'tint',
get: function get() {
return this._tint;
},
set: function set(value) // eslint-disable-line require-jsdoc
{
this._tint = value;
(0, _utils.hex2rgb)(value, this.tintRgb);
}
}]);
return ParticleContainer;
}(core.Container);
exports.default = ParticleContainer;
//# sourceMappingURL=ParticleContainer.js.map
/***/ }),
/* 530 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _ParticleShader = __webpack_require__(531);
var _ParticleShader2 = _interopRequireDefault(_ParticleShader);
var _ParticleBuffer = __webpack_require__(532);
var _ParticleBuffer2 = _interopRequireDefault(_ParticleBuffer);
var _utils = __webpack_require__(7);
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; }
/**
* @author Mat Groves
*
* Big thanks to the very clever Matt DesLauriers <mattdesl> https://github.com/mattdesl/
* for creating the original PixiJS version!
* Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that they now
* share 4 bytes on the vertex buffer
*
* Heavily inspired by LibGDX's ParticleRenderer:
* https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/ParticleRenderer.java
*/
/**
*
* @class
* @private
* @memberof PIXI
*/
var ParticleRenderer = function (_core$ObjectRenderer) {
_inherits(ParticleRenderer, _core$ObjectRenderer);
/**
* @param {PIXI.WebGLRenderer} renderer - The renderer this sprite batch works for.
*/
function ParticleRenderer(renderer) {
_classCallCheck(this, ParticleRenderer);
// 65535 is max vertex index in the index buffer (see ParticleRenderer)
// so max number of particles is 65536 / 4 = 16384
// and max number of element in the index buffer is 16384 * 6 = 98304
// Creating a full index buffer, overhead is 98304 * 2 = 196Ko
// let numIndices = 98304;
/**
* The default shader that is used if a sprite doesn't have a more specific one.
*
* @member {PIXI.Shader}
*/
var _this = _possibleConstructorReturn(this, _core$ObjectRenderer.call(this, renderer));
_this.shader = null;
_this.indexBuffer = null;
_this.properties = null;
_this.tempMatrix = new core.Matrix();
_this.CONTEXT_UID = 0;
return _this;
}
/**
* When there is a WebGL context change
*
* @private
*/
ParticleRenderer.prototype.onContextChange = function onContextChange() {
var gl = this.renderer.gl;
this.CONTEXT_UID = this.renderer.CONTEXT_UID;
// setup default shader
this.shader = new _ParticleShader2.default(gl);
this.properties = [
// verticesData
{
attribute: this.shader.attributes.aVertexPosition,
size: 2,
uploadFunction: this.uploadVertices,
offset: 0
},
// positionData
{
attribute: this.shader.attributes.aPositionCoord,
size: 2,
uploadFunction: this.uploadPosition,
offset: 0
},
// rotationData
{
attribute: this.shader.attributes.aRotation,
size: 1,
uploadFunction: this.uploadRotation,
offset: 0
},
// uvsData
{
attribute: this.shader.attributes.aTextureCoord,
size: 2,
uploadFunction: this.uploadUvs,
offset: 0
},
// tintData
{
attribute: this.shader.attributes.aColor,
size: 1,
unsignedByte: true,
uploadFunction: this.uploadTint,
offset: 0
}];
};
/**
* Starts a new particle batch.
*
*/
ParticleRenderer.prototype.start = function start() {
this.renderer.bindShader(this.shader);
};
/**
* Renders the particle container object.
*
* @param {PIXI.ParticleContainer} container - The container to render using this ParticleRenderer
*/
ParticleRenderer.prototype.render = function render(container) {
var children = container.children;
var maxSize = container._maxSize;
var batchSize = container._batchSize;
var renderer = this.renderer;
var totalChildren = children.length;
if (totalChildren === 0) {
return;
} else if (totalChildren > maxSize) {
totalChildren = maxSize;
}
var buffers = container._glBuffers[renderer.CONTEXT_UID];
if (!buffers) {
buffers = container._glBuffers[renderer.CONTEXT_UID] = this.generateBuffers(container);
}
var baseTexture = children[0]._texture.baseTexture;
// if the uvs have not updated then no point rendering just yet!
this.renderer.setBlendMode(core.utils.correctBlendMode(container.blendMode, baseTexture.premultipliedAlpha));
var gl = renderer.gl;
var m = container.worldTransform.copy(this.tempMatrix);
m.prepend(renderer._activeRenderTarget.projectionMatrix);
this.shader.uniforms.projectionMatrix = m.toArray(true);
this.shader.uniforms.uColor = core.utils.premultiplyRgba(container.tintRgb, container.worldAlpha, this.shader.uniforms.uColor, baseTexture.premultipliedAlpha);
// make sure the texture is bound..
this.shader.uniforms.uSampler = renderer.bindTexture(baseTexture);
var updateStatic = false;
// now lets upload and render the buffers..
for (var i = 0, j = 0; i < totalChildren; i += batchSize, j += 1) {
var amount = totalChildren - i;
if (amount > batchSize) {
amount = batchSize;
}
if (j >= buffers.length) {
if (!container.autoResize) {
break;
}
buffers.push(this._generateOneMoreBuffer(container));
}
var buffer = buffers[j];
// we always upload the dynamic
buffer.uploadDynamic(children, i, amount);
var bid = container._bufferUpdateIDs[j] || 0;
updateStatic = updateStatic || buffer._updateID < bid;
// we only upload the static content when we have to!
if (updateStatic) {
buffer._updateID = container._updateID;
buffer.uploadStatic(children, i, amount);
}
// bind the buffer
renderer.bindVao(buffer.vao);
buffer.vao.draw(gl.TRIANGLES, amount * 6);
}
};
/**
* Creates one particle buffer for each child in the container we want to render and updates internal properties
*
* @param {PIXI.ParticleContainer} container - The container to render using this ParticleRenderer
* @return {PIXI.ParticleBuffer[]} The buffers
*/
ParticleRenderer.prototype.generateBuffers = function generateBuffers(container) {
var gl = this.renderer.gl;
var buffers = [];
var size = container._maxSize;
var batchSize = container._batchSize;
var dynamicPropertyFlags = container._properties;
for (var i = 0; i < size; i += batchSize) {
buffers.push(new _ParticleBuffer2.default(gl, this.properties, dynamicPropertyFlags, batchSize));
}
return buffers;
};
/**
* Creates one more particle buffer, because container has autoResize feature
*
* @param {PIXI.ParticleContainer} container - The container to render using this ParticleRenderer
* @return {PIXI.ParticleBuffer} generated buffer
* @private
*/
ParticleRenderer.prototype._generateOneMoreBuffer = function _generateOneMoreBuffer(container) {
var gl = this.renderer.gl;
var batchSize = container._batchSize;
var dynamicPropertyFlags = container._properties;
return new _ParticleBuffer2.default(gl, this.properties, dynamicPropertyFlags, batchSize);
};
/**
* Uploads the verticies.
*
* @param {PIXI.DisplayObject[]} children - the array of display objects to render
* @param {number} startIndex - the index to start from in the children array
* @param {number} amount - the amount of children that will have their vertices uploaded
* @param {number[]} array - The vertices to upload.
* @param {number} stride - Stride to use for iteration.
* @param {number} offset - Offset to start at.
*/
ParticleRenderer.prototype.uploadVertices = function uploadVertices(children, startIndex, amount, array, stride, offset) {
var w0 = 0;
var w1 = 0;
var h0 = 0;
var h1 = 0;
for (var i = 0; i < amount; ++i) {
var sprite = children[startIndex + i];
var texture = sprite._texture;
var sx = sprite.scale.x;
var sy = sprite.scale.y;
var trim = texture.trim;
var orig = texture.orig;
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 - sprite.anchor.x * orig.width;
w0 = w1 + trim.width;
h1 = trim.y - sprite.anchor.y * orig.height;
h0 = h1 + trim.height;
} else {
w0 = orig.width * (1 - sprite.anchor.x);
w1 = orig.width * -sprite.anchor.x;
h0 = orig.height * (1 - sprite.anchor.y);
h1 = orig.height * -sprite.anchor.y;
}
array[offset] = w1 * sx;
array[offset + 1] = h1 * sy;
array[offset + stride] = w0 * sx;
array[offset + stride + 1] = h1 * sy;
array[offset + stride * 2] = w0 * sx;
array[offset + stride * 2 + 1] = h0 * sy;
array[offset + stride * 3] = w1 * sx;
array[offset + stride * 3 + 1] = h0 * sy;
offset += stride * 4;
}
};
/**
*
* @param {PIXI.DisplayObject[]} children - the array of display objects to render
* @param {number} startIndex - the index to start from in the children array
* @param {number} amount - the amount of children that will have their positions uploaded
* @param {number[]} array - The vertices to upload.
* @param {number} stride - Stride to use for iteration.
* @param {number} offset - Offset to start at.
*/
ParticleRenderer.prototype.uploadPosition = function uploadPosition(children, startIndex, amount, array, stride, offset) {
for (var i = 0; i < amount; i++) {
var spritePosition = children[startIndex + i].position;
array[offset] = spritePosition.x;
array[offset + 1] = spritePosition.y;
array[offset + stride] = spritePosition.x;
array[offset + stride + 1] = spritePosition.y;
array[offset + stride * 2] = spritePosition.x;
array[offset + stride * 2 + 1] = spritePosition.y;
array[offset + stride * 3] = spritePosition.x;
array[offset + stride * 3 + 1] = spritePosition.y;
offset += stride * 4;
}
};
/**
*
* @param {PIXI.DisplayObject[]} children - the array of display objects to render
* @param {number} startIndex - the index to start from in the children array
* @param {number} amount - the amount of children that will have their rotation uploaded
* @param {number[]} array - The vertices to upload.
* @param {number} stride - Stride to use for iteration.
* @param {number} offset - Offset to start at.
*/
ParticleRenderer.prototype.uploadRotation = function uploadRotation(children, startIndex, amount, array, stride, offset) {
for (var i = 0; i < amount; i++) {
var spriteRotation = children[startIndex + i].rotation;
array[offset] = spriteRotation;
array[offset + stride] = spriteRotation;
array[offset + stride * 2] = spriteRotation;
array[offset + stride * 3] = spriteRotation;
offset += stride * 4;
}
};
/**
*
* @param {PIXI.DisplayObject[]} children - the array of display objects to render
* @param {number} startIndex - the index to start from in the children array
* @param {number} amount - the amount of children that will have their rotation uploaded
* @param {number[]} array - The vertices to upload.
* @param {number} stride - Stride to use for iteration.
* @param {number} offset - Offset to start at.
*/
ParticleRenderer.prototype.uploadUvs = function uploadUvs(children, startIndex, amount, array, stride, offset) {
for (var i = 0; i < amount; ++i) {
var textureUvs = children[startIndex + i]._texture._uvs;
if (textureUvs) {
array[offset] = textureUvs.x0;
array[offset + 1] = textureUvs.y0;
array[offset + stride] = textureUvs.x1;
array[offset + stride + 1] = textureUvs.y1;
array[offset + stride * 2] = textureUvs.x2;
array[offset + stride * 2 + 1] = textureUvs.y2;
array[offset + stride * 3] = textureUvs.x3;
array[offset + stride * 3 + 1] = textureUvs.y3;
offset += stride * 4;
} else {
// TODO you know this can be easier!
array[offset] = 0;
array[offset + 1] = 0;
array[offset + stride] = 0;
array[offset + stride + 1] = 0;
array[offset + stride * 2] = 0;
array[offset + stride * 2 + 1] = 0;
array[offset + stride * 3] = 0;
array[offset + stride * 3 + 1] = 0;
offset += stride * 4;
}
}
};
/**
*
* @param {PIXI.DisplayObject[]} children - the array of display objects to render
* @param {number} startIndex - the index to start from in the children array
* @param {number} amount - the amount of children that will have their rotation uploaded
* @param {number[]} array - The vertices to upload.
* @param {number} stride - Stride to use for iteration.
* @param {number} offset - Offset to start at.
*/
ParticleRenderer.prototype.uploadTint = function uploadTint(children, startIndex, amount, array, stride, offset) {
for (var i = 0; i < amount; ++i) {
var sprite = children[startIndex + i];
var premultiplied = sprite._texture.baseTexture.premultipliedAlpha;
var alpha = sprite.alpha;
// we dont call extra function if alpha is 1.0, that's faster
var argb = alpha < 1.0 && premultiplied ? (0, _utils.premultiplyTint)(sprite._tintRGB, alpha) : sprite._tintRGB + (alpha * 255 << 24);
array[offset] = argb;
array[offset + stride] = argb;
array[offset + stride * 2] = argb;
array[offset + stride * 3] = argb;
offset += stride * 4;
}
};
/**
* Destroys the ParticleRenderer.
*
*/
ParticleRenderer.prototype.destroy = function destroy() {
if (this.renderer.gl) {
this.renderer.gl.deleteBuffer(this.indexBuffer);
}
_core$ObjectRenderer.prototype.destroy.call(this);
this.shader.destroy();
this.indices = null;
this.tempMatrix = null;
};
return ParticleRenderer;
}(core.ObjectRenderer);
exports.default = ParticleRenderer;
core.WebGLRenderer.registerPlugin('particle', ParticleRenderer);
//# sourceMappingURL=ParticleRenderer.js.map
/***/ }),
/* 531 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _Shader2 = __webpack_require__(67);
var _Shader3 = _interopRequireDefault(_Shader2);
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; }
/**
* @class
* @extends PIXI.Shader
* @memberof PIXI
*/
var ParticleShader = function (_Shader) {
_inherits(ParticleShader, _Shader);
/**
* @param {PIXI.Shader} gl - The webgl shader manager this shader works for.
*/
function ParticleShader(gl) {
_classCallCheck(this, ParticleShader);
return _possibleConstructorReturn(this, _Shader.call(this, gl,
// vertex shader
['attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', 'attribute vec4 aColor;', 'attribute vec2 aPositionCoord;', 'attribute float aRotation;', 'uniform mat3 projectionMatrix;', 'uniform vec4 uColor;', 'varying vec2 vTextureCoord;', 'varying vec4 vColor;', 'void main(void){', ' float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);', ' float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);', ' vec2 v = vec2(x, y);', ' v = v + aPositionCoord;', ' gl_Position = vec4((projectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);', ' vTextureCoord = aTextureCoord;', ' vColor = aColor * uColor;', '}'].join('\n'),
// hello
['varying vec2 vTextureCoord;', 'varying vec4 vColor;', 'uniform sampler2D uSampler;', 'void main(void){', ' vec4 color = texture2D(uSampler, vTextureCoord) * vColor;', ' gl_FragColor = color;', '}'].join('\n')));
}
return ParticleShader;
}(_Shader3.default);
exports.default = ParticleShader;
//# sourceMappingURL=ParticleShader.js.map
/***/ }),
/* 532 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _pixiGlCore = __webpack_require__(23);
var _pixiGlCore2 = _interopRequireDefault(_pixiGlCore);
var _createIndicesForQuads = __webpack_require__(129);
var _createIndicesForQuads2 = _interopRequireDefault(_createIndicesForQuads);
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"); } }
/**
* @author Mat Groves
*
* Big thanks to the very clever Matt DesLauriers <mattdesl> https://github.com/mattdesl/
* for creating the original PixiJS version!
* Also a thanks to https://github.com/bchevalier for tweaking the tint and alpha so that
* they now share 4 bytes on the vertex buffer
*
* Heavily inspired by LibGDX's ParticleBuffer:
* https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/ParticleBuffer.java
*/
/**
* The particle buffer manages the static and dynamic buffers for a particle container.
*
* @class
* @private
* @memberof PIXI
*/
var ParticleBuffer = function () {
/**
* @param {WebGLRenderingContext} gl - The rendering context.
* @param {object} properties - The properties to upload.
* @param {boolean[]} dynamicPropertyFlags - Flags for which properties are dynamic.
* @param {number} size - The size of the batch.
*/
function ParticleBuffer(gl, properties, dynamicPropertyFlags, size) {
_classCallCheck(this, ParticleBuffer);
/**
* The current WebGL drawing context.
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
/**
* The number of particles the buffer can hold
*
* @member {number}
*/
this.size = size;
/**
* A list of the properties that are dynamic.
*
* @member {object[]}
*/
this.dynamicProperties = [];
/**
* A list of the properties that are static.
*
* @member {object[]}
*/
this.staticProperties = [];
for (var i = 0; i < properties.length; ++i) {
var property = properties[i];
// Make copy of properties object so that when we edit the offset it doesn't
// change all other instances of the object literal
property = {
attribute: property.attribute,
size: property.size,
uploadFunction: property.uploadFunction,
unsignedByte: property.unsignedByte,
offset: property.offset
};
if (dynamicPropertyFlags[i]) {
this.dynamicProperties.push(property);
} else {
this.staticProperties.push(property);
}
}
this.staticStride = 0;
this.staticBuffer = null;
this.staticData = null;
this.staticDataUint32 = null;
this.dynamicStride = 0;
this.dynamicBuffer = null;
this.dynamicData = null;
this.dynamicDataUint32 = null;
this._updateID = 0;
this.initBuffers();
}
/**
* Sets up the renderer context and necessary buffers.
*
* @private
*/
ParticleBuffer.prototype.initBuffers = function initBuffers() {
var gl = this.gl;
var dynamicOffset = 0;
/**
* Holds the indices of the geometry (quads) to draw
*
* @member {Uint16Array}
*/
this.indices = (0, _createIndicesForQuads2.default)(this.size);
this.indexBuffer = _pixiGlCore2.default.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW);
this.dynamicStride = 0;
for (var i = 0; i < this.dynamicProperties.length; ++i) {
var property = this.dynamicProperties[i];
property.offset = dynamicOffset;
dynamicOffset += property.size;
this.dynamicStride += property.size;
}
var dynBuffer = new ArrayBuffer(this.size * this.dynamicStride * 4 * 4);
this.dynamicData = new Float32Array(dynBuffer);
this.dynamicDataUint32 = new Uint32Array(dynBuffer);
this.dynamicBuffer = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, dynBuffer, gl.STREAM_DRAW);
// static //
var staticOffset = 0;
this.staticStride = 0;
for (var _i = 0; _i < this.staticProperties.length; ++_i) {
var _property = this.staticProperties[_i];
_property.offset = staticOffset;
staticOffset += _property.size;
this.staticStride += _property.size;
}
var statBuffer = new ArrayBuffer(this.size * this.staticStride * 4 * 4);
this.staticData = new Float32Array(statBuffer);
this.staticDataUint32 = new Uint32Array(statBuffer);
this.staticBuffer = _pixiGlCore2.default.GLBuffer.createVertexBuffer(gl, statBuffer, gl.STATIC_DRAW);
this.vao = new _pixiGlCore2.default.VertexArrayObject(gl).addIndex(this.indexBuffer);
for (var _i2 = 0; _i2 < this.dynamicProperties.length; ++_i2) {
var _property2 = this.dynamicProperties[_i2];
if (_property2.unsignedByte) {
this.vao.addAttribute(this.dynamicBuffer, _property2.attribute, gl.UNSIGNED_BYTE, true, this.dynamicStride * 4, _property2.offset * 4);
} else {
this.vao.addAttribute(this.dynamicBuffer, _property2.attribute, gl.FLOAT, false, this.dynamicStride * 4, _property2.offset * 4);
}
}
for (var _i3 = 0; _i3 < this.staticProperties.length; ++_i3) {
var _property3 = this.staticProperties[_i3];
if (_property3.unsignedByte) {
this.vao.addAttribute(this.staticBuffer, _property3.attribute, gl.UNSIGNED_BYTE, true, this.staticStride * 4, _property3.offset * 4);
} else {
this.vao.addAttribute(this.staticBuffer, _property3.attribute, gl.FLOAT, false, this.staticStride * 4, _property3.offset * 4);
}
}
};
/**
* Uploads the dynamic properties.
*
* @param {PIXI.DisplayObject[]} children - The children to upload.
* @param {number} startIndex - The index to start at.
* @param {number} amount - The number to upload.
*/
ParticleBuffer.prototype.uploadDynamic = function uploadDynamic(children, startIndex, amount) {
for (var i = 0; i < this.dynamicProperties.length; i++) {
var property = this.dynamicProperties[i];
property.uploadFunction(children, startIndex, amount, property.unsignedByte ? this.dynamicDataUint32 : this.dynamicData, this.dynamicStride, property.offset);
}
this.dynamicBuffer.upload();
};
/**
* Uploads the static properties.
*
* @param {PIXI.DisplayObject[]} children - The children to upload.
* @param {number} startIndex - The index to start at.
* @param {number} amount - The number to upload.
*/
ParticleBuffer.prototype.uploadStatic = function uploadStatic(children, startIndex, amount) {
for (var i = 0; i < this.staticProperties.length; i++) {
var property = this.staticProperties[i];
property.uploadFunction(children, startIndex, amount, property.unsignedByte ? this.staticDataUint32 : this.staticData, this.staticStride, property.offset);
}
this.staticBuffer.upload();
};
/**
* Destroys the ParticleBuffer.
*
*/
ParticleBuffer.prototype.destroy = function destroy() {
this.dynamicProperties = null;
this.dynamicBuffer.destroy();
this.dynamicBuffer = null;
this.dynamicData = null;
this.dynamicDataUint32 = null;
this.staticProperties = null;
this.staticBuffer.destroy();
this.staticBuffer = null;
this.staticData = null;
this.staticDataUint32 = null;
};
return ParticleBuffer;
}();
exports.default = ParticleBuffer;
//# sourceMappingURL=ParticleBuffer.js.map
/***/ }),
/* 533 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _WebGLPrepare = __webpack_require__(534);
Object.defineProperty(exports, 'webgl', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_WebGLPrepare).default;
}
});
var _CanvasPrepare = __webpack_require__(535);
Object.defineProperty(exports, 'canvas', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_CanvasPrepare).default;
}
});
var _BasePrepare = __webpack_require__(131);
Object.defineProperty(exports, 'BasePrepare', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_BasePrepare).default;
}
});
var _CountLimiter = __webpack_require__(220);
Object.defineProperty(exports, 'CountLimiter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_CountLimiter).default;
}
});
var _TimeLimiter = __webpack_require__(536);
Object.defineProperty(exports, 'TimeLimiter', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_TimeLimiter).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map
/***/ }),
/* 534 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _BasePrepare2 = __webpack_require__(131);
var _BasePrepare3 = _interopRequireDefault(_BasePrepare2);
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; }
/**
* The prepare manager provides functionality to upload content to the GPU.
*
* An instance of this class is automatically created by default, and can be found at renderer.plugins.prepare
*
* @class
* @extends PIXI.prepare.BasePrepare
* @memberof PIXI.prepare
*/
var WebGLPrepare = function (_BasePrepare) {
_inherits(WebGLPrepare, _BasePrepare);
/**
* @param {PIXI.WebGLRenderer} renderer - A reference to the current renderer
*/
function WebGLPrepare(renderer) {
_classCallCheck(this, WebGLPrepare);
var _this = _possibleConstructorReturn(this, _BasePrepare.call(this, renderer));
_this.uploadHookHelper = _this.renderer;
// Add textures and graphics to upload
_this.registerFindHook(findGraphics);
_this.registerUploadHook(uploadBaseTextures);
_this.registerUploadHook(uploadGraphics);
return _this;
}
return WebGLPrepare;
}(_BasePrepare3.default);
/**
* Built-in hook to upload PIXI.Texture objects to the GPU.
*
* @private
* @param {PIXI.WebGLRenderer} renderer - instance of the webgl renderer
* @param {PIXI.DisplayObject} item - Item to check
* @return {boolean} If item was uploaded.
*/
exports.default = WebGLPrepare;
function uploadBaseTextures(renderer, item) {
if (item instanceof core.BaseTexture) {
// if the texture already has a GL texture, then the texture has been prepared or rendered
// before now. If the texture changed, then the changer should be calling texture.update() which
// reuploads the texture without need for preparing it again
if (!item._glTextures[renderer.CONTEXT_UID]) {
renderer.textureManager.updateTexture(item);
}
return true;
}
return false;
}
/**
* Built-in hook to upload PIXI.Graphics to the GPU.
*
* @private
* @param {PIXI.WebGLRenderer} renderer - instance of the webgl renderer
* @param {PIXI.DisplayObject} item - Item to check
* @return {boolean} If item was uploaded.
*/
function uploadGraphics(renderer, item) {
if (item instanceof core.Graphics) {
// if the item is not dirty and already has webgl data, then it got prepared or rendered
// before now and we shouldn't waste time updating it again
if (item.dirty || item.clearDirty || !item._webGL[renderer.plugins.graphics.CONTEXT_UID]) {
renderer.plugins.graphics.updateGraphics(item);
}
return true;
}
return false;
}
/**
* Built-in hook to find graphics.
*
* @private
* @param {PIXI.DisplayObject} item - Display object to check
* @param {Array<*>} queue - Collection of items to upload
* @return {boolean} if a PIXI.Graphics object was found.
*/
function findGraphics(item, queue) {
if (item instanceof core.Graphics) {
queue.push(item);
return true;
}
return false;
}
core.WebGLRenderer.registerPlugin('prepare', WebGLPrepare);
//# sourceMappingURL=WebGLPrepare.js.map
/***/ }),
/* 535 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _core = __webpack_require__(5);
var core = _interopRequireWildcard(_core);
var _BasePrepare2 = __webpack_require__(131);
var _BasePrepare3 = _interopRequireDefault(_BasePrepare2);
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 CANVAS_START_SIZE = 16;
/**
* The prepare manager provides functionality to upload content to the GPU
* This cannot be done directly for Canvas like in WebGL, but the effect can be achieved by drawing
* textures to an offline canvas.
* This draw call will force the texture to be moved onto the GPU.
*
* An instance of this class is automatically created by default, and can be found at renderer.plugins.prepare
*
* @class
* @extends PIXI.prepare.BasePrepare
* @memberof PIXI.prepare
*/
var CanvasPrepare = function (_BasePrepare) {
_inherits(CanvasPrepare, _BasePrepare);
/**
* @param {PIXI.CanvasRenderer} renderer - A reference to the current renderer
*/
function CanvasPrepare(renderer) {
_classCallCheck(this, CanvasPrepare);
var _this = _possibleConstructorReturn(this, _BasePrepare.call(this, renderer));
_this.uploadHookHelper = _this;
/**
* An offline canvas to render textures to
* @type {HTMLCanvasElement}
* @private
*/
_this.canvas = document.createElement('canvas');
_this.canvas.width = CANVAS_START_SIZE;
_this.canvas.height = CANVAS_START_SIZE;
/**
* The context to the canvas
* @type {CanvasRenderingContext2D}
* @private
*/
_this.ctx = _this.canvas.getContext('2d');
// Add textures to upload
_this.registerUploadHook(uploadBaseTextures);
return _this;
}
/**
* Destroys the plugin, don't use after this.
*
*/
CanvasPrepare.prototype.destroy = function destroy() {
_BasePrepare.prototype.destroy.call(this);
this.ctx = null;
this.canvas = null;
};
return CanvasPrepare;
}(_BasePrepare3.default);
/**
* Built-in hook to upload PIXI.Texture objects to the GPU.
*
* @private
* @param {*} prepare - Instance of CanvasPrepare
* @param {*} item - Item to check
* @return {boolean} If item was uploaded.
*/
exports.default = CanvasPrepare;
function uploadBaseTextures(prepare, item) {
if (item instanceof core.BaseTexture) {
var image = item.source;
// Sometimes images (like atlas images) report a size of zero, causing errors on windows phone.
// So if the width or height is equal to zero then use the canvas size
// Otherwise use whatever is smaller, the image dimensions or the canvas dimensions.
var imageWidth = image.width === 0 ? prepare.canvas.width : Math.min(prepare.canvas.width, image.width);
var imageHeight = image.height === 0 ? prepare.canvas.height : Math.min(prepare.canvas.height, image.height);
// Only a small subsections is required to be drawn to have the whole texture uploaded to the GPU
// A smaller draw can be faster.
prepare.ctx.drawImage(image, 0, 0, imageWidth, imageHeight, 0, 0, prepare.canvas.width, prepare.canvas.height);
return true;
}
return false;
}
core.CanvasRenderer.registerPlugin('prepare', CanvasPrepare);
//# sourceMappingURL=CanvasPrepare.js.map
/***/ }),
/* 536 */
/***/ (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"); } }
/**
* TimeLimiter limits the number of items handled by a {@link PIXI.BasePrepare} to a specified
* number of milliseconds per frame.
*
* @class
* @memberof PIXI
*/
var TimeLimiter = function () {
/**
* @param {number} maxMilliseconds - The maximum milliseconds that can be spent preparing items each frame.
*/
function TimeLimiter(maxMilliseconds) {
_classCallCheck(this, TimeLimiter);
/**
* The maximum milliseconds that can be spent preparing items each frame.
* @private
*/
this.maxMilliseconds = maxMilliseconds;
/**
* The start time of the current frame.
* @type {number}
* @private
*/
this.frameStart = 0;
}
/**
* Resets any counting properties to start fresh on a new frame.
*/
TimeLimiter.prototype.beginFrame = function beginFrame() {
this.frameStart = Date.now();
};
/**
* Checks to see if another item can be uploaded. This should only be called once per item.
* @return {boolean} If the item is allowed to be uploaded.
*/
TimeLimiter.prototype.allowedToUpload = function allowedToUpload() {
return Date.now() - this.frameStart < this.maxMilliseconds;
};
return TimeLimiter;
}();
exports.default = TimeLimiter;
//# sourceMappingURL=TimeLimiter.js.map
/***/ }),
/* 537 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedBloomFilter", function() { return s; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_pixi_js__ = __webpack_require__(116);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_pixi_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_pixi_js__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__pixi_filter_kawase_blur__ = __webpack_require__(538);
/*!
* @pixi/filter-advanced-bloom - v2.7.0
* Compiled Sun, 13 Jan 2019 22:51:52 UTC
*
* @pixi/filter-advanced-bloom is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
var o="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",i="\nuniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform float threshold;\n\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n // A simple & fast algorithm for getting brightness.\n // It's inaccuracy , but good enought for this feature.\n float _max = max(max(color.r, color.g), color.b);\n float _min = min(min(color.r, color.g), color.b);\n float brightness = (_max + _min) * 0.5;\n\n if(brightness > threshold) {\n gl_FragColor = color;\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n}\n",n=function(t){function r(r){void 0===r&&(r=.5),t.call(this,o,i),this.threshold=r}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var e={threshold:{configurable:!0}};return e.threshold.get=function(){return this.uniforms.threshold},e.threshold.set=function(t){this.uniforms.threshold=t},Object.defineProperties(r.prototype,e),r}(__WEBPACK_IMPORTED_MODULE_0_pixi_js__["Filter"]),l="uniform sampler2D uSampler;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D bloomTexture;\nuniform float bloomScale;\nuniform float brightness;\n\nvoid main() {\n vec4 color = texture2D(uSampler, vTextureCoord);\n color.rgb *= brightness;\n vec4 bloomColor = vec4(texture2D(bloomTexture, vTextureCoord).rgb, 0.0);\n bloomColor.rgb *= bloomScale;\n gl_FragColor = color + bloomColor;\n}\n",s=function(t){function i(i){t.call(this,o,l),"number"==typeof i&&(i={threshold:i}),i=Object.assign({threshold:.5,bloomScale:1,brightness:1,kernels:null,blur:8,quality:4,pixelSize:1,resolution:__WEBPACK_IMPORTED_MODULE_0_pixi_js__["settings"].RESOLUTION},i),this.bloomScale=i.bloomScale,this.brightness=i.brightness;var s=i.kernels,u=i.blur,a=i.quality,c=i.pixelSize,h=i.resolution;this._extractFilter=new n(i.threshold),this._extractFilter.resolution=h,this._blurFilter=s?new __WEBPACK_IMPORTED_MODULE_1__pixi_filter_kawase_blur__["a" /* KawaseBlurFilter */](s):new __WEBPACK_IMPORTED_MODULE_1__pixi_filter_kawase_blur__["a" /* KawaseBlurFilter */](u,a),this.pixelSize=c,this.resolution=h}t&&(i.__proto__=t),i.prototype=Object.create(t&&t.prototype),i.prototype.constructor=i;var s={resolution:{configurable:!0},threshold:{configurable:!0},kernels:{configurable:!0},blur:{configurable:!0},quality:{configurable:!0},pixelSize:{configurable:!0}};return i.prototype.apply=function(t,r,e,o,i){var n=t.getRenderTarget(!0);this._extractFilter.apply(t,r,n,!0,i);var l=t.getRenderTarget(!0);this._blurFilter.apply(t,n,l,!0,i),this.uniforms.bloomScale=this.bloomScale,this.uniforms.brightness=this.brightness,this.uniforms.bloomTexture=l,t.applyFilter(this,r,e,o),t.returnRenderTarget(l),t.returnRenderTarget(n)},s.resolution.get=function(){return this._resolution},s.resolution.set=function(t){this._resolution=t,this._extractFilter&&(this._extractFilter.resolution=t),this._blurFilter&&(this._blurFilter.resolution=t)},s.threshold.get=function(){return this._extractFilter.threshold},s.threshold.set=function(t){this._extractFilter.threshold=t},s.kernels.get=function(){return this._blurFilter.kernels},s.kernels.set=function(t){this._blurFilter.kernels=t},s.blur.get=function(){return this._blurFilter.blur},s.blur.set=function(t){this._blurFilter.blur=t},s.quality.get=function(){return this._blurFilter.quality},s.quality.set=function(t){this._blurFilter.quality=t},s.pixelSize.get=function(){return this._blurFilter.pixelSize},s.pixelSize.set=function(t){this._blurFilter.pixelSize=t},Object.defineProperties(i.prototype,s),i}(__WEBPACK_IMPORTED_MODULE_0_pixi_js__["Filter"]);
//# sourceMappingURL=filter-advanced-bloom.esm.js.map
/***/ }),
/* 538 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return n; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_pixi_js__ = __webpack_require__(116);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_pixi_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_pixi_js__);
/*!
* @pixi/filter-kawase-blur - v2.7.0
* Compiled Sun, 13 Jan 2019 22:51:52 UTC
*
* @pixi/filter-kawase-blur is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
var r="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",i="\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 uOffset;\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n\n // Sample top left pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y));\n\n // Sample top right pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y));\n\n // Sample bottom right pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y));\n\n // Sample bottom left pixel\n color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y));\n\n // Average\n color *= 0.25;\n\n gl_FragColor = color;\n}",o="\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n\nuniform vec2 uOffset;\nuniform vec4 filterClamp;\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n\n // Sample top left pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample top right pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample bottom right pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Sample bottom left pixel\n color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw));\n\n // Average\n color *= 0.25;\n\n gl_FragColor = color;\n}\n",n=function(t){function n(n,l,u){void 0===n&&(n=4),void 0===l&&(l=3),void 0===u&&(u=!1),t.call(this,r,u?o:i),this.uniforms.uOffset=new Float32Array(2),this._pixelSize=new __WEBPACK_IMPORTED_MODULE_0_pixi_js__["Point"],this.pixelSize=1,this._clamp=u,this._kernels=null,Array.isArray(n)?this.kernels=n:(this._blur=n,this.quality=l)}t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n;var l={kernels:{configurable:!0},clamp:{configurable:!0},pixelSize:{configurable:!0},quality:{configurable:!0},blur:{configurable:!0}};return n.prototype.apply=function(e,t,r,i){var o,n=this.pixelSize.x/t.size.width,l=this.pixelSize.y/t.size.height;if(1===this._quality||0===this._blur)o=this._kernels[0]+.5,this.uniforms.uOffset[0]=o*n,this.uniforms.uOffset[1]=o*l,e.applyFilter(this,t,r,i);else{for(var u,s=e.getRenderTarget(!0),a=t,f=s,p=this._quality-1,x=0;x<p;x++)o=this._kernels[x]+.5,this.uniforms.uOffset[0]=o*n,this.uniforms.uOffset[1]=o*l,e.applyFilter(this,a,f,!0),u=a,a=f,f=u;o=this._kernels[p]+.5,this.uniforms.uOffset[0]=o*n,this.uniforms.uOffset[1]=o*l,e.applyFilter(this,a,r,i),e.returnRenderTarget(s)}},n.prototype._generateKernels=function(){var e=this._blur,t=this._quality,r=[e];if(e>0)for(var i=e,o=e/t,n=1;n<t;n++)i-=o,r.push(i);this._kernels=r},l.kernels.get=function(){return this._kernels},l.kernels.set=function(e){Array.isArray(e)&&e.length>0?(this._kernels=e,this._quality=e.length,this._blur=Math.max.apply(Math,e)):(this._kernels=[0],this._quality=1)},l.clamp.get=function(){return this._clamp},l.pixelSize.set=function(t){"number"==typeof t?(this._pixelSize.x=t,this._pixelSize.y=t):Array.isArray(t)?(this._pixelSize.x=t[0],this._pixelSize.y=t[1]):t instanceof __WEBPACK_IMPORTED_MODULE_0_pixi_js__["Point"]?(this._pixelSize.x=t.x,this._pixelSize.y=t.y):(this._pixelSize.x=1,this._pixelSize.y=1)},l.pixelSize.get=function(){return this._pixelSize},l.quality.get=function(){return this._quality},l.quality.set=function(e){this._quality=Math.max(1,Math.round(e)),this._generateKernels()},l.blur.get=function(){return this._blur},l.blur.set=function(e){this._blur=e,this._generateKernels()},Object.defineProperties(n.prototype,l),n}(__WEBPACK_IMPORTED_MODULE_0_pixi_js__["Filter"]);
//# sourceMappingURL=filter-kawase-blur.esm.js.map
/***/ }),
/* 539 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TimelineLite_js__ = __webpack_require__(132);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TimelineMax_js__ = __webpack_require__(221);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__TweenMax_js__ = __webpack_require__(541);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__CSSPlugin_js__ = __webpack_require__(222);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__AttrPlugin_js__ = __webpack_require__(223);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__RoundPropsPlugin_js__ = __webpack_require__(224);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__DirectionalRotationPlugin_js__ = __webpack_require__(225);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__BezierPlugin_js__ = __webpack_require__(226);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__EasePack_js__ = __webpack_require__(227);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return __WEBPACK_IMPORTED_MODULE_3__TweenMax_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "TweenLite", function() { return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "TweenMax", function() { return __WEBPACK_IMPORTED_MODULE_3__TweenMax_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "TimelineLite", function() { return __WEBPACK_IMPORTED_MODULE_1__TimelineLite_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "TimelineMax", function() { return __WEBPACK_IMPORTED_MODULE_2__TimelineMax_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "CSSPlugin", function() { return __WEBPACK_IMPORTED_MODULE_4__CSSPlugin_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "AttrPlugin", function() { return __WEBPACK_IMPORTED_MODULE_5__AttrPlugin_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "BezierPlugin", function() { return __WEBPACK_IMPORTED_MODULE_8__BezierPlugin_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "RoundPropsPlugin", function() { return __WEBPACK_IMPORTED_MODULE_6__RoundPropsPlugin_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalRotationPlugin", function() { return __WEBPACK_IMPORTED_MODULE_7__DirectionalRotationPlugin_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "TweenPlugin", function() { return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["j"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Ease", function() { return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Power0", function() { return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["d"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Power1", function() { return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["e"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Power2", function() { return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["f"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Power3", function() { return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["g"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Power4", function() { return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["h"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Linear", function() { return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Back", function() { return __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["a"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Elastic", function() { return __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["d"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Bounce", function() { return __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["b"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "RoughEase", function() { return __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["g"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "SlowMo", function() { return __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["i"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "SteppedEase", function() { return __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["j"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Circ", function() { return __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["c"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Expo", function() { return __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["e"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Sine", function() { return __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["h"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "ExpoScaleEase", function() { return __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["f"]; });
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "_gsScope", function() { return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k"]; });
/*!
* 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
**/
/***/ }),
/* 540 */
/***/ (function(module, exports) {
module.exports = function(originalModule) {
if(!originalModule.webpackPolyfill) {
var module = Object.create(originalModule);
// module.parent = undefined by default
if(!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
get: function() {
return module.i;
}
});
Object.defineProperty(module, "exports", {
enumerable: true,
});
module.webpackPolyfill = 1;
}
return module;
};
/***/ }),
/* 541 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export TweenMax */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return TweenMax; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TweenMaxBase_js__ = __webpack_require__(542);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__CSSPlugin_js__ = __webpack_require__(222);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__AttrPlugin_js__ = __webpack_require__(223);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__RoundPropsPlugin_js__ = __webpack_require__(224);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__DirectionalRotationPlugin_js__ = __webpack_require__(225);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__TimelineLite_js__ = __webpack_require__(132);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__TimelineMax_js__ = __webpack_require__(221);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__BezierPlugin_js__ = __webpack_require__(226);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__EasePack_js__ = __webpack_require__(227);
/* unused harmony reexport TweenLite */
/* unused harmony reexport TimelineLite */
/* unused harmony reexport TimelineMax */
/* unused harmony reexport CSSPlugin */
/* unused harmony reexport AttrPlugin */
/* unused harmony reexport BezierPlugin */
/* unused harmony reexport DirectionalRotationPlugin */
/* unused harmony reexport RoundPropsPlugin */
/* unused harmony reexport TweenPlugin */
/* unused harmony reexport Ease */
/* unused harmony reexport Power0 */
/* unused harmony reexport Power1 */
/* unused harmony reexport Power2 */
/* unused harmony reexport Power3 */
/* unused harmony reexport Power4 */
/* unused harmony reexport Linear */
/* unused harmony reexport Back */
/* unused harmony reexport Elastic */
/* unused harmony reexport Bounce */
/* unused harmony reexport RoughEase */
/* unused harmony reexport SlowMo */
/* unused harmony reexport SteppedEase */
/* unused harmony reexport Circ */
/* unused harmony reexport Expo */
/* unused harmony reexport Sine */
/* unused harmony reexport ExpoScaleEase */
/*!
* 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 */
//the following two lines are designed to prevent tree shaking of the classes that were historically included with TweenMax (otherwise, folks would have to reference CSSPlugin, for example, to ensure their CSS-related animations worked)
var TweenMax = __WEBPACK_IMPORTED_MODULE_1__TweenMaxBase_js__["a" /* default */];
TweenMax._autoActivated = [__WEBPACK_IMPORTED_MODULE_6__TimelineLite_js__["a" /* default */], __WEBPACK_IMPORTED_MODULE_7__TimelineMax_js__["a" /* default */], __WEBPACK_IMPORTED_MODULE_2__CSSPlugin_js__["a" /* default */], __WEBPACK_IMPORTED_MODULE_3__AttrPlugin_js__["a" /* default */], __WEBPACK_IMPORTED_MODULE_8__BezierPlugin_js__["a" /* default */], __WEBPACK_IMPORTED_MODULE_4__RoundPropsPlugin_js__["a" /* default */], __WEBPACK_IMPORTED_MODULE_5__DirectionalRotationPlugin_js__["a" /* default */], __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["a" /* Back */], __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["d" /* Elastic */], __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["b" /* Bounce */], __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["g" /* RoughEase */], __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["i" /* SlowMo */], __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["j" /* SteppedEase */], __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["c" /* Circ */], __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["e" /* Expo */], __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["h" /* Sine */], __WEBPACK_IMPORTED_MODULE_9__EasePack_js__["f" /* ExpoScaleEase */]];
/***/ }),
/* 542 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export TweenMax */
/* unused harmony export TweenMaxBase */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return TweenMax; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__ = __webpack_require__(29);
/* unused harmony reexport TweenLite */
/* unused harmony reexport Ease */
/* unused harmony reexport Power0 */
/* unused harmony reexport Power1 */
/* unused harmony reexport Power2 */
/* unused harmony reexport Power3 */
/* unused harmony reexport Power4 */
/* unused harmony reexport Linear */
/*!
* 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 */
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["k" /* _gsScope */]._gsDefine("TweenMax", ["core.Animation","core.SimpleTimeline","TweenLite"], function() {
var _slice = function(a) { //don't use [].slice 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;
},
_applyCycle = function(vars, targets, i) {
var alt = vars.cycle,
p, val;
for (p in alt) {
val = alt[p];
vars[p] = (typeof(val) === "function") ? val(i, targets[i], targets) : val[i % val.length];
}
delete vars.cycle;
},
//for distributing values across an array. Can accept a number, a function or (most commonly) a function which can contain the following properties: {base, amount, from, ease, grid, axis, length, each}. Returns a function that expects the following parameters: index, target, array. Recognizes the following
_distribute = function(v) {
if (typeof(v) === "function") {
return v;
}
var vars = (typeof(v) === "object") ? v : {each:v}, //n:1 is just to indicate v was a number; we leverage that later to set v according to the length we get. If a number is passed in, we treat it like the old stagger value where 0.1, for example, would mean that things would be distributed with 0.1 between each element in the array rather than a total "amount" that's chunked out among them all.
ease = vars.ease,
from = vars.from || 0,
base = vars.base || 0,
cache = {},
isFromKeyword = isNaN(from),
axis = vars.axis,
ratio = {center:0.5, end:1}[from] || 0;
return function(i, target, a) {
var l = (a || vars).length,
distances = cache[l],
originX, originY, x, y, d, j, max, min, wrap;
if (!distances) {
wrap = (vars.grid === "auto") ? 0 : (vars.grid || [Infinity])[0];
if (!wrap) {
max = -Infinity;
while (max < (max = a[wrap++].getBoundingClientRect().left) && wrap < l) { }
wrap--;
}
distances = cache[l] = [];
originX = isFromKeyword ? (Math.min(wrap, l) * ratio) - 0.5 : from % wrap;
originY = isFromKeyword ? l * ratio / wrap - 0.5 : (from / wrap) | 0;
max = 0;
min = Infinity;
for (j = 0; j < l; j++) {
x = (j % wrap) - originX;
y = originY - ((j / wrap) | 0);
distances[j] = d = !axis ? Math.sqrt(x * x + y * y) : Math.abs((axis === "y") ? y : x);
if (d > max) {
max = d;
}
if (d < min) {
min = d;
}
}
distances.max = max - min;
distances.min = min;
distances.v = l = vars.amount || (vars.each * (wrap > l ? l : !axis ? Math.max(wrap, l / wrap) : axis === "y" ? l / wrap : wrap)) || 0;
distances.b = (l < 0) ? base - l : base;
}
l = (distances[i] - distances.min) / distances.max;
return distances.b + (ease ? ease.getRatio(l) : l) * distances.v;
};
},
TweenMax = function(target, duration, vars) {
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].call(this, target, duration, vars);
this._cycle = 0;
this._yoyo = (this.vars.yoyo === true || !!this.vars.yoyoEase);
this._repeat = this.vars.repeat || 0;
this._repeatDelay = this.vars.repeatDelay || 0;
if (this._repeat) {
this._uncache(true); //ensures that if there is any repeat, the totalDuration will get recalculated to accurately report it.
}
this.render = TweenMax.prototype.render; //speed optimization (avoid prototype lookup on this "hot" method)
},
_tinyNum = 0.00000001,
TweenLiteInternals = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */]._internals,
_isSelector = TweenLiteInternals.isSelector,
_isArray = TweenLiteInternals.isArray,
p = TweenMax.prototype = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].to({}, 0.1, {}),
_blankArray = [];
TweenMax.version = "2.1.2";
p.constructor = TweenMax;
p.kill()._gc = false;
TweenMax.killTweensOf = TweenMax.killDelayedCallsTo = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].killTweensOf;
TweenMax.getTweensOf = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].getTweensOf;
TweenMax.lagSmoothing = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].lagSmoothing;
TweenMax.ticker = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].ticker;
TweenMax.render = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].render;
TweenMax.distribute = _distribute;
p.invalidate = function() {
this._yoyo = (this.vars.yoyo === true || !!this.vars.yoyoEase);
this._repeat = this.vars.repeat || 0;
this._repeatDelay = this.vars.repeatDelay || 0;
this._yoyoEase = null;
this._uncache(true);
return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].prototype.invalidate.call(this);
};
p.updateTo = function(vars, resetDuration) {
var self = this,
curRatio = self.ratio,
immediate = self.vars.immediateRender || vars.immediateRender,
p;
if (resetDuration && self._startTime < self._timeline._time) {
self._startTime = self._timeline._time;
self._uncache(false);
if (self._gc) {
self._enabled(true, false);
} else {
self._timeline.insert(self, self._startTime - self._delay); //ensures that any necessary re-sequencing of Animations in the timeline occurs to make sure the rendering order is correct.
}
}
for (p in vars) {
self.vars[p] = vars[p];
}
if (self._initted || immediate) {
if (resetDuration) {
self._initted = false;
if (immediate) {
self.render(0, true, true);
}
} else {
if (self._gc) {
self._enabled(true, false);
}
if (self._notifyPluginsOfEnabled && self._firstPT) {
__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */]._onPluginEvent("_onDisable", self); //in case a plugin like MotionBlur must perform some cleanup tasks
}
if (self._time / self._duration > 0.998) { //if the tween has finished (or come extremely close to finishing), we just need to rewind it to 0 and then render it again at the end which forces it to re-initialize (parsing the new vars). We allow tweens that are close to finishing (but haven't quite finished) to work this way too because otherwise, the values are so small when determining where to project the starting values that binary math issues creep in and can make the tween appear to render incorrectly when run backwards.
var prevTime = self._totalTime;
self.render(0, true, false);
self._initted = false;
self.render(prevTime, true, false);
} else {
self._initted = false;
self._init();
if (self._time > 0 || immediate) {
var inv = 1 / (1 - curRatio),
pt = self._firstPT, endValue;
while (pt) {
endValue = pt.s + pt.c;
pt.c *= inv;
pt.s = endValue - pt.c;
pt = pt._next;
}
}
}
}
}
return self;
};
p.render = function(time, suppressEvents, force) {
if (!this._initted) if (this._duration === 0 && this.vars.repeat) { //zero duration tweens that render immediately have render() called from TweenLite's constructor, before TweenMax's constructor has finished setting _repeat, _repeatDelay, and _yoyo which are critical in determining totalDuration() so we need to call invalidate() which is a low-kb way to get those set properly.
this.invalidate();
}
var self = this,
totalDur = (!self._dirty) ? self._totalDuration : self.totalDuration(),
prevTime = self._time,
prevTotalTime = self._totalTime,
prevCycle = self._cycle,
duration = self._duration,
prevRawPrevTime = self._rawPrevTime,
isComplete, callback, pt, cycleDuration, r, type, pow, rawPrevTime, yoyoEase;
if (time >= totalDur - _tinyNum && time >= 0) { //to work around occasional floating point math artifacts.
self._totalTime = totalDur;
self._cycle = self._repeat;
if (self._yoyo && (self._cycle & 1) !== 0) {
self._time = 0;
self.ratio = self._ease._calcEnd ? self._ease.getRatio(0) : 0;
} else {
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 = self._cycle = 0;
self.ratio = self._ease._calcEnd ? self._ease.getRatio(0) : 0;
if (prevTotalTime !== 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) {
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) { //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.
force = true;
}
} else {
self._totalTime = self._time = time;
if (self._repeat !== 0) {
cycleDuration = duration + self._repeatDelay;
self._cycle = (self._totalTime / cycleDuration) >> 0; //originally _totalTime % cycleDuration but floating point errors caused problems, so I normalized it. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!)
if (self._cycle !== 0) if (self._cycle === self._totalTime / cycleDuration && prevTotalTime <= time) {
self._cycle--; //otherwise when rendered exactly at the end time, it will act as though it is repeating (at the beginning)
}
self._time = self._totalTime - (self._cycle * cycleDuration);
if (self._yoyo) if ((self._cycle & 1) !== 0) {
self._time = duration - self._time;
yoyoEase = self._yoyoEase || self.vars.yoyoEase; //note: we don't set this._yoyoEase in _init() like we do other properties because it's TweenMax-specific and doing it here allows us to optimize performance (most tweens don't have a yoyoEase). Note that we also must skip the this.ratio calculation further down right after we _init() in this function, because we're doing it here.
if (yoyoEase) {
if (!self._yoyoEase) {
if (yoyoEase === true && !self._initted) { //if it's not initted and yoyoEase is true, this._ease won't have been populated yet so we must discern it here.
yoyoEase = self.vars.ease;
self._yoyoEase = yoyoEase = !yoyoEase ? __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].defaultEase : (yoyoEase instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */]) ? yoyoEase : (typeof(yoyoEase) === "function") ? new __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */](yoyoEase, self.vars.easeParams) : __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */].map[yoyoEase] || __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].defaultEase;
} else {
self._yoyoEase = yoyoEase = (yoyoEase === true) ? self._ease : (yoyoEase instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */]) ? yoyoEase : __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["b" /* Ease */].map[yoyoEase];
}
}
self.ratio = yoyoEase ? 1 - yoyoEase.getRatio((duration - self._time) / duration) : 0;
}
}
if (self._time > duration) {
self._time = duration;
} else if (self._time < 0) {
self._time = 0;
}
}
if (self._easeType && !yoyoEase) {
r = self._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 : (self._time / duration < 0.5) ? r / 2 : 1 - (r / 2);
} else if (!yoyoEase) {
self.ratio = self._ease.getRatio(self._time / duration);
}
}
if (prevTime === self._time && !force && prevCycle === self._cycle) {
if (prevTotalTime !== self._totalTime) if (self._onUpdate) if (!suppressEvents) { //so that onUpdate fires even during the repeatDelay - as long as the totalTime changed, we should trigger onUpdate.
self._callback("onUpdate");
}
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))) { //we stick it in the queue for rendering at the very end of the tick - this is a performance optimization because browsers invalidate styles and force a recalculation if you read, write, and then read style data (so it's better to read/read/read/write/write/write than read/write/read/write/read/write). The down side, of course, is that usually you WANT things to render immediately because you may have code running right after that which depends on the change. Like imagine running TweenLite.set(...) and then immediately after that, creating a nother tween that animates the same property to another value; the starting values of that 2nd tween wouldn't be accurate if lazy is true.
self._time = prevTime;
self._totalTime = prevTotalTime;
self._rawPrevTime = prevRawPrevTime;
self._cycle = prevCycle;
TweenLiteInternals.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 && !yoyoEase) {
self.ratio = self._ease.getRatio(self._time / duration);
} else if (isComplete && this._ease._calcEnd && !yoyoEase) {
self.ratio = self._ease.getRatio((self._time === 0) ? 0 : 1);
}
}
if (self._lazy !== false) {
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 (prevTotalTime === 0) {
if (self._initted === 2 && time > 0) {
self._init(); //will just apply overwriting since _initted of (2) means it was a from() tween that had immediateRender:true
}
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._totalTime !== 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 && self._startTime) { //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._totalTime !== prevTotalTime || callback) {
self._callback("onUpdate");
}
}
if (self._cycle !== prevCycle) if (!suppressEvents) if (!self._gc) if (self.vars.onRepeat) {
self._callback("onRepeat");
}
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 && self._startTime) { //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);
}
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;
}
}
};
//---- STATIC FUNCTIONS -----------------------------------------------------------------------------------------------------------
TweenMax.to = function(target, duration, vars) {
return new TweenMax(target, duration, vars);
};
TweenMax.from = function(target, duration, vars) {
vars.runBackwards = true;
vars.immediateRender = (vars.immediateRender != false);
return new TweenMax(target, duration, vars);
};
TweenMax.fromTo = function(target, duration, fromVars, toVars) {
toVars.startAt = fromVars;
toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false);
return new TweenMax(target, duration, toVars);
};
TweenMax.staggerTo = TweenMax.allTo = function(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
var a = [],
staggerFunc = _distribute(vars.stagger || stagger),
cycle = vars.cycle,
fromCycle = (vars.startAt || _blankArray).cycle,
l, copy, i, p;
if (!_isArray(targets)) {
if (typeof(targets) === "string") {
targets = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].selector(targets) || targets;
}
if (_isSelector(targets)) {
targets = _slice(targets);
}
}
targets = targets || [];
l = targets.length - 1;
for (i = 0; i <= l; i++) {
copy = {};
for (p in vars) {
copy[p] = vars[p];
}
if (cycle) {
_applyCycle(copy, targets, i);
if (copy.duration != null) {
duration = copy.duration;
delete copy.duration;
}
}
if (fromCycle) {
fromCycle = copy.startAt = {};
for (p in vars.startAt) {
fromCycle[p] = vars.startAt[p];
}
_applyCycle(copy.startAt, targets, i);
}
copy.delay = staggerFunc(i, targets[i], targets) + (copy.delay || 0);
if (i === l && onCompleteAll) {
copy.onComplete = function() {
if (vars.onComplete) {
vars.onComplete.apply(vars.onCompleteScope || this, arguments);
}
onCompleteAll.apply(onCompleteAllScope || vars.callbackScope || this, onCompleteAllParams || _blankArray);
};
}
a[i] = new TweenMax(targets[i], duration, copy);
}
return a;
};
TweenMax.staggerFrom = TweenMax.allFrom = function(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
vars.runBackwards = true;
vars.immediateRender = (vars.immediateRender != false);
return TweenMax.staggerTo(targets, duration, vars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope);
};
TweenMax.staggerFromTo = TweenMax.allFromTo = function(targets, duration, fromVars, toVars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope) {
toVars.startAt = fromVars;
toVars.immediateRender = (toVars.immediateRender != false && fromVars.immediateRender != false);
return TweenMax.staggerTo(targets, duration, toVars, stagger, onCompleteAll, onCompleteAllParams, onCompleteAllScope);
};
TweenMax.delayedCall = function(delay, callback, params, scope, useFrames) {
return new TweenMax(callback, 0, {delay:delay, onComplete:callback, onCompleteParams:params, callbackScope:scope, onReverseComplete:callback, onReverseCompleteParams:params, immediateRender:false, useFrames:useFrames, overwrite:0});
};
TweenMax.set = function(target, vars) {
return new TweenMax(target, 0, vars);
};
TweenMax.isTweening = function(target) {
return (__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].getTweensOf(target, true).length > 0);
};
var _getChildrenOf = function(timeline, includeTimelines) {
var a = [],
cnt = 0,
tween = timeline._first;
while (tween) {
if (tween instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */]) {
a[cnt++] = tween;
} else {
if (includeTimelines) {
a[cnt++] = tween;
}
a = a.concat(_getChildrenOf(tween, includeTimelines));
cnt = a.length;
}
tween = tween._next;
}
return a;
},
getAllTweens = TweenMax.getAllTweens = function(includeTimelines) {
return _getChildrenOf(__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */]._rootTimeline, includeTimelines).concat( _getChildrenOf(__WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */]._rootFramesTimeline, includeTimelines) );
};
TweenMax.killAll = function(complete, tweens, delayedCalls, timelines) {
if (tweens == null) {
tweens = true;
}
if (delayedCalls == null) {
delayedCalls = true;
}
var a = getAllTweens((timelines != false)),
l = a.length,
allTrue = (tweens && delayedCalls && timelines),
isDC, tween, i;
for (i = 0; i < l; i++) {
tween = a[i];
if (allTrue || (tween instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["i" /* SimpleTimeline */]) || ((isDC = (tween.target === tween.vars.onComplete)) && delayedCalls) || (tweens && !isDC)) {
if (complete) {
tween.totalTime(tween._reversed ? 0 : tween.totalDuration());
} else {
tween._enabled(false, false);
}
}
}
};
TweenMax.killChildTweensOf = function(parent, complete) {
if (parent == null) {
return;
}
var tl = TweenLiteInternals.tweenLookup,
a, curParent, p, i, l;
if (typeof(parent) === "string") {
parent = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].selector(parent) || parent;
}
if (_isSelector(parent)) {
parent = _slice(parent);
}
if (_isArray(parent)) {
i = parent.length;
while (--i > -1) {
TweenMax.killChildTweensOf(parent[i], complete);
}
return;
}
a = [];
for (p in tl) {
curParent = tl[p].target.parentNode;
while (curParent) {
if (curParent === parent) {
a = a.concat(tl[p].tweens);
}
curParent = curParent.parentNode;
}
}
l = a.length;
for (i = 0; i < l; i++) {
if (complete) {
a[i].totalTime(a[i].totalDuration());
}
a[i]._enabled(false, false);
}
};
var _changePause = function(pause, tweens, delayedCalls, timelines) {
tweens = (tweens !== false);
delayedCalls = (delayedCalls !== false);
timelines = (timelines !== false);
var a = getAllTweens(timelines),
allTrue = (tweens && delayedCalls && timelines),
i = a.length,
isDC, tween;
while (--i > -1) {
tween = a[i];
if (allTrue || (tween instanceof __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["i" /* SimpleTimeline */]) || ((isDC = (tween.target === tween.vars.onComplete)) && delayedCalls) || (tweens && !isDC)) {
tween.paused(pause);
}
}
};
TweenMax.pauseAll = function(tweens, delayedCalls, timelines) {
_changePause(true, tweens, delayedCalls, timelines);
};
TweenMax.resumeAll = function(tweens, delayedCalls, timelines) {
_changePause(false, tweens, delayedCalls, timelines);
};
TweenMax.globalTimeScale = function(value) {
var tl = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */]._rootTimeline,
t = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].ticker.time;
if (!arguments.length) {
return tl._timeScale;
}
value = value || _tinyNum; //can't allow zero because it'll throw the math off
tl._startTime = t - ((t - tl._startTime) * tl._timeScale / value);
tl = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */]._rootFramesTimeline;
t = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["l" /* default */].ticker.frame;
tl._startTime = t - ((t - tl._startTime) * tl._timeScale / value);
tl._timeScale = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */]._rootTimeline._timeScale = value;
return value;
};
//---- GETTERS / SETTERS ----------------------------------------------------------------------------------------------------------
p.progress = function(value, suppressEvents) {
return (!arguments.length) ? this._time / this.duration() : this.totalTime( this.duration() * ((this._yoyo && (this._cycle & 1) !== 0) ? 1 - value : value) + (this._cycle * (this._duration + this._repeatDelay)), suppressEvents);
};
p.totalProgress = function(value, suppressEvents) {
return (!arguments.length) ? this._totalTime / this.totalDuration() : this.totalTime( this.totalDuration() * value, suppressEvents);
};
p.time = function(value, suppressEvents) {
if (!arguments.length) {
return this._time;
}
if (this._dirty) {
this.totalDuration();
}
var duration = this._duration,
cycle = this._cycle,
cycleDur = cycle * (duration + this._repeatDelay);
if (value > duration) {
value = duration;
}
return this.totalTime((this._yoyo && (cycle & 1)) ? duration - value + cycleDur : this._repeat ? value + cycleDur : value, suppressEvents);
};
p.duration = function(value) {
if (!arguments.length) {
return this._duration; //don't set _dirty = false because there could be repeats that haven't been factored into the _totalDuration yet. Otherwise, if you create a repeated TweenMax and then immediately check its duration(), it would cache the value and the totalDuration would not be correct, thus repeats wouldn't take effect.
}
return __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["a" /* Animation */].prototype.duration.call(this, value);
};
p.totalDuration = function(value) {
if (!arguments.length) {
if (this._dirty) {
//instead of Infinity, we use 999999999999 so that we can accommodate reverses
this._totalDuration = (this._repeat === -1) ? 999999999999 : this._duration * (this._repeat + 1) + (this._repeatDelay * this._repeat);
this._dirty = false;
}
return this._totalDuration;
}
return (this._repeat === -1) ? this : this.duration( (value - (this._repeat * this._repeatDelay)) / (this._repeat + 1) );
};
p.repeat = function(value) {
if (!arguments.length) {
return this._repeat;
}
this._repeat = value;
return this._uncache(true);
};
p.repeatDelay = function(value) {
if (!arguments.length) {
return this._repeatDelay;
}
this._repeatDelay = value;
return this._uncache(true);
};
p.yoyo = function(value) {
if (!arguments.length) {
return this._yoyo;
}
this._yoyo = value;
return this;
};
return TweenMax;
}, true);
var TweenMax = __WEBPACK_IMPORTED_MODULE_0__TweenLite_js__["m" /* globals */].TweenMax;
var TweenMaxBase = TweenMax;
/***/ })
/******/ ]);
var $pageWrapper = $('#jsi-page-wrapper'); if($pageWrapper.hasClass('jsc-art-detail') && (GYRE.ARTDETAIL.INIT.length > 0)){ GYRE.ARTDETAIL.DESTORY_ONE_FLAG = true; GYRE.ARTDETAIL.INIT.forEach(function(value){ value(); }); } else { GYRE.ARTDETAIL.DESTORY_ONE_FLAG = false; }