pixi-reactive
Version:
A library to help integrate PIXI into a React project
1,650 lines (1,420 loc) • 166 kB
JavaScript
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var PIXI = require('pixi.js');
var React = require('react');
var React__default = _interopDefault(React);
var AutoSizer = _interopDefault(require('react-virtualized-auto-sizer'));
var uuid = require('uuid');
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
var defaultAnimationContext = {
frameId: 0,
elapsed: 0,
fps: 0,
averageFps: 0,
minFps: 0,
maxFps: 0,
history: []
};
var AnimationContext = React__default.createContext(defaultAnimationContext);
var defaultParentContext = {
parent: new PIXI.Container(),
x: 0,
y: 0,
width: 0,
height: 0,
top: 0,
left: 0
};
var ParentContext = React__default.createContext(defaultParentContext);
var defaultRenderingContext = {
update: function update() {
return null;
},
getTexture: function getTexture() {
return undefined;
},
width: 0,
height: 0,
renderId: 0,
stage: new PIXI.Container()
};
var RenderingContext = React__default.createContext(defaultRenderingContext);
var defaultShapeTextureContext = {
setMatrix: function setMatrix() {
return null;
},
setTexture: function setTexture() {
return null;
}
};
var ShapeTextureContext = React__default.createContext(defaultShapeTextureContext);
var defaultShapeStyleContext = {
setFillStyle: function setFillStyle() {
return null;
},
setLineStyle: function setLineStyle() {
return null;
},
setHoles: function setHoles() {
return null;
}
};
var ShapeStyleContext = React__default.createContext(defaultShapeStyleContext);
var defaultGraphicsContext = {
drawShape: function drawShape() {
return null;
},
removeShape: function removeShape() {
return null;
}
};
var GraphicsContext = React__default.createContext(defaultGraphicsContext);
var defaultSpeedContext = {
speed: 1,
play: function play() {
return null;
},
pause: function pause() {
return null;
},
increase: function increase() {
return null;
},
decrease: function decrease() {
return null;
},
setSpeed: function setSpeed() {
return null;
}
};
var initialSpeedState = {
speed: 1
};
var SpeedContext = React__default.createContext(defaultSpeedContext);
var TextureContext = React__default.createContext({
textures: {},
resources: {}
});
var PointerContext = React__default.createContext({
x: 0,
y: 0,
over: false,
selected: false
});
var EffectContext = React__default.createContext({
updateEffect: function updateEffect() {
return null;
},
removeEffect: function removeEffect() {
return null;
}
});
var defaultPointsContext = {
points: [],
addPoint: function addPoint() {
return null;
},
removePoint: function removePoint() {
return null;
}
};
var PointsContext = React__default.createContext(defaultPointsContext);
var defaultImpactContext = {
items: [],
updateItem: function updateItem() {
return null;
},
removeItem: function removeItem() {
return null;
}
};
var ImpactContext = React__default.createContext(defaultImpactContext);
var defaultPropsContext = {
properties: {},
updateProperties: function updateProperties() {
return null;
}
};
var PropsContext = React__default.createContext(defaultPropsContext);
var isSprite = function isSprite(element) {
return element.isSprite;
};
var SpriteProps;
(function (SpriteProps) {
SpriteProps["AnchorX"] = "anchorX";
SpriteProps["AnchorY"] = "anchorY";
SpriteProps["RoundPixels"] = "roundPixels";
})(SpriteProps || (SpriteProps = {}));
var TilingSpriteProps;
(function (TilingSpriteProps) {
TilingSpriteProps["ClampMargin"] = "clampMargin";
TilingSpriteProps["TileX"] = "tileX";
TilingSpriteProps["TileY"] = "tileY";
TilingSpriteProps["TileScaleX"] = "tileScaleX";
TilingSpriteProps["TileScaleY"] = "tileScaleY";
TilingSpriteProps["UvRespectAnchor"] = "uvRespectAnchor";
})(TilingSpriteProps || (TilingSpriteProps = {}));
var isAnimatedSprite = function isAnimatedSprite(item) {
return !!item.textures;
};
var FilterProps;
(function (FilterProps) {
FilterProps["AutoFit"] = "autoFit";
FilterProps["BlendMode"] = "blendMode";
FilterProps["Enabled"] = "enabled";
FilterProps["Padding"] = "padding";
FilterProps["Resolution"] = "resolution";
FilterProps["Alpha"] = "alpha";
FilterProps["Blur"] = "blur";
FilterProps["BlurX"] = "blurX";
FilterProps["BlurY"] = "blurY";
FilterProps["Quality"] = "quality";
FilterProps["RepeatEdgePixels"] = "repeatEdgePixels";
FilterProps["Noise"] = "noise";
FilterProps["Seed"] = "seed";
})(FilterProps || (FilterProps = {}));
var GraphicsProps;
(function (GraphicsProps) {
GraphicsProps["BlendMode"] = "blendMode";
GraphicsProps["Tint"] = "tint";
})(GraphicsProps || (GraphicsProps = {}));
var AnimationActionType;
(function (AnimationActionType) {
AnimationActionType[AnimationActionType["Progress"] = 0] = "Progress";
AnimationActionType[AnimationActionType["Reset"] = 1] = "Reset";
})(AnimationActionType || (AnimationActionType = {}));
var RenderingContextAction;
(function (RenderingContextAction) {
RenderingContextAction[RenderingContextAction["Update"] = 0] = "Update";
RenderingContextAction[RenderingContextAction["Render"] = 1] = "Render";
})(RenderingContextAction || (RenderingContextAction = {}));
var SpeedContextAction;
(function (SpeedContextAction) {
SpeedContextAction[SpeedContextAction["Increase"] = 0] = "Increase";
SpeedContextAction[SpeedContextAction["Decrease"] = 1] = "Decrease";
SpeedContextAction[SpeedContextAction["Pause"] = 2] = "Pause";
SpeedContextAction[SpeedContextAction["Play"] = 3] = "Play";
SpeedContextAction[SpeedContextAction["Set"] = 4] = "Set";
})(SpeedContextAction || (SpeedContextAction = {}));
(function (CursorType) {
CursorType["Auto"] = "auto";
CursorType["Default"] = "default";
CursorType["None"] = "none";
CursorType["ContextMenu"] = "context-menu";
CursorType["Help"] = "help";
CursorType["Pointer"] = "pointer";
CursorType["Progress"] = "progress";
CursorType["Wait"] = "wait";
CursorType["Cell"] = "cell";
CursorType["CrossHair"] = "crosshair";
CursorType["Text"] = "text";
CursorType["VerticalText"] = "vertical-text";
CursorType["Alias"] = "alias";
CursorType["Copy"] = "copy";
CursorType["Move"] = "move";
CursorType["NoDrop"] = "no-drop";
CursorType["NotAllowed"] = "not-allowed";
CursorType["Grab"] = "grab";
CursorType["Grabbing"] = "grabbing";
CursorType["AllScroll"] = "all-scroll";
CursorType["ColResize"] = "col-resize";
CursorType["RowResize"] = "row-resize";
CursorType["NorthResize"] = "n-resize";
CursorType["EastResize"] = "e-resize";
CursorType["SouthResize"] = "s-resize";
CursorType["WestResize"] = "w-resize";
CursorType["NorthEastResize"] = "ne-resize";
CursorType["NorthWestResize"] = "nw-resize";
CursorType["SouthEastResize"] = "se-resize";
CursorType["SouthWestResize"] = "sw-resize";
CursorType["EastWestResize"] = "ew-resize";
CursorType["NorthSouthResize"] = "ns-resize";
CursorType["NorthEastSouthWestResize"] = "nesw-resize";
CursorType["NorthWestSouthEastResize"] = "nwse-resize";
CursorType["ZoomIn"] = "zoom-in";
CursorType["ZoomOut"] = "zoom-out";
})(exports.CursorType || (exports.CursorType = {}));
(function (Overflow) {
Overflow[Overflow["None"] = 0] = "None";
Overflow[Overflow["Horizontal"] = 1] = "Horizontal";
Overflow[Overflow["Vertical"] = 2] = "Vertical";
Overflow[Overflow["All"] = 3] = "All";
})(exports.Overflow || (exports.Overflow = {}));
var GenericProps;
(function (GenericProps) {
GenericProps["Alpha"] = "alpha";
GenericProps["Angle"] = "angle";
GenericProps["ButtonMode"] = "buttonMode";
GenericProps["Cursor"] = "cursor";
GenericProps["Interactive"] = "interactive";
GenericProps["Name"] = "name";
GenericProps["PivotX"] = "pivotX";
GenericProps["PivotY"] = "pivotY";
GenericProps["Rotation"] = "rotation";
GenericProps["ScaleX"] = "scaleX";
GenericProps["ScaleY"] = "scaleY";
GenericProps["SkewX"] = "skewX";
GenericProps["SkewY"] = "skewY";
GenericProps["Visible"] = "visible";
GenericProps["X"] = "x";
GenericProps["Y"] = "y";
GenericProps["ZIndex"] = "zIndex";
GenericProps["Width"] = "width";
GenericProps["Height"] = "height";
GenericProps["SortableChildren"] = "sortableChildren";
GenericProps["FilterArea"] = "filterArea";
GenericProps["HitArea"] = "hitArea";
})(GenericProps || (GenericProps = {}));
(function (SpecialKeys) {
SpecialKeys["Alt"] = "Alt";
SpecialKeys["AltGraph"] = "AltGraph";
SpecialKeys["CapsLock"] = "CapsLock";
SpecialKeys["Control"] = "Control";
SpecialKeys["Fn"] = "Fn";
SpecialKeys["FnLock"] = "FnLock";
SpecialKeys["Hyper"] = "Hyper";
SpecialKeys["Meta"] = "Meta";
SpecialKeys["NumLock"] = "NumLock";
SpecialKeys["ScrollLock"] = "ScrollLock";
SpecialKeys["Shift"] = "Shift";
SpecialKeys["Super"] = "Super";
SpecialKeys["Symbol"] = "Symbol";
SpecialKeys["SymbolLock"] = "SymbolLock";
SpecialKeys["Enter"] = "Enter";
SpecialKeys["Tab"] = "Tab";
SpecialKeys["Space"] = " ";
SpecialKeys["ArrowDown"] = "ArrowDown";
SpecialKeys["ArrowLeft"] = "ArrowLeft";
SpecialKeys["ArrowRight"] = "ArrowRight";
SpecialKeys["ArrowUp"] = "ArrowUp";
SpecialKeys["End"] = "End";
SpecialKeys["Home"] = "Home";
SpecialKeys["PageDown"] = "PageDown";
SpecialKeys["PageUp"] = "PageUp";
SpecialKeys["Backspace"] = "Backspace";
SpecialKeys["Clear"] = "Clear";
SpecialKeys["Copy"] = "Copy";
SpecialKeys["CrSel"] = "CrSel";
SpecialKeys["Cut"] = "Cut";
SpecialKeys["Delete"] = "Delete";
SpecialKeys["EraseEof"] = "EraseEof";
SpecialKeys["ExSel"] = "ExSel";
SpecialKeys["Insert"] = "Insert";
SpecialKeys["Paste"] = "Paste";
SpecialKeys["Redo"] = "Redo";
SpecialKeys["Undo"] = "Undo";
SpecialKeys["Accept"] = "Accept";
SpecialKeys["Again"] = "Again";
SpecialKeys["Attn"] = "Attn";
SpecialKeys["Cancel"] = "Cancel";
SpecialKeys["ContextMenu"] = "ContextMenu";
SpecialKeys["Escape"] = "Escape";
SpecialKeys["Execute"] = "Execute";
SpecialKeys["Find"] = "Find";
SpecialKeys["Finish"] = "Finish";
SpecialKeys["Help"] = "Help";
SpecialKeys["Pause"] = "Pause";
SpecialKeys["Play"] = "Play";
SpecialKeys["Props"] = "Props";
SpecialKeys["Select"] = "Select";
SpecialKeys["ZoomIn"] = "ZoomIn";
SpecialKeys["ZoomOut"] = "ZoomOut";
SpecialKeys["F1"] = "F1";
SpecialKeys["F2"] = "F2";
SpecialKeys["F3"] = "F3";
SpecialKeys["F4"] = "F4";
SpecialKeys["F5"] = "F5";
SpecialKeys["F6"] = "F6";
SpecialKeys["F7"] = "F7";
SpecialKeys["F8"] = "F8";
SpecialKeys["F9"] = "F9";
SpecialKeys["F10"] = "F10";
SpecialKeys["F11"] = "F11";
SpecialKeys["F12"] = "F12";
SpecialKeys["F13"] = "F13";
SpecialKeys["F14"] = "F14";
SpecialKeys["F15"] = "F15";
SpecialKeys["F16"] = "F16";
SpecialKeys["F17"] = "F17";
SpecialKeys["F18"] = "F18";
SpecialKeys["F19"] = "F19";
SpecialKeys["F20"] = "F20";
SpecialKeys["Soft1"] = "Soft1";
SpecialKeys["Soft2"] = "Soft2";
SpecialKeys["Soft3"] = "Soft3";
SpecialKeys["Soft4"] = "Soft4";
SpecialKeys["Decimal"] = "Decimal";
SpecialKeys["Key11"] = "11";
SpecialKeys["Key12"] = "12";
SpecialKeys["Multiply"] = "Multiply";
SpecialKeys["Add"] = "Add";
SpecialKeys["Divide"] = "Divide";
SpecialKeys["Subtract"] = "Subtract";
SpecialKeys["Separator"] = "Separator";
})(exports.SpecialKeys || (exports.SpecialKeys = {}));
var KeyboardActionType;
(function (KeyboardActionType) {
KeyboardActionType[KeyboardActionType["Set"] = 0] = "Set";
KeyboardActionType[KeyboardActionType["Reset"] = 1] = "Reset";
})(KeyboardActionType || (KeyboardActionType = {}));
(function (Events) {
Events["Click"] = "click";
Events["MouseDown"] = "mousedown";
Events["MouseMove"] = "mousemove";
Events["MouseOut"] = "mouseout";
Events["MouseOver"] = "mouseover";
Events["MouseUp"] = "mouseup";
Events["MouseUpOutside"] = "mouseupoutside";
Events["PointerCancel"] = "pointercancel";
Events["PointerDown"] = "pointerdown";
Events["PointerMove"] = "pointermove";
Events["PointerOut"] = "pointerout";
Events["PointerOver"] = "pointerover";
Events["PointerTap"] = "pointertap";
Events["PointerUp"] = "pointerup";
Events["PointerUpOutside"] = "pointerupoutside";
Events["RemovedFrom"] = "removedfrom";
Events["RightClick"] = "rightclick";
Events["RightDown"] = "rightdown";
Events["RightUp"] = "rightup";
Events["RightUpOutside"] = "rightupoutside";
Events["Tap"] = "tap";
Events["TouchCancel"] = "touchcancel";
Events["TouchEnd"] = "touchend";
Events["TouchEndOutside"] = "touchendoutside";
Events["TouchMove"] = "touchmove";
Events["TouchStart"] = "touchstart";
Events["Added"] = "added";
Events["Removed"] = "removed";
Events["ChildAdded"] = "childAdded";
})(exports.Events || (exports.Events = {}));
(function (BlendModes) {
BlendModes[BlendModes["Add"] = 0] = "Add";
BlendModes[BlendModes["AddNpm"] = 1] = "AddNpm";
BlendModes[BlendModes["Color"] = 2] = "Color";
BlendModes[BlendModes["ColorBurn"] = 3] = "ColorBurn";
BlendModes[BlendModes["ColorDodge"] = 4] = "ColorDodge";
BlendModes[BlendModes["Darken"] = 5] = "Darken";
BlendModes[BlendModes["Difference"] = 6] = "Difference";
BlendModes[BlendModes["DstAtop"] = 7] = "DstAtop";
BlendModes[BlendModes["DstIn"] = 8] = "DstIn";
BlendModes[BlendModes["DstOut"] = 9] = "DstOut";
BlendModes[BlendModes["DstOver"] = 10] = "DstOver";
BlendModes[BlendModes["Erase"] = 11] = "Erase";
BlendModes[BlendModes["Exclusion"] = 12] = "Exclusion";
BlendModes[BlendModes["HardLight"] = 13] = "HardLight";
BlendModes[BlendModes["Hue"] = 14] = "Hue";
BlendModes[BlendModes["Lighten"] = 15] = "Lighten";
BlendModes[BlendModes["Luminosity"] = 16] = "Luminosity";
BlendModes[BlendModes["Multiply"] = 17] = "Multiply";
BlendModes[BlendModes["None"] = 18] = "None";
BlendModes[BlendModes["Normal"] = 19] = "Normal";
BlendModes[BlendModes["NormalNpm"] = 20] = "NormalNpm";
BlendModes[BlendModes["Overlay"] = 21] = "Overlay";
BlendModes[BlendModes["Saturation"] = 22] = "Saturation";
BlendModes[BlendModes["Screen"] = 23] = "Screen";
BlendModes[BlendModes["ScreenNpm"] = 24] = "ScreenNpm";
BlendModes[BlendModes["SoftLight"] = 25] = "SoftLight";
BlendModes[BlendModes["SrcAtop"] = 26] = "SrcAtop";
BlendModes[BlendModes["SrcIn"] = 27] = "SrcIn";
BlendModes[BlendModes["SrcOut"] = 28] = "SrcOut";
BlendModes[BlendModes["SrcOver"] = 29] = "SrcOver";
BlendModes[BlendModes["Subtract"] = 30] = "Subtract";
BlendModes[BlendModes["Xor"] = 31] = "Xor";
})(exports.BlendModes || (exports.BlendModes = {}));
var BlendModesMap = new Map([[exports.BlendModes.Add, PIXI.BLEND_MODES.ADD], [exports.BlendModes.AddNpm, PIXI.BLEND_MODES.ADD_NPM], [exports.BlendModes.Color, PIXI.BLEND_MODES.COLOR], [exports.BlendModes.ColorBurn, PIXI.BLEND_MODES.COLOR_BURN], [exports.BlendModes.ColorDodge, PIXI.BLEND_MODES.COLOR_DODGE], [exports.BlendModes.Darken, PIXI.BLEND_MODES.DARKEN], [exports.BlendModes.Difference, PIXI.BLEND_MODES.DIFFERENCE], [exports.BlendModes.DstAtop, PIXI.BLEND_MODES.DST_ATOP], [exports.BlendModes.DstIn, PIXI.BLEND_MODES.DST_IN], [exports.BlendModes.DstOut, PIXI.BLEND_MODES.DST_OUT], [exports.BlendModes.DstOver, PIXI.BLEND_MODES.DST_OVER], [exports.BlendModes.Erase, PIXI.BLEND_MODES.ERASE], [exports.BlendModes.Exclusion, PIXI.BLEND_MODES.EXCLUSION], [exports.BlendModes.HardLight, PIXI.BLEND_MODES.HARD_LIGHT], [exports.BlendModes.Hue, PIXI.BLEND_MODES.HUE], [exports.BlendModes.Lighten, PIXI.BLEND_MODES.LIGHTEN], [exports.BlendModes.Luminosity, PIXI.BLEND_MODES.LUMINOSITY], [exports.BlendModes.Multiply, PIXI.BLEND_MODES.MULTIPLY], [exports.BlendModes.None, PIXI.BLEND_MODES.NONE], [exports.BlendModes.Normal, PIXI.BLEND_MODES.NORMAL], [exports.BlendModes.NormalNpm, PIXI.BLEND_MODES.NORMAL_NPM], [exports.BlendModes.Overlay, PIXI.BLEND_MODES.OVERLAY], [exports.BlendModes.Saturation, PIXI.BLEND_MODES.SATURATION], [exports.BlendModes.Screen, PIXI.BLEND_MODES.SCREEN], [exports.BlendModes.ScreenNpm, PIXI.BLEND_MODES.SCREEN_NPM], [exports.BlendModes.SoftLight, PIXI.BLEND_MODES.SOFT_LIGHT], [exports.BlendModes.SrcAtop, PIXI.BLEND_MODES.SRC_ATOP], [exports.BlendModes.SrcIn, PIXI.BLEND_MODES.SRC_IN], [exports.BlendModes.SrcOut, PIXI.BLEND_MODES.SRC_OUT], [exports.BlendModes.SrcOver, PIXI.BLEND_MODES.SRC_OVER], [exports.BlendModes.Subtract, PIXI.BLEND_MODES.SUBTRACT], [exports.BlendModes.Xor, PIXI.BLEND_MODES.XOR]]);
(function (LineJoin) {
LineJoin["Miter"] = "miter";
LineJoin["Round"] = "round";
LineJoin["Bevel"] = "bevel";
})(exports.LineJoin || (exports.LineJoin = {}));
(function (LineCap) {
LineCap["Butt"] = "butt";
LineCap["Round"] = "round";
LineCap["Square"] = "square";
})(exports.LineCap || (exports.LineCap = {}));
var ShapeAction;
(function (ShapeAction) {
ShapeAction[ShapeAction["UpdateShape"] = 0] = "UpdateShape";
ShapeAction[ShapeAction["RemoveShape"] = 1] = "RemoveShape";
})(ShapeAction || (ShapeAction = {}));
var Shapes;
(function (Shapes) {
Shapes[Shapes["Path"] = 0] = "Path";
Shapes[Shapes["Circle"] = 1] = "Circle";
Shapes[Shapes["Ellipse"] = 2] = "Ellipse";
Shapes[Shapes["Polygon"] = 3] = "Polygon";
Shapes[Shapes["Rect"] = 4] = "Rect";
Shapes[Shapes["RoundedRect"] = 5] = "RoundedRect";
Shapes[Shapes["Star"] = 6] = "Star";
Shapes[Shapes["Arc"] = 7] = "Arc";
Shapes[Shapes["ArcCurve"] = 8] = "ArcCurve";
Shapes[Shapes["BezierCurve"] = 9] = "BezierCurve";
Shapes[Shapes["QuadraticCurve"] = 10] = "QuadraticCurve";
})(Shapes || (Shapes = {}));
var PointAction;
(function (PointAction) {
PointAction[PointAction["Add"] = 0] = "Add";
PointAction[PointAction["Remove"] = 1] = "Remove";
})(PointAction || (PointAction = {}));
(function (TextAlign) {
TextAlign["Left"] = "left";
TextAlign["Center"] = "center";
TextAlign["Right"] = "right";
})(exports.TextAlign || (exports.TextAlign = {}));
(function (TextGradient) {
TextGradient[TextGradient["LinearVertical"] = 0] = "LinearVertical";
TextGradient[TextGradient["LinearHorizontal"] = 1] = "LinearHorizontal";
})(exports.TextGradient || (exports.TextGradient = {}));
(function (TextBaseline) {
TextBaseline["Alphabetic"] = "alphabetic";
TextBaseline["Top"] = "top";
TextBaseline["Hanging"] = "hanging";
TextBaseline["Middle"] = "middle";
TextBaseline["Ideographic"] = "ideographic";
TextBaseline["Bottom"] = "bottom";
})(exports.TextBaseline || (exports.TextBaseline = {}));
(function (TextWhiteLine) {
TextWhiteLine["Normal"] = "normal";
TextWhiteLine["Pre"] = "pre";
TextWhiteLine["PreLine"] = "pre-line";
})(exports.TextWhiteLine || (exports.TextWhiteLine = {}));
(function (FontStyle) {
FontStyle["Normal"] = "normal";
FontStyle["Italic"] = "italic";
FontStyle["Oblique"] = "oblique";
})(exports.FontStyle || (exports.FontStyle = {}));
(function (FontVariant) {
FontVariant["Normal"] = "normal";
FontVariant["SmallCaps"] = "small-caps";
})(exports.FontVariant || (exports.FontVariant = {}));
(function (FontWeight) {
FontWeight["Normal"] = "Normal";
FontWeight["Bold"] = "Bold";
FontWeight["Bolder"] = "Bolder";
FontWeight["Lighter"] = "Lighter";
FontWeight["W100"] = "100";
FontWeight["W200"] = "200";
FontWeight["W300"] = "300";
FontWeight["W400"] = "400";
FontWeight["W500"] = "500";
FontWeight["W600"] = "600";
FontWeight["W700"] = "700";
FontWeight["W800"] = "800";
FontWeight["W900"] = "900";
})(exports.FontWeight || (exports.FontWeight = {}));
var defaultTextStyle = {
align: exports.TextAlign.Left,
breakWords: false,
dropShadow: false,
dropShadowAlpha: 1,
dropShadowAngle: Math.PI / 6,
dropShadowBlur: 0,
dropShadowColor: 'black',
dropShadowDistance: 5,
fill: 'black',
fillGradientType: exports.TextGradient.LinearHorizontal,
fillGradientStops: [],
fontFamily: 'Arial',
fontSize: 26,
fontStyle: exports.FontStyle.Normal,
fontVariant: exports.FontVariant.Normal,
fontWeight: exports.FontWeight.Normal,
letterSpacing: 0,
lineHeight: 0,
lineJoin: exports.LineJoin.Miter,
miterLimit: 10,
padding: 0,
stroke: 'black',
strokeThickness: 0,
textBaseline: exports.TextBaseline.Alphabetic,
trim: false,
whiteSpace: exports.TextWhiteLine.Pre,
wordWrap: false,
wordWrapWidth: 100,
leading: 0
};
var EffectType;
(function (EffectType) {
EffectType[EffectType["BlackAndWhite"] = 0] = "BlackAndWhite";
EffectType[EffectType["Brightness"] = 1] = "Brightness";
EffectType[EffectType["Browni"] = 2] = "Browni";
EffectType[EffectType["ColorTone"] = 3] = "ColorTone";
EffectType[EffectType["Contrast"] = 4] = "Contrast";
EffectType[EffectType["Desaturate"] = 5] = "Desaturate";
EffectType[EffectType["GreyScale"] = 6] = "GreyScale";
EffectType[EffectType["Hue"] = 7] = "Hue";
EffectType[EffectType["Kodachrome"] = 8] = "Kodachrome";
EffectType[EffectType["Lsd"] = 9] = "Lsd";
EffectType[EffectType["Negative"] = 10] = "Negative";
EffectType[EffectType["Night"] = 11] = "Night";
EffectType[EffectType["Polaroid"] = 12] = "Polaroid";
EffectType[EffectType["Predator"] = 13] = "Predator";
EffectType[EffectType["Saturate"] = 14] = "Saturate";
EffectType[EffectType["Sepia"] = 15] = "Sepia";
EffectType[EffectType["Technicolor"] = 16] = "Technicolor";
EffectType[EffectType["ToBGR"] = 17] = "ToBGR";
EffectType[EffectType["Vintage"] = 18] = "Vintage";
})(EffectType || (EffectType = {}));
var EffectActionType;
(function (EffectActionType) {
EffectActionType[EffectActionType["UpdateEffect"] = 0] = "UpdateEffect";
EffectActionType[EffectActionType["RemoveEffect"] = 1] = "RemoveEffect";
})(EffectActionType || (EffectActionType = {}));
var ImpactAction;
(function (ImpactAction) {
ImpactAction[ImpactAction["Update"] = 0] = "Update";
ImpactAction[ImpactAction["Remove"] = 1] = "Remove";
})(ImpactAction || (ImpactAction = {}));
var useId = function useId(id) {
var _useState = React.useState(uuid.v4()),
state = _useState[0],
setState = _useState[1];
React.useEffect(function () {
setState(id ? id : uuid.v4());
}, [id]);
return state;
};
var useElement = function useElement(item) {
var _useContext = React.useContext(ParentContext),
parent = _useContext.parent;
var _useContext2 = React.useContext(RenderingContext),
update = _useContext2.update;
var _useState2 = React.useState(item),
element = _useState2[0];
React.useEffect(function () {
return function () {
element.destroy();
};
}, [element]);
React.useEffect(function () {
element.setParent(parent);
update();
}, [element, parent, update]);
return element;
};
var useRelativePosition = function useRelativePosition(item) {
var _useState3 = React.useState(0),
left = _useState3[0],
setLeft = _useState3[1];
var _useState4 = React.useState(0),
top = _useState4[0],
setTop = _useState4[1];
var _useState5 = React.useState(new PIXI.Point(0, 0)),
anchor = _useState5[0],
setAnchor = _useState5[1];
React.useEffect(function () {
if (item && item.anchor) {
setAnchor(item.anchor);
} else {
setAnchor(new PIXI.Point(0, 0));
}
}, [item]);
React.useEffect(function () {
setLeft(-anchor.x);
setTop(-anchor.y);
}, [anchor.x, anchor.y]);
return [left, top];
};
var updateKeyboardPressList = function updateKeyboardPressList(list, action) {
switch (action.type) {
case KeyboardActionType.Reset:
return new Array(action.index).fill(action.value);
case KeyboardActionType.Set:
list[action.index] = action.value;
return [].concat(list);
}
};
var useKeyboard = function useKeyboard() {
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
keys[_key] = arguments[_key];
}
var _useState6 = React.useState([]),
keyList = _useState6[0],
setKeyList = _useState6[1];
var _useReducer = React.useReducer(updateKeyboardPressList, []),
keyPressList = _useReducer[0],
updateKeyPressList = _useReducer[1];
var reset = React.useCallback(function () {
updateKeyPressList({
type: KeyboardActionType.Reset,
index: keyList.length,
value: false
});
}, [keyList]);
React.useEffect(function () {
if (JSON.stringify(keys) !== JSON.stringify(keyList)) {
setKeyList(keys);
}
}, [keys, keyList]);
React.useEffect(function () {
reset();
}, [keyList, reset]);
var onKeyUpdate = React.useCallback(function (event, updateValue) {
keyList.forEach(function (key, index) {
if (typeof key === 'string') {
if (event.key === key) {
updateKeyPressList({
type: KeyboardActionType.Set,
index: index,
value: updateValue
});
event.preventDefault();
}
} else {
var keyValid = event.key === key.key;
var altValid = key.alt === undefined ? true : key.alt === event.altKey;
var controlValid = key.control === undefined ? true : key.control === event.ctrlKey;
var shiftValid = key.shift === undefined ? true : key.shift === event.shiftKey;
if (keyValid && altValid && controlValid && shiftValid) {
updateKeyPressList({
type: KeyboardActionType.Set,
index: index,
value: updateValue
});
event.preventDefault();
}
}
});
}, [keyList]);
var onKeyDown = React.useCallback(function (event) {
return onKeyUpdate(event, true);
}, [onKeyUpdate]);
var onKeyUp = React.useCallback(function (event) {
return onKeyUpdate(event, false);
}, [onKeyUpdate]);
React.useEffect(function () {
window.addEventListener('keydown', onKeyDown);
window.addEventListener('keyup', onKeyUp);
window.addEventListener('blur', reset);
return function () {
window.removeEventListener('keydown', onKeyDown);
window.removeEventListener('keyup', onKeyUp);
window.removeEventListener('blur', reset);
};
}, [onKeyDown, onKeyUp, reset]);
return keyPressList;
};
var useFilter = function useFilter(item) {
var _useContext3 = React.useContext(ParentContext),
parent = _useContext3.parent;
var _useContext4 = React.useContext(RenderingContext),
update = _useContext4.update;
var _useState7 = React.useState(item),
element = _useState7[0];
React.useEffect(function () {
if (parent && !parent.filters) {
parent.filters = [];
}
if (parent && parent.filters.indexOf(element) < 0) {
parent.filters.push(element);
update();
}
return function () {
var index = parent.filters.indexOf(element);
if (index >= 0) {
parent.filters.splice(index, 1);
update();
}
};
}, [element, parent, update]);
return element;
};
var useLoadedTexture = function useLoadedTexture(textureValue) {
var _useContext5 = React.useContext(TextureContext),
context = _useContext5.textures;
var _useState8 = React.useState(typeof textureValue === 'string' && context[textureValue] instanceof PIXI.Texture ? context[textureValue] : textureValue instanceof PIXI.Texture ? textureValue : undefined),
texture = _useState8[0],
setTexture = _useState8[1];
React.useEffect(function () {
if (typeof textureValue === 'string' && context[textureValue] instanceof PIXI.Texture) {
var loadedTexture = context[textureValue];
if (loadedTexture && loadedTexture !== texture) {
setTexture(loadedTexture);
}
} else if (textureValue instanceof PIXI.Texture && textureValue !== texture) {
setTexture(textureValue);
}
}, [texture, context, textureValue]);
return texture;
};
var applyTexture = function applyTexture(sprite, texture, width, height) {
var currentScale = sprite.scale.clone();
sprite.texture = texture;
sprite.scale.copyFrom(currentScale);
if (width) {
sprite.width = width;
}
if (height) {
sprite.height = height;
}
};
var useTexture = function useTexture(sprite, textureValue, width, height) {
var _useContext6 = React.useContext(RenderingContext),
update = _useContext6.update;
var texture = useLoadedTexture(textureValue);
React.useEffect(function () {
if (texture) {
applyTexture(sprite, texture, width, height);
update();
}
}, [texture, sprite, update, width, height]);
};
var useFrames = function useFrames(sprite, frames, width, height) {
var _useContext7 = React.useContext(TextureContext),
context = _useContext7.textures;
var _useContext8 = React.useContext(RenderingContext),
update = _useContext8.update;
var _useContext9 = React.useContext(PropsContext),
updateProperties = _useContext9.updateProperties;
var _useState9 = React.useState([]),
textures = _useState9[0],
setTextures = _useState9[1];
var _useState10 = React.useState(0),
count = _useState10[0],
setCount = _useState10[1];
React.useEffect(function () {
if (frames) {
var textureList = [];
var frameList = [];
if (Array.isArray(frames)) {
frameList = frames;
} else if (Array.isArray(context[frames])) {
frameList = context[frames];
}
frameList.forEach(function (frameName) {
var loadedTexture = context[frameName];
if (loadedTexture instanceof PIXI.Texture) {
textureList.push(loadedTexture);
}
});
setTextures(textureList);
}
}, [context, frames]);
React.useEffect(function () {
if (textures && textures.length > 0) {
sprite.textures = textures;
updateProperties({
texture: textures[0]
});
update();
}
}, [textures, sprite, update, width, height]);
React.useEffect(function () {
setCount(sprite.textures.length);
}, [sprite.textures]);
return count;
};
var useTextureUpdate = function useTextureUpdate(texture) {
var _useContext10 = React.useContext(ParentContext),
parent = _useContext10.parent;
var _useContext11 = React.useContext(RenderingContext),
update = _useContext11.update;
var _useContext12 = React.useContext(ShapeTextureContext),
setTexture = _useContext12.setTexture;
var _useContext13 = React.useContext(PropsContext),
updateProperties = _useContext13.updateProperties;
React.useEffect(function () {
if (texture) {
var currentTexture = texture;
if (isSprite(parent)) {
if (isAnimatedSprite(parent)) {
var emptyIndex = parent.textures.indexOf(PIXI.Texture.EMPTY);
if (emptyIndex >= 0) {
parent.textures = [texture];
} else {
parent.textures = [].concat(parent.textures, [texture]);
}
currentTexture = parent.textures[0];
}
updateProperties({
texture: currentTexture
});
update();
} else {
setTexture(texture);
}
}
}, [parent, texture, update, setTexture]);
};
var useFrameAnimation = function useFrameAnimation(initialFrame, frameCount, fps, playing) {
var _useContext14 = React.useContext(AnimationContext),
frameId = _useContext14.frameId,
elapsed = _useContext14.elapsed;
var reducer = React.useCallback(function (state, action) {
var time, frame;
var initialTime = initialFrame * (1000 / fps);
var duration = 1000 / fps * frameCount;
if (isNaN(state.time) || isNaN(state.frame)) {
action.type = AnimationActionType.Reset;
}
switch (action.type) {
case AnimationActionType.Progress:
time = (state.time + (action.value || 0)) % duration;
frame = Math.floor(time / 1000 * fps) % frameCount;
return {
time: time,
frame: frame
};
case AnimationActionType.Reset:
if (state.time !== initialTime) {
return {
frame: initialFrame,
time: initialTime
};
} else {
return state;
}
default:
return state;
}
}, [initialFrame, fps, frameCount]);
var _useReducer2 = React.useReducer(reducer, {
time: initialFrame * (1000 / fps),
frame: initialFrame
}),
frame = _useReducer2[0].frame,
dispatch = _useReducer2[1];
React.useEffect(function () {
if (playing) {
dispatch({
type: AnimationActionType.Progress,
value: elapsed
});
} else {
dispatch({
type: AnimationActionType.Reset
});
}
}, [frameId, elapsed, playing, dispatch]);
return frame;
};
var isChildOf = function isChildOf(item1, item2) {
var checkItem = item1;
while (checkItem) {
if (checkItem === item2) {
return true;
}
checkItem = checkItem.parent;
}
return false;
};
var isPointIncluded = function isPointIncluded(x, y, area) {
return x >= area.x && x < area.x + area.width && y > area.y && y <= area.y + area.height;
};
var isImpactArea = function isImpactArea(area1, area2) {
return isPointIncluded(area1.x, area1.y, area2) || isPointIncluded(area1.x, area1.y + area1.height, area2) || isPointIncluded(area1.x + area1.width, area1.y, area2) || isPointIncluded(area1.x + area1.width, area1.y + area1.height, area2);
};
var isFilteredClass = function isFilteredClass(className, filter) {
return filter.length === 0 || filter.map(function (name) {
return name.toLowerCase();
}).indexOf(className.toLowerCase()) >= 0;
};
var isImpact = function isImpact(item1, item2) {
return item1.item !== item2.item && !isChildOf(item1.item, item2.item) && isFilteredClass(item1.className, item2.filter) && isImpactArea(item1.area, item2.area);
};
var useImpactDetection = function useImpactDetection(item, impactArea, impactClassName, impactFilter, detectImpacts, onImpact) {
var _useState11 = React.useState(impactArea),
area = _useState11[0],
setArea = _useState11[1];
var _useState12 = React.useState([]),
filter = _useState12[0],
setFilter = _useState12[1];
var _useState13 = React.useState(''),
className = _useState13[0],
setClassName = _useState13[1];
var _useState14 = React.useState(),
impactItem = _useState14[0],
setImpactItem = _useState14[1];
var _useContext15 = React.useContext(ImpactContext),
items = _useContext15.items,
updateItem = _useContext15.updateItem,
removeItem = _useContext15.removeItem;
var _useState15 = React.useState([]),
impactsDetected = _useState15[0],
setImpactsDetected = _useState15[1];
var impacts = React.useMemo(function () {
return (impactItem ? items.filter(function (item) {
return isImpact(item, impactItem);
}) : []).map(function (item) {
return item.className;
}).sort();
}, [items, impactItem]);
React.useEffect(function () {
if (detectImpacts) {
var impactRectangle = item.getBounds();
if (impactRectangle.width > 1 && impactRectangle.height > 1) {
var detectionArea = {
x: impactRectangle.x + (impactArea ? impactArea.x : 0),
y: impactRectangle.y + (impactArea ? impactArea.y : 0),
width: impactArea ? impactArea.width : impactRectangle.width,
height: impactArea ? impactArea.height : impactRectangle.height
};
setArea(detectionArea);
}
}
}, [item, item.worldTransform.a, item.worldTransform.b, item.worldTransform.c, item.worldTransform.d, item.worldTransform.tx, item.worldTransform.ty, impactArea, detectImpacts]);
React.useEffect(function () {
var list = (impactFilter || []).sort();
if (filter.join() !== list.join()) {
setFilter(list);
}
}, [filter, impactFilter]);
React.useEffect(function () {
setClassName(impactClassName || item.name);
}, [item.name, impactClassName, setClassName]);
React.useEffect(function () {
if (impacts.join() !== impactsDetected.join()) {
setImpactsDetected(impacts);
}
}, [impacts, impactsDetected]);
React.useEffect(function () {
if (area && detectImpacts) {
setImpactItem({
item: item,
filter: filter,
className: className,
area: area
});
} else {
setImpactItem(undefined);
}
}, [item, area, filter, className, detectImpacts]);
React.useEffect(function () {
if (impactItem) {
updateItem(impactItem);
}
return function () {
if (impactItem) {
removeItem(impactItem);
}
};
}, [updateItem, removeItem, impactItem]);
React.useEffect(function () {
if (onImpact && impactsDetected.length > 0 && detectImpacts) {
onImpact(impactsDetected);
}
}, [onImpact, impactsDetected, detectImpacts]);
};
var progressTimer = function progressTimer(currentTime, delta) {
return currentTime + delta;
};
var progressFrame = function progressFrame(time, frameRate) {
return Math.floor(time / (1000 / frameRate));
};
var progressTimeLine = function progressTimeLine(time, duration) {
return time / duration;
};
var useAnimatedEffect = function useAnimatedEffect(effect, dependencies, frameRate) {
if (frameRate === void 0) {
frameRate = 60;
}
var _useContext16 = React.useContext(AnimationContext),
elapsed = _useContext16.elapsed,
frameId = _useContext16.frameId;
var _useReducer3 = React.useReducer(progressTimer, 0),
time = _useReducer3[0],
updateTime = _useReducer3[1];
var _useState16 = React.useState(0),
frame = _useState16[0],
updateFrameId = _useState16[1];
React.useEffect(function () {
return updateTime(elapsed);
}, [elapsed, frameId]);
React.useEffect(function () {
return updateFrameId(progressFrame(time, frameRate));
}, [time, frameRate]);
React.useEffect(effect, dependencies ? [].concat(dependencies, [frame]) : [frame]);
};
var useAnimatedProgress = function useAnimatedProgress(duration, loop) {
if (loop === void 0) {
loop = false;
}
var _useContext17 = React.useContext(AnimationContext),
elapsed = _useContext17.elapsed,
frameId = _useContext17.frameId;
var _useReducer4 = React.useReducer(progressTimer, 0),
time = _useReducer4[0],
updateTime = _useReducer4[1];
var _useState17 = React.useState(0),
timeLine = _useState17[0],
updateTimeLine = _useState17[1];
React.useEffect(function () {
return updateTime(elapsed);
}, [elapsed, frameId]);
React.useEffect(function () {
var position = progressTimeLine(time, duration);
var value = loop ? position % 1 : Math.min(1, position);
if (value !== timeLine) {
updateTimeLine(value);
}
}, [time, duration, loop, timeLine]);
return timeLine;
};
var propsToMap = function propsToMap(props) {
var map = new Map();
Object.keys(props).forEach(function (key) {
map.set(key, props[key]);
});
return map;
};
var getMapUpdate = function getMapUpdate(state, props) {
var propMap = propsToMap(props);
var updatedMap = new Map();
state.forEach(function (value, key) {
var newValue = propMap.get(key);
if (value !== newValue) {
state.set(key, newValue);
updatedMap.set(key, newValue);
}
});
return updatedMap;
};
var updateGenericProps = function updateGenericProps(item, updatedProperties) {
updatedProperties === null || updatedProperties === void 0 ? void 0 : updatedProperties.forEach(function (value, key) {
var rectangle;
switch (key) {
case GenericProps.Alpha:
item.alpha = value;
break;
case GenericProps.Angle:
item.angle = value;
break;
case GenericProps.ButtonMode:
item.buttonMode = value;
break;
case GenericProps.Cursor:
if (typeof value === 'string') {
item.cursor = value;
}
break;
case GenericProps.Height:
item.height = value || item.height;
break;
case GenericProps.Interactive:
item.interactive = value;
break;
case GenericProps.Name:
item.name = value;
break;
case GenericProps.PivotX:
item.pivot.x = value;
break;
case GenericProps.PivotY:
item.pivot.y = value;
break;
case GenericProps.Rotation:
item.rotation = value;
break;
case GenericProps.ScaleX:
item.scale.x = value;
break;
case GenericProps.ScaleY:
item.scale.y = value;
break;
case GenericProps.SkewX:
item.skew.x = value;
break;
case GenericProps.SkewY:
item.skew.y = value;
break;
case GenericProps.SortableChildren:
item.sortableChildren = value;
break;
case GenericProps.Visible:
item.visible = value;
break;
case GenericProps.Width:
item.width = value || item.width;
break;
case GenericProps.X:
item.x = value;
break;
case GenericProps.Y:
item.y = value;
break;
case GenericProps.ZIndex:
item.zIndex = value;
break;
case GenericProps.FilterArea:
if (value) {
rectangle = value;
item.filterArea = new PIXI.Rectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
} else {
item.filterArea = null;
}
break;
case GenericProps.HitArea:
if (value) {
rectangle = value;
item.hitArea = new PIXI.Rectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
} else {
item.hitArea = null;
}
break;
}
});
};
var updateSpriteProps = function updateSpriteProps(item, updatedProperties) {
updatedProperties === null || updatedProperties === void 0 ? void 0 : updatedProperties.forEach(function (value, key) {
switch (key) {
case SpriteProps.AnchorX:
if (value) {
item.anchor.x = value;
}
break;
case SpriteProps.AnchorY:
if (value) {
item.anchor.y = value;
}
break;
case SpriteProps.RoundPixels:
item.roundPixels = value;
break;
}
});
};
var updateGraphicsProps = function updateGraphicsProps(item, updatedProperties) {
updatedProperties === null || updatedProperties === void 0 ? void 0 : updatedProperties.forEach(function (value, key) {
switch (key) {
case GraphicsProps.BlendMode:
item.blendMode = BlendModesMap.get(value) || 0;
break;
case GraphicsProps.Tint:
item.tint = value;
break;
}
});
};
var updateTilingSpriteProps = function updateTilingSpriteProps(item, updatedProperties) {
updatedProperties === null || updatedProperties === void 0 ? void 0 : updatedProperties.forEach(function (value, key) {
switch (key) {
case TilingSpriteProps.ClampMargin:
item.clampMargin = value;
break;
case TilingSpriteProps.TileScaleX:
item.tileScale.x = value;
break;
case TilingSpriteProps.TileScaleY:
item.tileScale.y = value;
break;
case TilingSpriteProps.TileX:
item.tilePosition.x = value % item.texture.width;
break;
case TilingSpriteProps.TileY:
item.tilePosition.y = value % item.texture.height;
break;
case TilingSpriteProps.UvRespectAnchor:
item.uvRespectAnchor = value;
break;
}
});
};
var updateFilterProps = function updateFilterProps(item, updatedProperties) {
updatedProperties === null || updatedProperties === void 0 ? void 0 : updatedProperties.forEach(function (value, key) {
switch (key) {
case FilterProps.AutoFit:
item.autoFit = value;
break;
case FilterProps.BlendMode:
item.blendMode = BlendModesMap.get(value) || 0;
break;
case FilterProps.Enabled:
item.enabled = value;
break;
case FilterProps.Padding:
item.padding = value;
break;
case FilterProps.Resolution:
item.resolution = value;
break;
case FilterProps.Alpha:
item.alpha = value;
break;
case FilterProps.Blur:
item.blur = value;
break;
case FilterProps.BlurX:
item.blurX = value;
break;
case FilterProps.BlurY:
item.blurY = value;
break;
case FilterProps.Quality:
item.quality = value;
break;
case FilterProps.RepeatEdgePixels:
item.repeatEdgePixels = value;
break;
case FilterProps.Noise:
item.noise = value;
break;
case FilterProps.Seed:
item.seed = value;
break;
}
});
};
var useUpdatedProps = function useUpdatedProps(props) {
var _useState = React.useState(propsToMap(props)),
state = _useState[0],
setState = _useState[1];
var _useState2 = React.useState(state),
updatedProperties = _useState2[0],
setUpdatedProperties = _useState2[1];
React.useEffect(function () {
var updatedMap = getMapUpdate(state, props);
if (updatedMap.size > 0) {
setUpdatedProperties(updatedMap);
setState(propsToMap(props));
}
}, [props, state]);
return updatedProperties;
};
var useGenericProps = function useGenericProps(item, props) {
var _useContext = React.useContext(RenderingContext),
update = _useContext.update;
var updatedProperties = useUpdatedProps(props);
React.useEffect(function () {
updateGenericProps(item, updatedProperties);
update();
}, [updatedProperties, update, item]);
};
var useSpriteProps = function useSpriteProps(sprite, props) {
var _useContext2 = React.useContext(RenderingContext),
update = _useContext2.update;
var updatedProperties = useUpdatedProps(props);
React.useEffect(function () {
updateSpriteProps(sprite, updatedProperties);
update();
}, [updatedProperties, update, sprite]);
};
var useGraphicsProps = function useGraphicsProps(graphics, props) {
var _useContext3 = React.useContext(RenderingContext),
update = _useContext3.update;
var updatedProperties = useUpdatedProps(props);
React.useEffect(function () {
updateGraphicsProps(graphics, updatedProperties);
update();
}, [updatedProperties, update, graphics]);
};
var useTransformMatrix = function useTransformMatrix(x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) {
if (x === void 0) {
x = 0;
}
if (y === void 0) {
y = 0;
}
if (pivotX === void 0) {
pivotX = 0;
}
if (pivotY === void 0) {
pivotY = 0;
}
if (scaleX === void 0) {
scaleX = 1;
}
if (scaleY === void 0) {
scaleY = 1;
}
if (rotation === void 0) {
rotation = 0;
}
if (skewX === void 0) {
skewX = 0;
}
if (skewY === void 0) {
skewY = 0;
}
var _useState3 = React.useState(new PIXI.Matrix()),
matrix = _useState3[0],
setMatrix = _useState3[1];
React.useEffect(function () {
var newMatrix = new PIXI.Matrix();
newMatrix.setTransform(x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY);
setMatrix(newMatrix);
}, [x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY]);
return matrix;
};
var useAlignedPosition = function useAlignedPosition(sprite, props) {
var _useContext4 = React.useContext(RenderingContext),
update = _useContext4.update;
var _useContext5 = React.useContext(ParentContext),
parentWidth = _useContext5.width,
parentHeight = _useContext5.height;
var _props$x = props.x,
x = _props$x === void 0 ? 0 : _props$x,
_props$y = props.y,
y = _props$y === void 0 ? 0 : _props$y,
alignX = props.alignX,
alignY = props.alignY;
React.useEffect(function () {
if (alignX) {
sprite.x = parentWidth * alignX + x;
sprite.anchor.x = alignX;
} else {
sprite.x = x;
}
update();
}, [update, sprite, parentWidth, x, alignX]);
React.useEffect(function () {
if (alignY) {
sprite.y = parentHeight * alignY + y;
sprite.anchor.y = alignY;
} else {
sprite.y = y;
}
update();
}, [update, sprite, parentHeight, y, alignY]);
};
var useTilingSpriteProps = function useTilingSpriteProps(sprite, props) {
var _useContext6 = React.useContext(RenderingContext),
update = _useContext6.update;
var updatedProperties = useUpdatedProps(props);
React.useEffect(function () {
updateTilingSpriteProps(sprite, updatedProperties);
update();
}, [updatedProperties, update, sprite]);
};
var useFilterProps = function useFilterProps(filter, props) {
var _useContext7 = React.useContext(RenderingContext),
update = _useContext7.update;
var updatedProperties = useUpdatedProps(props);
React.useEffect(function () {
updateFilterProps(filter, updatedProperties);
update();
}, [updatedProperties, update, filter]);
};
var useEvent = function useEvent(item, event, callback) {
React.useEffect(function () {
if (callback) {
item === null || item === void 0 ? void 0 : item.addListener(event, callback);
} else {
item === null || item === void 0 ? void 0 : item.removeListener(event);
}
return function () {
item === null || item === void 0 ? void 0 : it