diff --git a/LICENSE b/LICENSE
index d8c3bf7..99c6bec 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,7 @@
The MIT License (MIT)
-Copyright (c) 2014 Nathan Dinsmore
+Copyright (c) 2014-2015 Nathan Dinsmore
+Portions copyright (c) 2017 by John Feagans
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
diff --git a/Pixie.sublime-project b/Pixie.sublime-project
new file mode 100644
index 0000000..9cbd597
--- /dev/null
+++ b/Pixie.sublime-project
@@ -0,0 +1,9 @@
+{
+ "folders":
+ [
+ {
+ "follow_symlinks": true,
+ "path": "."
+ }
+ ]
+}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..eac3bf4
--- /dev/null
+++ b/README.md
@@ -0,0 +1,7 @@
+# Pixie
+
+A branch of the unofficial rewrite of [Scratch][] in JavaScript. Pixie aims to provide an application nearly identical to the current, Flash-based Scratch editor and player using only web technologies.
+
+The goal of this branch is to complete the missing features such as the libraries for sprite and backgrounds, and provide new methods of controlling programs such as voice recognition and text to speech.
+
+[scratch]: https://scratch.mit.edu
diff --git a/assets.png b/assets.png
deleted file mode 100644
index b20c00c..0000000
Binary files a/assets.png and /dev/null differ
diff --git a/assets.xcf b/assets.xcf
deleted file mode 100644
index 53bfced..0000000
Binary files a/assets.xcf and /dev/null differ
diff --git a/assets/assets.sketch b/assets/assets.sketch
new file mode 100644
index 0000000..4a5b929
Binary files /dev/null and b/assets/assets.sketch differ
diff --git a/assets/assets.svg b/assets/assets.svg
new file mode 100644
index 0000000..dd7080c
--- /dev/null
+++ b/assets/assets.svg
@@ -0,0 +1,517 @@
+
+
\ No newline at end of file
diff --git a/pixie.css b/assets/pixie.css
old mode 100644
new mode 100755
similarity index 62%
rename from pixie.css
rename to assets/pixie.css
index 14d5f37..f43259e
--- a/pixie.css
+++ b/assets/pixie.css
@@ -6,12 +6,25 @@ body {
cursor: default;
font: 12px Arial, Verdana, DejaVu Sans, sans-serif;
-webkit-perspective: 1500px;
+ -webkit-transform-style: preserve-3d;
+ transform-style: preserve-3d;
}
@media screen and (min-width: 960px) and (min-height: 600px) {
body {
overflow: hidden;
}
}
+
+button {
+ outline: 0;
+}
+button::-moz-focus-inner {
+ border: 0;
+}
+
+
+/* Main objects */
+
.editor {
position: absolute;
top: 0;
@@ -19,12 +32,11 @@ body {
width: 100%;
height: 100%;
background: #fff;
- -webkit-backface-visibility: hidden;
z-index: 1;
- box-shadow: 0 0 0 1px #888;
min-width: 960px;
min-height: 600px;
overflow: hidden;
+ -webkit-backface-visibility: hidden;
}
.player {
position: relative;
@@ -36,15 +48,26 @@ body {
-webkit-backface-visibility: hidden;
z-index: 1;
}
+.stage-wrapper {
+ position: fixed;
+ top: 0;
+ left: 0;
+ z-index: 10000;
+}
.player .project-name,
.player .project-author {
display: none;
}
+
+
+/* Project buttons */
+
.project-buttons {
position: absolute;
top: 33px;
right: 5px;
z-index: 1;
+ transition: opacity 1.2s;
}
.project-button {
height: 22px;
@@ -59,6 +82,7 @@ body {
background: #9c9ea2;
margin-left: 5px;
}
+
.flip,
.flip-back {
padding: 0 7px 0 5px;
@@ -73,20 +97,18 @@ body {
position: relative;
top: -1px;
margin: 0 3px 0 0;
- background: url(assets.png) -86px 0;
+ background: url(assets.svg) -86px 0;
}
.flip-back {
position: absolute;
top: auto;
right: 5px;
- bottom: 5px;
-}
-button {
- outline: 0;
-}
-button::-moz-focus-inner {
- border: 0;
+ top: 5px;
}
+
+
+/* Top bar */
+
.top-bar {
position: absolute;
top: 0;
@@ -95,7 +117,9 @@ button::-moz-focus-inner {
height: 28px;
background: #9c9ea2;
padding: 0 0 0 82px;
+ transition: opacity 1.2s;
}
+
.top-button {
vertical-align: middle;
border: 0;
@@ -117,43 +141,72 @@ button::-moz-focus-inner {
width: 19px;
height: 19px;
border-width: 4px 0 5px;
- background: url(assets.png) -67px 0;
-}
-.top-button.language:hover {
- background-position: -67px -19px;
+ background: url(assets.svg) -67px 0;
}
+.top-button.language:hover {background-position: -67px -19px}
.arrow {
+ display: inline-block;
vertical-align: middle;
margin: -2px 0 0 3px;
+ width: 8px;
+ height: 6px;
+ background: url(assets.svg) 0 -87px;
}
-.arrow.hovered,
-.top-button:hover .arrow.normal {
- display: none
+.top-button:hover .arrow {
+ background-position: -12px -87px;
}
-.top-button:hover .arrow.hovered {
- display: inline-block;
+
+.top-tools {
+ position: absolute;
+ top: 0;
+ left: 427px;
}
+.top-tool {
+ width: 23px;
+ height: 24px;
+ border-radius: 4px;
+ border: 0;
+ padding: 0;
+ margin: 2px 3px 2px 0;
+ background: url(assets.svg);
+}
+.top-tool:hover,
+.top-tool.selected {
+ background-color: rgb(0, 158, 217);
+}
+.top-tool-duplicate {background-position: 0 -54px}
+.top-tool-delete {background-position: -25px -54px}
+.top-tool-grow {background-position: -50px -54px}
+.top-tool-shrink {background-position: -75px -54px}
+.top-tool-help {background-position: -100px -54px}
+
+
+/* Stage panel */
+
.stage-panel {
position: absolute;
top: 33px;
left: 5px;
width: 482px;
- -webkit-transition: width .2s;
- -moz-transition: width .2s;
+ height: 400px;
+ z-index: 1;
transition: width .2s;
}
.player .stage-panel {
top: 0;
left: 0;
}
+
.mouse-coords {
position: absolute;
- right: 9px;
+ left: 386px;
top: 401px;
+ width: 87px;
+ height: 14px;
+ overflow: hidden;
color: #5c5d5f;
- -webkit-transition: top .2s;
- -moz-transition: top .2s;
- transition: top .2s;
+ transform: translateZ(0);
+ transition: transform .2s, opacity 1.2s;
}
.mouse-label {
display: inline-block;
@@ -168,6 +221,17 @@ button::-moz-focus-inner {
font-size: 10px;
width: 27px;
}
+
+.stage-toggle {
+ position: absolute;
+ top: 402px;
+ left: 477px;
+ width: 11px;
+ height: 16px;
+ background: url(assets.svg) -25px -87px;
+ transition: transform .2s, opacity 1.2s;
+}
+
.title-bar {
position: absolute;
top: 0;
@@ -180,13 +244,11 @@ button::-moz-focus-inner {
background: linear-gradient(#ffffff, #e6e8e8);
}
.title-label {
- -webkit-transition: opacity .2s;
- -moz-transition: opacity .2s;
transition: opacity .2s;
}
.title-button {
vertical-align: middle;
- background: url(assets.png);
+ background: url(assets.svg);
border: 0;
padding: 0;
margin: 0;
@@ -218,6 +280,21 @@ button::-moz-focus-inner {
.running .title-button.run {
background-position: -26px -21px;
}
+
+.turbo-indicator {
+ position: absolute;
+ top: 24px;
+ right: 73px;
+ color: #fba939;
+ font-size: 11px;
+ font-weight: bold;
+ line-height: 11px;
+ display: none;
+}
+.turbo .turbo-indicator {
+ display: block;
+}
+
.version {
position: absolute;
top: 29px;
@@ -228,11 +305,8 @@ button::-moz-focus-inner {
line-height: 9px;
color: #909090;
}
-.project-name {
- position: absolute;
- top: 2px;
- left: 50px;
- width: 350px;
+.sounds-info-name,.project-name,
+.sprite-info-name {
margin: 0;
outline: 0;
font: inherit;
@@ -249,10 +323,14 @@ button::-moz-focus-inner {
0 0 0 1px rgb(199, 200, 202),
inset 1px 1px 1px -1px rgba(0, 0, 0, .5);
-webkit-appearance: none;
- -webkit-transition: width .2s;
- -moz-transition: width .2s;
transition: width .2s;
}
+.project-name {
+ position: absolute;
+ top: 2px;
+ left: 50px;
+ width: 350px;
+}
.project-author {
position: absolute;
top: 24px;
@@ -260,6 +338,7 @@ button::-moz-focus-inner {
line-height: 12px;
color: #5c5d5f;
}
+
.stage {
position: absolute;
top: 39px;
@@ -268,14 +347,17 @@ button::-moz-focus-inner {
height: 360px;
box-shadow: 0 0 0 1px #d0d1d2;
background: #fff;
- -webkit-transform-origin: 0 0;
- -moz-transform-origin: 0 0;
transform-origin: 0 0;
- -webkit-transition: -webkit-transform .2s, box-shadow .2s;
- -moz-transition: -moz-transform .2s, box-shadow .2s;
transition: transform .2s, box-shadow .2s;
overflow: hidden;
}
+.stage > canvas {
+ transform-origin: 0 0;
+}
+
+
+/* Small stage layout */
+
.small-stage .stage-panel {
width: 242px;
}
@@ -286,8 +368,15 @@ button::-moz-focus-inner {
width: 243px;
top: 271px;
}
+.small-stage .new-group-label {
+ width: 0;
+}
.small-stage .mouse-coords {
- top: 221px;
+ transform: translate3d(-240px,-180px,0);
+}
+.small-stage .stage-toggle {
+ background-position: -38px -87px;
+ transform: translate(-240px, -180px);
}
.small-stage .tab-panel,
.small-stage .backpack-panel {
@@ -297,20 +386,33 @@ button::-moz-focus-inner {
opacity: 0;
}
.small-stage .stage {
- -webkit-transform: scale(.5);
- -moz-transform: scale(.5);
transform: scale(.5);
box-shadow: 0 0 0 2px #d0d1d2;
}
+
+
+/* Stage-only layout */
+.stage-only .sprite-panel,
+.stage-only .top-bar,
+.stage-only .project-buttons,
+.stage-only .mouse-coords,
+.stage-only .stage-toggle,
+.stage-only .tab-panel,
+.stage-only .backpack-panel,
+.stage-only .tips-panel {
+ opacity: 0;
+}
+
+
+/* Sprite panel */
+
.sprite-panel {
position: absolute;
top: 451px;
left: 5px;
bottom: 0;
width: 483px;
- -webkit-transition: top .2s, width .2s;
- -moz-transition: top .2s, width .2s;
- transition: top .2s, width .2s;
+ transition: top .2s, width .2s, opacity 1.2s;
}
.sprite-panel .title-bar {
position: relative;
@@ -320,6 +422,33 @@ button::-moz-focus-inner {
color: #5c5d5f;
font-size: 14px;
}
+.stage-section {
+ position: absolute;
+ top: 31px;
+ left: 0;
+ width: 76px;
+ bottom: 0;
+ border: 1px solid #d0d1d2;
+ border-top: 0;
+ background: #e6e8e8;
+ text-align: center;
+ color: #5c5d5f;
+}
+.sprite-section,
+.sprite-info {
+ position: absolute;
+ top: 31px;
+ right: 0;
+ left: 78px;
+ bottom: 0;
+ border: 1px solid #d0d1d2;
+ background: #e6e8e8;
+ border-top: 0;
+ border-left: 0;
+ padding: 1px;
+ overflow: auto;
+}
+
.new-group {
position: absolute;
right: 0;
@@ -330,6 +459,16 @@ button::-moz-focus-inner {
height: 29px;
padding-right: 11px;
line-height: 30px;
+ white-space: nowrap;
+ overflow: hidden;
+}
+.new-group-label {
+ display: inline-block;
+ transition: width .2s;
+ width: 80px;
+ text-align: right;
+ overflow: hidden;
+ white-space: nowrap;
}
.new-button {
width: 19px;
@@ -342,7 +481,12 @@ button::-moz-focus-inner {
position: relative;
top: 3px;
vertical-align: top;
- background: url(assets.png);
+ background: url(assets.svg);
+}
+.new-backdrop .new-button {
+ width: 18px;
+ height: 17px;
+ top: 6px;
}
.new-button-input {
position: absolute;
@@ -358,66 +502,53 @@ button::-moz-focus-inner {
background-position: -115px 0;
margin-left: 8px;
}
-.new-library:hover {
- background-position: -115px -19px;
-}
-.new-backdrop-library {
- background-position: -192px 0;
-}
-.new-backdrop-library:hover {
- background-position: -192px -19px;
-}
+.new-library:hover {background-position: -115px -19px}
+.new-backdrop-library {background-position: -192px 0}
+.new-backdrop-library:hover {background-position: -192px -19px} /* NS */
.new-paint {
background-position: -134px 0;
top: 4px;
margin-left: 3px;
}
-.new-paint:hover {
- background-position: -134px -19px;
-}
+.new-paint:hover {background-position: -134px -19px}
.new-import {
background-position: -153px 0;
margin-left: 4px;
}
-.new-import:hover {
- background-position: -153px -19px;
-}
+.new-import:hover {background-position: -153px -19px}
.new-camera {
background-position: -172px 0;
top: 5px;
margin-left: 8px;
}
-.new-camera:hover {
- background-position: -172px -19px;
- width: 20px;
- margin-right: -1px;
-}
-.stage-section {
- position: absolute;
- top: 31px;
- left: 0;
- width: 76px;
- bottom: 0;
- border: 1px solid #d0d1d2;
- border-top: 0;
- background: #e6e8e8;
- text-align: center;
- color: #5c5d5f;
-}
+.new-camera:hover {background-position: -172px -19px}
+.new-small-backdrop-library {background-position: -135px -43px}
+.new-small-backdrop-library:hover {background-position: -135px -61px}
+.new-small-paint {background-position: -153px -43px}
+.new-small-paint:hover {background-position: -153px -61px}
+.new-small-import {background-position: -171px -43px}
+.new-small-import:hover {background-position: -171px -61px}
+.new-small-camera {background-position: -189px -43px}
+.new-small-camera:hover {background-position: -189px -61px}
+
.sprite-icon {
position: relative;
display: inline-block;
- margin: 3px;
- padding: 1px;
+ margin: 2px;
+ padding: 2px;
width: 68px;
border-radius: 4px;
+ background: #fff;
color: #5c5d5f;
text-align: center;
}
.for-stage {
display: block;
+ background: 0;
}
.sprite-thumbnail {
+ width: 72px;
+ height: 55px;
position: relative;
display: block;
margin: -2px;
@@ -436,6 +567,11 @@ button::-moz-focus-inner {
.sprite-icon.selected {
box-shadow: 0 0 0 3px #179fd7;
background: #d0d0d0;
+ margin: 3px;
+ padding: 1px;
+}
+.for-stage.selected {
+ padding-bottom: 2px;
}
.sprite-icon.feedback {
box-shadow: 0 0 0 3px rgba(0, 0, 0, .3);
@@ -451,7 +587,7 @@ button::-moz-focus-inner {
left: -4px;
width: 18px;
height: 18px;
- background: url(assets.png) -211px 0;
+ background: url(assets.svg) -211px 0;
}
.sprite-icon-button:hover {
background-position: -211px -18px;
@@ -463,27 +599,101 @@ button::-moz-focus-inner {
margin-top: 11px;
font-size: 10px;
}
-.sprite-section {
+
+/* Sprite Info */
+
+.sprite-info {
+ background: #fff;
+ display: none;
+ padding: 6px 0 0 151px;
+ color: #a6a8ab;
+}
+.sprite-info-back {
position: absolute;
- top: 31px;
- right: 0;
- left: 78px;
- bottom: 0;
- border: 1px solid #d0d1d2;
- border-top: 0;
- border-left: 0;
- padding: 1px;
- overflow: auto;
+ top: 5px;
+ left: 5px;
+ width: 18px;
+ height: 18px;
+ background: url(assets.svg) -211px -37px;
+}
+.sprite-info-back:hover {
+ background-position: -211px -56px;
+}
+.sprite-info-name {
+ display: block;
+ width: 221px;
+ color: #929497;
+ margin-bottom: 11px;
+}
+
+.sprite-info-row {
+ margin: 8px 0 0 1px;
+}
+.sprite-info-row > strong {
+ margin-right: 5px;
+}
+.sprite-info-direction {
+ margin-left: 16px;
+}
+.sprite-info-value {
+ display: inline-block;
+ width: 31px;
+}
+.sprite-info-row .check-box {
+ margin-left: 3px;
+}
+/* Sounds*/
+.sounds-info {
+ background: #fff;
+ display: none;
+ padding: 6px 0 0 151px;
+ color: #a6a8ab;
+}
+.sounds-info-back {
+ position: absolute;
+ top: 5px;
+ left: 5px;
+ width: 18px;
+ height: 18px;
+ background: url(assets.svg) -211px -37px;
+}
+.sounds-info-back:hover {
+ background-position: -211px -56px;
+}
+.sounds-info-name {
+ display: block;
+ width: 221px;
+ color: #929497;
+ margin-bottom: 11px;
}
+
+.sounds-info-row {
+ margin: 8px 0 0 1px;
+}
+.sounds-info-row > strong {
+ margin-right: 5px;
+}
+.sounds-info-direction {
+ margin-left: 16px;
+}
+.sounds-info-value {
+ display: inline-block;
+ width: 31px;
+}
+.sounds-info-row .check-box {
+ margin-left: 3px;
+}
+
+
+/* Tabs */
+
.tab-panel {
position: absolute;
left: 492px;
top: 33px;
bottom: 22px;
right: 22px;
- -webkit-transition: left .2s, bottom .2s, right .2s;
- -moz-transition: left .2s, bottom .2s, right .2s;
- transition: left .2s, bottom .2s, right .2s;
+ transition: left .2s, bottom .2s, right .2s, opacity 1.2s;
}
.tab {
display: inline-block;
@@ -499,7 +709,6 @@ button::-moz-focus-inner {
position: relative;
color: #8f9193;
box-sizing: content-box;
- -moz-box-sizing: content-box;
}
.tab:hover,
.tab.selected {
@@ -526,6 +735,10 @@ button::-moz-focus-inner {
width: 100%;
height: 100%;
}
+
+
+/* Scripts: palette */
+
.palette-buttons,
.palette-contents {
position: absolute;
@@ -536,7 +749,7 @@ button::-moz-focus-inner {
width: 202px;
padding: 8px 7px 8px 0;
top: 0;
- height: 98px;
+ height: 88px;
}
.palette-buttons::before {
content: '';
@@ -551,17 +764,17 @@ button::-moz-focus-inner {
.palette-button {
float: left;
box-sizing: border-box;
- -moz-box-sizing: border-box;
width: 99px;
- height: 18px;
+ height: 17px;
padding: 0 0 0 8px;
border: 0;
background: 0;
- margin: 0 2px 2px 0;
+ margin: 0 2px 1px 0;
text-align: left;
white-space: nowrap;
overflow: hidden;
font: inherit;
+ vertical-align: top;
}
.palette-button div {
border-left: 7px solid;
@@ -585,7 +798,7 @@ button::-moz-focus-inner {
}
.palette-contents {
width: 209px;
- top: 114px;
+ top: 104px;
bottom: 0;
}
.palette-label {
@@ -614,6 +827,10 @@ button::-moz-focus-inner {
background: #179fd7;
color: #ffffff;
}
+
+
+/* Scripts: workspace */
+
.editor-workspace {
position: absolute;
top: 5px;
@@ -623,6 +840,10 @@ button::-moz-focus-inner {
background: rgb(221, 222, 222);
box-shadow: 0 0 0 1px #bcbdbe;
}
+
+
+/* Costume list */
+
.costume-new-label {
position: absolute;
left: 8px;
@@ -646,6 +867,7 @@ button::-moz-focus-inner {
.costume-new-group .new-camera {
margin-left: 9px;
}
+
.costume-list {
position: absolute;
top: 57px;
@@ -677,6 +899,8 @@ button::-moz-focus-inner {
position: absolute;
top: 11px;
left: 5px;
+ width: 68px;
+ height: 51px;
}
.costume-name {
position: absolute;
@@ -699,6 +923,120 @@ button::-moz-focus-inner {
overflow: hidden;
text-overflow: ellipsis;
}
+.costume-delete {
+ position: absolute;
+ top: 1px;
+ right: -9px;
+ width: 12px;
+ height: 12px;
+ margin: 0;
+ padding: 0;
+ border: 0;
+ background: url(assets.svg) -308px -77px;
+ display: none;
+}
+.costume-icon.selected > .costume-delete {
+ display: block;
+}
+/* Sound list */
+
+.sound-new-label {
+ position: absolute;
+ left: 8px;
+ top: 8px;
+ font-weight: bold;
+ color: #5c5d5f;
+}
+.sound-new-group {
+ position: absolute;
+ top: 26px;
+ left: 0px;
+}
+.sound-new-group .new-backdrop-library {
+ margin-left: 7px;
+ margin-top: 1px;
+ margin-right: 1px;
+}
+.sound-new-group .new-import {
+ margin-left: 2px;
+}
+.sound-new-group .new-camera {
+ margin-left: 9px;
+}
+
+.sound-list {
+ position: absolute;
+ top: 57px;
+ left: 6px;
+ width: 100px;
+ bottom: 0;
+ overflow: auto;
+}
+.sound-icon {
+ position: relative;
+ margin: 2px 0 3px;
+ border: 3px solid transparent;
+ border-radius: 7px;
+ width: 78px;
+ height: 91px;
+ color: #5c5d5f;
+}
+.sound-icon.selected {
+ border-color: #179fd7;
+ background: #d0d0d0;
+}
+.sounds-number {
+ position: absolute;
+ top: 1px;
+ left: 2px;
+ font-size: 9px;
+}
+.sound-thumbnail {
+ position: absolute;
+ top: 11px;
+ left: 5px;
+ width: 68px;
+ height: 51px;
+}
+.sounds-name {
+ position: absolute;
+ top: 66px;
+ left: 0;
+ right: 0;
+ text-align: center;
+ font-size: 11px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.sounds-info {
+ position: absolute;
+ top: 80px;
+ left: 0;
+ right: 0;
+ text-align: center;
+ font-size: 9px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.sound-delete {
+ position: absolute;
+ top: 1px;
+ right: -9px;
+ width: 12px;
+ height: 12px;
+ margin: 0;
+ padding: 0;
+ border: 0;
+ background: url(assets.svg) -308px -77px;
+ display: none;
+}
+.sounds-icon.selected > .sounds-delete {
+ display: block;
+}
+
+/* Image editor */
+
.image-editor {
position: absolute;
top: 5px;
@@ -708,6 +1046,7 @@ button::-moz-focus-inner {
background: #f2f2f2;
box-shadow: 0 0 0 1px #d0d1d2;
}
+
.image-editor-canvas {
position: absolute;
top: 39px;
@@ -730,6 +1069,7 @@ button::-moz-focus-inner {
.image-editor-canvas-layer {
position: absolute;
}
+
.image-editor-settings {
position: absolute;
bottom: 9px;
@@ -740,6 +1080,10 @@ button::-moz-focus-inner {
background: #f6f6f6;
text-align: center;
}
+
+
+/* Color picker */
+
.color-picker {
display: inline-block;
position: relative;
@@ -755,11 +1099,12 @@ button::-moz-focus-inner {
position: absolute;
left: 7px;
bottom: 4px;
- background: url(assets.png) -323px 0;
+ background: url(assets.svg) -323px 0;
}
.color-picker-swatch-button.wheel {
- background: url(assets.png) -323px -33px;
+ background: url(assets.svg) -323px -33px;
}
+
.color-picker-color {
position: absolute;
background: #fff;
@@ -776,6 +1121,7 @@ button::-moz-focus-inner {
top: 16px;
left: 17px;
}
+
.color-picker-eyedropper {
position: absolute;
top: 5px;
@@ -787,12 +1133,13 @@ button::-moz-focus-inner {
height: 25px;
border: 1px solid #d0d1d2;
border-radius: 5px;
- background: url(assets.png) -362px -1px, linear-gradient(#fff, #e6e8e8);
+ background: url(assets.svg) -362px -1px, linear-gradient(#fff, #e6e8e8);
}
.color-picker-eyedropper:hover,
.color-picker-eyedropper.selected {
- background: rgb(96, 183, 227) url(assets.png) -362px -25px;
+ background: rgb(96, 183, 227) url(assets.svg) -362px -25px;
}
+
.color-picker-palette {
position: absolute;
top: 5px;
@@ -808,6 +1155,10 @@ button::-moz-focus-inner {
height: 12px;
margin: 0 2px 2px 0;
}
+
+
+/* Bitmap editor: tools */
+
.image-editor-zoom {
position: absolute;
top: 4px;
@@ -819,20 +1170,15 @@ button::-moz-focus-inner {
border: 0;
width: 25px;
height: 22px;
- background: url(assets.png);
-}
-.zoom-button:hover {
- background-position-y: -23px;
-}
-.zoom-out {
- background-position: -728px 0;
-}
-.zoom-default {
- background-position: -754px 0;
-}
-.zoom-in {
- background-position: -780px 0;
-}
+ background: url(assets.svg);
+}
+.zoom-out {background-position: -728px 0}
+.zoom-out:hover {background-position: -728px -23px}
+.zoom-default {background-position: -754px 0}
+.zoom-default:hover {background-position: -754px -23px}
+.zoom-in {background-position: -780px 0}
+.zoom-in:hover {background-position: -780px -23px}
+
.image-editor-zoom-label {
position: absolute;
top: 31px;
@@ -840,6 +1186,7 @@ button::-moz-focus-inner {
width: 70px;
color: #5c5d5f;
}
+
.bitmap-tools {
position: absolute;
top: 39px;
@@ -847,7 +1194,7 @@ button::-moz-focus-inner {
}
.bitmap-tool {
border: 1px solid #d0d1d2;
- background: url(assets.png), linear-gradient(#fff, #e6e8e8);
+ background: url(assets.svg), linear-gradient(#fff, #e6e8e8);
margin: 0 0 3px;
padding: 0;
width: 38px;
@@ -858,50 +1205,48 @@ button::-moz-focus-inner {
.bitmap-tool:hover,
.bitmap-tool.selected {
background-color: rgb(73, 188, 226);
- background-image: url(assets.png);
- background-position-y: -35px;
-}
-.bitmap-tool-brush {
- background-position: -387px -1px, 0 0;
-}
-.bitmap-tool-line {
- background-position: -426px -1px, 0 0;
-}
-.bitmap-tool-rectangle {
- background-position: -462px -1px, 0 0;
-}
-.bitmap-tool-ellipse {
- background-position: -500px -1px, 0 0;
-}
-.bitmap-tool-text {
- background-position: -538px -1px, 0 0;
-}
-.bitmap-tool-fill {
- background-position: -576px -1px, 0 0;
-}
-.bitmap-tool-erase {
- background-position: -614px -1px, 0 0;
-}
-.bitmap-tool-select {
- background-position: -652px -1px, 0 0;
-}
-.bitmap-tool-duplicate {
- background: url(assets.png), linear-gradient(#fff, #e6e8e8 24px);
- background-position: -690px -1px, 0 0;
-}
+ background-image: url(assets.svg);
+ /* NS */
+ /* (for duplicate tool) */
+}
+.bitmap-tool-brush {background-position: -387px -1px, 0 0}
+.bitmap-tool-brush:hover,
+.bitmap-tool-brush.selected {background-position: -387px -35px}
+.bitmap-tool-line {background-position: -426px -1px, 0 0}
+.bitmap-tool-line:hover,
+.bitmap-tool-line.selected {background-position: -426px -35px}
+.bitmap-tool-rectangle {background-position: -462px -1px, 0 0}
+.bitmap-tool-rectangle:hover,
+.bitmap-tool-rectangle.selected {background-position: -462px -35px}
+.bitmap-tool-ellipse {background-position: -500px -1px, 0 0}
+.bitmap-tool-ellipse:hover,
+.bitmap-tool-ellipse.selected {background-position: -500px -35px}
+.bitmap-tool-text {background-position: -538px -1px, 0 0}
+.bitmap-tool-text:hover,
+.bitmap-tool-text.selected {background-position: -538px -35px}
+.bitmap-tool-fill {background-position: -576px -1px, 0 0}
+.bitmap-tool-fill:hover,
+.bitmap-tool-fill.selected {background-position: -576px -35px}
+.bitmap-tool-erase {background-position: -614px -1px, 0 0}
+.bitmap-tool-erase:hover,
+.bitmap-tool-erase.selected {background-position: -614px -35px}
+.bitmap-tool-select {background-position: -652px -1px, 0 0}
+.bitmap-tool-select:hover,
+.bitmap-tool-select.selected {background-position: -652px -35px}
+.bitmap-tool-duplicate {background-position: -690px -1px, 0 0} /* NS */
.bitmap-tool-duplicate:hover,
-.bitmap-tool-duplicate.selected {
- background-color: #179fd7;
-}
+.bitmap-tool-duplicate.selected {background-position: -690px -35px} /* NS */
+
+
+/* Backpack */
+
.backpack-panel {
position: absolute;
bottom: -117px;
left: 492px;
right: 22px;
height: 136px;
- -webkit-transition: bottom .2s, right .2s, left .2s;
- -moz-transition: bottom .2s, right .2s, left .2s;
- transition: bottom .2s, right .2s, left .2s;
+ transition: bottom .2s, right .2s, left .2s, opacity 1.2s;
}
.backpack-title {
background: linear-gradient(#ffffff, #e6e8e8);
@@ -925,15 +1270,17 @@ button::-moz-focus-inner {
.backpack-open .backpack-panel {
bottom: 1px;
}
+
+
+/* Tips */
+
.tips-panel {
position: absolute;
top: 60px;
right: 0;
bottom: 0;
width: 19px;
- -webkit-transition: width .2s;
- -moz-transition: width .2s;
- transition: width .2s;
+ transition: width .2s, opacity 1.2s;
}
.tips-title {
width: 100%;
@@ -946,7 +1293,6 @@ button::-moz-focus-inner {
border: 1px solid #bbb;
border-right: 0;
border-radius: 10px 0 0 0;
- -moz-box-sizing: border-box;
box-sizing: border-box;
}
.tips-label {
@@ -963,7 +1309,7 @@ button::-moz-focus-inner {
left: 0;
width: 18px;
height: 15px;
- background: url(assets.png) -86px -23px no-repeat;
+ background: url(assets.svg) -86px -23px no-repeat;
}
.tips-label:hover {
color: #1aa0d8;
@@ -995,8 +1341,6 @@ button::-moz-focus-inner {
.tips-frame,
.tips-label {
opacity: 0;
- -webkit-transition: opacity .2s;
- -moz-transition: opacity .2s;
transition: opacity .2s;
pointer-events: none;
}
@@ -1005,8 +1349,6 @@ button::-moz-focus-inner {
border: 2px solid #aaa;
border-radius: 10px;
padding: 0 3px;
- -webkit-transition: opacity .2s;
- -moz-transition: opacity .2s;
transition: opacity .2s;
}
.tips-icon:hover {
@@ -1049,6 +1391,10 @@ button::-moz-focus-inner {
.tips-open .tips-panel {
width: 321px;
}
+
+
+/* Dialogs */
+
.dialog {
position: fixed;
left: 0;
@@ -1077,10 +1423,49 @@ button::-moz-focus-inner {
border-top: 0;
font-size: 14px;
}
+.dialog-content article {
+ text-align: left;
+ max-width: 300px;
+ margin-bottom: 14px;
+}
+.dialog-content h1 {
+ margin: 0 0 14px;
+ font-size: 24px;
+}
+.dialog-content p {
+ margin: 0 0 14px;
+}
+.dialog-content a {
+ text-decoration: none;
+ color: #05c;
+ margin: -1px -3px;
+ padding: 1px 3px;
+ border-radius: 3px;
+}
+.dialog-content a:hover {
+ text-decoration: underline;
+}
+.dialog-content a:active {
+ text-decoration: none;
+ color: #fff;
+ background: #47d;
+}
+.dialog-content .links {
+ list-style: none;
+ margin: 0 0 14px;
+ padding: 0 0 0 14px;
+}
+.dialog-content .links li::before {
+ content: '– ';
+}
.dialog-label {
display: block;
margin-bottom: 14px;
}
+.dialog-label.video-error {
+ text-align: center;
+ margin: 0;
+}
.dialog-buttons {
margin-top: 14px;
}
@@ -1134,7 +1519,7 @@ button::-moz-focus-inner {
outline: 0;
padding: 0;
border: 0;
- background: url(assets.png) -309px 0;
+ background: url(assets.svg) -309px 0;
width: 13px;
height: 12px;
vertical-align: middle;
@@ -1152,18 +1537,74 @@ button::-moz-focus-inner {
border-bottom: 1px solid #909090;
margin: -3px 0 10px;
}
+
+
+/* Bubbles */
+
.bubble {
position: fixed;
z-index: 3;
}
+
+/* Watchers */
+
+.watcher {
+ position: absolute;
+ top: 0;
+ left: 0;
+ border: 1px solid #949191;
+ background: #c1c4c7;
+ border-radius: 4px;
+ padding: 2px 7px 3px 6px;
+}
+.watcher.large {
+ border: 0;
+ background: 0;
+ border-radius: 0;
+ padding: 0;
+}
+.watcher-label {
+ display: inline-block;
+ font-size: 11px;
+ font-weight: bold;
+ margin-right: 6px;
+ margin-top: 1px;
+}
+.watcher-contents {
+ display: inline-block;
+ font-size: 10px;
+ font-weight: bold;
+ color: #fff;
+ background: rgb(240, 125, 0);
+ box-shadow:
+ inset -1px -1px 2px rgba(255, 255, 255, .5),
+ inset 1px 1px 1px rgba(0, 0, 0, .4);
+ border: 1px solid #fff;
+ border-radius: 4px;
+ padding: 1px 4px;
+ min-width: 41px;
+ box-sizing: border-box;
+ text-align: center;
+}
+.watcher.large > .watcher-label {
+ display: none;
+}
+.watcher.large > .watcher-contents {
+ font-size: 15px;
+ min-width: 49px;
+ margin-top: 3px;
+}
+
+
+/* List watchers */
+
.list-watcher {
position: absolute;
top: 0;
left: 0;
border: 2px solid #949191;
background: #c1c4c7;
- -moz-box-sizing: border-box;
box-sizing: border-box;
border-radius: 7px;
margin: -1px;
@@ -1178,6 +1619,9 @@ button::-moz-focus-inner {
text-align: center;
font-size: 12px;
font-weight: bold;
+ white-space: nowrap;
+ overflow: hidden; /* NS */
+ text-overflow: ellipsis; /* NS */
}
.list-watcher-length {
position: absolute;
@@ -1198,6 +1642,16 @@ button::-moz-focus-inner {
overflow-x: hidden;
overflow-y: scroll;
}
+.list-watcher-empty {
+ position: absolute;
+ top: 21px;
+ left: 1px;
+ right: 1px;
+ bottom: 19px;
+ text-align: center;
+ font-size: 11px;
+ display: none;
+}
.list-watcher-filler {
position: absolute;
top: 0;
@@ -1208,7 +1662,7 @@ button::-moz-focus-inner {
position: absolute;
left: 0;
bottom: 0;
- background: url(assets.png) -309px -24px;
+ background: url(assets.svg) -308px -24px;
border: 0;
padding: 0;
margin: 0;
@@ -1229,16 +1683,17 @@ button::-moz-focus-inner {
.list-cell-index {
position: absolute;
top: 0;
- left: -6px;
- /*left: -3px;*/
+ left: -4px; /* NS */
text-align: right;
}
.list-cell-contents {
position: absolute;
top: 0;
left: 0;
+ font: inherit;
font-size: 11px;
font-weight: bold;
+ line-height: 1.15;
color: #fff;
background: #cc5b22;
box-shadow:
@@ -1246,12 +1701,21 @@ button::-moz-focus-inner {
inset -1px -1px 2px rgba(255, 255, 255, .4);
border: 1px solid #fff;
border-radius: 4px;
- -moz-box-sizing: border-box;
box-sizing: border-box;
white-space: pre-wrap;
word-wrap: break-word;
padding: 2px 4px 5px;
/*padding: 3px 4px 4px;*/
+ resize: none;
+ outline: 0;
+ margin: 0;
+ cursor: text;
+ overflow: hidden;
+ text-rendering: geometricPrecision;
+}
+.list-cell-contents:focus {
+ background: rgb(245, 188, 157);
+ color: #000;
}
.list-cell-metrics {
position: fixed;
diff --git a/assets/speakericon.png b/assets/speakericon.png
new file mode 100644
index 0000000..edb99c3
Binary files /dev/null and b/assets/speakericon.png differ
diff --git a/index.html b/index.html
old mode 100644
new mode 100755
index 61678e2..b645a3d
--- a/index.html
+++ b/index.html
@@ -1,15 +1,22 @@
-
-
-
-
-
-
Pixie
-
-
-
+
+
+
+
+
+
+
+ Pixie
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/pixie/.jshintrc b/lib/pixie/.jshintrc
new file mode 100644
index 0000000..2d33220
--- /dev/null
+++ b/lib/pixie/.jshintrc
@@ -0,0 +1,26 @@
+{
+ "eqeqeq": true,
+ "strict": true,
+ "forin": true,
+ "funcscope": true,
+ "latedef": true,
+ "noarg": true,
+ "nonbsp": true,
+ "unused": "vars",
+
+ "shadow": true,
+ "eqnull": true,
+ "lastsemic": true,
+ "validthis": true,
+ "sub": true,
+ "boss": true,
+ "supernew": true,
+ "newcap": false,
+
+ "undef": true,
+ "browser": true,
+ "devel": true,
+ "globals": {"JSZip": false, "Visual": false, "chrome": false, "innerWidth": false, "innerHeight": false},
+
+ "-W008": true // A leading decimal point can be confused with a dot: '…'.
+}
diff --git a/background.js b/lib/pixie/background.js
similarity index 100%
rename from background.js
rename to lib/pixie/background.js
diff --git a/pixie.js b/lib/pixie/pixie.js
old mode 100644
new mode 100755
similarity index 57%
rename from pixie.js
rename to lib/pixie/pixie.js
index fd34647..b2b68b7
--- a/pixie.js
+++ b/lib/pixie/pixie.js
@@ -1,6 +1,9 @@
(function() {
'use strict';
+ PIXI.dontSayHello = true;
+ var audio;
+ var imageSrc;
var vis = Visual({
strings: {
'_mouse_': 'mouse-pointer',
@@ -13,255 +16,254 @@
// return '\u2023' + (vis.options.strings[key] || key);
// },
categories: {
- undefined: ["Undefined", '#d42828'],
- 1: ["Motion", '#4a6cd4'],
- 2: ["Looks", '#8a55d7'],
- 3: ["Sound", '#bb42c3'],
- 4: ["Pen", '#0e9a6c'], // Scratch 1.4: #009870
- 5: ["Events", '#c88330'],
- 6: ["Control", '#e1a91a'],
- 7: ["Sensing", '#2ca5e2'],
- 8: ["Operators", '#5cb712'],
- 9: ["Data", '#ee7d16'], // Scratch 1.4: #f3761d
- 10: ["More Blocks", '#632d99'], // #531e99
- 11: ["Parameter", '#5947b1'],
- 12: ["List", '#cc5b22'], // Scratch 1.4: #d94d11
- 20: ["Extension", '#4b4a60'] // #72228c / #672d79
+ undefined: ['Undefined', '#d42828'],
+ 1: ['Motion', '#4a6cd4'],
+ 2: ['Looks', '#8a55d7'],
+ 3: ['Sound', '#bb42c3'],
+ 4: ['Pen', '#0e9a6c'], // Scratch 1.4: #009870
+ 5: ['Events', '#c88330'],
+ 6: ['Control', '#e1a91a'],
+ 7: ['Sensing', '#2ca5e2'],
+ 8: ['Operators', '#5cb712'],
+ 9: ['Data', '#ee7d16'], // Scratch 1.4: #f3761d
+ 10: ['More Blocks', '#632d99'], // #531e99
+ 11: ['Parameter', '#5947b1'],
+ 12: ['List', '#cc5b22'], // Scratch 1.4: #d94d11
+ 20: ['Extension', '#4b4a60'] // #72228c / #672d79
},
blocks: {
// motion
- "forward:": ["c", "move %n steps", 1, 10],
- "turnRight:": ["c", "turn @turnRight %n degrees", 1, 15],
- "turnLeft:": ["c", "turn @turnLeft %n degrees", 1, 15],
+ 'forward:': ['c', 'move %n steps', 1, 10],
+ 'turnRight:': ['c', 'turn @turnRight %n degrees', 1, 15],
+ 'turnLeft:': ['c', 'turn @turnLeft %n degrees', 1, 15],
- "heading:": ["c", "point in direction %d.direction", 1, 90],
- "pointTowards:": ["c", "point towards %m.spriteOrMouse", 1, ""],
+ 'heading:': ['c', 'point in direction %d.direction', 1, 90],
+ 'pointTowards:': ['c', 'point towards %m.spriteOrMouse', 1, ''],
- "gotoX:y:": ["c", "go to x:%n y:%n", 1, 0, 0],
- "gotoSpriteOrMouse:": ["c", "go to %m.spriteOrMouse", 1, "_mouse_"],
- "glideSecs:toX:y:elapsed:from:": ["c", "glide %n secs to x:%n y:%n", 1, 1, 0, 0],
+ 'gotoX:y:': ['c', 'go to x:%n y:%n', 1, 0, 0],
+ 'gotoSpriteOrMouse:': ['c', 'go to %m.spriteOrMouse', 1, '_mouse_'],
+ 'glideSecs:toX:y:elapsed:from:': ['c', 'glide %n secs to x:%n y:%n', 1, 1, 0, 0],
- "changeXposBy:": ["c", "change x by %n", 1, 10],
- "xpos:": ["c", "set x to %n", 1, 0],
- "changeYposBy:": ["c", "change y by %n", 1, 10],
- "ypos:": ["c", "set y to %n", 1, 0],
+ 'changeXposBy:': ['c', 'change x by %n', 1, 10],
+ 'xpos:': ['c', 'set x to %n', 1, 0],
+ 'changeYposBy:': ['c', 'change y by %n', 1, 10],
+ 'ypos:': ['c', 'set y to %n', 1, 0],
- "bounceOffEdge": ["c", "if on edge, bounce", 1],
+ 'bounceOffEdge': ['c', 'if on edge, bounce', 1],
+ /*'doIf xpos = "240"| xpos = "-240" | ypos = "180" ypos = "-180" heading "0" - heading': ['c', 'if on edge, bounce', 1],*/
+ 'setRotationStyle': ['c', 'set rotation style %m.rotationStyle', 1, 'left-right'],
- "setRotationStyle": ["c", "set rotation style %m.rotationStyle", 1, "left-right"],
-
- "xpos": ["r", "x position", 1],
- "ypos": ["r", "y position", 1],
- "heading": ["r", "direction", 1],
+ 'xpos': ['r', 'x position', 1],
+ 'ypos': ['r', 'y position', 1],
+ 'heading': ['r', 'direction', 1],
// looks
- "say:duration:elapsed:from:": ["c", "say %s for %n secs", 2, "Hello!", 2],
- "say:": ["c", "say %s", 2, "Hello!"],
- "think:duration:elapsed:from:": ["c", "think %s for %n secs", 2, "Hmm...", 2],
- "think:": ["c", "think %s", 2, "Hmm..."],
+ 'say:duration:elapsed:from:': ['c', 'say %s for %n secs', 2, 'Hello!', 2],
+ 'say:': ['c', 'say %s', 2, 'Hello!'],
+ 'think:duration:elapsed:from:': ['c', 'think %s for %n secs', 2, 'Hmm...', 2],
+ 'think:': ['c', 'think %s', 2, 'Hmm...'],
- "show": ["c", "show", 2],
- "hide": ["c", "hide", 2],
+ 'show': ['c', 'show', 2],
+ 'hide': ['c', 'hide', 2],
- "lookLike:": ["c", "switch costume to %m.costume", 2, "costume1"],
- "nextCostume": ["c", "next costume", 2],
- "startScene": ["c", "switch backdrop to %m.backdrop", 2, "backdrop1"],
+ 'lookLike:': ['c', 'switch costume to %m.costume', 2, 'costume1'],
+ 'nextCostume': ['c', 'next costume', 2],
+ 'startScene': ['c', 'switch backdrop to %m.backdrop', 2, 'backdrop1'],
- "changeGraphicEffect:by:": ["c", "change %m.effect effect by %n", 2, "color", 25],
- "setGraphicEffect:to:": ["c", "set %m.effect effect to %n", 2, "color", 0],
- "filterReset": ["c", "clear graphic effects", 2],
+ 'changeGraphicEffect:by:': ['c', 'change %m.effect effect by %n', 2, 'color', 25],
+ 'setGraphicEffect:to:': ['c', 'set %m.effect effect to %n', 2, 'color', 0],
+ 'filterReset': ['c', 'clear graphic effects', 2],
- "changeSizeBy:": ["c", "change size by %n", 2, 10],
- "setSizeTo:": ["c", "set size to %n%", 2, 100],
+ 'changeSizeBy:': ['c', 'change size by %n', 2, 10],
+ 'setSizeTo:': ['c', 'set size to %n%', 2, 100],
- "comeToFront": ["c", "go to front", 2],
- "goBackByLayers:": ["c", "go back %n layers", 2, 1],
+ 'comeToFront': ['c', 'go to front', 2],
+ 'goBackByLayers:': ['c', 'go back %n layers', 2, 1],
- "costumeIndex": ["r", "costume #", 2],
- "sceneName": ["r", "backdrop name", 2],
- "scale": ["r", "size", 2],
+ 'costumeIndex': ['r', 'costume #', 2],
+ 'sceneName': ['r', 'backdrop name', 2],
+ 'scale': ['r', 'size', 2],
// stage looks
- "startSceneAndWait": ["c", "switch backdrop to %m.backdrop and wait", 2, "backdrop1"],
- "nextScene": ["c", "next backdrop", 2],
+ 'startSceneAndWait': ['c', 'switch backdrop to %m.backdrop and wait', 2, 'backdrop1'],
+ 'nextScene': ['c', 'next backdrop', 2],
- "backgroundIndex": ["r", "backdrop #", 2],
+ 'backgroundIndex': ['r', 'backdrop #', 2],
// sound
- "playSound:": ["c", "play sound %m.sound", 3, "pop"],
- "doPlaySoundAndWait": ["c", "play sound %m.sound until done", 3, "pop"],
- "stopAllSounds": ["c", "stop all sounds", 3],
-
- "playDrum": ["c", "play drum %d.drum for %n beats", 3, 1, 0.25],
- "rest:elapsed:from:": ["c", "rest for %n beats", 3, 0.25],
+ 'playSound:': ['c', 'play sound %m.sound', 3, 'pop'],
+ 'doPlaySoundAndWait': ['c', 'play sound %m.sound until done', 3, 'pop'],
+ 'stopAllSounds': ['c', 'stop all sounds', 3],
- "noteOn:duration:elapsed:from:": ["c", "play note %d.note for %n beats", 3, 60, 0.5],
- "instrument:": ["c", "set instrument to %d.instrument", 3, 1],
+ 'playDrum': ['c', 'play drum %d.drum for %n beats', 3, 1, 0.25],
+ 'rest:elapsed:from:': ['c', 'rest for %n beats', 3, 0.25],
+ 'noteOn:duration:elapsed:from:': ['c', 'play note %d.note for %n beats', 3, 60, 0.5],
+ 'instrument:': ['c', 'set instrument to %d.instrument', 3, 1],
- "changeVolumeBy:": ["c", "change volume by %n", 3, -10],
- "setVolumeTo:": ["c", "set volume to %n%", 3, 100],
- "volume": ["r", "volume", 3],
+ 'changeVolumeBy:': ['c', 'change volume by %n', 3, -10],
+ 'setVolumeTo:': ['c', 'set volume to %n%', 3, 100],
+ 'volume': ['r', 'volume', 3],
- "changeTempoBy:": ["c", "change tempo by %n", 3, 20],
- "setTempoTo:": ["c", "set tempo to %n bpm", 3, 60],
- "tempo": ["r", "tempo", 3],
+ 'changeTempoBy:': ['c', 'change tempo by %n', 3, 20],
+ 'setTempoTo:': ['c', 'set tempo to %n bpm', 3, 60],
+ 'tempo': ['r', 'tempo', 3],
// pen
- "clearPenTrails": ["c", "clear", 4],
+ 'clearPenTrails': ['c', 'clear', 4],
- "stampCostume": ["c", "stamp", 4],
+ 'stampCostume': ['c', 'stamp', 4],
- "putPenDown": ["c", "pen down", 4],
- "putPenUp": ["c", "pen up", 4],
+ 'putPenDown': ['c', 'pen down', 4],
+ 'putPenUp': ['c', 'pen up', 4],
- "penColor:": ["c", "set pen color to %c", 4],
- "changePenHueBy:": ["c", "change pen color by %n", 4, 10],
- "setPenHueTo:": ["c", "set pen color to %n", 4, 0],
+ 'penColor:': ['c', 'set pen color to %c', 4],
+ 'changePenHueBy:': ['c', 'change pen color by %n', 4, 10],
+ 'setPenHueTo:': ['c', 'set pen color to %n', 4, 0],
- "changePenShadeBy:": ["c", "change pen shade by %n", 4, 10],
- "setPenShadeTo:": ["c", "set pen shade to %n", 4, 50],
+ 'changePenShadeBy:': ['c', 'change pen shade by %n', 4, 10],
+ 'setPenShadeTo:': ['c', 'set pen shade to %n', 4, 50],
- "changePenSizeBy:": ["c", "change pen size by %n", 4, 1],
- "penSize:": ["c", "set pen size to %n", 4, 1],
+ 'changePenSizeBy:': ['c', 'change pen size by %n', 4, 1],
+ 'penSize:': ['c', 'set pen size to %n', 4, 1],
// triggers
- "whenGreenFlag": ["h", "when @greenFlag clicked", 5],
- "whenKeyPressed": ["h", "when %m.key key pressed", 5, "space"],
- "whenClicked": ["h", "when this sprite clicked", 5],
- "whenSceneStarts": ["h", "when backdrop switches to %m.backdrop", 5, "backdrop1"],
+ 'whenGreenFlag': ['h', 'when @greenFlag clicked', 5],
+ 'whenKeyPressed': ['h', 'when %m.key key pressed', 5, 'space'],
+ 'whenClicked': ['h', 'when this sprite clicked', 5],
+ 'whenSceneStarts': ['h', 'when backdrop switches to %m.backdrop', 5, 'backdrop1'],
- "whenSensorGreaterThan": ["h", "when %m.triggerSensor > %n", 5, "loudness", 10],
+ 'whenSensorGreaterThan': ['h', 'when %m.triggerSensor > %n', 5, 'loudness', 10],
- "whenIReceive": ["h", "when I receive %m.broadcast", 5, "message1"],
- "broadcast:": ["c", "broadcast %m.broadcast", 5, "message1"],
- "doBroadcastAndWait": ["c", "broadcast %m.broadcast and wait", 5, "message1"],
+ 'whenIReceive': ['h', 'when I receive %m.broadcast', 5, 'message1'],
+ 'broadcast:': ['c', 'broadcast %m.broadcast', 5, 'message1'],
+ 'doBroadcastAndWait': ['c', 'broadcast %m.broadcast and wait', 5, 'message1'],
// control - sprite
- "wait:elapsed:from:": ["c", "wait %n secs", 6, 1],
+ 'wait:elapsed:from:': ['c', 'wait %n secs', 6, 1],
- "doRepeat": ["c", "@loop repeat %n %t", 6, 10],
- "doForever": ["f", "@loop forever %t", 6],
+ 'doRepeat': ['c', '@loop repeat %n %t', 6, 10],
+ 'doForever': ['f', '@loop forever %t', 6],
- "doIf": ["c", "if %b then %t", 6],
- "doIfElse": ["c", "if %b then %t else %t", 6],
- "doWaitUntil": ["c", "wait until %b", 6],
- "doUntil": ["c", "@loop repeat until %b %t", 6],
+ 'doIf': ['c', 'if %b then %t', 6],
+ 'doIfElse': ['c', 'if %b then %t else %t', 6],
+ 'doWaitUntil': ['c', 'wait until %b', 6],
+ 'doUntil': ['c', '@loop repeat until %b %t', 6],
- "stopScripts": ["f", "stop %m.stop", 6, "all"],
+ 'stopScripts': ['f', 'stop %m.stop', 6, 'all'],
- "whenCloned": ["h", "when I start as a clone", 6],
- "createCloneOf": ["c", "create clone of %m.spriteOnly", 6, '_myself_'],
- "deleteClone": ["f", "delete this clone", 6],
+ 'whenCloned': ['h', 'when I start as a clone', 6],
+ 'createCloneOf': ['c', 'create clone of %m.spriteOnly', 6, '_myself_'],
+ 'deleteClone': ['f', 'delete this clone', 6],
// sensing
- "touching:": ["b", "touching %m.touching?", 7, ""],
- "touchingColor:": ["b", "touching color %c?", 7],
- "color:sees:": ["b", "color %c is touching %c?", 7],
- "distanceTo:": ["r", "distance to %m.spriteOrMouse", 7, ""],
+ 'touching:': ['b', 'touching %m.touching?', 7, ''],
+ 'touchingColor:': ['b', 'touching color %c?', 7],
+ 'color:sees:': ['b', 'color %c is touching %c?', 7],
+ 'distanceTo:': ['r', 'distance to %m.spriteOrMouse', 7, ''],
- "doAsk": ["c", "ask %s and wait", 7, "What's your name?"],
- "answer": ["r", "answer", 7],
+ 'doAsk': ['c', 'ask %s and wait', 7, "What's your name?"],
+ 'answer': ['r', 'answer', 7],
- "keyPressed:": ["b", "key %m.key pressed?", 7, "space"],
- "mousePressed": ["b", "mouse down?", 7],
- "mouseX": ["r", "mouse x", 7],
- "mouseY": ["r", "mouse y", 7],
+ 'keyPressed:': ['b', 'key %m.key pressed?', 7, 'space'],
+ 'mousePressed': ['b', 'mouse down?', 7],
+ 'mouseX': ['r', 'mouse x', 7],
+ 'mouseY': ['r', 'mouse y', 7],
- "soundLevel": ["r", "loudness", 7],
+ 'soundLevel': ['r', 'loudness', 7],
- "senseVideoMotion": ["r", "video %m.videoMotionType on %m.stageOrThis", 7, "motion", 'this sprite'],
- "setVideoState": ["c", "turn video %m.videoState", 7, "on"],
- "setVideoTransparency": ["c", "set video transparency to %n%", 7, 50],
+ 'senseVideoMotion': ['r', 'video %m.videoMotionType on %m.stageOrThis', 7, 'motion', 'this sprite'],
+ 'setVideoState': ['c', 'turn video %m.videoState', 7, 'on'],
+ 'setVideoTransparency': ['c', 'set video transparency to %n%', 7, 50],
- "timer": ["r", "timer", 7],
- "timerReset": ["c", "reset timer", 7],
+ 'timer': ['r', 'timer', 7],
+ 'timerReset': ['c', 'reset timer', 7],
- "getAttribute:of:": ["r", "%m.attribute of %m.spriteOrStage", 7, 'x position', 'Sprite1'],
+ 'getAttribute:of:': ['r', '%m.attribute of %m.spriteOrStage', 7, 'x position', 'Sprite1'],
- "timeAndDate": ["r", "current %m.timeAndDate", 7, "minute"],
- "timestamp": ["r", "days since 2000", 7],
- "getUserName": ["r", "username", 7],
+ 'timeAndDate': ['r', 'current %m.timeAndDate', 7, 'minute'],
+ 'timestamp': ['r', 'days since 2000', 7],
+ 'getUserName': ['r', 'username', 7],
// operators
- "+": ["r", "%n + %n", 8, "", ""],
- "-": ["r", "%n - %n", 8, "", ""],
- "*": ["r", "%n * %n", 8, "", ""],
- "/": ["r", "%n / %n", 8, "", ""],
+ '+': ['r', '%n + %n', 8, '', ''],
+ '-': ['r', '%n - %n', 8, '', ''],
+ '*': ['r', '%n * %n', 8, '', ''],
+ '/': ['r', '%n / %n', 8, '', ''],
- "randomFrom:to:": ["r", "pick random %n to %n", 8, 1, 10],
+ 'randomFrom:to:': ['r', 'pick random %n to %n', 8, 1, 10],
- "<": ["b", "%s < %s", 8, "", ""],
- "=": ["b", "%s = %s", 8, "", ""],
- ">": ["b", "%s > %s", 8, "", ""],
+ '<': ['b', '%s < %s', 8, '', ''],
+ '=': ['b', '%s = %s', 8, '', ''],
+ '>': ['b', '%s > %s', 8, '', ''],
- "&": ["b", "%b and %b", 8],
- "|": ["b", "%b or %b", 8],
- "not": ["b", "not %b", 8],
+ '&': ['b', '%b and %b', 8],
+ '|': ['b', '%b or %b', 8],
+ 'not': ['b', 'not %b', 8],
- "concatenate:with:": ["r", "join %s %s", 8, "hello ", "world"],
- "letter:of:": ["r", "letter %n of %s", 8, 1, "world"],
- "stringLength:": ["r", "length of %s", 8, "world"],
+ 'concatenate:with:': ['r', 'join %s %s', 8, 'hello ', 'world'],
+ 'letter:of:': ['r', 'letter %n of %s', 8, 1, 'world'],
+ 'stringLength:': ['r', 'length of %s', 8, 'world'],
- "%": ["r", "%n mod %n", 8, "", ""],
- "rounded": ["r", "round %n", 8, ""],
+ '%': ['r', '%n mod %n', 8, '', ''],
+ 'rounded': ['r', 'round %n', 8, ''],
- "computeFunction:of:": ["r", "%m.mathOp of %n", 8, "sqrt", 9],
+ 'computeFunction:of:': ['r', '%m.mathOp of %n', 8, 'sqrt', 9],
// variables
- "readVariable": ["r", "%l", 9, 'variable'],
- "setVar:to:": ["c", "set %m.var to %s", 9, 'variable', 0],
- "changeVar:by:": ["c", "change %m.var by %n", 9, 'variable', 1],
- "showVariable:": ["c", "show variable %m.var", 9, 'variable'],
- "hideVariable:": ["c", "hide variable %m.var", 9, 'variable'],
+ 'readVariable': ['r', '%l', 9, 'variable'],
+ 'setVar:to:': ['c', 'set %m.var to %s', 9, 'variable', 0],
+ 'changeVar:by:': ['c', 'change %m.var by %n', 9, 'variable', 1],
+ 'showVariable:': ['c', 'show variable %m.var', 9, 'variable'],
+ 'hideVariable:': ['c', 'hide variable %m.var', 9, 'variable'],
// lists
- "contentsOfList:": ["r", "%l", 12, 'list'],
- "append:toList:": ["c", "add %s to %m.list", 12, 'thing', 'list'],
+ 'contentsOfList:': ['r', '%l', 12, 'list'],
+ 'append:toList:': ['c', 'add %s to %m.list', 12, 'thing', 'list'],
- "deleteLine:ofList:": ["c", "delete %d.listDeleteItem of %m.list", 12, '1', 'list'],
- "insert:at:ofList:": ["c", "insert %s at %d.listItem of %m.list", 12, 'thing', '1', 'list'],
- "setLine:ofList:to:": ["c", "replace item %d.listItem of %m.list with %s", 12, '1', 'list', 'thing'],
+ 'deleteLine:ofList:': ['c', 'delete %d.listDeleteItem of %m.list', 12, '1', 'list'],
+ 'insert:at:ofList:': ['c', 'insert %s at %d.listItem of %m.list', 12, 'thing', '1', 'list'],
+ 'setLine:ofList:to:': ['c', 'replace item %d.listItem of %m.list with %s', 12, '1', 'list', 'thing'],
- "getLine:ofList:": ["r", "item %d.listItem of %m.list", 12, '1', 'list'],
- "lineCountOfList:": ["r", "length of %m.list", 12, 'list'],
- "list:contains:": ["b", "%m.list contains %s", 12, 'list', 'thing'],
+ 'getLine:ofList:': ['r', 'item %d.listItem of %m.list', 12, '1', 'list'],
+ 'lineCountOfList:': ['r', 'length of %m.list', 12, 'list'],
+ 'list:contains:': ['b', '%m.list contains %s?', 12, 'list', 'thing'],
- "showList:": ["c", "show list %m.list", 12, 'list'],
- "hideList:": ["c", "hide list %m.list", 12, 'list'],
+ 'showList:': ['c', 'show list %m.list', 12, 'list'],
+ 'hideList:': ['c', 'hide list %m.list', 12, 'list'],
// obsolete blocks from Scratch 1.4 that may be used in older projects
- "drum:duration:elapsed:from:": ["c", "play drum %n for %n beats", 98, 1, 0.25], // Scratch 1.4 MIDI drum
- "midiInstrument:": ["c", "set instrument to %n", 98, 1],
- "isLoud": ["b", "loud?", 98],
+ 'drum:duration:elapsed:from:': ['c', 'play drum %n for %n beats', 98, 1, 0.25], // Scratch 1.4 MIDI drum
+ 'midiInstrument:': ['c', 'set instrument to %n', 98, 1],
+ 'isLoud': ['b', 'loud?', 98],
// obsolete blocks from Scratch 1.4 that are converted to new forms (so should never appear):
- "abs": ["r", "abs %n", 98],
- "sqrt": ["r", "sqrt %n", 98],
- "doReturn": ["f", "stop script", 98],
- "stopAll": ["f", "stop all", 98],
- "showBackground:": ["c", "switch to background %m.costume", 98, "backdrop1"],
- "nextBackground": ["c", "next background", 98],
- "doForeverIf": ["f", "forever if %b %t", 98],
+ 'abs': ['r', 'abs %n', 98],
+ 'sqrt': ['r', 'sqrt %n', 98],
+ 'doReturn': ['f', 'stop script', 98],
+ 'stopAll': ['f', 'stop all', 98],
+ 'showBackground:': ['c', 'switch to background %m.costume', 98, 'backdrop1'],
+ 'nextBackground': ['c', 'next background', 98],
+ 'doForeverIf': ['f', 'forever if %b %t', 98],
// testing and experimental control prims
- "COUNT": ["r", "counter", 99],
- "CLR_COUNT": ["c", "clear counter", 99],
- "INCR_COUNT": ["c", "incr counter", 99],
- "doForLoop": ["c", "for each %m.varName in %s %t", 99, "v", 10],
- "doWhile": ["c", "while %b %t", 99],
- "warpSpeed": ["c", "all at once %t", 99],
+ 'COUNT': ['r', 'counter', 99],
+ 'CLR_COUNT': ['c', 'clear counter', 99],
+ 'INCR_COUNT': ['c', 'incr counter', 99],
+ 'doForLoop': ['c', 'for each %m.varName in %s %t', 99, 'v', 10],
+ 'doWhile': ['c', 'while %b %t', 99],
+ 'warpSpeed': ['c', 'all at once %t', 99],
// stage motion (scrolling)
- "scrollRight": ["c", "scroll right %n", 99, 10],
- "scrollUp": ["c", "scroll up %n", 99, 10],
- "scrollAlign": ["c", "align scene %m.scrollAlign", 99, 'bottom-left'],
- "xScroll": ["r", "x scroll", 99],
- "yScroll": ["r", "y scroll", 99],
+ 'scrollRight': ['c', 'scroll right %n', 99, 10],
+ 'scrollUp': ['c', 'scroll up %n', 99, 10],
+ 'scrollAlign': ['c', 'align scene %m.scrollAlign', 99, 'bottom-left'],
+ 'xScroll': ['r', 'x scroll', 99],
+ 'yScroll': ['r', 'y scroll', 99],
// other obsolete blocks from alpha/beta
- "hideAll": ["c", "hide all sprites", 99],
- "getUserId": ["r", "user id", 99],
+ 'hideAll': ['c', 'hide all sprites', 99],
+ 'getUserId': ['r', 'user id', 99],
},
menus: {
direction: function() {
@@ -270,7 +272,7 @@
[-90, 'left'],
[0, 'up'],
[180, 'down']].forEach(function(item) {
- m.add(['('+item[0]+') '+T(item[1]), item[0]]);
+ m.add(['('+item[0]+') '+_(item[1]), item[0]]);
});
return m;
},
@@ -303,10 +305,10 @@
return m;
},
spriteOrMouse: function(arg) {
- return spriteMenu(arg, '_mouse_');
+ return spriteMenu(arg, false, '_mouse_');
},
touching: function(arg) {
- return spriteMenu(arg, '_mouse_', '_edge_');
+ return spriteMenu(arg, false, '_mouse_', '_edge_');
},
rotationStyle: function() {
return new Menu('left-right', 'all around', "don't rotate").translate();
@@ -321,14 +323,13 @@
return new Menu().addAll(arg.app.editor.stage.costumes.map(getName)).addLine().addTranslated('next backdrop').addTranslated('previous backdrop');
},
sound: function(arg) {
- return new Menu().addAll(arg.app.editor.selectedSprite.sounds.map(getName)).add(Menu.line).add([T('record...'), function() {
- // TODO record a sound
- }]);
+ //TODO this is taking the sound information from the SoundsPanel rather than the sprite in question
+ return new Menu().addLine().addTranslated('miaow').addTranslated('purring').addTranslated('siamese').addTranslated('yowl').addAll(arg.app.editor.tabPanel.soundsPanel.icons.map(getName)).add(Menu.line).add([_('record...'), function() {}]);
},
broadcast: function(arg) {
- return new Menu().addAll(arg.app.editor.broadcastNames).add(Menu.line).add([T('new message...'), function() {
+ return new Menu().addAll(arg.app.editor.broadcastNames).add(Menu.line).add([_('new message...'), function() {
var arg = this;
- Dialog.prompt(T('New Message'), T('Message name:'), function(value) { // NS
+ Dialog.prompt(_('New Message'), _('Message name:'), function(value) { // NS
if (value) arg.value = value;
}).show(arg.app.editor);
}]);
@@ -338,7 +339,7 @@
},
stop: function(arg) {
function item(value, type) {
- return [T(value), function() {
+ return [_(value), function() {
arg.value = value;
if (arg.parent) arg.parent.type = type;
}];
@@ -349,7 +350,7 @@
item('other scripts in sprite', 'c'));
},
spriteOnly: function(arg) {
- return spriteMenu(arg, '_myself_');
+ return spriteMenu(arg, true, '_myself_');
},
videoMotionType: function() {
return new Menu('motion', 'direction').translate();
@@ -361,7 +362,7 @@
return new Menu('off', 'on', 'on-flipped').translate();
},
spriteOrStage: function(arg) {
- return spriteMenu(arg, '_stage_');
+ return spriteMenu(arg, false, '_stage_');
},
attribute: function(arg) {
var stage = arg.app.editor.stage;
@@ -377,10 +378,10 @@
return new Menu('abs', 'floor', 'ceiling', 'sqrt', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'ln', 'log', 'e ^', '10 ^').translate();
},
drum: function() {
- return new Menu().addAll(['Snare Drum', 'Bass Drum', 'Side Stick', 'Crash Cymbal', 'Open Hi-Hat', 'Closed Hi-Hat', 'Tambourine', 'Hand Clap', 'Claves', 'Wood Block', 'Cowbell', 'Triangle', 'Bongo', 'Conga', 'Cabassa', 'Guiro', 'Vibraslap', 'Open Culca'].map(function(x, i) {return ['('+(i + 1)+') ' + T(x), i + 1]}));
+ return new Menu().addAll(['Snare Drum', 'Bass Drum', 'Side Stick', 'Crash Cymbal', 'Open Hi-Hat', 'Closed Hi-Hat', 'Tambourine', 'Hand Clap', 'Claves', 'Wood Block', 'Cowbell', 'Triangle', 'Bongo', 'Conga', 'Cabassa', 'Guiro', 'Vibraslap', 'Open Culca'].map(function(x, i) {return ['('+(i + 1)+') ' + _(x), i + 1]}));
},
instrument: function() {
- return new Menu().addAll(['Piano', 'Electric Piano', 'Organ', 'Guitar', 'Electric Guitar', 'Bass', 'Pizzicato', 'Cello', 'Trombone', 'Clarinet', 'Saxophone', 'Flute', 'Wooden Flute', 'Bassoon', 'Choir', 'Vibraphone', 'Music Box', 'Steel Drum', 'Marimba', 'Synth Lead', 'Synth Pad'].map(function(x, i) {return ['('+(i + 1)+') ' + T(x), i + 1]}));
+ return new Menu().addAll(['Piano', 'Electric Piano', 'Organ', 'Guitar', 'Electric Guitar', 'Bass', 'Pizzicato', 'Cello', 'Trombone', 'Clarinet', 'Saxophone', 'Flute', 'Wooden Flute', 'Bassoon', 'Choir', 'Vibraphone', 'Music Box', 'Steel Drum', 'Marimba', 'Synth Lead', 'Synth Pad'].map(function(x, i) {return ['('+(i + 1)+') ' + _(x), i + 1]}));
},
note: function() {
return new Menu().addAll([
@@ -398,7 +399,7 @@
[67, 'G'],
[69, 'A'],
[71, 'B'],
- [72, 'High C']].map(function(i) {return ['('+i[0]+') '+T(i[1]), i[0]]}));
+ [72, 'High C']].map(function(i) {return ['('+i[0]+') '+_(i[1]), i[0]]}));
},
listItem: function() {
return new Menu(1).addTranslated('last').addTranslated('random');
@@ -412,236 +413,236 @@
var palettes = {
1: [
// motion
- {if: "stage", then: [
- {text: "Stage selected:"},
- {text: "No motion blocks"}
+ {if: 'stage', then: [
+ {text: 'Stage selected:'},
+ {text: 'No motion blocks'}
], else: [
- "forward:",
- "turnRight:",
- "turnLeft:",
- "---",
- "heading:",
- "pointTowards:",
- "---",
- ["gotoX:y:", {current: 'x'}, {current: 'y'}],
- "gotoSpriteOrMouse:",
- ["glideSecs:toX:y:elapsed:from:", 1, {current: 'x'}, {current: 'y'}],
- "---",
- "changeXposBy:",
- "xpos:",
- "changeYposBy:",
- "ypos:",
- "---",
- "bounceOffEdge",
- "--",
- "setRotationStyle",
- "---",
- {watcher: "xpos"},
- {watcher: "ypos"},
- {watcher: "heading"}
+ 'forward:',
+ 'turnRight:',
+ 'turnLeft:',
+ '---',
+ 'heading:',
+ 'pointTowards:',
+ '---',
+ ['gotoX:y:', {current: 'x'}, {current: 'y'}],
+ 'gotoSpriteOrMouse:',
+ ['glideSecs:toX:y:elapsed:from:', 1, {current: 'x'}, {current: 'y'}],
+ '---',
+ 'changeXposBy:',
+ 'xpos:',
+ 'changeYposBy:',
+ 'ypos:',
+ '---',
+ 'bounceOffEdge',
+ '--',
+ 'setRotationStyle',
+ '---',
+ {watcher: 'xpos'},
+ {watcher: 'ypos'},
+ {watcher: 'heading'}
]}
],
2: [
// looks
- {if: "sprite", then: [
- "say:duration:elapsed:from:",
- "say:",
- "think:duration:elapsed:from:",
- "think:",
- "--",
- "show",
- "hide",
- "--",
- ["lookLike:", {first: 'costume'}],
- "nextCostume"
+ {if: 'sprite', then: [
+ 'say:duration:elapsed:from:',
+ 'say:',
+ 'think:duration:elapsed:from:',
+ 'think:',
+ '--',
+ 'show',
+ 'hide',
+ '--',
+ ['lookLike:', {first: 'costume'}],
+ 'nextCostume'
]},
- ["startScene", {first: 'backdrop'}],
- {if: "stage", then: [
- ["startSceneAndWait", {first: 'backdrop'}],
- "nextScene"
+ ['startScene', {first: 'backdrop'}],
+ {if: 'stage', then: [
+ ['startSceneAndWait', {first: 'backdrop'}],
+ 'nextScene'
]},
- "--",
- "changeGraphicEffect:by:",
- "setGraphicEffect:to:",
- "filterReset",
- "--",
- {if: "sprite", then: [
- "changeSizeBy:",
- "setSizeTo:",
- "--",
- "comeToFront",
- "goBackByLayers:",
- "--",
- {watcher: "costumeIndex"}
+ '--',
+ 'changeGraphicEffect:by:',
+ 'setGraphicEffect:to:',
+ 'filterReset',
+ '--',
+ {if: 'sprite', then: [
+ 'changeSizeBy:',
+ 'setSizeTo:',
+ '--',
+ 'comeToFront',
+ 'goBackByLayers:',
+ '--',
+ {watcher: 'costumeIndex'}
]},
- {watcher: "sceneName"},
- {if: "stage", then: [{watcher: "backgroundIndex"}], else: [{watcher: "scale"}]}
+ {watcher: 'sceneName'},
+ {if: 'stage', then: [{watcher: 'backgroundIndex'}], else: [{watcher: 'scale'}]}
],
3: [
// sound
- ["playSound:", {first: 'sound'}],
- ["doPlaySoundAndWait", {first: 'sound'}],
- "stopAllSounds",
- "--",
- "playDrum",
- "rest:elapsed:from:",
- "--",
- "noteOn:duration:elapsed:from:",
- "instrument:",
- "--",
- "changeVolumeBy:",
- "setVolumeTo:",
- {watcher: "volume"},
- "--",
- "changeTempoBy:",
- "setTempoTo:",
- {watcher: "tempo"}
+ ['playSound:', {first: 'sound'}],
+ ['doPlaySoundAndWait', {first: 'sound'}],
+ 'stopAllSounds',
+ '--',
+ 'playDrum',
+ 'rest:elapsed:from:',
+ '--',
+ 'noteOn:duration:elapsed:from:',
+ 'instrument:',
+ '--',
+ 'changeVolumeBy:',
+ 'setVolumeTo:',
+ {watcher: 'volume'},
+ '--',
+ 'changeTempoBy:',
+ 'setTempoTo:',
+ {watcher: 'tempo'}
],
4: [
// pen
- "clearPenTrails",
- {if: "sprite", then: [
- "--",
- "stampCostume",
- "--",
- "putPenDown",
- "putPenUp",
- "--",
- "penColor:",
- "changePenHueBy:",
- "setPenHueTo:",
- "--",
- "changePenShadeBy:",
- "setPenShadeTo:",
- "--",
- "changePenSizeBy:",
- "penSize:"
+ 'clearPenTrails',
+ {if: 'sprite', then: [
+ '--',
+ 'stampCostume',
+ '--',
+ 'putPenDown',
+ 'putPenUp',
+ '--',
+ 'penColor:',
+ 'changePenHueBy:',
+ 'setPenHueTo:',
+ '--',
+ 'changePenShadeBy:',
+ 'setPenShadeTo:',
+ '--',
+ 'changePenSizeBy:',
+ 'penSize:'
]}
],
5: [
// triggers
- "whenGreenFlag",
- "whenKeyPressed",
- "whenClicked",
- ["whenSceneStarts", {first: 'backdrop'}],
- "---",
- "whenSensorGreaterThan",
- "---",
- "whenIReceive",
- "broadcast:",
- "doBroadcastAndWait",
+ 'whenGreenFlag',
+ 'whenKeyPressed',
+ 'whenClicked',
+ ['whenSceneStarts', {first: 'backdrop'}],
+ '---',
+ 'whenSensorGreaterThan',
+ '---',
+ 'whenIReceive',
+ 'broadcast:',
+ 'doBroadcastAndWait',
],
6: [
// control - sprite
- "wait:elapsed:from:",
- "--",
- "doRepeat",
- "doForever",
- "--",
- "doIf",
- "doIfElse",
- "doWaitUntil",
- "doUntil",
- "--",
- "stopScripts",
- "--",
- {if: "sprite", then: ["whenCloned"]},
- "createCloneOf",
- {if: "sprite", then: ["deleteClone"]}
+ 'wait:elapsed:from:',
+ '--',
+ 'doRepeat',
+ 'doForever',
+ '--',
+ 'doIf',
+ 'doIfElse',
+ 'doWaitUntil',
+ 'doUntil',
+ '--',
+ 'stopScripts',
+ '--',
+ {if: 'sprite', then: ['whenCloned']},
+ 'createCloneOf',
+ {if: 'sprite', then: ['deleteClone']}
],
7: [
// sensing
- {if: "sprite", then: [
- "touching:",
- "touchingColor:",
- "color:sees:",
- "distanceTo:",
- "--",
+ {if: 'sprite', then: [
+ 'touching:',
+ 'touchingColor:',
+ 'color:sees:',
+ 'distanceTo:',
+ '--',
]},
- "doAsk",
- {watcher: "answer"},
- "--",
- "keyPressed:",
- "mousePressed",
- "mouseX",
- "mouseY",
- "--",
- {watcher: "soundLevel"},
- "--",
- {watcher: "senseVideoMotion"},
- "setVideoState",
- "setVideoTransparency",
- "--",
- {watcher: "timer"},
- "timerReset",
- "--",
- ["getAttribute:of:", {first: 'attribute'}, {first: 'sprite'}],
- "--",
- {watcher: "timeAndDate"},
- "timestamp",
- "getUserName"
+ 'doAsk',
+ {watcher: 'answer'},
+ '--',
+ 'keyPressed:',
+ 'mousePressed',
+ 'mouseX',
+ 'mouseY',
+ '--',
+ {watcher: 'soundLevel'},
+ '--',
+ {watcher: 'senseVideoMotion'},
+ 'setVideoState',
+ 'setVideoTransparency',
+ '--',
+ {watcher: 'timer'},
+ 'timerReset',
+ '--',
+ ['getAttribute:of:', {first: 'attribute'}, {first: 'otherSprite'}],
+ '--',
+ {watcher: 'timeAndDate'},
+ 'timestamp',
+ 'getUserName'
],
8: [
// operators
- "+",
- "-",
- "*",
- "/",
- "--",
- "randomFrom:to:",
- "--",
- "<",
- "=",
- ">",
- "--",
- "&",
- "|",
- "not",
- "--",
- "concatenate:with:",
- "letter:of:",
- "stringLength:",
- "--",
- "%",
- "rounded",
- "--",
- "computeFunction:of:"
+ '+',
+ '-',
+ '*',
+ '/',
+ '--',
+ 'randomFrom:to:',
+ '--',
+ '<',
+ '=',
+ '>',
+ '--',
+ '&',
+ '|',
+ 'not',
+ '--',
+ 'concatenate:with:',
+ 'letter:of:',
+ 'stringLength:',
+ '--',
+ '%',
+ 'rounded',
+ '--',
+ 'computeFunction:of:'
],
9: [
// variables
- {text: "Make a Variable", action: "newVariable"},
- {if: "variables", then: [
- {all: "variables"},
- "--",
- ["setVar:to:", {first: 'var'}, '0'],
- ["changeVar:by:", {first: 'var'}, 1],
- ["showVariable:", {first: 'var'}],
- ["hideVariable:", {first: 'var'}],
- "--"
+ {text: 'Make a Variable', action: 'newVariable'},
+ {if: 'variables', then: [
+ {all: 'variables'},
+ '--',
+ ['setVar:to:', {first: 'var'}, '0'],
+ ['changeVar:by:', {first: 'var'}, 1],
+ ['showVariable:', {first: 'var'}],
+ ['hideVariable:', {first: 'var'}],
+ '--'
]},
// lists
- {text: "Make a List", action: "newList"},
- {if: "lists", then: [
- {all: "lists"},
- "--",
- ["append:toList:", "thing", {first: 'list'}],
- "--",
- ["deleteLine:ofList:", 1, {first: 'list'}],
- ["insert:at:ofList:", "thing", 1, {first: 'list'}],
- ["setLine:ofList:to:", 1, {first: 'list'}, "thing"],
- "--",
- ["getLine:ofList:", 1, {first: 'list'}],
- ["lineCountOfList:", {first: 'list'}],
- ["list:contains:", {first: 'list'}, "thing"],
- "--",
- ["showList:", {first: 'list'}],
- ["hideList:", {first: 'list'}]
+ {text: 'Make a List', action: 'newList'},
+ {if: 'lists', then: [
+ {all: 'lists'},
+ '--',
+ ['append:toList:', 'thing', {first: 'list'}],
+ '--',
+ ['deleteLine:ofList:', 1, {first: 'list'}],
+ ['insert:at:ofList:', 'thing', 1, {first: 'list'}],
+ ['setLine:ofList:to:', 1, {first: 'list'}, 'thing'],
+ '--',
+ ['getLine:ofList:', 1, {first: 'list'}],
+ ['lineCountOfList:', {first: 'list'}],
+ ['list:contains:', {first: 'list'}, 'thing'],
+ '--',
+ ['showList:', {first: 'list'}],
+ ['hideList:', {first: 'list'}]
]}
],
10: [
- {text: "Make a Block", action: "newBlock"},
- {text: "Add an Extension", action: "addExtension"},
+ {text: 'Make a Block', action: 'newBlock'},
+ {text: 'Add an Extension', action: 'addExtension'},
]
};
@@ -800,10 +801,10 @@
var Icon = vis.Icon;
var Menu = vis.Menu;
- function T(key, values) {
+ function _(key, values) {
var text = vis.getText(key);
return values ? vis.util.format(text, values) : text;
- };
+ }
var menusThatAcceptReporters = ['broadcast', 'costume', 'backdrop', 'scene', 'sound', 'spriteOnly', 'spriteOrMouse', 'spriteOrStage', 'touching'];
Arg.prototype.acceptsDropOf = function(b) {
@@ -879,7 +880,7 @@
m.action = function(value) {
this.name = value;
this.infoSpec = vis.getBlock(value)[1];
- this.spec = T(this.infoSpec);
+ this.spec = _(this.infoSpec);
this.fn = null;
}.bind(this);
var gs = this.groups;
@@ -888,7 +889,7 @@
if (g.indexOf(this.name) !== -1) {
for (var j = 0, l = g.length; j < l; j++) {
var b = vis.getBlock(g[j]);
- m.add([T(b[1]).replace(/%[\w.]+/g, '').trim(), b[2]]);
+ m.add([_(b[1]).replace(/%[\w.]+/g, '').trim(), b[2]]);
}
}
}
@@ -898,7 +899,7 @@
Block.prototype.help = function() {
// TODO
- Dialog.alert(T('Help'), T('Help is not available yet.')).show(this.app.editor);
+ Dialog.alert(_('Help'), _('Help is not available yet.')).show(this.app.editor);
};
Arg.prototype.menuTranslations = {
@@ -935,7 +936,7 @@
height: 15,
draw: function(context) {
if (!assetsLoaded) return onAssetsLoaded(this.redraw, this);
- context.drawImage(assets, 230, 30, 30, 29, 0, 0, 15, 14.5);
+ context.drawImage(assets, 230, 30, 31, 29, 0, 0, 15.5, 14.5);
}
};
@@ -970,12 +971,48 @@
return this;
};
- function el(tagName, className) {
- var e = document.createElement(className == null ? 'div' : tagName);
- e.className = className || tagName || '';
+ function el(tagName, properties, children) {
+ if (Array.isArray(properties)) {
+ children = properties;
+ properties = undefined;
+ }
+ var e = document.createElement(tagName);
+ if (properties) {
+ extendr(e, properties);
+ }
+ if (children) {
+ for (var i = 0, l = children.length; i < l; i++) {
+ var c = children[i];
+ e.appendChild(typeof c === 'object' ? c : document.createTextNode(c));
+ }
+ }
return e;
}
+ function cl(tagName, className, properties, children) {
+ if (typeof className !== 'string') {
+ children = properties;
+ properties = className;
+ className = tagName;
+ tagName = 'div';
+ }
+ var e = el(tagName, properties, children);
+ e.className = className;
+ return e;
+ }
+
+ function extendr(o, properties) {
+ for (var k in properties) if (hasOwnProperty.call(properties, k)) {
+ var v = properties[k];
+ if (typeof v === 'object') {
+ extendr(o[k], v);
+ } else {
+ o[k] = v;
+ }
+ }
+ return o;
+ }
+
var Server = {
getProjectURL: function(id) {
return 'http://projects.scratch.mit.edu/internalapi/project/' + id + '/get/';
@@ -984,7 +1021,7 @@
return 'http://scratch.mit.edu/api/v1/project/' + id + '/';
},
getAssetURL: function(md5) {
- return 'http://cdn.scratch.mit.edu/internalapi/asset/' + md5 + '/get/';
+ return 'http://cdn.assets.scratch.mit.edu/internalapi/asset/' + md5 + '/get/';
},
imageAssetCache: {},
imageAssetStatus: {},
@@ -1010,7 +1047,7 @@
img = document.createElement('img');
Server.imageAssetCache[md5] = img;
Server.imageAssetStatus[md5] = 'loading';
- img.crossOrigin = "anonymous";
+ img.crossOrigin = 'anonymous';
img.src = Server.getAssetURL(md5);
if (cb) {
img.addEventListener('load', function() {
@@ -1065,7 +1102,7 @@
IO.imageCount = 0;
IO.soundCount = 0;
IO.contents.file((object.isStage ? 'project' : 'sprite') + '.json', JSON.stringify(object));
- cb.call(context, null, zip.generate({type: "arraybuffer"}));
+ cb.call(context, null, zip.generate({type: 'arraybuffer'}));
} catch (e) {
cb.call(context, e);
} finally {
@@ -1152,7 +1189,7 @@
var assets = document.createElement('img');
var assetsLoaded = false;
- assets.src = 'assets.png';
+ assets.src = 'assets/assets.svg';
assets.onload = function() {
assetsLoaded = true;
@@ -1179,14 +1216,20 @@
var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;
- function spriteMenu(arg) { // TODO include/exclude self
+ function getCategoryColor(id) {
+ return vis.getCategory(id)[2];
+ }
+
+ function spriteMenu(arg, includeCurrent) {
var m = new Menu;
- var a = slice.call(arguments, 1);
+ var a = slice.call(arguments, 2);
for (var i = 0, l = a.length; i < l; i++) {
m.add(a[i]);
}
m.translate().add(Menu.line);
- arg.app.editor.stage.sprites.forEach(function(sprite) {
+ var editor = arg.app.editor;
+ editor.stage.sprites.forEach(function(sprite) {
+ if (!includeCurrent && sprite === editor.selectedSprite) return;
m.add(sprite.name);
});
return m;
@@ -1200,14 +1243,6 @@
return o.copy();
}
- function resize(o) {
- if (o.resize) o.resize();
- }
-
- function step(o) {
- if (o.step) o.step();
- }
-
function inherits(sub, sup) {
sub.prototype = Object.create(sup.prototype);
sub.prototype.constructor = sub;
@@ -1274,6 +1309,26 @@
return filename.replace(/(.)\.[^.]+$/, '$1');
}
+ function uniqueName(extant, base) {
+ var x = /\d+$/.exec(base);
+ var i = 2;
+ var name = base;
+ if (x) {
+ base = base.slice(0, -x[0].length);
+ i = +x[0];
+ }
+ search: for (;;) {
+ var j = extant.length;
+ while (j--) {
+ if (extant[j].name === name) {
+ name = base + i++;
+ continue search;
+ }
+ }
+ return name;
+ }
+ }
+
var KEY_NAMES = {
13: 'return',
32: 'space',
@@ -1294,10 +1349,6 @@
typeof value === 'boolean' ? value : 0;
}
- function notNull(value) {
- return value != null;
- }
-
function deserializeScript(json) {
// TODO not very defensive
return (json.length > 3 ? deserializeComment(json) : deserializeStack(json[2])).moveTo(json[0], json[1]);
@@ -1383,7 +1434,7 @@
data[i] = b64.charCodeAt(i);
}
}
- var blob = new Blob([data], {type: mimeType})
+ var blob = new Blob([data], {type: mimeType});
a.href = URL.createObjectURL(blob);
a.download = defaultName;
a.click();
@@ -1396,6 +1447,156 @@
saveFile(defaultName + '.png', 'image/png', canvas.toDataURL().slice('data:image/png;base64,'.length), true);
}
+ function scrollIntoView(el, container) {
+ var bb = el.getBoundingClientRect();
+ var cbb = container.getBoundingClientRect();
+ if (bb.top < cbb.top) {
+ container.scrollTop += bb.top - cbb.top;
+ } else if (bb.bottom > cbb.bottom) {
+ container.scrollTop += bb.bottom - cbb.bottom;
+ }
+ if (bb.left < cbb.left) {
+ container.scrollLeft += bb.left - cbb.left;
+ } else if (bb.right > cbb.right) {
+ container.scrollLeft += bb.right - cbb.right;
+ }
+ }
+
+
+ function EffectsFilter() {
+ PIXI.AbstractFilter.call(this);
+
+ this.uniforms = {
+ dimensions: {type: '2fv', value:[0,0]},
+ alpha: {type: '1f', value: 1},
+ hueShift: {type: '1f', value: 0},
+ valueShift: {type: '1f', value: 0},
+ mosaic: {type: '1f', value: 1},
+ pixelSize: {type: '1f', value: 1},
+ whirlAngle: {type: '1f', value: 0},
+ fisheye: {type: '1f', value: 1}
+ };
+
+ this.passes = [this];
+
+ this.fragmentSrc = [
+ 'precision mediump float;',
+ 'varying vec2 vTextureCoord;',
+ 'uniform vec2 dimensions;',
+ 'uniform float alpha;',
+ 'uniform float hueShift;',
+ 'uniform float valueShift;',
+ 'uniform float mosaic;',
+ 'uniform float pixelSize;',
+ 'uniform float whirlAngle;',
+ 'uniform float fisheye;',
+ 'uniform sampler2D uSampler;',
+
+ 'void main(void) {',
+ ' vec2 pos = vTextureCoord;',
+ ' if (mosaic != 1.) pos = mod(pos * mosaic, 1.);',
+ ' if (pixelSize != 1.) pos = (floor(pos * dimensions / pixelSize) + 0.5) / dimensions * pixelSize;',
+ ' if (whirlAngle != 0.) {',
+ ' float wh = min(dimensions.x, dimensions.y);',
+ ' vec2 scale = vec2(wh) / dimensions;',
+ ' vec2 offset = scale * dimensions * (pos - vec2(.5));',
+ ' float r = 1. - length(offset) / (wh / 2.);',
+ ' if (r > 0.) {',
+ ' float a = whirlAngle * r * r;',
+ ' float s = sin(a); float c = cos(a);',
+ ' mat2 m = mat2(c, -s, s, c);',
+ ' pos = m * offset / scale / dimensions + vec2(.5);',
+ ' }',
+ ' }',
+ ' if (fisheye != 1.) {',
+ ' vec2 offset = 2. * (pos - vec2(.5));',
+ ' float l = length(offset);',
+ ' float r = pow(l, fisheye);',
+ ' if (r < 1.) pos = vec2(.5) + .5 * offset / l * r;',
+ ' }',
+ ' gl_FragColor = texture2D(uSampler, pos);',
+ ' if (hueShift != 0. || valueShift != 0.) {',
+ ' float M = max(gl_FragColor.r, max(gl_FragColor.g, gl_FragColor.b));',
+ ' float m = min(gl_FragColor.r, min(gl_FragColor.g, gl_FragColor.b));',
+ ' float c = M - m;',
+ ' float h =',
+ ' c == 0. ? 0. :',
+ ' M == gl_FragColor.r ?',
+ ' (gl_FragColor.g - gl_FragColor.b) / c :',
+ ' M == gl_FragColor.r ?',
+ ' 2. + (gl_FragColor.b - gl_FragColor.r) / c :',
+ ' 4. + (gl_FragColor.r - gl_FragColor.g) / c ;',
+ ' float s = c == 0. ? 0. : c / M;',
+ ' M = max(0., min(1., M + valueShift));',
+ ' h = mod(h + hueShift, 6.);',
+ ' c = M * s;',
+ ' float x = c * (1. - abs(mod(h, 2.) - 1.));',
+ ' gl_FragColor.rgb = vec3(M - c) + (',
+ ' h < 1. ? vec3(c,x,0) :',
+ ' h < 2. ? vec3(x,c,0) :',
+ ' h < 3. ? vec3(0,c,x) :',
+ ' h < 4. ? vec3(0,x,c) :',
+ ' h < 5. ? vec3(x,0,c) :',
+ ' vec3(c,0,x));',
+ ' }',
+ ' gl_FragColor *= alpha;',
+ '}',
+ ];
+ }
+
+ EffectsFilter.prototype = Object.create(PIXI.AbstractFilter.prototype);
+ EffectsFilter.prototype.constructor = EffectsFilter;
+
+ def(EffectsFilter.prototype, 'alpha', {
+ get: function() {return this.uniforms.alpha.value},
+ set: function(value) {
+ this.uniforms.alpha.value = value;
+ this.dirty = true;
+ }
+ });
+ def(EffectsFilter.prototype, 'hueShift', {
+ get: function() {return this.uniforms.hueShift.value},
+ set: function(value) {
+ this.uniforms.hueShift.value = value;
+ this.dirty = true;
+ }
+ });
+ def(EffectsFilter.prototype, 'valueShift', {
+ get: function() {return this.uniforms.valueShift.value},
+ set: function(value) {
+ this.uniforms.valueShift.value = value;
+ this.dirty = true;
+ }
+ });
+ def(EffectsFilter.prototype, 'mosaic', {
+ get: function() {return this.uniforms.mosaic.value},
+ set: function(value) {
+ this.uniforms.mosaic.value = value;
+ this.dirty = true;
+ }
+ });
+ def(EffectsFilter.prototype, 'pixelSize', {
+ get: function() {return this.uniforms.pixelSize.value},
+ set: function(value) {
+ this.uniforms.pixelSize.value = value;
+ this.dirty = true;
+ }
+ });
+ def(EffectsFilter.prototype, 'whirlAngle', {
+ get: function() {return this.uniforms.whirlAngle.value},
+ set: function(value) {
+ this.uniforms.whirlAngle.value = value;
+ this.dirty = true;
+ }
+ });
+ def(EffectsFilter.prototype, 'fisheye', {
+ get: function() {return this.uniforms.fisheye.value},
+ set: function(value) {
+ this.uniforms.fisheye.value = value;
+ this.dirty = true;
+ }
+ });
+
function ScratchObj(name) {
this.name = name;
@@ -1406,6 +1607,21 @@
this.variables = [];
this.lists = [];
this.info = {};
+
+ this.pixiSprite = new PIXI.Sprite;
+ this.pixiEmptyTexture = this.pixiSprite.texture;
+ this.pixiSprite.shader = this.pixiEffectsFilter = new EffectsFilter;
+
+ this.effectsChanged = false;
+ this.effects = {
+ color: 0,
+ fisheye: 0,
+ whirl: 0,
+ pixelate: 0,
+ mosaic: 0,
+ brightness: 0,
+ ghost: 0
+ };
}
ScratchObj.prototype.toJSON = function() {
@@ -1413,7 +1629,7 @@
var comments = [];
this.scripts.filter(function(s) {
(s.isScript ? scripts : comments).push(s);
- })
+ });
return {
objName: this.name,
variables: this.variables.length ? this.variables : undefined,
@@ -1431,15 +1647,15 @@
this.variables = Array.isArray(json.variables) ? json.variables.map(Variable.deserialize) : [];
this.lists = Array.isArray(json.lists) ? json.lists.map(function(j) {
var list = List.deserialize(j);
- list.watcher = new ListWatcher(this, list, Number(j.width) || 100, Number(j.height) || 200);
- list.watcher.moveTo(Number(j.x) || 0, Number(j.y) || 0);
+ list.watcher = new ListWatcher(this, list, +j.width || 100, +j.height || 200);
+ list.watcher.moveTo(+j.x || 0, +j.y || 0);
list.watcher.visible = !!j.visible;
return list;
}, this) : [];
this.scripts = (Array.isArray(json.scriptComments) ? json.scriptComments : []).concat(Array.isArray(json.scripts) ? json.scripts : []).map(deserializeScript);
// this.sounds = Array.isArray(json.sounds) ? json.sounds.map(...) : []; // TODO
if (Array.isArray(json.costumes)) json.costumes.map(Costume.deserialize).forEach(this.addCostume, this);
- this.costume = (Math.round(Number(json.currentCostumeIndex)) % this.costumes.length + this.costumes.length) % this.costumes.length || 0;
+ this.setCostume(Math.round(+json.currentCostumeIndex) || 0);
return this;
};
@@ -1451,15 +1667,118 @@
return this;
};
+ ScratchObj.prototype.removeCostume = function(costume) {
+ var i = this.costumes.indexOf(costume);
+ if (i !== -1) {
+ this.costumes.splice(i, 1);
+ costume.owner = null;
+ if (this.costume >= this.costumes.length && this.costume) {
+ this.costume--;
+ }
+ }
+ return this;
+ };
+
ScratchObj.prototype.setCostume = function(i) {
- this.costume = i % this.costumes.length || 0;
- if (this.costume < 0) this.costume += this.costumes.length
+ this.costume = Math.round(i) % this.costumes.length || 0;
+ if (this.costume < 0) this.costume += this.costumes.length;
+ var costume = this.costumes[this.costume];
+ };
+
+ ScratchObj.prototype.setEffect = function(name, value) {
+ switch (name) {
+ case 'brightness':
+ if (value < -100) value = -100;
+ else if (value > 100) value = 100;
+ break;
+ case 'ghost':
+ if (value < 0) value = 0;
+ else if (value > 100) value = 100;
+ break;
+ }
+ this.effects[name] = value;
+ this.effectsChanged = true;
+ };
+
+ ScratchObj.prototype.clearEffects = function() {
+ this.effects.color = 0;
+ this.effects.fisheye = 0;
+ this.effects.whirl = 0;
+ this.effects.pixelate = 0;
+ this.effects.mosaic = 0;
+ this.effects.brightness = 0;
+ this.effects.ghost = 0;
};
ScratchObj.prototype.redraw = function() {
this.stage.redraw();
};
+ ScratchObj.prototype.updatePixi = function() {
+ var costume = this.costumes[this.costume];
+ if (!costume) {
+ this.pixiSprite.setTexture(this.pixiEmptyTexture);
+ return;
+ }
+ this.pixiSprite.setTexture(costume.baseLayerTexture);
+
+ if (!this.isSprite) return;
+
+ this.pixiSprite.visible = this.visible;
+
+ this.pixiEffectsFilter.alpha = 1 - this.effects.ghost / 100;
+ this.pixiEffectsFilter.valueShift = this.effects.brightness / 100;
+ var hs = this.effects.color * 0.03 % 6;
+ this.pixiEffectsFilter.hueShift = hs < 0 ? hs + 6 : hs;
+ this.pixiEffectsFilter.mosaic = Math.round(Math.abs(this.effects.mosaic) / 10 + 1);
+ this.pixiEffectsFilter.whirlAngle = -this.effects.whirl * Math.PI / 180;
+ this.pixiEffectsFilter.fisheye = Math.max(0.001, 1 + this.effects.fisheye / 100); // NS
+ this.pixiEffectsFilter.pixelSize = this.effects.pixelate ? Math.min(Math.abs(this.effects.pixelate / 10) + 1, costume.width, costume.height) : 1;
+ if (this.effects.pixelate || this.effects.whirl) {
+ this.pixiEffectsFilter.uniforms.dimensions.value[0] = costume.width;
+ this.pixiEffectsFilter.uniforms.dimensions.value[1] = costume.height;
+ }
+
+ this.pixiSprite.scale.x =
+ this.pixiSprite.scale.y = this.scale;
+ this.pixiSprite.anchor.x = costume.cx / costume.baseLayerTexture.width;
+ this.pixiSprite.anchor.y = costume.cy / costume.baseLayerTexture.height;
+ this.pixiSprite.position.x = 240 + this.x;
+ this.pixiSprite.position.y = 180 - this.y;
+
+ if (this.rotationStyle === 'normal') {
+ this.pixiSprite.rotation = (this.direction - 90) * Math.PI / 180;
+ } else {
+ this.pixiSprite.rotation = 0;
+ if (this.rotationStyle === 'leftRight') {
+ this.pixiSprite.scale.x *= this.direction < 0 ? -1 : 1;
+ }
+ }
+ };
+
+ ScratchObj.prototype.uniqueCostumeName = function(base) {
+ return uniqueName(this.costumes, base);
+ };
+
+ ScratchObj.prototype.makeEmptyCostume = function() {
+ var empty = document.createElement('canvas');
+ if (this.isStage) {
+ empty.width = 960;
+ empty.height = 720;
+ var cx = empty.getContext('2d');
+ cx.fillStyle = '#fff';
+ cx.fillRect(0, 0, empty.width, empty.height);
+ } else {
+ empty.width = 2;
+ empty.height = 2;
+ }
+ return new Costume(this.newCostumeName(), empty, 0, 0, 2);
+ };
+
+ ScratchObj.prototype.newCostumeName = function() {
+ return this.uniqueCostumeName(this.isStage ? 'backdrop1' : 'costume1');
+ };
+
ScratchObj.prototype.findLocal = function(name) {
var vars = this.variables;
for (var i = vars.length; i--;) {
@@ -1573,41 +1892,47 @@
}).length;
}});
-
- function Costume(name, canvas, cx, cy, pixelRatio, textLayer) {
- this.baseLayerMD5 = null;
- this.loaded = true;
- if (typeof canvas === 'string') { // MD5
- this.baseLayerMD5 = canvas;
- canvas = Server.getImageAsset(canvas);
- }
- if (typeof textLayer === 'string') { // MD5
- this.textLayerMD5 = textLayer;
- textLayer = Server.getImageAsset(textLayer);
- }
- this.name = name;
- this.canvas = canvas;
- if (canvas.tagName === 'IMG') {
- this.textLayer = textLayer;
- this.baseLayer = canvas;
- if (!canvas.width) {
- this.loaded = false;
- canvas.addEventListener('load', this.baseLayerLoaded.bind(this));
- } else if (this.textLayer) {
- this.composite();
- }
- }
- this.cx = cx || 0;
- this.cy = cy || 0;
- this.pixelRatio = pixelRatio || 1;
- this.scale = 1 / this.pixelRatio;
- this.updateSize();
- }
-
- Costume.prototype.updateSize = function() {
- this.width = this.canvas.width * this.scale;
- this.height = this.canvas.height * this.scale;
- };
+ function Costume(name, baseLayer, cx, cy, pixelRatio, textLayer) {
+ this.baseLayerMD5 = null;
+ if (typeof baseLayer === 'string') { // MD5
+ this.baseLayerMD5 = baseLayer;
+ // Data URI to allow operation without internet connection
+ if (baseLayer=="c68e7b211672862001dd4fce12129813.png") // cat.png
+ this.baseLayerTexture = PIXI.Texture.fromImage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALEAAADaCAYAAADpGqNcAAAMjUlEQVR42u2dTXIkNRCF7XDhWwx4AjZcgyVHsCM4yBxgDkIEHIEl1/BmCAbmFhBEgzwjW2gklX4ypczUy03b7XZ3V+mrVy/1kzquEKbi66/uLu7xtz/eX+9yzAea3R7AuwUgBsCAGCEH4Me3/zz9/u2bm6fndrEUh/SG2c3fjQIMJRbcUAAZAKuF2DWQvz1ClQGwWiX2IEOV6wAOL/wdzpWaxC5OWnZVZSiwIogdoK7BHLRhg+2sygBYuRLvrsoA2BjEu6kyADYM8Q6q3AvwTsmdmRE7i6oMBd4MYmuqDIA3hVi7KseTeADwxhAXVNk9XM+CkOL7IzaGOKXKn8KDdi0B1k8X1lP89dMrlmO3ntxtMRXzRZXvQmguZyC3wtqjnrcP4c8f2ICGEi+K3KjdmDLdhQr4DHILsJS3+hDWEGL3M0CGEteq8kWKL80BjQDERVX29sI9SlI+qu+ygy/eennSR6V99ax8uIUDYtXh4PUgI7ECxOpBtpZYWbcUgDjjRa0lVpZBBsTMiRVABsQIRpDd7xZgFg8x9YAHwt60VSixkYjmhxQBDh8t2AtAvBHA4WtDmLWDDIiNAPzu/e9Vr//m7vXz/6VA1uiTAfFm4WF3MKdA1uiTAfFGKhzD7EH2EGv1yYB4Q4BjkEv2QgPIgBj2omgvNIAMiBuzfKt91aG90AbyAXBvul5vEWatIKuAmGvULga4xl+mPKRGP9wS0kHeVol7Qch5SMtqjMTOeGZv0V5oA/kAwOONvdpe7G4p1Gw8I9VLWrUXmpK8Q5sa4Bb8ApP7vFnJHewEgQprUDiNSZGF49nGE8/qlrIGsgZvjBE7gKzeG4uGGIWmEaoh1g4wtxojuYOdQBjyxoB4czX2gzWlpFe6xxcJMbzwnAgB9r9rtCbHLgCv8pBS1TgGGJ4YYUqday8GKb4YEBPcilffgnfvqRAFsRYvLNFL7gzyAYDHAK4BeVZ2vyvIW9kJDBB8fmGlns9duOHf/v75SzG+GJ544wt15EL+4v7PZ5ChxJOtxA5qHB4jZ+IZg7xKjaHExhU5Zwdac4DS/8Z13NzjTJirIY6XCGmuZzuixi1eUsJxuqCAuaTGT+95/9EnryhK2K3EVFecxiHmVgg8PKuOMVwHeNaT0qrCMdAhzDNU2X1GNcTxF/FfUGtN2116KrxSxjDXDjv3nBv3mY9X/Krs2etWYv+lNMMsGWSKLchyO0DlLBF170WsypRshLwNJ3Y5mLX7ZqqIb8k13VJUe+i597nc0wPaA7M7DxRCl+KLrHcihrkGaAl+mFuNY9Xzt/camH/4/ruhz/7xl1+vrq+vry6Xy/KLObQyLaqcqzkS/j95F1v45i1AW7UVufcMvSrHoIED2IUEgFMXdQ7ks0I5qf9h7ScuAS0ZZKrbbW3yFAL95GX/S4qcFXAgjqqx5FykprJTDSfTBjtioKlKU3Gc3J7upRy8vdn91YOtdOL/F/TNELTLII6/qESIQ3/eCzPVPGNnA5yf9bagRZGlWglKcJdDHIMssTxqDuaWJGY0PMgeTM3WojQ7bjREzZ2QtprWdw+1nHDqxNCraa0qa1Jhqmmch5SDCVVvJbSz4BxV5RTM2mzE0/l+M67Gh7QrUxq8kiJU5RDa1Gs09lT0qvHWUzG1wHsGs1aAqdT4ALx6QyO0HHEAXgQgRiAAsS0VjrvisKcGf3LXDDHHvGHLW81KqhQEJc7ADBVOR7wkKPwZMC+GODVvmOJ2Ykl1Q0jDn8M1bjuqc85q+Tvx9H5iKjvBsfG41B6JkjoDaiR2qiKlzqWGtQJ2fBzxsfbc3UnW2I2Gn82mfbusXr971rCW7Yc7lrBWBZTYoEqnILas1KrnTlhR4xX2Q7tSjyZ1UOINlFoy1B8XyI5PvxUDMdR4XqLYepFIVuEtlNhd7TtN/KlJFGsSVE3WRBTEmtXY11OQVhKrt/ghd/jPoRhvgCdGJC9GTSEOYnjjtTFjfgelCotVYmqQd/PFOwEs2k5oVGSpvthiMqfGE1OCDDVeDzCHCiOx21yNZ85v5gJYBcQa1Vg6yLPtAyfAapQYIANgE3YC/liXfZgFsDpPHILsYgTmGSBLUuMV/ncGwCoTu7gkrCaQZ6qgZftgonciXKxKAbILTpjDodxVijjr81xb3D58mFrmXnUXmyafnNrVkwOuFfOJQ/W9fZjPQRXEpQV8qzeQ0Zbw5WAegS43YceqfWiCuGb1qYSdkLQlfCmYz4Bsfd9Z8K6wD11KnDsxXFue7pDw5c5tD8Qzk8VwdfIq+1ANsQPCgVBqTKpy9VwJ34gqr+pLljpU/QIvzZIidohrAPZBUa4+ti2jJ4hqZ6YZPRfSI4ZXGsBFJa5tuF41LvltjmKFgNkevFmIewBqVeP4M2KwOHdRAsy1PR3y4S0qcasva1FjD3AJIspJ8LkLIny+9fOswZwrJSUd3iTEmmoOt9wlztQ9/lst1Fph9t/75bhv1IFbVGLO7LhGhblhDhsvV2u5FWqJMPvvlD4uvapbhHhUhc+Weq8EuOThS5C3Qh2DMwPqFKy1eYVmcLNKTKHCEgY+WkBOQXmWaKYASYEdAjYCdBnU+iTYCrRJiLm9sCQVToF8NsJX03tyqnxDg0LtvTVWgS0qMYUKa6weUwvymequ2Fx9J1CLEO+qwpyJY0tQVYbcGmKcgj415kgyAfIAxNTdar5BdlFh6vOGMwElVnsnQABiqDEgpgmNPRQIQMweszYwl+LdocZCINYymWjWBYJQrMSjcIQJTyn5qfkcJE+GIa4ps5Qbv5cyc6sXUCjwJkqcAzj+GwfQYfdTySfW2BcAuynEJYBzr318O//WPQp4S9RcrC3nDbFB7wRFgjmqwq13Gf/6GpjD5BK+fQDiVJ0FqMm4TWqBGdEJcVgC6t09AOZKXN374JzCTky1EhxJKlQZEC/xwtyBwRYiiL2l8EWSATC/RYEaQ4lZAZ41gAMVJoYYG4MjoMSIdrV/8xqCQQ0xpRpTrVtrWUipaTkU5lwrUeKZCzApAV65WSMWjhJATO2NV64klq7COB+MSswJcvgclZXgsBHcagyAFSZ28eSWXbuXarwwLAURxBxdbqnKk2eztlaoMJcat9gIgEykxJx9xzXFryU0HhXIPT4YIAuzE7U2Q2JjSemtkHiRq4B4xkheCLJvLGkNJAHknJXaHe4qJZ4FcmgvwgaS0ii92xpQdKm1lJOVeO5E2AnK/ZNbvbI0dW5RZc4+4dx7ps6dZaCrIU5tzsLZPZbqyZBUkMXDWVNRdEW52BzQFkE+aqEtXfGzykudbeM1ExbvU0s1OyTMj4iBtgjyUQtwad+KWQClFCYEfAXIOVV2z2F6qwA7cbYZS67EFHeDSRvtC1V51x4CURC3jIDlun44IZM6XJ2zPJLU2OrgyUF1YkL18RdC73azPQBLmS2HUbbFEFPNQ6jZbpary0kiyPDGwpW4pD6xEoVQt9qC2tfH0z5XQVMCWaId2h7i2tto+HzKcpx13rdslhjOkpMG8urvBYiJ/GDKcqSA7lWuuOttlfqlQPbHPRtkqxs/HtyNVuufa4AeTTxXwZw6J7PtheWdSw/qpC5utJYTl1Jnqu8TNqQUXxrbi7PvPwKvVYBZlDilgC3dTZwrNVbCfJb8lob5KWoWW+7uY1+y7xuhRpVn1Y1IwbwS5NrzAngXQJxT5RrAZocEkHcGUTzEKfVbDXBqlFEyyAgBEK9W2rNMHYMRyiHWVMOMA+BcbwH3pH+osVIlXg3vmcdcORiBAMTDAKdUGSADYtH2YTXIsBSAmBVgBCA2AzBsxUYQS+maop4rsFPPDZQ4AdHshtc22QV2RxjEqRG5meoMIAAxecYdA8YJMhfAsBJI7D4bOKAGQvNcWdw5iCHmzsBzk797Pis1gYgDBKgwlLioyiUge94TAYinRm5NnSRwocKAuHo4VaKSzgAYfli5EksOKLByiDG8il4JKLHyhoIKA2LYCIQMiGEpYCWgxAobapYKA+CJEO+ixtSlshBGlFij2gBgoxD31GDA7RLnRpwS11ZsjP9Hy4HPsk0AeLGdqKnYqBHg3fw/PDFUBCq8U2KnMWaoMepKAGK1IPcWGkcAYnEge2sBkAGxamuBklWAeAnIoZJSg4yEDxBPAdnbAPhkQKwWZA8afDIghk+GTwbElkFGAGL1IEONATEUGQGIJYAMNQbEUGRAjJAAMtQYEEORATFiNciYewyIociAGAGQATFiAGRYCUAsFmTf6wCAAbFakENIU0ADYEAsHmT3eLZHCQAGxGpgjoEGwHTxLzILQsBkPD7CAAAALXRFWHRTb2Z0d2FyZQBieS5ibG9vZGR5LmNyeXB0by5pbWFnZS5QTkcyNEVuY29kZXKoBn/uAAAAAElFTkSuQmCC", true, PIXI.scaleModes.LINEAR);
+ else if (baseLayer=="739b5e2a2435f6e1ec2993791b423146.png") // stage.png
+ this.baseLayerTexture = PIXI.Texture.fromImage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAEfklEQVR42u3VOQEAAAjEMIbzb5nHBFMioUvTqwCAV5EAAAwYAAwYADBgADBgAMCAAcCAAQADBgADBgAMGAAMGAAMGAAwYAAwYADAgAHAgAEAAwYAAwYADBgADBgADBgAMGAAMGAAwIABwIABAAMGAAMGAAwYAAwYAAwYADBgADBgAMCAAcCAAQADBgADBgAMGAAMGAAMGAAwYAAwYADAgAHAgAEAAwYAAwYADBgADBgADBgAMGAAMGAAwIABwIABAAMGAAMGAAwYAAwYAAwYADBgADBgAMCAAcCAAQADBgADBgAMGAAMGAAMGAAwYAAwYADAgAHAgAEAAwYAAwYADBgADBgADBgAMGAAMGAAwIABwIABAAMGAAMGAAwYAAwYAAwYADBgADBgAMCAAcCAAQADBgADBgAMGAAMGAAwYAAwYAAwYADAgAHAgAEAAwYAAwYADBgADBgAMGAAMGAAMGAAwIABwIABAAMGAAMGAAwYAAwYADBgADBgADBgAMCAAcCAAQADBgADBgAMGAAMGAAwYAAwYAAwYADAgAHAgAEAAwYAAwYADBgADBgAMGAAMGAAMGAAwIABwIABAAMGAAMGAAwYAAwYADBgADBgADBgAMCAAcCAAQADBgADBgAMGAAMGAAwYAAwYAAwYADAgAHAgAEAAwYAAwYADBgADBgAMGAAMGAAMGAAwIABwIABAAMGAAMGAAwYAAwYADBgADBgADBgAMCAAcCAAQADBgADBgAMGAAMGAAwYAAwYADAgAHAgAHAgAEAAwYAAwYADBgADBgAMGAAMGAAwIABwIABwIABAAMGAAMGAAwYAAwYADBgADBgAMCAAcCAAcCAAQADBgADBgAMGAAMGAAwYAAwYADAgAHAgAHAgAEAAwYAAwYADBgADBgAMGAAMGAAwIABwIABwIABAAMGAAMGAAwYAAwYADBgADBgAMCAAcCAAcCAAQADBgADBgAMGAAMGAAwYAAwYADAgAHAgAHAgAEAAwYAAwYADBgADBgAMGAAMGAAwIABwIABwIABAAMGAAMGAAwYAAwYADBgADBgAMCAAcCAAcCAAQADBgADBgAMGAAMGAAwYAAwYADAgAHAgAHAgCUAAAMGAAMGAAwYAAwYADBgADBgAMCAAcCAAQADBgADBgADBgAMGAAMGAAwYAAwYADAgAHAgAEAAwYAAwYAAwYADBgADBgAMGAAMGAAwIABwIABAAMGAAMGAAMGAAwYAAwYADBgADBgAMCAAcCAAQADBgADBgADBgAMGAAMGAAwYAAwYADAgAHAgAEAAwYAAwYAAwYADBgADBgAMGAAMGAAwIABwIABAAMGAAMGAAMGAAwYAAwYADBgADBgAMCAAcCAAQADBgADBgADBgAMGAAMGAAwYAAwYADAgAHAgAEAAwYAAwYAAwYADBgADBgAMGAAMGAAwIABwIABAAMGAAMGAAMGAAwYAAwYADBgADBgAMCAAcCAAQADBgADBgAMGAAMGAAMGAAwYAAwYADAgAHAgAEAAwYAAwYAzgDzBgmdc+DZigAAAC10RVh0U29mdHdhcmUAYnkuYmxvb2RkeS5jcnlwdG8uaW1hZ2UuUE5HMjRFbmNvZGVyqAZ/7gAAAABJRU5ErkJggg==", true, PIXI.scaleModes.LINEAR);
+ else if (baseLayer=="f9a1c175dbe2e5dee472858dd30d16bb.svg") // cat.svg
+ this.baseLayerTexture = PIXI.Texture.fromImage("data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJjYXQiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iOTVweCIgaGVpZ2h0PSIxMTFweCIgdmlld0JveD0iMCAwIDk1IDExMSIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgOTUgMTExIiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICA8Zz4KICAgIDxnIGlkPSJMYXllcl8zIj4KICAgICAgPHBhdGggZmlsbD0iI0ZBQTUxRCIgc3Ryb2tlPSIjMDAwMDAwIiBkPSJNMjIuNDYyLDc5LjAzOWMtMi40MTUtMC40NTEtNS4zMDQtMS4zMDktNy43NDItMy41MDMmI3hEOyYjeEE7JiN4OTsmI3g5O0M5LjI2OCw3MC42MjksNy41MjYsNjIuNTM1LDMuNjcyLDY0LjYyMmMtMy44NTYsMi4wODgtMy43ODIsMTUuMTY1LDguMzUzLDE5LjE5NGM0LjE4MiwxLjM5MSw3Ljk5OCwxLjM5NiwxMS4wOTEsMS4zMTImI3hEOyYjeEE7JiN4OTsmI3g5O2MwLjgxMS0wLjAyNSw3LjcxNy0wLjY1NCwxMC4wNzktNC4wNzRjMi4zNjEtMy40MiwwLjcxOS00LjI3Mi0wLjA5LTQuNzQ0QzMyLjI5NSw3NS44MzgsMjUuODc4LDc5LjY3NywyMi40NjIsNzkuMDM5eiIvPgogICAgICA8cGF0aCBmaWxsPSIjRkZGRkZGIiBkPSJNNC4yMzYsNjQuODc3Yy0xLjk4OSwwLjYxMy0zLjA3NSw0Ljk5OC0yLjA3Niw4LjQ4NGMwLjk5OCwzLjQ5LDIuNjM0LDUuMDIyLDMuODYzLDYuMzk4JiN4RDsmI3hBOyYjeDk7JiN4OTtjMS41MjgsMS4wMzgtMC43Mi0yLjQwMiwxLjM2MS00LjE1YzIuMDc1LTEuNzQ0LDUuNzMzLTAuOTE0LDUuNzMzLTAuOTE0cy0yLjkwOS0zLjk4Ny00LjU3LTYuMzk2JiN4RDsmI3hBOyYjeDk7JiN4OTtDNi45NzUsNjUuOTg4LDYuMzU5LDY0LjM3NSw0LjIzNiw2NC44Nzd6Ii8+CiAgICA8L2c+CiAgICA8Zz4KICAgICAgPHBhdGggZmlsbD0iI0ZBQTUxRCIgZD0iTTM4LjIxNyw4Ni43NTZjMCwwLTguODMyLDYuMi0xNy4wNzEsOC40MTJsMC4wODYsMC4yMTVjMS4yNDcsMS44MjQsNS44Nyw3LjQ5Ny0wLjMzNCw5LjQ5NiYjeEQ7JiN4QTsmI3g5OyYjeDk7Yy01LjMzMywxLjcxNy0xNS4xMi0xMy4xMDQtMTAuODIxLTE1LjkwMmMyLjYyNi0xLjcxMyw0Ljg5Mi0wLjI1Miw0Ljg5Mi0wLjI1MnMzLjQ3NC0xLjA3LDYuMDAxLTIuMzQ1JiN4RDsmI3hBOyYjeDk7JiN4OTtjNC4zMDMtMi4xNjEsNS43ODQtMy40NTMsNS43ODQtMy40NTNzNC4xODQtNC4zMDYsNi44NTYtNC4xMzdDMzYuMjgxLDc4Ljk2LDQxLjY2OSw4My41MDQsMzguMjE3LDg2Ljc1NnoiLz4KICAgICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMjMxRjIwIiBzdHJva2Utd2lkdGg9IjEuMiIgZD0iTTIxLjIzMiw5NS4zODNjMS4yNDcsMS44MjQsNS44Nyw3LjQ5Ny0wLjMzNCw5LjQ5NiYjeEQ7JiN4QTsmI3g5OyYjeDk7Yy01LjMzMywxLjcxNy0xNS4zMjktMTMuMzQ0LTExLjAzLTE2LjE0NWMyLjYyNi0xLjcxMyw1LjEwMS0wLjAxLDUuMTAxLTAuMDFzMy40NzQtMS4wNzIsNi4wMDEtMi4zNDgmI3hEOyYjeEE7JiN4OTsmI3g5O2M0LjMwMy0yLjE2MSw1Ljc4NC0zLjQ1Myw1Ljc4NC0zLjQ1MyIvPgogICAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiMyMzFGMjAiIHN0cm9rZS13aWR0aD0iMS4yIiBkPSJNMzguMjE3LDg2Ljc1NmMwLDAtMTAuMTIzLDcuMTA3LTE4LjgwNCw4LjgxOSIvPgogICAgPC9nPgogICAgPHBhdGggZmlsbD0iI0ZBQTUxRCIgc3Ryb2tlPSIjMjMxRjIwIiBzdHJva2Utd2lkdGg9IjEuMiIgZD0iTTUyLjE2OSw3NC44ODVjMCwwLDEuMjM1LDAuMTY1LDQuNzQ0LDMuNjc2JiN4RDsmI3hBOyYjeDk7YzMuNTA5LDMuNTA4LDYuMDI2LDIuMTYsOC45MTEsMC43MjRjMi44NzctMS40NDMsMTAuNTM3LTYuMTI2LDYuNDktOS44MTdjLTQuMDQ5LTMuNjg4LTYuMjA3LDEuMTQ2LTkuNzE1LDIuNDA1JiN4RDsmI3hBOyYjeDk7Yy0zLjUxMiwxLjI2LTUuMDYxLTIuNDg3LTYuODU4LTQuMjg3Yy0wLjU4OS0wLjU5My0xLjE4OC0xLjA5OS0xLjcyOS0xLjUwNWMwLDAtMC45NzEtMC43Ni0xLjkwNiwyLjc5JiN4RDsmI3hBOyYjeDk7QzUxLjE3Miw3Mi40MTIsNTAuMTYyLDczLjQxNSw1Mi4xNjksNzQuODg1eiIvPgogICAgPGcgaWQ9IkxheWVyXzJfMV8iPgogICAgICA8cGF0aCBmaWxsPSIjRkFBNTFEIiBzdHJva2U9IiMyMzFGMjAiIHN0cm9rZS13aWR0aD0iMS4yIiBkPSJNNDYuNzUzLDgyLjAxMmMxLjE4OC0wLjkxMiwyLjM5Ny0yLjQwMiwzLjk1MS00LjcxMyYjeEQ7JiN4QTsmI3g5OyYjeDk7YzEuMjk2LTEuOTI3LDIuNy01LjU3OCwyLjctNS41NzhjMC44NzUtMi41MjEsMS45MzQtNi41NzYtMS45MDItNy4yOTZjLTEuNTUzLTAuMjkxLTQuMDc5LTAuMDk4LTcuNjctMC43NzYmI3hEOyYjeEE7JiN4OTsmI3g5O2MtMy41OTMtMC42ODEtNi43OTgtMi41MjItOS41MTcsMi4yMzNjLTIuNzE4LDQuNzU3LTkuNTksOC4yNzEtMS4wNTYsMTYuNTYzYzAsMCw0LjkwMSwzLjg0MiwxMC43NjQsOS42MzkmI3hEOyYjeEE7JiN4OTsmI3g5O2M0LjgzMSw0Ljc3NSwxMi4wNDUsMTAuNjAyLDEyLjA0NSwxMC42MDJzMTguOTcyLDIuMTg4LDE5LjUzNS0wLjY5M2MxLjkyMi05Ljc5LTE0Ljc3Ny02LjkxMS0xNC43NzctNi45MTEmI3hEOyYjeEE7JiN4OTsmI3g5O3MtNC42MDUtMy45MzMtNi43MjUtNS43OTRjLTMuNDc4LTMuMDU5LTExLjEyNS0xMC43NzEtMTEuMTI1LTEwLjc3MSIvPgogICAgICA8cGF0aCBmaWxsPSIjRkZGRkZGIiBkPSJNNTEuMjUzLDc1LjQzNGMwLDAsMi40Ny0yLjY2LTIuNDY5LTUuMzE3Yy00LjkzOS0yLjY1Ny03LjIxMy0wLjAxNy04LjczOSwxLjUyMSYjeEQ7JiN4QTsmI3g5OyYjeDk7Yy0yLjY0NCwyLjY1NSwzLjQ0Myw2LjYxMSwzLjQ0Myw2LjYxMWwzLjE3NiwzLjIwNGMwLDAsMS43MzgtMS42NDcsMi40OTktMi45NzlDNTAuMDM2LDc3LjI2LDUxLjI1Myw3NS40MzQsNTEuMjUzLDc1LjQzNCIvPgogICAgPC9nPgogICAgPGcgaWQ9IkxheWVyXzgiLz4KICAgIDxwYXRoIGZpbGw9IiNGQUE1MUQiIHN0cm9rZT0iIzIzMUYyMCIgc3Ryb2tlLXdpZHRoPSIxLjIiIGQ9Ik0yOS45MjYsNzMuMjE4YzAuNzQ5LTAuNTcxLDIuODg5LTIuMjAyLDQuODU0LTMuNjU3JiN4RDsmI3hBOyYjeDk7YzIuNDI4LTEuNzk5LDYuMTE3LTUuODQ5LDEuMDc3LTcuNjQ2Yy01LjA0LTEuODAxLTcuNTA3LDEuNjA0LTExLjUxOSw0Ljk0NmMtMi4xNTksMS44MDEtNS4zMDgsMi42OTktNC4zMTksNi4yMDkmI3hEOyYjeEE7JiN4OTtjMC45OTMsMy41MTEsNC44NjIsMTMuNDA4LDExLjc4OSwxMC4xN2M2LjkyOS0zLjIzOS0xLjc5OS05LjE4LTMuMDYtMTEuMTU3Ii8+CiAgICA8ZyBpZD0iTGF5ZXJfMiI+CiAgICAgIDxwYXRoIGZpbGw9IiNGQUE1MUQiIHN0cm9rZT0iIzIzMUYyMCIgc3Ryb2tlLXdpZHRoPSIxLjIiIGQ9Ik01Mi43MDksMTQuMTU2Yy0xLjU0LTAuMTQzLTQuNzUtMC4zMTYtNi41MTgtMC4yMzEmI3hEOyYjeEE7JiN4OTsmI3g5O2MtNC43MjgsMC4yMjUtOS4yMjQsMS45MjgtOS4yMjQsMS45MjhMMjMuOTQ5LDcuMzU3bDIuMjM1LDE4LjkwNmMwLjY0Ni0wLjc4Mi0xMC41NTUsMTIuODA0LTMuNDc5LDI0LjIyNCYjeEQ7JiN4QTsmI3g5OyYjeDk7YzcuMDgsMTEuNDI2LDIyLjIzMywxNi41MTgsNDAuOTg4LDEyLjc5MmMxOC43NTUtMy43MjksMjMuMjI5LTE0LjUzMSwyMS45ODYtMjAuMjQ2Yy0xLjI0Mi01LjcxNC04LjMyMi03LjgyMy04LjMyMi03LjgyMyYjeEQ7JiN4QTsmI3g5OyYjeDk7cy0wLjA5LTQuNDgtMy4zMjgtOS45N2MtMS45MjYtMy4yNjgtOC4zNDgtOC4wNDEtOC4zNDgtOC4wNDFMNjIuODIyLDUuNjQ3bC03LjQ1Miw3LjIwNEw1Mi43MDksMTQuMTU2eiIvPgogICAgICA8cGF0aCBmaWxsPSIjRkZGRkZGIiBkPSJNNzYuNDIsMzUuMDY2bC0yLjQ4Mi0yLjA2NGwtOS4xMTUsMi42NjFjMCwwLDAsMy40MTktNC4zNjcsNC4zNjdjLTQuMzcsMC45NTEtMTEuMjExLTIuMjc3LTExLjIxMS0yLjI3NyYjeEQ7JiN4QTsmI3g5OyYjeDk7TDQxLjQ2LDQxLjE3YzAsMC04LjQzNywwLjkyOC04LjczOSw2LjA4MUMzMi4wNDgsNTguNzA0LDQ2LjEsNjMuNDc5LDUxLjQyNSw2My43ODNjMi45MDUsMC4xNjcsOC4yMzUtMC4zMzgsMTIuMjc3LTEuMTQxJiN4RDsmI3hBOyYjeDk7JiN4OTtjMTcuNzUyLTMuMjM0LDIyLjU1MS0xMy45MTksMjEuMzEtMTkuNjM1Yy0xLjI0Mi01LjcxNC03Ljk3OC03LjE5Ni03Ljk3OC03LjE5Nkw3Ni40MiwzNS4wNjZ6Ii8+CiAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzIzMUYyMCIgc3Ryb2tlLXdpZHRoPSIxLjIiIGQ9Ik0xMC42NzMsNDYuMTU1YzAsMCw0LjEwNywwLjM3NCw1Ljk3NCwwLjI2OCYjeEQ7JiN4QTsmI3g5OyYjeDk7YzEuODY1LTAuMTA3LDUuNDkyLTAuNTg3LDUuNDkyLTAuNTg3Ii8+CiAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzIzMUYyMCIgc3Ryb2tlLXdpZHRoPSIxLjIiIGQ9Ik04MS42NTYsNDAuNjcxYzAsMCw0LjU0OS0wLjc0Myw2Ljg1OS0xLjU0OSYjeEQ7JiN4QTsmI3g5OyYjeDk7YzIuNzE1LTAuOTQyLDQuNTQzLTIuNTQ1LDQuNTQzLTIuNTQ1Ii8+CiAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzIzMUYyMCIgc3Ryb2tlLXdpZHRoPSIxLjIiIGQ9Ik0yMi4zMzcsNDEuOTA5YzAsMC0yLjM4NC0xLjc3Ny02LjExNy0zLjQzJiN4RDsmI3hBOyYjeDk7JiN4OTtjLTQuMTM0LTEuODMxLTYuNDA1LTIuMzAzLTYuNDA1LTIuMzAzIi8+CiAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzIzMUYyMCIgc3Ryb2tlLXdpZHRoPSIxLjIiIGQ9Ik04Mi4xMTcsNDYuNjIyYzAsMCwyLjcyNiwxLjEwNCw1LjUzMywxLjM4NSYjeEQ7JiN4QTsmI3g5OyYjeDk7YzIuNzcsMC4yNzYsNC42NDYsMC4xMSw0LjY0NiwwLjExIi8+CiAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzAwMDAwMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIGQ9Ik01Mi4zNSwxNC4yMTImI3hEOyYjeEE7JiN4OTsmI3g5O2MyLjg0LDAuNywzLjg4NywxLjQ2OSwzLjg4NywxLjQ2OSIvPgogICAgICA8bGluZSBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAwMDAiIHgxPSIzMy44OTgiIHkxPSIxMy42ODQiIHgyPSIzOS45NTYiIHkyPSIxOC4wNDIiLz4KICAgIDwvZz4KICAgIDxnIGlkPSJMYXllcl81Ij4KICAgICAgPHBhdGggZmlsbD0iI0ZGRkZGRiIgc3Ryb2tlPSIjMjMxRjIwIiBkPSJNNzEuODQsMjUuMzY2YzIuOTI0LDQuNDc5LDMuMDMzLDkuNTkxLDAuMjQyLDExLjQxNSYjeEQ7JiN4QTsmI3g5OyYjeDk7Yy0yLjc5MywxLjgyNS03LjQyNi0wLjMzMi0xMC4zNTQtNC44MTNjLTIuOTMzLTQuNDgtMy4wMzctOS41ODktMC4yNDQtMTEuNDE1QzY0LjI3NSwxOC43Myw2OC45MTMsMjAuODg0LDcxLjg0LDI1LjM2NnoiLz4KICAgICAgPHBhdGggZmlsbD0iIzIzMUYyMCIgZD0iTTcxLjA4OSwzMi41MjJjMCwxLjA4LTAuODAyLDEuOTU2LTEuOCwxLjk1NmMtMC45OTMsMC0xLjgwMy0wLjg3Ny0xLjgwMy0xLjk1NiYjeEQ7JiN4QTsmI3g5OyYjeDk7YzAtMS4wOCwwLjgxLTEuOTU4LDEuODAzLTEuOTU4QzcwLjI4NywzMC41NjQsNzEuMDg5LDMxLjQ0Miw3MS4wODksMzIuNTIyIi8+CiAgICA8L2c+CiAgICA8ZyBpZD0iTGF5ZXJfNyI+CiAgICAgIDxwYXRoIGZpbGw9IiNGRkZGRkYiIHN0cm9rZT0iIzIzMUYyMCIgZD0iTTQ3Ljg2NywyOC42MTljMi45MjYsNC40OCwyLjYxOSw5Ljg2Mi0wLjY4MSwxMi4wMTUmI3hEOyYjeEE7JiN4OTsmI3g5O2MtMy4zMDIsMi4xNTktOC4zNTEsMC4yNzItMTEuMjc2LTQuMjA4Yy0yLjkyOC00LjQ4LTIuNjI0LTkuODYsMC42NzgtMTIuMDE3QzM5Ljg5MSwyMi4yNTMsNDQuOTM4LDI0LjEzNyw0Ny44NjcsMjguNjE5eiIvPgogICAgICA8cGF0aCBmaWxsPSIjMjMxRjIwIiBkPSJNNDYuMDc5LDM0LjUwN2MwLDEuMDgxLTAuODAzLDEuOTU3LTEuODAxLDEuOTU3Yy0wLjk5MiwwLTEuODAzLTAuODc4LTEuODAzLTEuOTU3JiN4RDsmI3hBOyYjeDk7JiN4OTtjMC0xLjA4LDAuODExLTEuOTU3LDEuODAzLTEuOTU3QzQ1LjI3NCwzMi41NSw0Ni4wNzksMzMuNDI3LDQ2LjA3OSwzNC41MDciLz4KICAgIDwvZz4KICAgIDxwYXRoIGZpbGw9IiM1RTRBNDIiIHN0cm9rZT0iIzAwMDAwMCIgZD0iTTU5Ljc2NiwzNy45MjZjMS44NTQsMCw0LjU1NS0wLjI4NCw0LjY5NywwLjU2OWMwLjE0MywwLjg1NS0xLjcwOSw0LjIwMy0yLjk4OCw0LjM0NSYjeEQ7JiN4QTsmI3g5O2MtMS4yODMsMC4xNDItNi4xMjUtMi4zNTMtNi4xOTUtMy45MTlDNTUuMjA2LDM3LjM1NSw1OC4wNTUsMzcuOTI2LDU5Ljc2NiwzNy45MjZ6Ii8+CiAgICA8ZyBpZD0iTGF5ZXJfNCI+CiAgICAgIDxwYXRoIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzIzMUYyMCIgc3Ryb2tlLXdpZHRoPSIxLjIiIGQ9Ik00Ni43NzQsNDUuMjM1YzAsMCwxMC4zNDcsMy4wNTQsMTQuMjE3LDMuODk3JiN4RDsmI3hBOyYjeDk7JiN4OTtjMy44NjgsMC44NDIsMTAuODUxLDEuNjg0LDEwLjg1MSwxLjY4NHMtNy45OSwxMC4yNDUtMTcuMzI4LDcuNjQ0QzQ1LjE3Niw1NS44NjMsNDUuMzQ1LDQ5Ljk3NSw0Ni43NzQsNDUuMjM1eiIvPgogICAgPC9nPgogIDwvZz4KPC9zdmc+", true, PIXI.scaleModes.LINEAR);
+ else {
+ //console.log("not default"+baseLayer);
+ //TODO temporary get resource from localhost
+ //this.baseLayerTexture = PIXI.Texture.fromImage(Server.getAssetURL(baseLayer), true, PIXI.scaleModes.LINEAR);
+ this.baseLayerTexture = PIXI.Texture.fromImage(baseLayer, true, PIXI.scaleModes.LINEAR);
+ }
+ } else if (baseLayer) {
+ this.baseLayerTexture = PIXI.Texture.fromCanvas(baseLayer, PIXI.scaleModes.LINEAR);
+ }
+ if (typeof baseLayer === 'object') {this.baseLayerTexture = PIXI.Texture.fromImage(baseLayer.src, true, PIXI.scaleModes.LINEAR);}
+ if (typeof textLayer === 'string') { // MD5
+ this.textLayerMD5 = textLayer;
+ this.textLayerTexture = PIXI.Texture.fromImage(Server.getAssetURL(textLayer), true, PIXI.scaleModes.LINEAR);
+ }
+ this.name = name;
+ this.cx = cx || 0;
+ this.cy = cy || 0;
+ this.pixelRatio = pixelRatio || 1;
+ this.scale = 1 / this.pixelRatio;
+ this.width = this.height = 1;
+ this.loaded = false;
+ if (this.baseLayerTexture) {
+ this.baseLayerTexture.baseTexture.resolution = this.pixelRatio;
+ this.baseLayerTexture.on('update', this.updateSize.bind(this));
+ }
+ }
+
+ Costume.centered = function(name, image) {
+ return new Costume(name, image, image.width / 2 | 0, image.height / 2 | 0);
+ };
Costume.prototype.toJSON = function() {
return {
@@ -1621,9 +1946,9 @@
};
Costume.deserialize = function(json) {
- var cx = Math.max(-1e6, Math.min(1e6, Number(json.rotationCenterX)));
- var cy = Math.max(-1e6, Math.min(1e6, Number(json.rotationCenterY)));
- var pr = Math.max(1, Math.min(16, Number(json.bitmapResolution) || 0));
+ var cx = Math.max(-1e6, Math.min(1e6, +json.rotationCenterX));
+ var cy = Math.max(-1e6, Math.min(1e6, +json.rotationCenterY));
+ var pr = Math.max(1, Math.min(16, +json.bitmapResolution || 0));
var canvas = ''+json.baseLayerMD5;
var textLayer = json.textLayerMD5 && ''+json.textLayerMD5;
if (typeof json.baseLayerID === 'number' && json.baseLayerID > -1) {
@@ -1636,42 +1961,28 @@
};
Costume.prototype.copy = function() {
- var c = new Costume(this.name, this.canvas, this.cx, this.cy);
+ var c = new Costume(this.name, null, this.cx, this.cy, this.pixelRatio);
+ c.baseLayerTexture = this.baseLayerTexture;
c.baseLayerMD5 = this.baseLayerMD5;
+ c.textLayerTexture = this.textLayerTexture;
+ c.textLayerMD5 = this.textLayerMD5;
+ c.updateSize();
return c;
};
- Costume.prototype.baseLayerLoaded = function() {
- if (this.textLayer) {
- if (this.textLayer.width) {
- this.composite();
- } else {
- this.textLayer.addEventListener('load', this.composite.bind(this));
- }
- } else {
- this.imageLoaded();
- }
- };
-
- Costume.prototype.composite = function() {
- this.canvas = document.createElement('canvas');
- this.canvas.width = this.baseLayer.width;
- this.canvas.height = this.baseLayer.height;
- var context = this.canvas.getContext('2d');
- context.drawImage(this.baseLayer, 0, 0);
- if (this.textLayer.width) context.drawImage(this.textLayer, 0, 0);
- this.imageLoaded();
- };
-
- Costume.prototype.imageLoaded = function() {
+ Costume.prototype.updateSize = function() {
this.loaded = true;
- this.updateSize();
+ this.width = this.baseLayerTexture.width * this.scale;
+ this.height = this.baseLayerTexture.height * this.scale;
this.changed();
};
Costume.prototype.changed = function(fromEditor) {
if (this.owner) {
- this.owner.redraw();
+ var i = this.owner.costumes.indexOf(this);
+ if (i === this.owner.costume) {
+ this.owner.redraw();
+ }
var s = this.owner.stage || this.owner;
if (s.isStage && s.editor && s.editor.selectedSprite === this.owner) {
var costumesPanel = s.editor.tabPanel.costumesPanel;
@@ -1712,6 +2023,8 @@
this.contents = contents || [];
}
+ List.prototype.isList = true;
+
List.prototype.toJSON = function() {
return {
listName: this.name,
@@ -1777,13 +2090,13 @@
this.rotationStyle =
json.rotationStyle === 'leftRight' ||
json.rotationStyle === 'none' ? json.rotationStyle : 'normal';
- this.x = Math.max(-1e6, Math.min(1e6, Number(json.scratchX) || 0));
- this.y = Math.max(-1e6, Math.min(1e6, Number(json.scratchY) || 0));
- this.direction = json.direction == null ? 90 : 180 - (180 - (Number(json.direction) || 0) % 360) % 360 || 0;
- this.scale = json.scale == null ? 1 : Math.max(0, Math.min(1000, Number(json.scale) || 0));
- this.visible = json.visible == null ? true : !!json.visible;
+ this.x = Math.max(-1e6, Math.min(1e6, +json.scratchX || 0));
+ this.y = Math.max(-1e6, Math.min(1e6, +json.scratchY || 0));
+ this.direction = json.direction == null ? 90 : 180 - (180 - (+json.direction || 0) % 360) % 360 || 0;
+ this.scale = json.scale == null ? 1 : Math.max(0, Math.min(1000, +json.scale || 0));
+ this.visible = json.visible == null || !!json.visible;
this.isDraggable = !!json.isDraggable;
- this.indexInLibrary = Math.max(-1e6, Math.min(1e6, Number(json.indexInLibrary) || 0));
+ this.indexInLibrary = Math.max(-1e6, Math.min(1e6, +json.indexInLibrary || 0));
this.info = typeof json.spriteInfo === 'object' && !Array.isArray(json.spriteInfo) ? json.spriteInfo : {};
return this;
};
@@ -1830,8 +2143,8 @@
Sprite.prototype.opaqueAt = function(x, y) {
hitTestCanvas.width = hitTestCanvas.height = 1;
var costume = this.costumes[this.costume];
- if (!costume || !costume.canvas.width) return false;
- hitTestContext.drawImage(costume.canvas, -x - costume.cx, -y - costume.cy);
+ if (!costume || !costume.loaded) return false;
+ hitTestContext.drawImage(costume.baseLayerTexture.baseTexture.source, -x - costume.cx, -y - costume.cy);
return hitTestContext.getImageData(0, 0, 1, 1).data[3] !== 0;
};
@@ -1880,8 +2193,10 @@
this.width = 480;
this.height = 360;
+ this.visible = true;
this.tempo = 60;
+ this.volume = 100;
this.children = [];
this.sprites = [];
@@ -1894,23 +2209,41 @@
this.author = '';
this.isPublic = true;
- this.el = el('stage');
+ this.pixiStage = new PIXI.Stage(0xffffff);
+ this.pixiStage.addChild(this.pixiSprite);
+ this.pixiRenderer = PIXI.autoDetectRenderer(480, 360);
- this.canvas = el('canvas', 'Visual-absolute');
- this.canvas.width = this.width;
- this.canvas.height = this.height;
- this.context = this.canvas.getContext('2d');
- this.el.appendChild(this.canvas);
+ this.el = cl('stage', [
+ this.pixiRenderer.view
+ ]);
- this.penCanvas = document.createElement('canvas');
- this.penCanvas.width = this.width;
- this.penCanvas.height = this.height;
+ this.penCanvas = el('canvas');
this.penContext = this.penCanvas.getContext('2d');
+
+ this.updatePixelRatio(true);
+ this.render = this.render.bind(this);
+ this.renderScheduled = false;
}
inherits(Stage, ScratchObj);
Stage.prototype.isStage = true;
+ Stage.prototype.redraw = function() {
+ if (this.renderScheduled) return;
+ requestAnimationFrame(this.render);
+ this.renderScheduled = true;
+ };
+
+ Stage.prototype.render = function() {
+ this.renderScheduled = false;
+ this.updatePixi();
+ var sprites = this.sprites;
+ for (var i = sprites.length; i--;) {
+ sprites[i].updatePixi();
+ }
+ this.pixiRenderer.render(this.pixiStage);
+ };
+
Stage.prototype.toJSON = function() {
var json = ScratchObj.prototype.toJSON.call(this, json);
json.tempoBPM = this.tempo;
@@ -1935,12 +2268,18 @@
Stage.prototype.fromJSON = function(json) {
ScratchObj.prototype.fromJSON.call(this, json);
- this.tempo = json.tempoBPM == null ? 60 : Math.max(20, Math.min(500, Number(json.tempoBPM) || 0));
+ this.tempo = json.tempoBPM == null ? 60 : Math.max(20, Math.min(500, +json.tempoBPM || 0));
if (Array.isArray(json.children)) {
json.children.forEach(function(child) {
if (child.objName) this.add(new Sprite().fromJSON(child));
}, this);
- this.children.concat(this).forEach(function(child, i) {
+ json.children.forEach(function(child, i) {
+ if (child.cmd) {
+ var watcher = Watcher.deserialize(this, child);
+ if (watcher) this.add(watcher);
+ }
+ }, this);
+ this.sprites.concat(this).forEach(function(child, i) {
child.lists.forEach(function(list) {
if (list.watcher) this.add(list.watcher);
}, this);
@@ -1957,12 +2296,23 @@
if (this.children.indexOf(child) === -1) {
this.children.push(child);
child.stage = this;
- if (child.isSprite) this.sprites.push(child);
+ if (child.isSprite) {
+ this.sprites.push(child);
+ this.pixiStage.addChild(child.pixiSprite);
+ }
if (child.isWatcher) this.el.appendChild(child.el);
}
return this;
};
+ Stage.prototype.bringToFront = function(child) {
+ if (child.isSprite) {
+ this.pixiStage.setChildIndex(child.pixiSprite, this.pixiStage.children.length - 1);
+ } else {
+ this.el.appendChild(child.el);
+ }
+ };
+
Stage.prototype.remove = function(child) {
if (!child || child.stage !== this) return;
var i = this.children.indexOf(child);
@@ -1976,9 +2326,20 @@
return this;
};
- Stage.prototype.redraw = function() {
- this.canvas.width = this.canvas.width;
- this.drawOn(this.context);
+ Stage.prototype.updatePixelRatio = function(quiet) {
+ var pr = window.devicePixelRatio || 1;
+ if (pr === this.pixelRatio) return;
+
+ this.pixelRatio = pr;
+ this.pixiRenderer.resolution = pr;
+ this.pixiRenderer.resize(this.width, this.height);
+ this.pixiRenderer.view.style.transform = 'scale('+(1/pr)+','+(1/pr)+')';
+
+ this.penCanvas.width = this.width * pr;
+ this.penCanvas.height = this.height * pr;
+ this.penContext.scale(pr, pr);
+
+ if (!quiet) this.redraw();
};
Stage.prototype.drawOn = function(context) {
@@ -1989,13 +2350,22 @@
context.drawImage(costume.canvas, 0, 0);
context.restore();
}
- context.drawImage(this.penCanvas, 0, 0);
+ context.drawImage(this.penCanvas, 0, 0, this.width, this.height);
var sprites = this.sprites;
for (var i = 0, length = sprites.length; i < length; i++) {
sprites[i].drawOn(context);
}
};
+ Stage.prototype.reset = function() {
+ this.clearEffects();
+ var sprites = this.sprites;
+ for (var i = 0, l = sprites.length; i < l; i++) {
+ sprites[i].clearEffects();
+ }
+ this.redraw();
+ };
+
Stage.prototype.forEachScript = function(fn, context) {
var sprites = this.sprites;
for (var i = 0, l = sprites.length; i < l; i++) {
@@ -2027,14 +2397,81 @@
};
Stage.prototype.findObject = function(name) {
+ return this.name === name ? this : this.findSprite(name);
+ };
+
+ Stage.prototype.findSprite = function(name) {
var sprites = this.sprites;
for (var i = 0, l = sprites.length; i < l; i++) {
if (sprites[i].name === name) return sprites[i];
}
- return this.name === name ? this : null;
+ return null;
+ };
+
+ Stage.prototype.toggleWatcher = function(array, target, force) {
+ if (array[0] === 'contentsOfList:') {
+ return this.toggleListWatcher(array[1], target, force);
+ }
+ return this.toggleValueWatcher(array[0], array[1], target, force);
+ };
+
+ Stage.prototype.toggleValueWatcher = function(kind, arg, target, force) {
+ var info = Watcher.kinds[kind];
+ if (info && (info.isGlobal || info.isSensor)) target = this;
+ if (kind === 'readVariable' && !target.findLocal(arg)) {
+ target = this;
+ target.findOrCreateLocal(arg);
+ }
+ var watcher = this.findValueWatcher(kind, arg, target);
+ if (watcher) {
+ if (watcher.visible = force == null ? !watcher.visible : force) {
+ this.bringToFront(watcher);
+ watcher.update();
+ }
+ return watcher.visible;
+ }
+ if (force === false) return;
+ watcher = new Watcher(target, kind, arg);
+ watcher.moveTo(5, 5); // NS
+ this.add(watcher);
+ return true;
+ };
+
+ Stage.prototype.toggleListWatcher = function(name, target, force) {
+ var list = target.findLocalList(name);
+ if (!list) {
+ target = this;
+ list = target.findOrCreateLocalList(name);
+ }
+ var watcher = this.findListWatcher(name, target);
+ if (watcher) {
+ if (watcher.visible = force == null ? !watcher.visible : force) {
+ this.bringToFront(watcher);
+ watcher.update();
+ }
+ return watcher.visible;
+ }
+ watcher = new ListWatcher(target, list);
+ watcher.moveTo(5, 5); // NS
+ this.add(watcher);
+ return true;
+ };
+
+ Stage.prototype.findWatcher = function(array, target) {
+ if (array[0] === 'contentsOfList:') {
+ return this.findListWatcher(array[1], target);
+ }
+
+ var info = Watcher.kinds[array[0]];
+ if (info && (info.isGlobal || info.isSensor) ||
+ array[0] === 'readVariable' && !target.findLocal(array[1])) {
+ target = this;
+ }
+ return this.findValueWatcher(array[0], array[1], target);
};
Stage.prototype.findListWatcher = function(name, target) {
+ if (!target.findLocalList(name)) target = this;
var children = this.children;
for (var i = children.length; i--;) {
var c = children[i];
@@ -2043,27 +2480,54 @@
return null;
};
- Stage.prototype.uniqueName = function(base) {
- var x = /\d+$/.exec(base);
- var i = 2;
- if (x) {
- base = base.slice(0, -x[0].length);
- i = Number(x[0]);
+ Stage.prototype.findValueWatcher = function(kind, arg, target) {
+ var children = this.children;
+ for (var i = children.length; i--;) {
+ var c = children[i];
+ if (c.isWatcher && c.kind === kind && c.arg === arg && c.target === target) return c;
}
- var sprites = this.children;
- search: for (;;) {
- var name = base + i;
- var j = sprites.length;
- while (j--) {
- if (sprites[j].name === name) {
- i++;
- continue search;
- }
- }
- return name;
+ return null;
+ };
+
+ Stage.prototype.removeWatcher = function(array, target) {
+ var watcher = this.findWatcher(array, target);
+ if (watcher) this.remove(watcher);
+ };
+
+ Stage.prototype.updateWatcher = function(array, target) {
+ var watcher = this.findWatcher(array, target);
+ if (watcher && watcher.visible) watcher.update();
+ };
+
+ Stage.prototype.updateWatchers = function(sensorOnly) {
+ var children = this.children;
+ for (var i = children.length; i--;) {
+ var c = children[i];
+ if (c.update && c.visible && (!sensorOnly || c.isSensor)) c.update();
}
};
+ Stage.prototype.updateWatcherLabels = function(target) {
+ var children = this.children;
+ for (var i = children.length; i--;) {
+ var c = children[i];
+ if (c.isWatcher && (!target || c.target === target)) c.updateLabel();
+ }
+ };
+
+ Stage.prototype.uniqueSpriteName = function(base) {
+ if (['_myself_', '_mouse_', '_edge_', '_stage_'].indexOf(base) !== -1) {
+ base = base + '2';
+ }
+ return uniqueName(this.sprites, base);
+ };
+ Stage.prototype.uniqueSoundName = function(base) {
+ if (['_myself_', '_mouse_', '_edge_', '_stage_'].indexOf(base) !== -1) {
+ base = base + '2';
+ }
+ return uniqueName(this.sprites, base);
+ };
+
def(Stage.prototype, 'spriteCount', {get: function() {
return this.sprites.length;
}});
@@ -2084,6 +2548,266 @@
};
+ function Watcher(target, kind, arg, hidden) {
+ this.target = target;
+ this.kind = kind;
+ this.arg = arg;
+ this.value = null;
+ this._visible = true;
+ this._mode = WatcherMode.normal;
+
+ if (kind === 'readVariable') {
+ this.variable = target.findLocal(arg);
+ if (!this.variable) kind = 'undefined';
+ }
+
+ var info = Watcher.kinds[kind];
+ this.color = info.color || Watcher.kinds.undefined.color;
+ this.isSensor = info.isSensor;
+ this.label = info.label || Watcher.kinds.undefined.label;
+ this.read = info.read || Watcher.kinds.undefined.read;
+
+ this.el = cl('watcher', [
+ this.elLabel = cl('watcher-label'),
+ this.elContents = cl('watcher-contents')
+ ]);
+ this.elContents.style.backgroundColor = this.color;
+
+ this.updateLabel();
+ if (hidden) {
+ this.visible = false;
+ } else {
+ this.update();
+ }
+ }
+
+ Watcher.prototype.updateLabel = function() {
+ var label = typeof this.label === 'function' ? this.label() : this.label;
+ this.elLabel.textContent = this.target.isStage ? label : this.target.name + ': ' + label;
+ };
+
+ Watcher.prototype.update = function() {
+ var value = this.read();
+ if (this.value === value) return;
+ // debug:
+ // console.log('update', this.target.name, this.kind, this.arg);
+ this.value = value;
+ if (typeof value === 'number' || ''+(+value) === value) {
+ value = +value;
+ if (Math.abs(value) < 1e10) value = Math.round(value * 1e6) / 1e6;
+ }
+ this.elContents.textContent = value === '' ? '\u200B' : value;
+ };
+
+ Watcher.prototype.objectFromPoint = function(x, y) {
+ var bb = this.el.getBoundingClientRect();
+ return x >= 0 && y >= 0 && x < bb.width && y < bb.height ? this : null;
+ };
+
+ def(Watcher.prototype, 'contextMenu', {get: function() {
+ return new Menu().addAll([].concat([
+ ['normal readout', this.modeSetter(WatcherMode.normal)],
+ ['large readout', this.modeSetter(WatcherMode.large)],
+ ['slider', this.modeSetter(WatcherMode.slider)]],
+ this.mode === WatcherMode.slider ? [
+ Menu.line,
+ ['set slider min and max', this.chooseBounds]] : [], [
+ Menu.line,
+ ['hide', this.hide]])).withContext(this).translate();
+ }});
+
+ Watcher.prototype.modeSetter = function(n) {
+ return function() {this.mode = n}.bind(this);
+ };
+
+ Watcher.prototype.hide = function() {
+ this.visible = false;
+ };
+
+ Watcher.prototype.isWatcher = true;
+ Watcher.prototype.moveTo = vis.util.moveTo;
+
+ def(Watcher.prototype, 'mode', {
+ get: function() {return this._mode},
+ set: function(value) {
+ if (this._mode !== value) {
+ this._mode = value;
+ this.el.className = 'watcher' + (
+ value === WatcherMode.large ? ' large' :
+ value === WatcherMode.slider ? ' slider' : '');
+ }
+ }
+ });
+
+ def(Watcher.prototype, 'visible', {
+ get: function() {return this._visible},
+ set: function(value) {
+ if (this._visible !== value) {
+ this._visible = value;
+ this.el.style.visibility = value ? 'visible' : 'hidden';
+ }
+ }
+ });
+
+ Watcher.prototype.toJSON = function() {
+ return {
+ target: this.target.name,
+ cmd: this.kind === 'readVariable' ? 'getVar:' : this.kind,
+ param: this.arg,
+ color: this.color,
+ label: this.elLabel.textContent,
+ mode: this.mode,
+ sliderMin: undefined,
+ sliderMax: undefined,
+ isDiscrete: undefined,
+ x: this.x,
+ y: this.y,
+ visible: this.visible
+ };
+ };
+
+ Watcher.deserialize = function(stage, json) {
+ var target = stage.findObject(json.target);
+ return target && new Watcher(target, json.cmd === 'getVar:' ? 'readVariable' : json.cmd, json.param, !json.visible).fromJSON(json);
+ };
+
+ Watcher.prototype.fromJSON = function(json) {
+ this.moveTo(+json.x || 0, +json.y || 0);
+ this.sliderMin = +json.sliderMin || 0;
+ this.sliderMax = json.sliderMin == null ? 100 : +json.sliderMin || 0;
+ this.isDiscrete = json.isDiscrete == null || !!json.isDiscrete;
+ this.mode = json.mode === WatcherMode.large || json.mode === WatcherMode.slider ? json.mode : WatcherMode.normal;
+ // TODO
+ return this;
+ };
+
+ var WatcherMode = {
+ normal: 1,
+ large: 2,
+ slider: 3
+ };
+
+ Watcher.kinds = {
+ answer: {
+ isGlobal: true,
+ color: getCategoryColor(7),
+ label: 'answer'
+ },
+ backgroundIndex: {
+ isGlobal: true,
+ color: getCategoryColor(2),
+ label: 'backdrop #',
+ read: function() {
+ return this.target.costume + 1;
+ }
+ },
+ costumeIndex: {
+ color: getCategoryColor(2),
+ label: 'costume #',
+ read: function() {
+ return this.target.costume + 1;
+ }
+ },
+ readVariable: {
+ color: getCategoryColor(9),
+ label: function() {
+ return this.arg;
+ },
+ read: function() {
+ return this.variable.value;
+ }
+ },
+ heading: {
+ color: getCategoryColor(1),
+ label: 'direction',
+ read: function() {
+ return this.target.isSprite ? this.target.direction : 0;
+ }
+ },
+ scale: {
+ color: getCategoryColor(2),
+ label: 'size',
+ read: function() {
+ return this.target.isSprite ? this.target.scale * 100 : 1;
+ }
+ },
+ sceneName: {
+ isGlobal: true,
+ color: getCategoryColor(2),
+ label: 'backdrop name',
+ read: function() {
+ var costume = this.target.costumes[this.target.costume];
+ return costume ? costume.name : '';
+ }
+ },
+ senseVideoMotion: {
+ isSensor: true,
+ color: getCategoryColor(7),
+ label: function() {
+ return _('video {type}', {type: this.arg});
+ }
+ },
+ soundLevel: {
+ isSensor: true,
+ color: getCategoryColor(7),
+ label: 'loudness'
+ },
+ tempo: {
+ isGlobal: true,
+ color: getCategoryColor(3),
+ label: 'tempo',
+ read: function() {
+ return this.target.tempo;
+ }
+ },
+ timeAndDate: {
+ isSensor: true,
+ color: getCategoryColor(7),
+ label: function() {
+ return _('current {time}', {time: this.arg});
+ }
+ },
+ timer: {
+ isSensor: true,
+ color: getCategoryColor(7),
+ label: 'timer',
+ read: function() {
+ return this.target.exec ? this.target.exec.getTimer().toFixed(1) : 0; // NS
+ }
+ },
+ volume: {
+ isGlobal: true,
+ color: getCategoryColor(3),
+ label: 'volume',
+ read: function() {
+ return this.target.volume;
+ }
+
+ },
+ xpos: {
+ color: getCategoryColor(1),
+ label: 'x position',
+ read: function() {
+ return this.target.isSprite ? this.target.x : 0;
+ }
+ },
+ ypos: {
+ color: getCategoryColor(1),
+ label: 'y position',
+ read: function() {
+ return this.target.isSprite ? this.target.y : 0;
+ }
+ },
+ undefined: {
+ color: getCategoryColor(undefined),
+ label: '???',
+ read: function() {
+ return '';
+ }
+ }
+ };
+
+
function ListWatcher(target, list, width, height) {
this.target = target;
this.list = list;
@@ -2097,30 +2821,43 @@
}
this.scrollTop = 0;
this._visible = true;
+ this.editIndex = null;
+ this.editor = null;
this.updateCells = this.updateCells.bind(this);
- this.el = el('list-watcher');
- this.el.appendChild(this.elTitle = el('list-watcher-title'));
- this.el.appendChild(this.elContents = el('list-watcher-contents'));
- this.elContents.appendChild(this.elFiller = el('list-watcher-filler'));
- this.el.appendChild(this.elLength = el('list-watcher-length'));
- this.el.appendChild(this.elAddButton = el('button', 'list-watcher-add-button'));
+ this.el = cl('list-watcher', [
+ this.elLabel = cl('list-watcher-title'),
+ this.elContents = cl('list-watcher-contents', [
+ this.elFiller = cl('list-watcher-filler')
+ ]),
+ this.elEmpty = cl('list-watcher-empty', [_('(empty)')]),
+ this.elLength = cl('list-watcher-length'),
+ this.elAddButton = cl('button', 'list-watcher-add-button')
+ ]);
this.elAddButton.addEventListener('click', this.addItem.bind(this));
this.elContents.addEventListener('scroll', this.scroll.bind(this));
+ this.elContents.addEventListener('keydown', this.keyDown.bind(this));
+ this.elContents.addEventListener('mousedown', this.mouseDown.bind(this));
+ this.recoverScroll = this.recoverScroll.bind(this);
- this.elMeasure = el('list-cell-contents list-cell-metrics');
- this.measureNode = document.createTextNode('');
- this.elMeasure.appendChild(this.measureNode);
+ this.elMeasure = cl('list-cell-contents list-cell-metrics', [
+ this.measureNode = document.createTextNode('')
+ ]);
vis.util.metricsContainer.appendChild(this.elMeasure);
this.updateIndexWidth(true);
this.resizeTo(width || 100, height || 200);
this.updateFiller();
- this.updateTitle();
+ this.updateLabel();
this.updateLength();
+
+ this.lengthChanged = false;
+ this.heightChanged = false;
+ this.cellsChanged = false;
+ this.indexChanged = null;
}
ListWatcher.prototype.isWatcher = true;
@@ -2138,10 +2875,17 @@
if (this._visible !== value) {
this._visible = value;
this.el.style.visibility = value ? 'visible' : 'hidden';
+ if (value) setTimeout(this.recoverScroll);
}
}
});
+ ListWatcher.prototype.recoverScroll = function() {
+ if (this.elContents.scrollTop !== this.scrollTop) {
+ this.elContents.scrollTop = this.scrollTop;
+ }
+ };
+
ListWatcher.prototype.objectFromPoint = function(x, y) {
return x >= -1 && y >= -1 && x < this.width && y < this.height ? this : null;
};
@@ -2166,8 +2910,8 @@
var delim = this.guessDelimiter(lines);
if (delim) {
var count = lines[0].split(delim).length;
- Dialog.prompt(T('Import List'), T('Which column do you want to import? (1-{count} or "all")?', {count: count}), '1', function(column) {
- var n = Math.round(Number(column)) - 1;
+ Dialog.prompt(_('Import List'), _('Which column do you want to import? (1-{count} or "all")?', {count: count}), '1', function(column) {
+ var n = Math.round(+column) - 1;
if (n !== n || n < 0 || n >= count) {
this.setContents(lines);
} else {
@@ -2202,6 +2946,7 @@
};
ListWatcher.prototype.setContents = function(lines) {
+ if (this.editor) this.editor.acceptEdit();
this.list.contents = lines;
this.updateLength();
this.updateFiller();
@@ -2213,7 +2958,7 @@
if (hasOwnProperty.call(this.measureCache, text)) {
return this.measureCache[text];
}
- this.measureNode.data = text + '\u200C';
+ this.measureNode.data = text + '\u200B';
return this.measureCache[text] = this.elMeasure.offsetHeight - 1;
};
@@ -2246,6 +2991,7 @@
this.frameHeight = h - 42;
this.el.style.width = (w + 2)+'px';
this.el.style.height = (h + 2)+'px';
+ this.elEmpty.style.lineHeight = this.frameHeight+'px';
this.updateCellWidth();
};
@@ -2259,11 +3005,15 @@
var w = ListWatcher.measureIndex(n).width + 7;
this.indexWidth = w;
+ var transform = 'translate('+w+'px,0)';
+ var css = w+'px';
+
var pool = this.cellPool;
for (var i = pool.length; i--;) {
var cell = pool[i];
- vis.util.setTransform(cell.elContents, 'translate('+w+'px,0)');
- cell.elIndex.style.width = w+'px';
+ vis.util.setTransform(cell.elContents, transform);
+ if (cell.elField) vis.util.setTransform(cell.elField, transform);
+ cell.elIndex.style.width = css;
}
if (!quiet) this.updateCellWidth();
@@ -2273,43 +3023,84 @@
ListWatcher.prototype.updateCellWidth = function() {
// console.log('update cell width'); // debug
this.cellWidth = this.width - 7 - this.indexWidth - vis.util.scrollbarWidth;
- this.elMeasure.style.width = this.cellWidth+'px';
+ var css = this.cellWidth+'px';
+ this.elMeasure.style.width = css;
this.measureCache = Object.create(null);
var pool = this.cellPool;
for (var i = pool.length; i--;) {
- pool[i].elContents.style.width = this.cellWidth+'px';
+ var cell = pool[i];
+ cell.elContents.style.width = css;
+ if (cell.elField) cell.elField.style.width = css;
}
this.measureAll();
this.updateCells();
};
- ListWatcher.prototype.addItem = function() {
- this.list.contents.push('');
- this.itemAdded();
+ ListWatcher.prototype.addItem = function(e) {
+ var i = this.lastEditIndex;
+ var length = this.list.contents.length;
+ var j = i == null ? // NS for shift + add button
+ (e.shiftKey ? 0 : length) :
+ e.shiftKey ? i : Math.min(length, i + 1);
+ this.list.contents.splice(j, 0, '');
+ this.itemInserted(j);
+ this.edit(j);
};
ListWatcher.prototype.moveTo = vis.util.moveTo;
- ListWatcher.prototype.updateTitle = function() {
- // console.log('update title'); // debug
- this.elTitle.textContent = this.target.isStage ? this.list.name : T('{object}: {name}', {object: this.target.name, name: this.list.name});
+ ListWatcher.prototype.updateLabel = function() {
+ // console.log('update label'); // debug
+ this.elLabel.textContent = this.target.isStage ? this.list.name : _('{object}: {name}', {object: this.target.name, name: this.list.name});
};
ListWatcher.prototype.updateLength = function(quiet) {
+ if (ListWatcher.atomic) {
+ this.lengthChanged = true;
+ return;
+ }
// console.log('update length'); // debug
- this.elLength.textContent = T('length: {count}', {count: this.list.contents.length});
+ this.elLength.textContent = _('length: {count}', {count: this.list.contents.length});
this.updateIndexWidth(quiet);
};
ListWatcher.prototype.updateFiller = function() {
+ if (ListWatcher.atomic) {
+ this.heightChanged = true;
+ return;
+ }
// console.log('update filler'); // debug
this.elFiller.style.height = this.contentHeight + 'px';
};
+ ListWatcher.prototype.update = function() {
+ if (!this.visible) return;
+ if (this.lengthChanged) {
+ this.updateLength();
+ this.lengthChanged = false;
+ }
+ if (this.heightChanged) {
+ this.updateFiller();
+ this.heightChanged = false;
+ }
+ if (this.editIndex != null) {
+ this.edit(this.editIndex);
+ } else if (this.indexChanged) {
+ this.scrollToIndex(this.indexChanged, true);
+ } else if (this.cellsChanged) {
+ this.updateCells();
+ }
+ this.indexChanged = this.cellsChanged = false;
+ };
+
ListWatcher.prototype.itemsCleared = function() {
+ if (this.editor) {
+ this.editor.acceptEdit();
+ }
this.cellHeights = [];
+ this.accessTimes = [];
this.contentHeight = 0;
this.updateLength();
this.updateFiller();
@@ -2321,6 +3112,7 @@
var last = contents.length - 1;
var h = this.measure(contents[last]);
this.cellHeights.push(h);
+ this.accessTimes.push(0);
this.contentHeight += h;
this.updateLength();
this.updateFiller();
@@ -2330,22 +3122,35 @@
ListWatcher.prototype.itemInserted = function(i) {
var h = this.measure(this.list.contents[i]);
this.cellHeights.splice(i, 0, h);
+ this.accessTimes.splice(i, 0, 0);
this.contentHeight += h;
+ var ei = this.editIndex;
this.updateLength();
this.updateFiller();
this.scrollToIndex(i);
+ if (ei != null && ei >= i) {
+ this.edit(ei + 1);
+ }
};
ListWatcher.prototype.itemDeleted = function(i) {
var heights = this.cellHeights;
this.contentHeight -= heights[i];
heights.splice(i, 1);
+ this.accessTimes.splice(i, 1);
+ var ei = this.editIndex;
+ if (ei === i) {
+ this.editor.acceptEdit();
+ }
this.updateLength();
this.updateFiller();
this.scrollToIndex(i === this.list.contents.length ? i - 1 : i);
+ if (ei != null && ei > i) {
+ this.edit(ei - 1);
+ }
};
- ListWatcher.prototype.itemChanged = function(i) {
+ ListWatcher.prototype.itemChanged = function(i, quiet) {
var heights = this.cellHeights;
var oh = heights[i];
var h = this.measure(this.list.contents[i]);
@@ -2354,27 +3159,37 @@
heights[i] = h;
this.updateFiller();
}
- this.scrollToIndex(i);
+ if (quiet) {
+ this.updateCells();
+ } else {
+ this.scrollToIndex(i);
+ }
};
ListWatcher.prototype.itemAccessed = function(i) {
this.scrollToIndex(i);
};
- ListWatcher.prototype.scrollToIndex = function(i) {
- var heights = this.cellHeights;
- var y = 0;
- for (var j = 0; j < i; j++) {
- y += heights[j];
+ ListWatcher.prototype.scrollToIndex = function(i, quiet) {
+ if (ListWatcher.atomic) {
+ this.indexChanged = i;
+ } else {
+ var heights = this.cellHeights;
+ var y = 0;
+ for (var j = 0; j < i; j++) {
+ y += heights[j];
+ }
+ var y2 = y + heights[i] + 1;
+ var top = this.scrollTop;
+ if (y < top) {
+ this.elContents.scrollTop = this.scrollTop = y;
+ } else if (y2 > top + this.frameHeight) {
+ this.elContents.scrollTop = this.scrollTop = y2 - this.frameHeight;
+ }
}
- var y2 = y + heights[i] + 1;
- var top = this.scrollTop;
- if (y < top) {
- this.elContents.scrollTop = this.scrollTop = y;
- } else if (y2 > top + this.frameHeight) {
- this.elContents.scrollTop = this.scrollTop = y2 - this.frameHeight;
+ if (!quiet) {
+ this.accessTimes[i] = Date.now();
}
- this.accessTimes[i] = Date.now();
this.updateCells();
};
@@ -2386,7 +3201,70 @@
}
};
+ ListWatcher.prototype.keyDown = function(e) {
+ if (e.metaKey || e.ctrlKey) return;
+ var k = e.keyCode;
+ if ((k === 9 || k === 38 || k === 40) && this.editIndex != null) {
+ e.preventDefault();
+ var length = this.list.contents.length;
+ this.edit((this.editIndex + (k === 9 && e.shiftKey || k === 38 ? length - 1 : 1)) % length);
+ }
+ if (k === 13) {
+ e.preventDefault();
+ this.addItem(e);
+ }
+ e.stopPropagation();
+ };
+
+ ListWatcher.prototype.mouseDown = function(e) {
+ if (e.button !== 0) return;
+ var t = e.target;
+ while (!t.classList.contains('list-cell')) {
+ if (t === this.elContents || t.tagName === 'TEXTAREA') return;
+ t = t.parentNode;
+ }
+ e.preventDefault();
+ var pool = this.cellPool;
+ for (var i = pool.length; i--;) {
+ var cell = pool[i];
+ if (cell.el === t) {
+ this.edit(cell.index);
+ return;
+ }
+ }
+ };
+
+ ListWatcher.prototype.edit = function(index) {
+ if (this.editor) {
+ this.editor.endEdit();
+ }
+ if (ListWatcher.atomic) {
+ this.editIndex = index;
+ return;
+ }
+ this.editIndex = this.lastEditIndex = index;
+ this.scrollToIndex(index, true);
+ this.editor = this.cellCache[index];
+ this.editor.startEdit();
+ };
+
ListWatcher.prototype.updateCells = function() {
+ if (ListWatcher.atomic) {
+ this.cellsChanged = true;
+ return;
+ }
+ var contents = this.list.contents;
+ var length = contents.length;
+ if (length === 0) {
+ if (!this.showEmpty) {
+ this.showEmpty = true;
+ this.elEmpty.style.display = 'block';
+ }
+ } else if (this.showEmpty) {
+ this.showEmpty = false;
+ this.elEmpty.style.display = 'none';
+ }
+
var now = Date.now();
this.animating = false;
@@ -2395,8 +3273,6 @@
var heights = this.cellHeights;
var accessTimes = this.accessTimes;
- var contents = this.list.contents;
- var length = contents.length;
var startIndex = 0;
var startY = 0;
@@ -2430,11 +3306,13 @@
// this.pooledCells = 0;
// this.allocatedCells = 0;
+ this.editor = null;
i = startIndex;
- y = startY
+ y = startY;
while (i < endIndex) {
var cell = this.getCell(i, now - accessTimes[i], heights[i], contents[i]);
cell.moveTo(0, y);
+ if (cell.editing) this.editor = cell;
y += heights[i++];
}
@@ -2447,9 +3325,15 @@
this.cellCache[c.index] = null;
c.index = null;
c.visible = false;
+ if (c.editing) c.endEdit();
c.el.style.display = 'none';
}
+ if (this.editor) {
+ this.editor.elField.focus();
+ this.elContents.scrollTop = this.scrollTop;
+ }
+
if (this.animating) {
cancelAnimationFrame(this.animationFrame);
this.animationFrame = requestAnimationFrame(this.updateCells);
@@ -2462,7 +3346,8 @@
// this.reusedCells++; // debug
if (cell.text !== text) {
cell.text = text;
- cell.elContents.textContent = text+'\u200C';
+ cell.elContents.textContent = text+'\u200B';
+ if (cell.editing) cell.elField.value = text;
}
} else {
if (this.usablePool.length) {
@@ -2470,16 +3355,22 @@
var cell = this.usablePool.pop();
if (cell.text !== text) {
cell.text = text;
- cell.elContents.textContent = text+'\u200C';
+ cell.elContents.textContent = text+'\u200B';
+ if (cell.editing) cell.elField.value = text;
}
if (cell.index != null) {
this.cellCache[cell.index] = null;
}
+ if (cell.editing) {
+ if (this.editIndex !== i) cell.endEdit();
+ } else if (this.editIndex === i) {
+ cell.startEdit();
+ }
cell.index = i;
cell.elIndex.textContent = i + 1;
} else {
// this.allocatedCells++; // debug
- cell = new ListCell(i, height, text);
+ cell = new ListCell(this, i, height, text);
cell.elContents.style.width = this.cellWidth+'px';
vis.util.setTransform(cell.elContents, 'translate('+this.indexWidth+'px,0)');
cell.elIndex.style.width = this.indexWidth+'px';
@@ -2505,25 +3396,66 @@
if (cell.height !== height) {
cell.height = height;
cell.elIndex.style.lineHeight = (height + 1)+'px';
+ if (cell.elField) cell.elField.style.height = (height + 1)+'px';
}
return cell;
};
- function ListCell(index, height, text) {
- this.el = el('list-cell');
- this.el.appendChild(this.elIndex = el('list-cell-index'));
- this.el.appendChild(this.elContents = el('list-cell-contents'));
- this.dt = 800;
+ function ListCell(watcher, index, height, text) {
+ this.watcher = watcher;
this.text = text;
- this.elContents.textContent = text+'\u200C';
this.index = index;
- this.elIndex.textContent = index + 1;
this.height = height;
- this.elIndex.style.lineHeight = (height + 1)+'px';
this.visible = true;
+ this.dt = 800;
+
+ this.el = cl('list-cell', [
+ this.elIndex = cl('list-cell-index', {
+ style: {lineHeight: (height + 1)+'px'}
+ }, [''+(index + 1)]),
+ this.elContents = cl('list-cell-contents', [text+'\u200B'])
+ ]);
}
+ ListCell.prototype.startEdit = function() {
+ this.editing = true;
+ this.elContents.style.display = 'none';
+ if (!this.elField) {
+ this.el.appendChild(this.elField = cl('textarea', 'list-cell-contents'));
+ this.elField.addEventListener('blur', this.acceptEdit.bind(this));
+ this.elField.addEventListener('input', this.update.bind(this));
+ this.elField.spellcheck = false;
+ this.elField.style.height = (this.height + 1)+'px';
+ this.elField.style.width = this.watcher.cellWidth+'px';
+ this.elField.style.transform = this.elContents.style.transform;
+ }
+ this.elField.value = this.text;
+ this.elField.style.display = 'block';
+ this.elField.focus();
+ };
+
+ ListCell.prototype.update = function() {
+ this.watcher.list.contents[this.index] = this.elField.value;
+ this.watcher.itemChanged(this.index, true);
+ };
+
+ ListCell.prototype.endEdit = function() {
+ if (this.editing) {
+ this.editing = false;
+ this.elField.style.display = 'none';
+ this.elContents.style.display = 'block';
+ }
+ };
+
+ ListCell.prototype.acceptEdit = function() {
+ if (this.editing) {
+ this.watcher.editIndex = null;
+ this.watcher.editor = null;
+ this.endEdit();
+ }
+ };
+
ListCell.prototype.moveTo = vis.util.moveTo;
@@ -2534,6 +3466,7 @@
function Interpreter(stage, editor) {
this.stage = stage;
+ this.stage.exec = this;
this.editor = editor;
this.frameRate = 30;
this.warpTime = 500;
@@ -2608,6 +3541,7 @@
};
Interpreter.prototype.stopAll = function() {
+ this.stage.reset();
var threads = this.threads;
for (var i = threads.length; i--;) {
this.stopThread(threads[i]);
@@ -2619,7 +3553,10 @@
if (script.isReporter) {
var pos = script.blocks[0].worldPosition;
this.activeThread = new Thread(this, script, target);
- this.editor.showBubble(this.evalBlock(script.blocks[0]), pos.x + script.width, pos.y);
+ var result = this.evalBlock(script.blocks[0]);
+ if (this.editor) {
+ this.editor.showBubble(result, pos.x + script.width, pos.y);
+ }
return;
}
if (script.thread) {
@@ -2660,8 +3597,9 @@
};
Interpreter.prototype.step = function() {
+ if (this.editor) this.editor.stagePanel.running = !!this.threads.length;
if (this.threads.length === 0) {
- if (this.editor) this.editor.stagePanel.running = false;
+ this.stage.updateWatchers(true);
return;
}
@@ -2670,6 +3608,7 @@
this.redraw = false;
this.start = Date.now();
this.time = this.start;
+ ListWatcher.atomic = true;
do {
if (this.warpThread && this.warpThread.done) this.warpThread = null;
@@ -2694,7 +3633,11 @@
if (this.redraw) {
this.stage.redraw();
}
- if (this.editor) this.editor.stagePanel.running = !!this.threads.length;
+ ListWatcher.atomic = false;
+ this.stage.updateWatchers();
+ if (this.editor) {
+ this.editor.updateInfo();
+ }
};
Interpreter.prototype.stepActiveThread = function() {
@@ -2752,7 +3695,7 @@
Interpreter.prototype.narg = function(b, i) {
var a = b.args[i];
var x = a.isArg ? a.value : this.evalBlock(a);
- return typeof x === 'number' ? x : Number(x) || 0;
+ return typeof x === 'number' ? x : +x || 0;
};
Interpreter.prototype.barg = function(b, i) {
@@ -2765,6 +3708,10 @@
this.timerStart = Date.now();
};
+ Interpreter.prototype.getTimer = function() {
+ return (Date.now() - this.timerStart) / 1000;
+ };
+
Interpreter.prototype.startTimed = function(duration) {
var thread = this.activeThread;
thread.tmp = this.time + Math.max(duration * 1000, 0);
@@ -2824,7 +3771,7 @@
}
function asNumber(x) {
- return typeof x !== 'string' ? Number(x) : /\d/.test(x) ? Number(x) : NaN;
+ return typeof x !== 'string' ? +x : /\d/.test(x) ? +x : NaN;
}
function compare(x, y) {
@@ -2870,7 +3817,7 @@
if (name === '_mouse_') {
pointSpriteTowards(sprite, interp.stage.mouseX, interp.stage.mouseY);
} else {
- var other = interp.stage.findObject(name);
+ var other = interp.stage.findSprite(name);
if (other) pointSpriteTowards(sprite, other.x, other.y);
}
};
@@ -2888,7 +3835,7 @@
if (name === '_mouse_') {
moveSpriteTo(sprite, interp.stage.mouseX, interp.stage.mouseY);
} else {
- var other = interp.stage.findObject(name);
+ var other = interp.stage.findSprite(name);
if (other) moveSpriteTo(sprite, other.x, other.y);
}
};
@@ -2941,6 +3888,23 @@
if (sprite.isSprite) moveSpriteTo(sprite, sprite.x, interp.narg(b, 0));
};
+ table['bounceOffEdge'] = function() {
+ var sprite = interp.activeThread.target;
+ if (sprite.isSprite) {
+ var heading = sprite.isSprite ? sprite.direction : 0;
+ if (sprite.x >= "240"|| sprite.x <= "-240"){
+ heading = (360-heading) % 360;
+ }
+ if (sprite.y >= "180" || sprite.y <= "-180") {
+ heading = (180-heading) % 360;
+ }
+ if (heading !== sprite.direction) {
+ //console.log("bounce off edge. New heading "+heading+" Old heading "+sprite.direction);
+ sprite.direction=heading;
+ }
+ }
+ }
+
var ROTATION_STYLES = {
'all around': 'normal',
'left-right': 'leftRight',
@@ -2971,8 +3935,6 @@
// Looks
- table['say:'] = function(b) {console.log(interp.arg(b, 0))};
-
table['show'] = function() {
var sprite = interp.activeThread.target;
if (sprite.isSprite) {
@@ -2992,11 +3954,13 @@
table['lookLike:'] = function(b) {
var name = interp.arg(b, 0);
var target = interp.activeThread.target;
+ if (target.visible) interp.redraw = true;
if (typeof name !== 'number') {
name = ''+name;
for (var i = target.costumes.length; i--;) {
if (target.costumes[i].name === name) {
- return target.costume = i;
+ target.costume = i;
+ return;
}
}
if (name === 'previous costume') {
@@ -3008,7 +3972,7 @@
name = asNumber(name);
if (name !== name) return;
}
- target.setCostume(name);
+ target.setCostume(name - 1);
};
table['nextCostume'] = function() {
@@ -3028,7 +3992,7 @@
} else {
var n = +name;
if (n === n) {
- i = (n - 1) % count;
+ var i = (n - 1) % count;
if (i < 0) i += count;
} else {
name = ''+name;
@@ -3057,13 +4021,33 @@
interp.yield = true;
interp.waiting = true;
}
- }
+ };
table['nextScene'] = function() {
interp.stage.costume = (interp.stage.costume + 1) % interp.stage.costumes.length;
interp.redraw = true;
};
+ table['changeGraphicEffect:by:'] = function(b) {
+ var target = interp.activeThread.target;
+ var name = interp.arg(b, 0);
+ var v = target.effects[name];
+ if (v == null) return;
+ target.setEffect(name, v + interp.narg(b, 1));
+ interp.redraw = true;
+ };
+
+ table['setGraphicEffect:to:'] = function(b) {
+ var target = interp.activeThread.target;
+ target.setEffect(interp.arg(b, 0), interp.narg(b, 1));
+ interp.redraw = true;
+ };
+
+ table['filterReset'] = function() {
+ interp.activeThread.target.clearEffects();
+ interp.redraw = true;
+ };
+
table['changeSizeBy:'] = function(b) {
var sprite = interp.activeThread.target;
if (sprite.isSprite) {
@@ -3084,10 +4068,7 @@
table['comeToFront'] = function(b) {
var sprite = interp.activeThread.target;
if (sprite.isSprite) {
- var sprites = interp.stage.sprites;
- var i = sprites.indexOf(sprite);
- if (i !== -1) sprites.splice(i, 1);
- sprites.splice(sprites.length, 0, sprite);
+ interp.stage.bringToFront(sprite);
if (sprite.visible) interp.redraw = true;
}
};
@@ -3138,6 +4119,82 @@
table['tempo'] = function() {return interp.stage.tempo};
+ table['playSound:'] = function(b) {
+ //console.log(b.args[0]._value);
+ if(audio){audio.pause();}
+ audio = new Audio('library/sounds/'+b.args[0]._value+'.mp3');
+ audio.volume = parseFloat(interp.stage.volume/100);
+ audio.play();
+ };
+
+ table['doPlaySoundAndWait'] = function(b) {
+ if(audio){audio.pause();}
+ audio = new Audio('library/sounds/'+b.args[0]._value+'.mp3');
+ audio.volume = parseFloat(interp.stage.volume/100);
+ audio.onplaying = function() {
+ console.log(audio.duration);
+ };
+ audio.play();
+ };
+ table['stopAllSounds'] = function(b) {
+ if(audio){audio.pause();}
+ };
+
+ table['playDrum'] = function(b) {
+ //console.log(b.args[0]._value);
+ //console.log(b.args[1]._value);
+ var drums =[
+ 'soundbank/drums/SnareDrum(1)_22k.wav',
+ 'soundbank/drums/BassDrum(1b)_22k.wav',
+ 'soundbank/drums/SideStick(1)_22k.wav',
+ 'soundbank/drums/Crash(2)_22k.wav',
+ 'soundbank/drums/HiHatOpen(2)_22k.wav',
+ 'soundbank/drums/HiHatClosed(1)_22k.wav',
+ 'soundbank/drums/Tambourine(3)_22k.wav',
+ 'soundbank/drums/Clap(1)_22k.wav',
+ 'soundbank/drums/Claves(1)_22k.wav',
+ 'soundbank/drums/WoodBlock(1)_22k.wav',
+ 'soundbank/drums/Cowbell(3)_22k.wav',
+ 'soundbank/drums/Triangle(1)_22k.wav',
+ 'soundbank/drums/Bongo_22k.wav',
+ 'soundbank/drums/Conga(1)_22k.wav',
+ 'soundbank/drums/Cabasa(1)_22k.wav',
+ 'soundbank/drums/GuiroShort(1)_22k.wav',
+ 'soundbank/drums/Vibraslap(1)_22k.wav',
+ 'soundbank/drums/Cuica(2)_22k.wav'
+ ];
+ var fileName=drums[b.args[0]._value-1];
+ //console.log(fileName);
+ if(audio){audio.pause();}
+ audio = new Audio(fileName);
+ audio.volume = parseFloat(interp.stage.volume/100);
+ audio.play();
+ if (interp.activeThread.tmp === null) {
+ interp.startTimed(b.args[1]._value);
+ } else {
+ interp.stepTimed();
+ }
+
+ };
+
+ table['rest:elapsed:from:'] = function(b) {};
+ table['noteOn:duration:elapsed:from:'] = function(b) {};
+
+ table['instrument:'] = function(b) {
+ //console.log(Instr.wavs.getOwnPropertyNames(interp.narg(b, 0)));
+ console.log(b.args[0]._value);
+ //var keys = Object.keys(Instr.wavs)
+ //console.log(Instr.wavs[keys[interp.narg(b, 0)]]);
+ };
+
+ table['changeVolumeBy:'] = function(b) {setVolume(interp.stage.volume + interp.narg(b, 0));};
+
+ table['setVolumeTo:'] = function(b) {setVolume(interp.narg(b, 0));};
+
+ function setVolume(percent){interp.stage.volume = Math.max(0, Math.min(100,percent));}
+
+ table['volume'] = function() {return interp.stage.volume};
+
// Pen
table['clearPenTrails'] = function() {
@@ -3248,7 +4305,15 @@
table['changeVar:by:'] = function(b) {
var v = getVar(interp.arg(b, 0));
- v.value = Number(v.value) + interp.narg(b, 1);
+ v.value = +v.value + interp.narg(b, 1);
+ };
+
+ table['showVariable:'] = function(b) {
+ interp.stage.toggleWatcher(['readVariable', ''+interp.arg(b, 0)], interp.activeThread.target, true);
+ };
+
+ table['hideVariable:'] = function(b) {
+ interp.stage.toggleWatcher(['readVariable', ''+interp.arg(b, 0)], interp.activeThread.target, false);
};
function getListIndex(n, end) {
@@ -3259,7 +4324,7 @@
if (n === 'any' || n === 'random') {
return Math.floor(Math.random() * end);
}
- var i = Number(n);
+ var i = +n;
return i >= 1 && i <= end ? i - 1 : -1;
}
@@ -3351,6 +4416,14 @@
return false;
};
+ table['showList:'] = function(b) {
+ interp.stage.toggleWatcher(['contentsOfList:', ''+interp.arg(b, 0)], interp.activeThread.target, true);
+ };
+
+ table['hideList:'] = function(b) {
+ interp.stage.toggleWatcher(['contentsOfList:', ''+interp.arg(b, 0)], interp.activeThread.target, false);
+ };
+
// Events
table['whenGreenFlag'] = this.primNoop;
@@ -3462,10 +4535,28 @@
var target = interp.arg(b, 0);
if (target === '_mouse_') return sprite.isTouchingMouse();
if (target === '_edge_') return false; // TODO
- target = interp.stage.findObject(target);
+ target = interp.stage.findSprite(target);
return target ? sprite.isTouchingSprite(target) : false;
};
+ table['distanceTo:'] = function(b) {
+ var sprite = interp.activeThread.target;
+ if (!sprite.isSprite) return 10000;
+ var target = interp.arg(b, 0);
+ if (target === '_mouse_') {
+ var x = interp.stage.mouseX;
+ var y = interp.stage.mouseY;
+ } else {
+ target = interp.stage.findSprite(target);
+ if (!target) return 10000;
+ var x = target.x;
+ var y = target.y;
+ }
+ var dx = sprite.x - x;
+ var dy = sprite.y - y;
+ return Math.sqrt(dx * dx + dy * dy);
+ };
+
table['keyPressed:'] = function(b) {
return !!interp.stage.keys[interp.arg(b, 0)];
};
@@ -3475,7 +4566,7 @@
table['mouseY'] = function() {return interp.stage.mouseY};
table['timer'] = function() {
- return (Date.now() - interp.timerStart) / 1000;
+ return interp.getTimer();
};
table['timerReset'] = function() {
interp.resetTimer();
@@ -3665,16 +4756,18 @@
Thread.prototype.expandStack = function() {
var i = this.stack.length || 4;
while (i--) {
- this.stack.push({
- script: null,
- pc: null,
- tmp: null,
- isLoop: null,
- args: null
- });
+ this.stack.push(new StackFrame);
}
};
+ function StackFrame() {
+ this.script = null;
+ this.pc = null;
+ this.tmp = null;
+ this.isLoop = null;
+ this.args = null;
+ }
+
function Editor() {
if (location.hash.length > 1) {
@@ -3682,7 +4775,7 @@
var id = location.hash.slice(1).match(/\d+/)+'';
Server.getProject(id, function(err, data) {
if (err) {
- Dialog.alert(T('Error'), T('Could not fetch project from scratch.mit.edu.')).show(this);
+ Dialog.alert(_('Error'), _('Could not fetch project from scratch.mit.edu.')).show(this);
return;
}
this.installProject(Stage.deserialize(JSON.parse(data)));
@@ -3692,7 +4785,7 @@
this.stage.author = data.creator.username;
this.stage.isPublic = true;
} else {
- this.stage.title = T('Unshared Project ({id})', {id: id});
+ this.stage.title = _('Unshared Project ({id})', {id: id});
this.stage.author = '';
this.stage.isPublic = false;
}
@@ -3703,6 +4796,7 @@
} else {
try {
console.time('load');
+ console.log(localStorage.getItem('pixie project'));
this.stage = Stage.deserialize(JSON.parse(localStorage.getItem('pixie project')));
console.timeEnd('load');
} catch (e) {
@@ -3735,24 +4829,25 @@
this.app.add(this.backpackPanel);
this.app.add(this.tipsPanel);
- this.el = el('editor Visual-no-select');
-
- this.el.appendChild(this.elTopButtons = el('project-buttons'));
- this.elTopButtons.appendChild(this.elShareButton = el('button', 'project-button'));
- this.elShareButton.textContent = T('Share');
- this.elTopButtons.appendChild(this.elFlipButton = el('button', 'project-button flip'));
- this.elFlipButton.innerHTML = ''+T('See project page');
-
- this.el.appendChild(this.topBar.el);
- this.el.appendChild(this.tabPanel.el);
- this.el.appendChild(this.stagePanel.el);
- this.el.appendChild(this.spritePanel.el);
- this.el.appendChild(this.backpackPanel.el);
- this.el.appendChild(this.tipsPanel.el);
+ this.el = cl('editor Visual-no-select', [
+ this.elTopButtons = cl('project-buttons', [
+ this.elShareButton = cl('button', 'project-button', [_('Share')]),
+ this.elFlipButton = cl('button', 'project-button flip', [
+ el('i'),
+ _('See project page')
+ ])
+ ]),
+ this.topBar.el,
+ this.tabPanel.el,
+ this.spritePanel.el,
+ this.backpackPanel.el,
+ this.tipsPanel.el,
+ this.stagePanel.el
+ ]);
this.tabPanel.scriptsPanel.category = 1;
- window.addEventListener('resize', this.app.resize.bind(this.app));
+ window.addEventListener('resize', this.resize.bind(this));
document.addEventListener('mousemove', this.mouseMove.bind(this));
document.addEventListener('mousedown', this.hideBubble.bind(this));
document.addEventListener('wheel', this.hideBubble.bind(this));
@@ -3817,7 +4912,7 @@
stage.add(new Sprite('Sprite1')
.addCostume(new Costume('costume1', 'f9a1c175dbe2e5dee472858dd30d16bb.svg', 47, 55))
.addCostume(new Costume('costume2', 'c68e7b211672862001dd4fce12129813.png', 94, 108, 2)));
- stage.title = T('Untitled');
+ stage.title = _('Untitled');
return stage;
};
@@ -3825,16 +4920,14 @@
this.exec.installProject(stage);
this.spritePanel.installProject(stage);
this.stagePanel.installProject(stage);
+ //this.soundsPanel.installProject(stage); //TODO ????
this.stage = stage;
stage.editor = this;
};
- Editor.prototype.stop = function() {
- clearInterval(this.interval);
- };
-
Editor.prototype.resize = function() {
this.app.resize();
+ this.stage.updatePixelRatio();
};
Editor.prototype.setTitle = function(name) {
@@ -3851,84 +4944,73 @@
Editor.prototype.addVariable = function(name, local, cloud) {
name = name.trim();
if (!name) return;
- if (local && this.selectedSprite.isSprite ? this.selectedSprite.findVariable(name) : this.stage.findNestedLocal(name)) {
- Dialog.alert(T('New Variable'), T('A variable with that name already exists.')).show(this); // NS
- return;
- }
+ if (this.checkName(name, local, _('New Variable'))) return;
(local ? this.selectedSprite : this.stage).createLocal(name);
+ this.toggleWatcher(['readVariable', name]);
+ this.refreshPalette();
+ };
+
+ Editor.prototype.addList = function(name, local, cloud) {
+ name = name.trim();
+ if (!name) return;
+ if (this.checkName(name, local, _('New List'))) return;
+ (local ? this.selectedSprite : this.stage).lists.push(new List(name));
+ this.toggleWatcher(['contentsOfList:', name]);
this.refreshPalette();
};
+ Editor.prototype.checkName = function(name, local, title) {
+ var old = this.findName(name, local);
+ if (old) {
+ Dialog.alert(title, _(old.isList ? 'A list with the name “{name}” already exists.' : 'A variable with the name “{name}” already exists.', {name: name})).show(this); // NS
+ }
+ return old;
+ };
+
+ Editor.prototype.findName = function(name, local) {
+ var t = this.selectedSprite;
+ return local && t.isSprite ? t.findVariable(name) || t.findList(name) : this.stage.findNestedLocal(name) || this.stage.findNestedLocalList(name);
+ };
+
Editor.prototype.removeVariable = function(name) {
- Dialog.confirm(T('Delete Variable'), T('Are you sure you want to delete {name}?', {name: name}), function(allow) { // NS
- if (allow && this.selectedSprite.deleteVariable(name)) {
+ Dialog.confirm(_('Delete Variable'), _('Are you sure you want to delete “{name}”?', {name: name}), function(allow) { // NS
+ if (!allow) return;
+ this.removeWatcher(['readVariable', name]);
+ if (this.selectedSprite.deleteVariable(name)) {
this.refreshPalette();
}
}.bind(this)).show(this);
};
Editor.prototype.removeList = function(name) {
- Dialog.confirm(T('Delete List'), T('Are you sure you want to delete {name}?', {name: name}), function(allow) { // NS
- if (allow && this.selectedSprite.deleteList(name)) {
+ Dialog.confirm(_('Delete List'), _('Are you sure you want to delete “{name}”?', {name: name}), function(allow) { // NS
+ if (!allow) return;
+ this.removeWatcher(['contentsOfList:', name]);
+ if (this.selectedSprite.deleteList(name)) {
this.refreshPalette();
}
}.bind(this)).show(this);
};
- Editor.prototype.addList = function(name, local, cloud) {
- name = name.trim();
- if (!name) return;
- if (local && this.selectedSprite.isSprite ? this.selectedSprite.findList(name) : this.stage.findNestedLocalList(name)) {
- Dialog.alert(T('New List'), T('A list with that name already exists.')).show(this); // NS
- return;
- }
- (local ? this.selectedSprite : this.stage).lists.push(new List(name));
- this.toggleWatcher(['contentsOfList:', name]);
- this.refreshPalette();
- };
-
Editor.prototype.hasWatcher = function(array) {
- if (array[0] === 'contentsOfList:') {
- return this.hasListWatcher(array[1]);
- }
- return false; // TODO
+ var watcher = this.findWatcher(array);
+ return !!watcher && watcher.visible;
};
- Editor.prototype.hasListWatcher = function(name) {
- var watcher = this.findListWatcher(name);
- return !!watcher && watcher.visible;
+ Editor.prototype.toggleWatcher = function(array, force) {
+ return this.stage.toggleWatcher(array, this.selectedSprite, force);
};
- Editor.prototype.toggleWatcher = function(array) {
- if (array[0] === 'contentsOfList:') {
- return this.toggleListWatcher(array[1]);
- }
- return false;
+ Editor.prototype.removeWatcher = function(array) {
+ return this.stage.removeWatcher(array, this.selectedSprite);
};
- Editor.prototype.toggleListWatcher = function(name) {
- var target = this.selectedSprite;
- var list = target.findLocalList(name);
- if (!list) {
- target = this.stage;
- list = target.findOrCreateLocalList(name);
- }
- var watcher = this.stage.findListWatcher(name, target);
- if (watcher) {
- watcher.visible = !watcher.visible;
- return watcher.visible;
- }
- watcher = new ListWatcher(target, list);
- watcher.moveTo(5, 5);
- this.stage.add(watcher);
- return true;
+ Editor.prototype.findWatcher = function(array) {
+ return this.stage.findWatcher(array, this.selectedSprite);
};
- Editor.prototype.findListWatcher = function(name) {
- var target = this.selectedSprite;
- var list = target.findLocalList(name);
- if (!list) target = this.stage;
- return this.stage.findListWatcher(name, target);
+ Editor.prototype.updateInfo = function() {
+ this.spritePanel.updateSpriteInfo();
};
Editor.prototype.refreshPalette = function() {
@@ -3944,11 +5026,11 @@
};
Editor.prototype.newDialog = function(list) {
- var name = new Dialog.Field(T(list ? 'List name:' : 'Variable name:'));
+ var name = new Dialog.Field(_(list ? 'List name:' : 'Variable name:'));
var local = new Dialog.Radio(
- [T('For all sprites'), false],
- [T('For this sprite only'), true]);
- var cloud = new Dialog.CheckBox(T(list ? 'Cloud list (stored on server)' : 'Cloud variable (stored on server)'));
+ [_('For all sprites'), false],
+ [_('For this sprite only'), true]);
+ var cloud = new Dialog.CheckBox(_(list ? 'Cloud list (stored on server)' : 'Cloud variable (stored on server)'));
local.setEnabled(1, this.selectedSprite.isSprite); // NS
cloud.enabled = !list; // NS
local.onchange = function() {
@@ -3957,14 +5039,14 @@
cloud.onchange = function() {
local.setEnabled(1, this.selectedSprite.isSprite && !cloud.value);
}.bind(this);
- var d = new Dialog(T(list ? 'New List' : 'New Variable'), Dialog.content(
+ var d = new Dialog(_(list ? 'New List' : 'New Variable'), Dialog.content(
name.el,
local.el,
Dialog.line(),
cloud.el,
Dialog.buttons(
- [T('OK'), function() {d.commit()}],
- [T('Cancel'), function() {d.hide()}])));
+ [_('OK'), function() {d.commit()}],
+ [_('Cancel'), function() {d.hide()}])));
d.oncommit = function() {
if (list) {
@@ -3976,6 +5058,17 @@
d.show(this);
};
+ Editor.prototype.newBlock = function() {
+ var d = new Dialog(_('New Block'), Dialog.content(
+ Dialog.buttons(
+ [_('OK'), function() {d.commit()}],
+ [_('Cancel'), function() {d.hide()}])));
+ d.oncommit = function() {
+ // TODO
+ }.bind(this);
+ d.show(this);
+ };
+
def(Editor.prototype, 'broadcastNames', {get: function() {
function add(script) {
if (!script || !script.isScript) return;
@@ -4043,7 +5136,7 @@
var sc = this.bubbleShadowColor;
var sb = this.bubbleShadowBlur;
var r = this.bubbleRadius;
- var canvas = el('canvas', 'Visual-absolute bubble');
+ var canvas = cl('canvas', 'Visual-absolute bubble');
var ct = canvas.getContext('2d');
ct.font = this.bubbleFont;
var w = Math.max(ct.measureText(text).width, this.bubbleMinWidth) + px + Math.max(px, ix);
@@ -4096,14 +5189,20 @@
};
Editor.prototype.toggleSmallStage = function() {
- if (this.isSmallStage = !this.isSmallStage) {
- this.el.classList.add('small-stage');
- } else {
- this.el.classList.remove('small-stage');
- }
+ this.isSmallStage = !this.isSmallStage;
+ this.el.classList.toggle('small-stage', this.isSmallStage);
setTimeout(this.resize, 200);
};
+ Editor.prototype.toggleTurbo = function() {
+ this.exec.turbo = !this.exec.turbo;
+ this.el.classList.toggle('turbo', this.exec.turbo);
+ };
+
+ Editor.prototype.showCostumes = function() {
+ this.tabPanel.panel = this.tabPanel.costumesPanel;
+ };
+
Editor.prototype.languageMenu = function() {
return new Menu(
'English').withContext(this);
@@ -4128,17 +5227,18 @@
'Undelete',
Menu.line,
['Small stage layout', this.toggleSmallStage, {checked: this.isSmallStage}],
- 'Turbo mode').translate().withContext(this);
+ ['Turbo mode', this.toggleTurbo, {checked: this.exec.turbo}]).translate().withContext(this);
};
function ScriptsPanel(editor) {
this.editor = editor;
- this.el = el('scripts-panel');
- this.el.appendChild(this.elButtons = el('palette-buttons'));
- this.el.appendChild(this.elPalette = el('palette-contents'));
- this.el.appendChild(this.elWorkspace = el('editor-workspace'));
+ this.el = cl('scripts-panel', [
+ this.elButtons = cl('palette-buttons'),
+ this.elPalette = cl('palette-contents'),
+ this.elWorkspace = cl('editor-workspace')
+ ]);
this.createButtons();
this.palette = new Palette(this.elPalette);
@@ -4173,9 +5273,11 @@
[1, 5, 2, 6, 3, 7, 4, 8, 9, 10].forEach(function(id) {
var cat = vis.getCategory(id);
- var b = el('button', 'palette-button');
- b.value = id;
- b.innerHTML = '' + T(cat[1]) + '
';
+ var b = cl('button', 'palette-button', {value: id}, [
+ el('div', {style: {color: cat[2]}}, [
+ el('strong', [_(cat[1])])
+ ])
+ ]);
b.addEventListener('click', buttonClick);
this.buttons[cat[0]] = b;
@@ -4200,14 +5302,14 @@
this.refreshPalette();
return;
}
- value = Number(value);
+ value = +value;
this._category = value;
if (this.categoryButton) {
- this.categoryButton.className = 'palette-button';
+ this.categoryButton.classList.remove('selected');
}
this.categoryButton = this.buttons[value];
- this.categoryButton.className = 'palette-button selected';
+ this.categoryButton.classList.add('selected');
this.refreshPalette(true);
}
@@ -4225,63 +5327,58 @@
}
this.palette.clear();
- (palettes[this._category] || []).forEach(this.eval, this);
+ (palettes[this._category] || []).forEach(this.append, this);
if (!resetScroll) {
this.palette.scrollTo(sx, sy);
}
};
- ScriptsPanel.prototype.eval = function(t) {
+ ScriptsPanel.prototype.append = function(t) {
if (t.if) {
- ((this.evalCondition(t.if) ? t.then : t.else) || []).forEach(this.eval, this);
+ ((this.appendCondition(t.if) ? t.then : t.else) || []).forEach(this.append, this);
return;
}
if (t.action) {
var editor = this.editor;
- var button = el('button', 'ui-button');
- button.textContent = T(t.text);
+ var button = cl('button', 'ui-button', [_(t.text)]);
if (editor[t.action]) button.addEventListener('click', editor[t.action].bind(editor));
return this.palette.add(Palette.element(button, 0, 26));
}
if (t.text) {
- var div = el('palette-label');
- div.textContent = T(t.text);
+ var div = cl('palette-label', [_(t.text)]);
return this.palette.add(Palette.element(div, 0, 14));
}
if (t.watcher) {
var b = t.watcher;
if (!Array.isArray(b)) b = [b];
var checked = this.editor.hasWatcher(b);
- var button = el('button', 'check-box'+(checked ? ' checked' : ''));
+ var button = cl('button', 'check-box'+(checked ? ' checked' : ''));
button.addEventListener('click', function() {
- if (checked = this.editor.toggleWatcher(b)) {
- button.classList.add('checked');
- } else {
- button.classList.remove('checked');
- }
+ checked = this.editor.toggleWatcher(b);
+ button.classList.toggle('checked', !!checked);
}.bind(this));
this.palette.add(Palette.inline(button, 13, 12));
- return this.eval(b);
+ return this.append(b);
}
if (t === '==') {
- return this.palette.add(Palette.element(el('palette-separator'), 0, 2));
+ return this.palette.add(Palette.element(cl('palette-separator'), 0, 2));
}
if (t === '--' || t === '---') {
return this.palette.add(Palette.space(t.length * 10 - 5));
}
if (t.all) {
- return (this.evalAll(t.all) || []).forEach(this.eval, this);
+ return (this.appendAll(t.all) || []).forEach(this.append, this);
}
if (!Array.isArray(t)) {
t = [t];
}
- var script = new Script().add(new Block(t[0], t.slice(1).map(this.evalArg, this)));
+ var script = new Script().add(new Block(t[0], t.slice(1).map(this.appendArg, this)));
if (!this.editor.exec.table[t[0]]) script.addEffect(script.outline.bind(script, 2, '#faa'));
this.palette.add(script);
};
- ScriptsPanel.prototype.evalArg = function(arg) {
+ ScriptsPanel.prototype.appendArg = function(arg) {
if (typeof arg !== 'object') return arg;
if (arg.first) {
var key = arg.first === 'var' ? 'variables' : arg.first === 'list' ? 'lists' : '';
@@ -4294,11 +5391,17 @@
var sound = this.editor.selectedSprite.sounds[0];
return sound ? sound.name : '';
}
- if (arg.first === 'attribute') {
- return this.editor.stage.sprites.length ? 'x position' : 'volume';
- }
- if (arg.first === 'sprite') {
- return this.editor.stage.sprites.length ? this.editor.stage.sprites[0].name : '_stage_';
+ if (arg.first === 'attribute' || arg.first === 'otherSprite') {
+ var sprites = this.editor.stage.sprites;
+ var sprite = this.editor.stage;
+ if (sprites.length) {
+ if (sprites[0] !== this.editor.selectedSprite) {
+ sprite = sprites[0];
+ } else if (sprites.length > 1) {
+ sprite = sprites[1];
+ }
+ }
+ return arg.first === 'attribute' ? sprite.isStage ? 'backdrop #' : 'x position' : sprite.isStage ? '_stage_' : sprite.name;
}
}
if (arg.current) {
@@ -4310,7 +5413,7 @@
return '';
};
- ScriptsPanel.prototype.evalCondition = function(condition) {
+ ScriptsPanel.prototype.appendCondition = function(condition) {
var stage = this.editor.stage;
var sprite = this.editor.selectedSprite;
switch (condition) {
@@ -4321,7 +5424,7 @@
}
};
- ScriptsPanel.prototype.evalAll = function(all) {
+ ScriptsPanel.prototype.appendAll = function(all) {
function getter(get) {
return function(name) {return {watcher: [get, name]}};
}
@@ -4329,7 +5432,7 @@
function collection(key, make) { // NS
var stagec = stage[key].map(getName).sort().map(make);
var spritec = sprite.isStage ? [] : sprite[key].map(getName).sort().map(make);
- return stagec.concat(stagec.length && spritec.length ? "==" : [], spritec);
+ return stagec.concat(stagec.length && spritec.length ? '==' : [], spritec);
}
var stage = this.editor.stage;
@@ -4346,26 +5449,29 @@
function CostumesPanel(editor) {
this.editor = editor;
- this.el = el('costumes-panel');
- this.el.appendChild(this.elNewLabel = el('costume-new-label'));
- this.el.appendChild(this.elNewGroup = el('costume-new-group'));
- this.elLibraryButton = this.addNewButton('new-library', T('Choose costume from library'), this.newFromLibrary);
- this.elPaintButton = this.addNewButton('new-paint', T('Paint new costume'), this.newFromEditor);
- this.elImportButton = this.addNewButton('new-import', T('Upload costume from file'), this.newFromFile, 'image/*');
- this.elCameraButton = this.addNewButton('new-camera', T('New costume from camera'), this.newFromCamera);
- this.el.appendChild(this.elList = el('costume-list'));
-
this.imageEditor = new ImageEditor(this);
- this.el.appendChild(this.imageEditor.el);
+
+ this.el = cl('costumes-panel', [
+ this.elNewLabel = cl('costume-new-label'),
+ this.elNewGroup = cl('costume-new-group', [
+ this.elLibraryButton = this.makeNewButton('new-library', _('Choose costume from library'), this.newFromLibrary),
+ this.elPaintButton = this.makeNewButton('new-paint', _('Paint new costume'), this.newFromEditor),
+ this.elImportButton = this.makeNewButton('new-import', _('Upload costume from file'), this.newFromFile, 'image/*'),
+ this.elCameraButton = this.makeNewButton('new-camera', _('New costume from camera'), this.newFromCamera)
+ ]),
+ this.elList = cl('costume-list'),
+ this.imageEditor.el
+ ]);
}
- CostumesPanel.prototype.addNewButton = function(name, title, fn, file, multiple) {
- var button = el(file ? 'div' : 'button', 'new-button '+name);
- button.title = title;
+ CostumesPanel.prototype.makeNewButton = function(name, title, fn, file, multiple) {
+ var button = cl(file ? 'div' : 'button', 'new-button '+name, {title: title});
if (file) {
- var form = el('form', 'new-button-form');
- var input = el('input', 'new-button-input');
- input.type = 'file';
+ var form = cl('form', 'new-button-form');
+ var input = cl('input', 'new-button-input', {
+ type: 'file',
+ title: title
+ });
if (typeof file === 'string') input.accept = file;
if (multiple) input.multiple = true;
form.appendChild(input);
@@ -4378,26 +5484,34 @@
} else {
if (fn) button.addEventListener('click', fn.bind(this));
}
- this.elNewGroup.appendChild(button);
return button;
};
CostumesPanel.prototype.showSprite = function(sprite) {
this.sprite = sprite;
- this.elNewLabel.textContent = sprite.isSprite ? T('New costume:') : T('New backdrop:');
+ this.elNewLabel.textContent = sprite.isSprite ? _('New costume:') : _('New backdrop:');
this.elLibraryButton.classList.toggle('new-backdrop-library', sprite.isStage);
- this.elLibraryButton.title = sprite.isSprite ? T('Choose costume from library') : T('Choose backdrop from library');
- this.elPaintButton.title = sprite.isSprite ? T('Paint new costume') : T('Paint new backdrop');
- this.elImportButton.title = sprite.isSprite ? T('Upload costume from file') : T('Upload backdrop from file');
- this.elCameraButton.title = sprite.isSprite ? T('New costume from camera') : T('New backdrop from camera');
+ this.elLibraryButton.title = sprite.isSprite ? _('Choose costume from library') : _('Choose backdrop from library');
+ this.elPaintButton.title = sprite.isSprite ? _('Paint new costume') : _('Paint new backdrop');
+ this.elImportButton.title = sprite.isSprite ? _('Upload costume from file') : _('Upload backdrop from file');
+ this.elCameraButton.title = sprite.isSprite ? _('New costume from camera') : _('New backdrop from camera');
this.updateList();
};
CostumesPanel.prototype.updateList = function() {
while (this.elList.firstChild) this.elList.removeChild(this.elList.lastChild);
+ if (this.parent) {
+ this.icons.forEach(function(icon) {
+ //this.parent.remove(icon); //why?
+ });
+ }
this.icons = this.sprite.costumes.map(function(c) {
var icon = new CostumeIcon(this, c);
this.elList.appendChild(icon.el);
+ if (this.parent) {
+ this.parent.add(icon);
+ icon.resize();
+ }
return icon;
}, this);
};
@@ -4418,47 +5532,97 @@
}
if (this.selectedIcon = icon) {
icon.select();
+ scrollIntoView(icon.el, this.elList);
this.imageEditor.costume = icon.costume;
+ this.sprite.costume = icon.index;
+ if (this.sprite.isStage) {
+ this.sprite.updateWatcher(['sceneName'], this.sprite);
+ this.sprite.updateWatcher(['backgroundIndex'], this.sprite);
+ } else {
+ this.sprite.stage.updateWatcher(['costumeIndex'], this.sprite);
+ }
+ this.sprite.redraw();
}
};
CostumesPanel.prototype.newFromEditor = function(file) {
- var empty = document.createElement('canvas');
- if (this.sprite.isStage) {
- empty.width = 960;
- empty.height = 720;
- var cx = empty.getContext('2d');
- cx.fillStyle = '#fff';
- cx.fillRect(0, 0, empty.width, empty.height);
- } else {
- empty.width = 2;
- empty.height = 2;
- }
- this.addCostume(new Costume('costume1', empty, 0, 0, 2));
+ this.addCostume(this.sprite.makeEmptyCostume());
+ };
+
+ CostumesPanel.prototype.newFromLibrary = function(file) {
+ var arrValues;
+ if (this.sprite.isSprite) {
+ arrValues = showModalDialog("library/sprite/costumeLibrary.html","","center=yes;dialogWidth=1024;dialogHeight=768; resizable: Yes; status: Yes; scroll:yes");
+ } else {
+ arrValues = showModalDialog("library/backdrop/backdropLibrary.html","","center=yes;dialogWidth=1024;dialogHeight=768; resizable: Yes; status: Yes; scroll:yes");
+ }
+ if(arrValues)
+ {
+ var image = document.createElement('img');
+ image.src = arrValues[0];
+ //this.addCostume(Costume.centered(arrValues[1], image));
+ this.addCostume(new Costume(arrValues[1], arrValues[0]));
+ }
+ };
+
+ CostumesPanel.prototype.newFromCamera = function() {
+ Dialog.camera(function(image) {
+ this.addCostume(Costume.centered('photo1', image));
+ }, this).show(this.editor);
};
CostumesPanel.prototype.newFromFile = function(file) {
IO.readImageFile(file, function(err, image) {
if (err) return;
- this.addCostume(new Costume(stripExtension(file.name), image, image.width / 2 | 0, image.height / 2 | 0));
+ this.addCostume(Costume.centered(stripExtension(file.name), image));
}, this);
};
CostumesPanel.prototype.addCostume = function(c) {
- this.sprite.addCostume(c);
- this.sprite.costume = this.sprite.costumes.indexOf(c);
- this.sprite.redraw();
- var icon = new CostumeIcon(this, c);
- this.elList.appendChild(icon.el);
- this.icons.push(icon);
+ this.sprite.addCostume(c);
+ var icon = new CostumeIcon(this, c);
+ this.elList.appendChild(icon.el);
+ if (this.icons.length === 1) {
+ this.icons[0].enableDelete();
+ }
+ if (this.parent) {
+ this.parent.add(icon);
+ icon.resize();
+ }
+ this.icons.push(icon);
+ this.select(icon);
+ };
+
+ CostumesPanel.prototype.removeIcon = function(icon) {
+ this.sprite.removeCostume(icon.costume);
+ if (this.parent) {
+ this.parent.remove(icon);
+ }
+ var i = this.icons.indexOf(icon);
+ if (i === -1) return;
+ for (var j = this.icons.length; j-- > i;) {
+ this.icons[j].updateIndex();
+ }
+ this.icons.splice(i, 1);
+ this.elList.removeChild(icon.el);
+ this.select(this.icons[i] || this.icons[i - 1]);
+ if (this.icons.length === 1) {
+ this.icons[0].disableDelete();
+ }
};
CostumesPanel.prototype.install = function(parent) {
parent.add(this.imageEditor);
+ this.icons.forEach(function(icon) {
+ parent.add(icon);
+ });
};
CostumesPanel.prototype.uninstall = function(parent) {
parent.remove(this.imageEditor);
+ this.icons.forEach(function(icon) {
+ parent.remove(icon);
+ });
};
function CostumeIcon(costumesPanel, costume) {
@@ -4466,24 +5630,26 @@
this.sprite = costumesPanel.editor.selectedSprite;
this.costume = costume;
- this.el = el('costume-icon');
- this.el.appendChild(this.elThumbnail = el('canvas', 'costume-thumbnail'));
- this.elThumbnail.width = 68;
- this.elThumbnail.height = 51;
- this.context = this.elThumbnail.getContext('2d');
- this.el.appendChild(this.elNumber = el('costume-number'));
- this.el.appendChild(this.elName = el('costume-name'));
- this.el.appendChild(this.elInfo = el('costume-info'));
+ this.el = cl('costume-icon', {draggable: true}, [
+ this.elThumbnail = cl('canvas', 'costume-thumbnail'),
+ this.elNumber = cl('costume-number'),
+ this.elName = cl('costume-name'),
+ this.elInfo = cl('costume-info'),
+ this.elDelete = cl('button', 'costume-delete')
+ ]);
+ this.context = this.elThumbnail.getContext('2d');
this.el.addEventListener('click', this.click.bind(this));
+ this.elDelete.addEventListener('click', this.deleteCostume.bind(this));
this.updateIndex();
this.updateName();
- this.updateThumbnail();
+ this.resize();
if (costume === this.sprite.costumes[this.sprite.costume]) {
costumesPanel.select(this);
}
+ if (this.sprite.costumes.length === 1) this.disableDelete();
}
CostumeIcon.prototype.select = function() {
@@ -4496,8 +5662,19 @@
CostumeIcon.prototype.click = function() {
this.costumesPanel.select(this);
- this.sprite.costume = this.index;
- this.sprite.redraw();
+ };
+
+ CostumeIcon.prototype.deleteCostume = function(e) {
+ e.stopPropagation();
+ this.costumesPanel.removeIcon(this);
+ };
+
+ CostumeIcon.prototype.enableDelete = function() {
+ this.elDelete.style.display = '';
+ };
+
+ CostumeIcon.prototype.disableDelete = function() {
+ this.elDelete.style.display = 'none';
};
CostumeIcon.prototype.updateIndex = function() {
@@ -4506,89 +5683,107 @@
};
CostumeIcon.prototype.updateName = function() {
- this.elName.textContent = this.costume.name;
+ this.elName.textContent = this.elName.title = this.costume.name;
};
CostumeIcon.prototype.updateInfo = function() {
- var s = this.costume.scale;
- this.elInfo.textContent = (this.costume.canvas.width * s | 0) + '\xd7' + (this.costume.canvas.height * s | 0);
+ this.elInfo.textContent = (this.costume.width | 0) + '\xd7' + (this.costume.height | 0);
};
CostumeIcon.prototype.updateThumbnail = function() {
this.updateInfo();
var tw = this.elThumbnail.width;
var th = this.elThumbnail.height;
- var iw = this.costume.canvas.width;
- var ih = this.costume.canvas.height;
+ if (!this.costume.loaded) return;
+ var source = this.costume.baseLayerTexture.baseTexture.source;
+ var iw = source.width;
+ var ih = source.height;
this.context.clearRect(0, 0, tw, th);
if (!iw || !ih) return;
- var s = Math.min(1, tw / iw, th / ih);
+ var s = Math.min(this.scale, tw / iw, th / ih);
var sw = s * iw;
var sh = s * ih;
- this.context.drawImage(this.costume.canvas, (tw - sw) / 2, (th - sh) / 2, sw, sh);
+ this.context.drawImage(source, (tw - sw) / 2, (th - sh) / 2, sw, sh);
+ };
+
+ CostumeIcon.prototype.resize = function() {
+ this.scale = window.devicePixelRatio || 1;
+ this.elThumbnail.width = this.scale * 68;
+ this.elThumbnail.height = this.scale * 51;
+ this.updateThumbnail();
};
function ImageEditor() {
- this.canvas = document.createElement('canvas');
+ this.canvas = el('canvas');
this.context = this.canvas.getContext('2d');
+ this.toolButtons = {};
- this.el = el('image-editor');
-
- this.el.appendChild(this.elCanvas = el('image-editor-canvas'));
- this.el.appendChild(this.elSettings = el('image-editor-settings'));
- this.el.appendChild(this.elBitmapTools = el('bitmap-tools'));
-
- this.elCanvas.appendChild(this.elCanvasGrid = el('image-editor-canvas-layer'));
- this.gridCanvas = document.createElement('canvas');
- this.gridContext = this.gridCanvas.getContext('2d');
+ var grad = 'linear-gradient(45deg, #e8e8e8 25%, transparent 25.5%, transparent 74.5%, #e8e8e8 75%)';
- this.elCanvas.appendChild(this.elBitmap = el('canvas', 'image-editor-canvas-layer'));
+ this.el = cl('image-editor', [
+ this.elCanvas = cl('image-editor-canvas', [
+ this.elCanvasGrid = cl('image-editor-canvas-layer', {
+ style: {
+ backgroundColor: '#fff',
+ backgroundImage: grad+', '+grad
+ }
+ }),
+ this.elBitmap = cl('canvas', 'image-editor-canvas-layer'),
+ this.elCursor = cl('canvas', 'image-editor-canvas-layer'),
+ this.elCanvasScroll = cl('image-editor-canvas-scroll', [
+ this.elCanvasFill = cl('image-editor-canvas-fill')
+ ])
+ ]),
+ this.elSettings = cl('image-editor-settings', [
+ this.elZoom = cl('image-editor-zoom', [
+ this.elZoomOut = cl('button', 'zoom-button zoom-out'),
+ this.elZoomDefault = cl('button', 'zoom-button zoom-default'),
+ this.elZoomIn = cl('button', 'zoom-button zoom-in')
+ ]),
+ this.elZoomLabel = cl('image-editor-zoom-label'),
+ this.elColorPicker = cl('color-picker', [
+ this.elSwatchButton = cl('button', 'color-picker-swatch-button wheel'),
+ this.elColors = cl('color-picker-colors', [
+ this.elBackground = cl('color-picker-color background'),
+ this.elForeground = cl('color-picker-color foreground')
+ ]),
+ this.toolButtons.eyedropper =
+ this.elEyedropperButton = cl('button', 'color-picker-eyedropper', {
+ title: _('Pick up color')
+ }),
+ this.elPalette = cl('color-picker-palette')
+ ])
+ ]),
+ this.elBitmapTools = cl('bitmap-tools', [
+ this.addBitmapTool('brush', _('Brush')),
+ this.addBitmapTool('line', _('Line')),
+ this.addBitmapTool('rectangle', _('Rectangle (Shift: Square)')),
+ this.addBitmapTool('ellipse', _('Ellipse (Shift: Circle)')),
+ this.addBitmapTool('text', _('Text')),
+ this.addBitmapTool('fill', _('Fill with color')),
+ this.addBitmapTool('erase', _('Erase')),
+ this.addBitmapTool('select', _('Select')),
+ this.addBitmapTool('duplicate', _('Select and duplicate'))
+ ])
+ ]);
+
+ this.brushCanvas = el('canvas', {
+ width: 480 * 2,
+ height: 360 * 2
+ });
this.bitmapContext = this.elBitmap.getContext('2d');
-
- this.elCanvas.appendChild(this.elCursor = el('canvas', 'image-editor-canvas-layer'));
this.cursorContext = this.elCursor.getContext('2d');
- this.brushCanvas = document.createElement('canvas');
- this.brushCanvas.width = 480 * 2;
- this.brushCanvas.height = 360 * 2;
this.brushContext = this.brushCanvas.getContext('2d');
- this.elCanvas.appendChild(this.elCanvasScroll = el('image-editor-canvas-scroll'));
- this.elCanvasScroll.appendChild(this.elCanvasFill = el('image-editor-canvas-fill'));
this.elCanvasScroll.addEventListener('scroll', this.updateScroll.bind(this));
this.elCanvasScroll.addEventListener('mousedown', this.mouseDown.bind(this));
- this.toolButtons = {};
- this.addBitmapTool('brush', T('Brush'));
- this.addBitmapTool('line', T('Line'));
- this.addBitmapTool('rectangle', T('Rectangle (Shift: Square)'));
- this.addBitmapTool('ellipse', T('Ellipse (Shift: Circle)'));
- this.addBitmapTool('text', T('Text'));
- this.addBitmapTool('fill', T('Fill with color'));
- this.addBitmapTool('erase', T('Erase'));
- this.addBitmapTool('select', T('Select'));
- this.addBitmapTool('duplicate', T('Select and duplicate'));
-
- this.elSettings.appendChild(this.elZoom = el('image-editor-zoom'));
- this.elZoom.appendChild(this.elZoomOut = el('button', 'zoom-button zoom-out'));
- this.elZoom.appendChild(this.elZoomDefault = el('button', 'zoom-button zoom-default'));
- this.elZoom.appendChild(this.elZoomIn = el('button', 'zoom-button zoom-in'));
this.elZoomOut.addEventListener('click', this.zoomOut.bind(this));
this.elZoomDefault.addEventListener('click', this.zoomDefault.bind(this));
this.elZoomIn.addEventListener('click', this.zoomIn.bind(this));
- this.elSettings.appendChild(this.elZoomLabel = el('image-editor-zoom-label'));
-
- this.elSettings.appendChild(this.elColorPicker = el('color-picker'));
- this.elColorPicker.appendChild(this.elSwatchButton = el('button', 'color-picker-swatch-button wheel'));
- this.elColorPicker.appendChild(this.elColors = el('color-picker-colors'));
- this.elColors.appendChild(this.elBackground = el('color-picker-color background'));
- this.elColors.appendChild(this.elForeground = el('color-picker-color foreground'));
- this.elColorPicker.appendChild(this.elEyedropperButton = el('button', 'color-picker-eyedropper'));
- this.elEyedropperButton.title = T('Pick up color');
- this.toolButtons.eyedropper = this.elEyedropperButton;
this.elEyedropperButton.addEventListener('mousedown', this.setTool.bind(this, 'eyedropper'));
- this.elColorPicker.appendChild(this.elPalette = el('color-picker-palette'));
this.elPalette.addEventListener('mousedown', this.swatchClick.bind(this));
this.elColors.addEventListener('mousedown', this.swapColors.bind(this));
this.createPalette();
@@ -4616,10 +5811,8 @@
};
ImageEditor.prototype.addBitmapTool = function(name, title) {
- var b = el('button', 'bitmap-tool bitmap-tool-'+name);
+ var b = cl('button', 'bitmap-tool bitmap-tool-'+name, {title: title});
b.addEventListener('mousedown', this.setTool.bind(this, name));
- b.title = title;
- this.elBitmapTools.appendChild(b);
this.toolButtons[name] = b;
return b;
};
@@ -4645,8 +5838,7 @@
});
ImageEditor.prototype.addPaletteColor = function(color) {
- var b = el('color-picker-palette-color');
- b.style.backgroundColor = color;
+ var b = cl('color-picker-palette-color', {style: {backgroundColor: color}});
if (color === 'transparent') {
b.style.backgroundImage = 'linear-gradient(-45deg, transparent 7.5px, #f00 7.5px, #f00 9.5px, transparent 9.5px)';
}
@@ -4658,16 +5850,8 @@
var vh = this.viewportHeight = this.elCanvas.offsetHeight;
var zoom = this._zoom;
var size = 4 * zoom;
- this.gridCanvas.width = size * 2;
- this.gridCanvas.height = size * 2;
- var cx = this.gridContext;
- cx.fillStyle = '#fff';
- cx.fillRect(0, 0, size, size);
- cx.fillRect(size, size, size, size);
- cx.fillStyle = '#e8e8e8';
- cx.fillRect(size, 0, size, size);
- cx.fillRect(0, size, size, size);
- this.elCanvasGrid.style.backgroundImage = 'url('+JSON.stringify(this.gridCanvas.toDataURL())+')';
+ this.elCanvasGrid.style.backgroundSize = size * 2+'px '+size * 2+'px';
+ this.elCanvasGrid.style.backgroundPosition = '0 0,'+size+'px '+size+'px';
this.viewportOffsetX = Math.max(0, (vw - zoom * 480) / 2 | 0);
this.viewportOffsetY = Math.max(0, (vh - zoom * 360) / 2 | 0);
this.elCanvasGrid.style.left =
@@ -5061,10 +6245,6 @@
cx.fill();
} else {
cx.clip();
- var x1 = Math.min(sx, point.x);
- var y1 = Math.min(sy, point.y);
- var x2 = Math.max(sx, point.x);
- var y2 = Math.max(sy, point.y);
cx.fillRect(-1, -1, 2, 2);
}
cx.restore();
@@ -5120,7 +6300,6 @@
};
ImageEditor.prototype.showSelection = function() {
- var d = this.toolData;
this.clearCursor();
var cx = this.cursorContext;
this.drawSelection(cx, true);
@@ -5335,21 +6514,408 @@
el.style.backgroundImage = 'none';
}
};
-
-
- function SoundsPanel() {
- this.el = el('sounds-panel');
- }
-
- SoundsPanel.prototype.showSprite = function(sprite) {};
-
+//***************************Sounds Panel*********************************************************************
+
+ function SoundsPanel(editor) {
+ this.editor = editor;
+ this.stageIcon = new SpriteIcon(this, editor.stage);
+ this.icons = [];
+ this.infoVisible = false;
+ this.el = cl('sounds-panel', [
+ this.elNewLabel = cl('sound-new-label'),
+ this.elNewGroup = cl('sound-new-group', [
+ this.elLibraryButton = this.makeNewButton('new-library', _('Choose sound from library'), this.newFromLibrary),
+ this.elImportButton = this.makeNewButton('new-import', _('Upload sound from file'), this.newFromFile, 'image/*')
+ ]),
+ this.elList = cl('sound-list'),
+ this.elSoundsSection = cl('sounds-section'),
+ this.elSoundsInfo = cl('sounds-info', [
+ this.elSoundsInfoBack = cl('sounds-info-back'),
+ this.elSoundsName = cl('input', 'sounds-info-name')
+ ])
+ ]);
+ this.elSoundsInfoBack.addEventListener('click', this.hideInfo.bind(this));
+ }
+
+ SoundsPanel.prototype.makeNewButton = function(name, title, fn, file, multiple) {
+ var button = cl(file ? 'div' : 'button', 'new-button '+name, {title: title});
+ if (file) {
+ var form = cl('form', 'new-button-form');
+ var input = cl('input', 'new-button-input', {
+ type: 'file',
+ title: title
+ });
+ if (typeof file === 'string') {input.accept = file;}
+ if (multiple) {input.multiple = true;}
+ form.appendChild(input);
+ button.appendChild(form);
+ var self = this;
+ if (fn) input.addEventListener('change', function() {
+ fn.call(self, multiple ? slice.call(input.files) : input.files[0]);
+ form.reset();
+ });
+ } else {
+ if (fn) {button.addEventListener('click', fn.bind(this));}
+ }
+ return button;
+ };
+
+ SoundsPanel.prototype.showSprite = function(sound) {
+ console.log('show sprite in sounds panel?');
+ };
+
+ SoundsPanel.prototype.updateList = function() {
+ console.log("SoundsPanel.prototype.updateList missing");
+ };
+
+ SoundsPanel.prototype.iconFor = function(Sound) {
+ console.log("SoundsPanel.prototype.iconFor missing");
+ };
+
+ SoundsPanel.prototype.select = function(icon) {
+ console.log("SoundsPanel.prototype.select missing");
+ };
+
+ SoundsPanel.prototype.newFromEditor = function(file) {
+ console.log("SoundsPanel.prototype.newFromEditor missing");
+ };
+
+ SoundsPanel.prototype.newFromLibrary = function() {
+ var arrValues;
+ arrValues = showModalDialog("library/sounds/soundLibrary.html","","center=yes;dialogWidth=1024;dialogHeight=768; resizable: Yes; status: Yes; scroll:yes");
+ if(arrValues) {
+ var image = document.createElement('img');
+ image.src = "assets/speakericon.png"; //arrValues[0]; contains path and filename
+ //TODO create buffer for sound
+ var soundBuffer = 'library/sounds/'+arrValues[0];
+ this.addSound(Sound.centered(arrValues[1], image), soundBuffer,arrValues[1]);
+ }
+ };
+
+ SoundsPanel.prototype.newFromCamera = function() {
+ console.log("SoundsPanel.prototype.newFromCamera missing");
+ };
+
+ SoundsPanel.prototype.newFromFile = function(file) {
+ IO.readSoundFile(file, function(err, sound) {
+ if (err) {return;}
+ console.log("Sounds panel newFromFile not implemented");
+ var soundBuffer;
+ this.addSound(Sound.centered(stripExtension(file.name), sound), soundBuffer);
+ }, this);
+ };
+
+ SoundsPanel.prototype.addSound = function(c, soundBuffer,soundName) {
+ //this.sprite.addSound(c);
+ console.log(this);
+ var icon = new SoundIcon(this, c, soundBuffer);
+ icon.name = soundName;
+ this.icons.push(icon);
+ this.elList.appendChild(icon.el);
+ if (parseInt(this.icons.length) === 1) {
+ this.icons[0].enableDelete();
+ }
+ //console.log(this.parent);
+ if (this.parent) {
+ this.parent.add(icon);
+ icon.resize();
+ }
+ //this.icons.push(icon);
+ this.select(icon);
+ };
+
+ SoundsPanel.prototype.removeIcon = function(icon) {
+ console.log("SoundsPanel.prototype.removeIcon missing");
+ };
+
+ SoundsPanel.prototype.install = function(parent) {
+ //console.log("SoundsPanel.prototype.install missing");
+ //parent.add(this.imageEditor);
+ this.icons.forEach(function(icon) {
+ parent.add(icon);
+ });
+ };
+
+ SoundsPanel.prototype.uninstall = function(parent) {
+ console.log("SoundsPanel.prototype.uninstall missing");
+ };
+
+ function SoundIcon(soundsPanel, sound, soundBuffer) {
+ this.soundsPanel = soundsPanel;
+ this.editor = soundsPanel.editor;
+ this.sprite = soundsPanel.editor.selectedSprite;
+ this.sound = sound;
+ this.soundBuffer = soundBuffer;
+ this.elTmp = el('canvas');
+ this.el = cl('sound-icon', {draggable: true}, [
+ this.elThumbnail = cl('canvas', 'sound-thumbnail'),
+ this.elNumber = cl('sounds-number'),
+ this.elName = cl('sounds-name'),
+ this.elInfo = cl('sounds-info'),
+ this.elDelete = cl('button', 'sound-delete')
+ ]);
+ this.tmpContext = this.elTmp.getContext('2d');
+ this.context = this.elThumbnail.getContext('2d');
+ this.el.addEventListener('click', this.click.bind(this));
+ this.elDelete.addEventListener('click', this.deleteSound.bind(this));
+ this.updateIndex();
+ this.updateName();
+ this.resize();
+ if (sound === this.sprite.sounds[this.sprite.sound]) {
+ soundsPanel.select(this);
+ }
+ if (this.sprite.sounds.length === 1) {this.disableDelete();}
+/* this.panel = panel;
+ this.editor = panel.editor;
+ this.sound = sound;
+
+ this.el = cl('sound-icon', [
+ this.elThumbnail = cl('canvas', 'sound-thumbnail'),
+ this.elName = cl('sound-icon-label')
+ ]);
+ this.elTmp = el('canvas');
+
+ this.context = this.elThumbnail.getContext('2d');
+ this.tmpContext = this.elTmp.getContext('2d');
+
+ if (sound.isStage) {
+ this.el.classList.add('for-stage');
+ this.el.appendChild(this.elInfo = cl('sound-icon-info'));
+ this.updateInfo();
+ } else {
+ this.el.appendChild(this.elButton = cl('button', 'sound-icon-button'));
+ this.elButton.addEventListener('click', function() {
+ this.panel.showInfo();
+ }.bind(this));
+ }
+
+ this.el.addEventListener('click', function() {
+ this.panel.select(this);
+ }.bind(this));
+
+ this.resize();
+ this.updateName();
+ //setInterval(this.update.bind(this), 200);*/
+ }
+
+ SoundsPanel.prototype.addIcon = function(sprite, soundBuffer) {
+ console.log("add icon");
+ var icon = new SoundIcon(this, sprite, soundBuffer);
+ this.icons.push(icon);
+ this.elSoundsSection.appendChild(icon.el);
+ if (this.parent) {
+ this.parent.add(icon);
+ icon.resize();
+ }
+ return icon;
+ };
+
+ SoundsPanel.prototype.select = function(icon) {
+ if (this.selectedIcon === icon) return;
+ if (this.selectedIcon) {
+ this.selectedIcon.el.classList.remove('selected');
+ }
+ if (this.selectedIcon = icon) {
+ icon.el.classList.add('selected');
+ }
+ var tbb = this.elSoundsSection.getBoundingClientRect();
+ var ibb = icon.el.getBoundingClientRect();
+ var t = ibb.top - 3;
+ var b = ibb.bottom + 3;
+ if (t < tbb.top) {this.elSoundsSection.scrollTop += t - tbb.top;}
+ else if (b > tbb.bottom) {this.elSoundsSection.scrollTop += b - tbb.bottom;}
+ this.editor.selectedSprite = icon.sprite;
+ //this.editor.tabPanel.showSound(icon.sprite);
+ return this;
+ };
+
+ SoundsPanel.prototype.soundNameKeyDown = function(e) {
+ if (e.metaKey || e.ctrlKey) return;
+ if (e.keyCode === 27) {
+ this.resetSoundName();
+ e.preventDefault();
+ }
+ if (e.keyCode === 13) {
+ this.renameSound();
+ e.preventDefault();
+ }
+ e.stopPropagation();
+ };
+
+ SoundsPanel.prototype.showInfo = function() {
+ this.infoVisible = true;
+ this.elSoundsInfo.style.display = 'block';
+ this.resetSoundName();
+ this.updateSoundsInfo();
+ };
+
+ SoundsPanel.prototype.hideInfo = function() {
+ this.infoVisible = false;
+ this.elSoundsInfo.style.display = 'none';
+ };
+
+ SoundsPanel.prototype.resetSoundName = function() {
+ this.elSoundsName.value = this.editor.selectedSound.name;
+ };
+
+ SoundsPanel.prototype.renameSound = function() {
+ var sound = this.editor.selectedSound;
+ var oldName = sound.name;
+ sound.name = null;
+ var newName = sound.stage.uniqueSoundName(this.elSoundsName.value.trim());
+ if (oldName === newName || !newName) {
+ sound.name = oldName;
+ this.resetSoundName();
+ return;
+ }
+ sound.name = newName;
+ this.resetSoundName();
+ var icon = this.findIcon(sound);
+ if (icon) icon.updateName();
+ sound.stage.updateWatcherLabels(sound);
+ // TODO change name in scripts
+ };
+
+ SoundIcon.prototype.deselect = function() {
+ console.log("SoundIcon.prototype.deselect missing");
+ };
+
+ SoundIcon.prototype.click = function() {
+ var audio;
+ this.soundPanel.select(this);
+ console.log(this.soundBuffer);
+ audio = new Audio(this.soundBuffer);
+ audio.play();
+ };
+
+ SoundIcon.prototype.deleteSound = function(e) {
+ console.log("SoundIcon.prototype.deleteSound missing");
+ };
+
+ SoundIcon.prototype.enableDelete = function() {
+ this.elDelete.style.display = 'block';
+ };
+
+ SoundIcon.prototype.disableDelete = function() {
+ this.elDelete.style.display = 'none';
+ };
+
+ SoundIcon.prototype.updateIndex = function() {
+ this.index = this.sprite.sounds.indexOf(this.sound);
+ this.elNumber.textContent = this.index + 1;
+ };
+
+ SoundIcon.prototype.updateName = function() {
+ this.elName.textContent = this.elName.title = this.sound.name;
+ };
+
+ SoundIcon.prototype.updateInfo = function() {
+ console.log("SoundIcon.prototype.updateInfo missing");
+ };
+
+ SoundIcon.prototype.updateThumbnail = function() {
+ console.log("SoundIcon.prototype.updateThumbnail missing");
+ /*
+ this.updateInfo();
+ var tw = this.elThumbnail.width;
+ var th = this.elThumbnail.height;
+ if (!this.costume.loaded) return;
+ var source = this.sound.baseLayerTexture.baseTexture.source;
+ var iw = source.width;
+ var ih = source.height;
+ this.context.clearRect(0, 0, tw, th);
+ if (!iw || !ih) return;
+ var s = Math.min(this.scale, tw / iw, th / ih);
+ var sw = s * iw;
+ var sh = s * ih;
+ this.context.drawImage(source, (tw - sw) / 2, (th - sh) / 2, sw, sh);
+ */
+ };
+
+ SoundIcon.prototype.resize = function() {
+ this.scale = window.devicePixelRatio || 1;
+ this.elThumbnail.width = this.elTmp.width = this.scale * (68 + 4);
+ this.elThumbnail.height = this.elTmp.height = this.scale * (51 + 4);
+ this.update();
+ };
+
+ SoundIcon.prototype.update = function() {
+ if (this.sprite.isStage) this.updateInfo();
+ var costume = this.sound; //sprite.sounds[this.sprite.sound];
+ //if (costume === this.costume) return;
+ //this.costume = costume && costume.loaded;
+
+ var w = this.elThumbnail.width;
+ var h = this.elThumbnail.height;
+ this.context.clearRect(0, 0, w, h);
+ //if (!costume || !costume.loaded) return;
+ var source = costume.baseLayerTexture.baseTexture.source;
+ var cw = source.width;
+ var ch = source.height;
+ var scale = Math.min(this.scale, (w - 4) / cw, (h - 4) / ch);
+ var aw = scale * cw;
+ var ah = scale * ch;
+ var x = (w - aw)/2;
+ var y = (h - ah)/2;
+ this.elTmp.width = this.elTmp.width;
+ this.tmpContext.drawImage(source, x, y, aw, ah);
+ this.context.shadowBlur = 1.5 * this.scale;
+ this.context.shadowColor = 'rgba(0, 0, 0, .5)';
+ this.context.drawImage(this.elTmp, 0, 0);
+ };
+
+ SoundIcon.prototype.showSound = function() {
+ console.log("show sound icon");
+ //if (this.sound.isSprite) {
+ this.sprite.visible = true;
+ this.sprite.stage.redraw();
+ //}
+ };
+
+ Sound.prototype.updateSize = function() {
+ this.loaded = true;
+ this.width = this.baseLayerTexture.width * this.scale;
+ this.height = this.baseLayerTexture.height * this.scale;
+ this.changed();
+ };
+
+ SoundsPanel.prototype.emptySound = function() {
+ return new Sound(this.editor.stage.uniqueSoundName(_('Sound1')));
+ };
+
+ Sound.centered = function(name, image) {
+ return new Sound(name, image, image.width / 2 | 0, image.height / 2 | 0);
+ };
+
+ function Sound(name, baseLayer, cx, cy, pixelRatio, textLayer) {
+ this.baseLayerMD5 = null;
+ if (typeof baseLayer === 'string') { // MD5
+ this.baseLayerMD5 = baseLayer;
+ this.baseLayerTexture = PIXI.Texture.fromImage(Server.getAssetURL(baseLayer), true, PIXI.scaleModes.LINEAR);
+ } else if (baseLayer) {
+ this.baseLayerTexture = PIXI.Texture.fromCanvas(baseLayer, PIXI.scaleModes.LINEAR);
+ }
+ if (typeof textLayer === 'string') { // MD5
+ this.textLayerMD5 = textLayer;
+ this.textLayerTexture = PIXI.Texture.fromImage(Server.getAssetURL(textLayer), true, PIXI.scaleModes.LINEAR);
+ }
+ this.name = name;
+ this.cx = cx || 0;
+ this.cy = cy || 0;
+ this.pixelRatio = pixelRatio || 1;
+ this.scale = 1 / this.pixelRatio;
+ this.width = this.height = 1;
+ this.loaded = false;
+ if (this.baseLayerTexture) {
+ this.baseLayerTexture.baseTexture.resolution = this.pixelRatio;
+ this.baseLayerTexture.on('update', this.updateSize.bind(this));
+ }
+ }
+//********************Sounds Panel ^^^^^^^^^^^^^^^^^^^^^************************************************************
function TabPanel(editor) {
this.editor = editor;
- this.el = el('tab-panel');
- this.el.appendChild(this.elContent = el('tab-panel-content'));
-
this.tabPanels = [
this.scriptsPanel = new ScriptsPanel(editor),
this.costumesPanel = new CostumesPanel(editor),
@@ -5360,20 +6926,23 @@
this.tabClick = function() {
self.panel = self.tabPanels[this.dataset.index];
};
- this.scriptsTab = this.makeTab(T('Scripts'));
- this.costumesTab = this.makeTab(T('Costumes'));
- this.soundsTab = this.makeTab(T('Sounds'));
- this.panel = this.costumesPanel;
+ this.el = cl('tab-panel', [
+ this.elContent = cl('tab-panel-content'),
+ this.scriptsTab = this.makeTab(_('Scripts')),
+ this.costumesTab = this.makeTab(_('Costumes')),
+ this.soundsTab = this.makeTab(_('Sounds'))
+ ]);
+
+ this.panel = this.scriptsPanel;
}
TabPanel.prototype.makeTab = function(text) {
- var tab = el('button', 'tab');
- tab.textContent = T(text);
- tab.dataset.index = this.tabs.length;
+ var tab = cl('button', 'tab', {
+ dataset: {index: this.tabs.length}
+ }, [_(text)]);
tab.addEventListener('click', this.tabClick);
this.tabs.push(tab);
- this.el.appendChild(tab);
return tab;
};
@@ -5381,14 +6950,14 @@
get: function() {return this._panel},
set: function(value) {
if (this._panel) {
- this._tab.className = 'tab';
+ this._tab.classList.remove('selected');
this.elContent.removeChild(this._panel.el);
if (this.parent) this.parent.remove(this._panel);
}
this._panel = value;
this._tab = value && this.tabs[this.tabPanels.indexOf(value)];
if (value) {
- this._tab.className = 'tab selected';
+ this._tab.classList.add('selected');
this.elContent.appendChild(value.el);
if (this.parent) {
this.parent.add(value);
@@ -5407,7 +6976,7 @@
};
TabPanel.prototype.showSprite = function(sprite) {
- this.costumesTab.textContent = sprite.isStage ? T('Backdrops') : T('Costumes');
+ this.costumesTab.textContent = sprite.isStage ? _('Backdrops') : _('Costumes');
this.tabPanels.forEach(function(panel) {
if (panel) panel.showSprite(sprite);
});
@@ -5417,37 +6986,38 @@
function TopBar(editor) {
this.editor = editor;
- this.el = el('top-bar');
- this.languageButton = this.addButton('Language', this.languageMenu);
+ this.el = cl('top-bar', [
+ this.languageButton = this.makeButton('Language', this.languageMenu),
+ this.fileButton = this.makeButton(_('File'), this.fileMenu, true),
+ this.editButton = this.makeButton(_('Edit'), this.editMenu, true),
+ this.tipsButton = this.makeButton(_('Tips'), this.showTips),
+ this.aboutButton = this.makeButton(_('About'), this.showAbout),
+
+ this.elTools = cl('top-tools', [
+ this.duplicateButton = this.makeTool('duplicate', _('Duplicate')),
+ this.deleteButton = this.makeTool('delete', _('Delete')),
+ this.growButton = this.makeTool('grow', _('Grow')),
+ this.shrinkButton = this.makeTool('shrink', _('Shrink')),
+ this.helpButton = this.makeTool('help', _('Block help'))
+ ])
+ ]);
+
this.languageButton.classList.add('first');
- this.fileButton = this.addButton(T('File'), this.fileMenu, true);
- this.editButton = this.addButton(T('Edit'), this.editMenu, true);
- this.tipsButton = this.addButton(T('Tips'), this.showTips);
- this.aboutButton = this.addButton(T('About'), this.showAbout);
}
- TopBar.prototype.addButton = function(text, action, arrow) {
- var button = el('button', 'top-button' + (text === 'Language' ? ' language' : ''));
- button.textContent = text === 'Language' ? '' : text;
+ TopBar.prototype.makeButton = function(text, action, arrow) {
+ var button = cl('button', 'top-button' + (text === 'Language' ? ' language' : ''), text === 'Language' ? [] : [text]);
button.addEventListener('click', action.bind(this));
- this.el.appendChild(button);
if (arrow) {
- [['#ffffff', 'arrow normal'], ['#fba939', 'arrow hovered']].forEach(function(info) {
- var canvas = el('canvas', info[1]);
- canvas.width = 8;
- canvas.height = 6;
- var context = canvas.getContext('2d');
- context.moveTo(0, 0);
- context.lineTo(8, 0);
- context.lineTo(4, 6);
- context.fillStyle = info[0];
- context.fill();
- button.appendChild(canvas);
- });
+ button.appendChild(cl('arrow'));
}
return button;
};
+ TopBar.prototype.makeTool = function(name, title) {
+ return cl('button', 'top-tool top-tool-' + name, {title: title});
+ };
+
TopBar.prototype.languageMenu = function() {
this.showMenu(this.languageButton, this.editor.languageMenu());
};
@@ -5464,7 +7034,24 @@
this.editor.tipsPanel.home();
};
- TopBar.prototype.showAbout = function() {};
+ TopBar.prototype.showAbout = function() { // NS
+ function link(text, url) {
+ return el('a', {target: '_blank', href: url}, [text]);
+ }
+
+ var d = new Dialog(_('About Pixie'), Dialog.content(
+ el('article', [
+ el('h1', ['Pixie']),
+ el('p', ['An unofficial rewrite of ', link('Scratch', 'https://scratch.mit.edu'), ' in JavaScript, created by ', link('Nathan Dinsmore', 'https://github.com/nathan'), '. This fork off the master created by ', link('John Feagans', 'https://github.com/videophonegeek'), '.' ]),
+ el('p', ['Pixie aims to provide an application nearly identical to the current, Flash-based Scratch editor and player using only web technologies. The source code is ', link('available on GitHub', 'https://github.com/videophonegeek/pixie'), '.']),
+ el('p', ['This fork of the main project aims to complete the missing functionality, and add the libraries of costumes, backdrops, and sounds that make Scratch ideal for story telling.']),
+ cl('ul', 'links', [
+ el('li', [link('Issues', 'https://github.com/videophonegeek/pixie/issues')]),
+ el('li', [link('Contributors', 'https://github.com/videophonegeek/pixie/graphs/contributors')])
+ ])
+ ]),
+ Dialog.buttons(['OK', function() {d.commit()}]))).show(this.editor);
+ };
TopBar.prototype.showMenu = function(button, menu) {
if (!this.parent) return;
@@ -5478,39 +7065,42 @@
this.editor = editor;
this.stage = editor.stage;
this._running = false;
+ this._showMouseCoords = true;
- this.el = el('stage-panel stopped');
-
- this.el.appendChild(this.elTitleBar = el('title-bar'));
- this.fullScreenButton = this.addButton('full-screen');
- this.stopButton = this.addButton('stop', function() {
- this.parent.exec.stopAll();
- });
- this.runButton = this.addButton('run', function() {
- this.parent.exec.triggerGreenFlag();
- });
-
- this.elTitleBar.appendChild(this.elVersion = el('version'));
- this.elVersion.textContent = editor.version;
+ this.el = cl('stage-panel stopped', [
+ this.elTitleBar = cl('title-bar', [
+ this.fullScreenButton = this.makeButton('full-screen'),
+ this.stopButton = this.makeButton('stop', function() {
+ this.parent.exec.stopAll();
+ }),
+ this.runButton = this.makeButton('run', function(e) {
+ if (e.shiftKey) {
+ this.editor.toggleTurbo();
+ } else {
+ this.parent.exec.triggerGreenFlag();
+ }
+ }),
+ this.elVersion = cl('version', [editor.version]),
+ this.elTurbo = cl('turbo-indicator', [_('Turbo Mode')]),
+ this.elTitle = cl('input', 'project-name'),
+ this.elAuthor = cl('project-author')
+ ]),
+ this.elStage = this.stage.el,
+ this.elToggle = cl('stage-toggle'),
+ this.elMouseCoords = cl('mouse-coords', [
+ this.elMouseXLabel = cl('mouse-label x-axis', ['x:']),
+ this.elMouseX = cl('mouse-coord x-axis'),
+ this.elMouseXLabel = cl('mouse-label y-axis', ['y:']),
+ this.elMouseY = cl('mouse-coord x-axis')
+ ])
+ ]);
- this.elTitleBar.appendChild(this.elTitle = el('input', 'project-name'));
this.elTitle.addEventListener('input', this.titleChanged.bind(this));
+ this.elToggle.addEventListener('click', editor.toggleSmallStage.bind(editor));
this.updateTitle();
-
- this.elTitleBar.appendChild(this.elAuthor = el('project-author'));
this.updateAuthor();
this.stage.redraw();
- this.el.appendChild(this.elStage = this.stage.el);
-
- this._showMouseCoords = true;
- this.el.appendChild(this.elMouseCoords = el('mouse-coords'));
- this.elMouseCoords.appendChild(this.elMouseXLabel = el('mouse-label x-axis'));
- this.elMouseXLabel.textContent = 'x:';
- this.elMouseCoords.appendChild(this.elMouseX = el('mouse-coord x-axis'));
- this.elMouseCoords.appendChild(this.elMouseXLabel = el('mouse-label y-axis'));
- this.elMouseXLabel.textContent = 'y:';
- this.elMouseCoords.appendChild(this.elMouseY = el('mouse-coord x-axis'));
document.addEventListener('mousedown', this.mouseDown.bind(this));
document.addEventListener('mousemove', this.updateMouse.bind(this));
@@ -5550,7 +7140,7 @@
var x = e.clientX - bb.left;
var y = e.clientY - bb.top;
var target = this.objectFromPoint(x, y);
- if (target) this.editor.exec.triggerClick(target);
+ if (target && target.isSprite) this.editor.exec.triggerClick(target);
};
StagePanel.prototype.installProject = function(stage) {
@@ -5579,13 +7169,13 @@
};
StagePanel.prototype.updateAuthor = function() {
- this.elAuthor.textContent = this.stage.author ? T(this.stage.isPublic ? 'by {author}' : 'by {author} (unshared)', {author: this.stage.author}) : '';
+ this.elAuthor.textContent = this.stage.author ? _(this.stage.isPublic ? 'by {author}' : 'by {author} (unshared)', {author: this.stage.author}) : '';
};
StagePanel.prototype.keyDown = function(e) {
var name = getKeyName(e.keyCode);
if (e.metaKey || e.ctrlKey) {
- switch ((e.altKey ? '~' : '') + (e.shiftKey ? '!' : '') + name) {
+ switch ((e.altKey ? '~' : '') + (e.shiftKey ? '!' : '') + name) { // NS
case 's':
this.editor.save();
break;
@@ -5604,13 +7194,13 @@
default:
return;
}
- }
- if (document.activeElement === document.body) {
e.preventDefault();
+ return;
}
+ if (document.activeElement === document.body) e.preventDefault();
if (name) {
this.stage.keys[name] = true;
- this.editor.exec.triggerKey(getKeyName(name));
+ this.editor.exec.triggerKey(name);
}
};
@@ -5621,9 +7211,8 @@
}
};
- StagePanel.prototype.addButton = function(className, fn) {
- var button = el('button', 'title-button ' + className);
- this.elTitleBar.appendChild(button);
+ StagePanel.prototype.makeButton = function(className, fn) {
+ var button = cl('button', 'title-button ' + className);
if (fn) button.addEventListener('click', fn.bind(this));
return button;
};
@@ -5662,12 +7251,25 @@
}
});
+ var MIN_RUN_TIME = 50;
+
def(StagePanel.prototype, 'running', {
get: function() {return this._running},
set: function(running) {
if (running !== this._running) {
this._running = running;
- this.el.className = running ? 'stage-panel running' : 'stage-panel stopped';
+ if (running) {
+ this.startTime = Date.now();
+ }
+
+ var delta;
+ if (!running && (delta = this.startTime + MIN_RUN_TIME - Date.now()) > 0) {
+ setTimeout(function() {
+ this.el.className = 'stage-panel stopped';
+ }.bind(this), delta);
+ } else {
+ this.el.className = running ? 'stage-panel running' : 'stage-panel stopped';
+ }
}
}
});
@@ -5678,26 +7280,59 @@
this.stageIcon = new SpriteIcon(this, editor.stage);
this.icons = [];
-
- this.el = el('sprite-panel');
-
- this.el.appendChild(this.elTitleBar = el('title-bar'));
- this.elTitleBar.appendChild(this.elLabel = el('title-label'));
- this.elLabel.textContent = T('Sprites');
-
- this.elTitleBar.appendChild(this.elNewGroup = el('new-group'));
- this.elNewGroup.textContent = T('New sprite:');
- this.addNewButton('new-library', T('Choose sprite from library'), this.newFromLibrary);
- this.addNewButton('new-paint', T('Paint new sprite'), this.newFromEditor);
- this.addNewButton('new-import', T('Upload sprite from file'), this.newFromFile, 'image/*,.sprite2');
- this.addNewButton('new-camera', T('New sprite from file'), this.newFromCamera);
-
- this.el.appendChild(this.elStageSection = el('stage-section'));
- this.elStageSection.appendChild(this.stageIcon.el);
- this.elStageSection.appendChild(this.elNewBackdrop = el('new-backdrop'));
- this.elNewBackdrop.textContent = T('New backdrop:');
-
- this.el.appendChild(this.elSpriteSection = el('sprite-section'));
+ this.infoVisible = false;
+
+ this.el = cl('sprite-panel', [
+ this.elTitleBar = cl('title-bar', [
+ this.elLabel = cl('title-label', [_('Sprites')]),
+ this.elNewGroup = cl('new-group', [
+ this.elNewGroupLabel = cl('new-group-label', [_('New sprite:')]),
+ this.makeNewButton('new-library', _('Choose sprite from library'), this.newFromLibrary),
+ this.makeNewButton('new-paint', _('Paint new sprite'), this.newFromEditor),
+ this.makeNewButton('new-import', _('Upload sprite from file'), this.newFromFile, 'image/*,.sprite2'),
+ this.makeNewButton('new-camera', _('New sprite from camera'), this.newFromCamera)
+ ])
+ ]),
+ this.elStageSection = cl('stage-section', [
+ this.stageIcon.el,
+ this.elNewBackdrop = cl('new-backdrop', [
+ _('New backdrop:'),
+ this.makeNewButton('new-small-backdrop-library', _('Choose backdrop from library'), this.newBackdrop('newFromLibrary')),
+ this.makeNewButton('new-small-paint', _('Paint new backdrop'), this.newBackdrop('newFromEditor')),
+ this.makeNewButton('new-small-import', _('Upload backdrop from file'), this.newBackdrop('newFromFile'), 'image/*'),
+ this.makeNewButton('new-small-camera', _('New backdrop from camera'), this.newBackdrop('newFromCamera'))
+ ])
+ ]),
+ this.elSpriteSection = cl('sprite-section'),
+ this.elSpriteInfo = cl('sprite-info', [
+ this.elSpriteInfoBack = cl('sprite-info-back'),
+ this.elSpriteName = cl('input', 'sprite-info-name'),
+ cl('sprite-info-row', [
+ el('strong', [_('x:')]),
+ this.elSpriteX = cl('sprite-info-value'),
+ el('strong', [_('y:')]),
+ this.elSpriteY = cl('sprite-info-value'),
+ el('strong', {className: 'sprite-info-direction'}, [_('direction:')]),
+ this.elSpriteDirection = cl('sprite-info-value')
+ ]),
+ cl('sprite-info-row', [
+ el('strong', [_('rotation style:')])
+ ]),
+ cl('sprite-info-row', [
+ el('strong', [_('can drag in player:')]),
+ this.elSpriteDraggable = cl('button', 'check-box')
+ ]),
+ cl('sprite-info-row', [
+ el('strong', [_('show:')]),
+ this.elSpriteVisible = cl('button', 'check-box')
+ ])
+ ])
+ ]);
+
+ this.elSpriteInfoBack.addEventListener('click', this.hideInfo.bind(this));
+ this.elSpriteName.addEventListener('keydown', this.spriteNameKeyDown.bind(this));
+ this.elSpriteVisible.addEventListener('click', this.toggleSpriteVisible.bind(this));
+ this.elSpriteDraggable.addEventListener('click', this.toggleSpriteDraggable.bind(this));
this.addIcons(editor.stage);
}
@@ -5715,22 +7350,154 @@
this.select(this.icons[0] || this.stageIcon);
};
- SpritePanel.prototype.emptySprite = function() {
- return new Sprite(this.editor.stage.uniqueName(T('Sprite1')));
+ SpritePanel.prototype.showInfo = function() {
+ this.infoVisible = true;
+ this.elSpriteInfo.style.display = 'block';
+ this.resetSpriteName();
+ this.updateSpriteInfo();
};
- SpritePanel.prototype.newFromLibrary = function() {
- this.editor.addSprite(this.emptySprite()
- .addCostume(new Costume('costume1', 'f9a1c175dbe2e5dee472858dd30d16bb.svg', 47, 55))
- .addCostume(new Costume('costume2', 'c68e7b211672862001dd4fce12129813.png', 94, 108, 2)));
+ SpritePanel.prototype.spriteNameKeyDown = function(e) {
+ if (e.metaKey || e.ctrlKey) return;
+ if (e.keyCode === 27) {
+ this.resetSpriteName();
+ e.preventDefault();
+ }
+ if (e.keyCode === 13) {
+ this.renameSprite();
+ e.preventDefault();
+ }
+ e.stopPropagation();
+ };
+
+ SpritePanel.prototype.resetSpriteName = function() {
+ this.elSpriteName.value = this.editor.selectedSprite.name;
+ };
+
+ SpritePanel.prototype.renameSprite = function() {
+ var sprite = this.editor.selectedSprite;
+ var oldName = sprite.name;
+ sprite.name = null;
+ var newName = sprite.stage.uniqueSpriteName(this.elSpriteName.value.trim());
+ if (oldName === newName || !newName) {
+ sprite.name = oldName;
+ this.resetSpriteName();
+ return;
+ }
+ sprite.name = newName;
+ this.resetSpriteName();
+ var icon = this.findIcon(sprite);
+ if (icon) icon.updateName();
+ sprite.stage.updateWatcherLabels(sprite);
+ // TODO change name in scripts
+ };
+
+ SpritePanel.prototype.updateSpriteInfo = function() {
+ if (!this.infoVisible) return;
+ var sprite = this.editor.selectedSprite;
+ this.elSpriteX.textContent = Math.round(sprite.x);
+ this.elSpriteY.textContent = Math.round(sprite.y);
+ this.elSpriteDirection.textContent = Math.round(sprite.direction)+'°';
+ this.elSpriteDraggable.classList.toggle('checked', sprite.isDraggable);
+ this.elSpriteVisible.classList.toggle('checked', sprite.visible);
+ };
+
+ SpritePanel.prototype.toggleSpriteVisible = function() {
+ var sprite = this.editor.selectedSprite;
+ this.elSpriteVisible.classList.toggle('checked', sprite.visible = !sprite.visible);
+ sprite.stage.redraw();
+ };
+
+ SpritePanel.prototype.toggleSpriteDraggable = function() {
+ var sprite = this.editor.selectedSprite;
+ this.elSpriteDraggable.classList.toggle('checked', sprite.isDraggable = !sprite.isDraggable);
+ };
+
+ SpritePanel.prototype.hideInfo = function() {
+ this.infoVisible = false;
+ this.elSpriteInfo.style.display = 'none';
};
+ SpritePanel.prototype.emptySprite = function() {
+ return new Sprite(this.editor.stage.uniqueSpriteName(_('Sprite1')));
+ };
+
+ SpritePanel.prototype.newFromLibrary = function() {
+ var arrValues;
+ arrValues = showModalDialog("library/sprite/costumeLibrary.html","","center=yes;dialogWidth=1024;dialogHeight=768; resizable: Yes; status: Yes; scroll:yes");
+ if(arrValues)
+ {
+ /*
+ //var image = document.createElement('img');
+ //image.src = arrValues[0];
+ //console.log(arrValues[0]);
+ //this.editor.addSprite(this.emptySprite().addCostume(Costume.centered(arrValues[1], image)));
+ this.editor.addSprite(this.emptySprite().addCostume(new Costume(arrValues[1], arrValues[0])));
+
+ // Animated GIF store as multiple costumes for a sprite
+ var temp = this.emptySprite();
+ for (var i=0;i<3;i++) {temp.addCostume(new Costume("costume"+i, arrValues[0]));}
+ this.editor.addSprite(temp);
+ */
+ var temp = this.emptySprite();
+ var temp2 = this.editor;
+ imageSrc = new Image();
+ imageSrc.src = arrValues[0];
+ imageSrc.setAttribute("rel:auto_play","0");
+ imageSrc.setAttribute("rel:rubbable","0");
+ if (/^.+\.gif$/.test(imageSrc.src)) {
+ var rub = new SuperGif({ gif: imageSrc, progressbar_height: 0 } );
+ rub.load(function(){
+ for (var i = 0; i < rub.get_length(); i++) {
+ rub.move_to(i);
+ var img_uri= rub.get_canvas().toDataURL("image/png");
+ temp.addCostume(new Costume("costume"+i, img_uri));
+ }
+ temp2.addSprite(temp);
+ });
+ } else {
+ temp.addCostume(new Costume("costume1", arrValues[0]));
+ this.editor.addSprite(temp);
+ }
+
+ }
+/*
+ this.editor.addSprite(this.emptySprite()
+ .addCostume(new Costume('costume1', 'f9a1c175dbe2e5dee472858dd30d16bb.svg', 47, 55))
+ .addCostume(new Costume('costume2', 'c68e7b211672862001dd4fce12129813.png', 94, 108, 2)));
+ console.log("newFromLibrary unimplemented");
+ */
+ };
+
+ SpritePanel.prototype.newFromEditor = function() {
+ var sprite = this.emptySprite();
+ this.editor.addSprite(sprite.addCostume(sprite.makeEmptyCostume()));
+ this.editor.showCostumes();
+ };
+
+ SpritePanel.prototype.newFromCamera = function() {
+ Dialog.camera(function(image) {
+ var sprite = this.emptySprite();
+ this.editor.addSprite(sprite.addCostume(Costume.centered('photo1', image)));
+ this.editor.showCostumes();
+ }, this).show(this.editor);
+ };
+
+ SpritePanel.prototype.newBackdrop = function(name) {
+ return function(file) {
+ this.select(this.stageIcon);
+ this.editor.showCostumes();
+ this.editor.tabPanel.costumesPanel[name](file);
+ };
+ };
+
SpritePanel.prototype.newFromFile = function(file) {
+ console.log("newFromFile: "+file.name);
if (/^image\//.test(file.type)) {
- IO.readImageFile(file, function(image) {
+ IO.readImageFile(file, function(err, image) {
this.editor.addSprite(this.emptySprite()
- .addCostume(new Costume(stripExtension(file.name), image, image.width / 2, image.height / 2)));
- }, this);
+ .addCostume(Costume.centered(stripExtension(file.name), image)));
+ }, this);
} else {
IO.readArchiveFile(file, function(err, object) {
if (err || !object.isSprite) return console.warn(err, object); // TODO
@@ -5740,6 +7507,7 @@
};
SpritePanel.prototype.select = function(icon) {
+ if (this.selectedIcon === icon) return;
if (this.selectedIcon) {
this.selectedIcon.el.classList.remove('selected');
}
@@ -5768,6 +7536,14 @@
return icon;
};
+ SpritePanel.prototype.findIcon = function(sprite) {
+ var icons = this.icons;
+ for (var i = icons.length; i--;) {
+ var icon = icons[i];
+ if (icon.sprite === sprite) return icon;
+ }
+ };
+
SpritePanel.prototype.removeIcon = function(icon) {
var i = this.icons.indexOf(icon);
if (i !== -1) this.icons.splice(i, 1);
@@ -5786,7 +7562,7 @@
this.icons = [];
};
- SpritePanel.prototype.addNewButton = CostumesPanel.prototype.addNewButton;
+ SpritePanel.prototype.makeNewButton = CostumesPanel.prototype.makeNewButton;
SpritePanel.prototype.install = function(parent) {
parent.add(this.stageIcon);
@@ -5808,30 +7584,32 @@
this.editor = panel.editor;
this.sprite = sprite;
- this.el = el('sprite-icon');
- this.el.appendChild(this.elThumbnail = el('canvas', 'sprite-thumbnail'));
- this.elTmp = el('canvas', '');
- this.elThumbnail.width = this.elTmp.width = 68 + 4;
- this.elThumbnail.height = this.elTmp.height = 51 + 4;
+ this.el = cl('sprite-icon', [
+ this.elThumbnail = cl('canvas', 'sprite-thumbnail'),
+ this.elName = cl('sprite-icon-label')
+ ]);
+ this.elTmp = el('canvas');
+
this.context = this.elThumbnail.getContext('2d');
this.tmpContext = this.elTmp.getContext('2d');
- this.el.appendChild(this.elName = el('sprite-icon-label'));
- this.elName.textContent = sprite.name;
-
if (sprite.isStage) {
- this.el.className += ' for-stage';
- this.el.appendChild(this.elInfo = el('sprite-icon-info'));
+ this.el.classList.add('for-stage');
+ this.el.appendChild(this.elInfo = cl('sprite-icon-info'));
this.updateInfo();
} else {
- this.el.appendChild(this.elButton = el('button', 'sprite-icon-button'));
+ this.el.appendChild(this.elButton = cl('button', 'sprite-icon-button'));
+ this.elButton.addEventListener('click', function() {
+ this.panel.showInfo();
+ }.bind(this));
}
this.el.addEventListener('click', function() {
this.panel.select(this);
}.bind(this));
- this.update();
+ this.resize();
+ this.updateName();
setInterval(this.update.bind(this), 200);
}
inherits(SpriteIcon, vis.Target);
@@ -5852,7 +7630,7 @@
SpriteIcon.prototype.duplicateSprite = function() {
var sprite = this.sprite.copy();
- sprite.name = this.editor.stage.uniqueName(sprite.name);
+ sprite.name = this.editor.stage.uniqueSpriteName(sprite.name);
this.editor.addSprite(sprite);
};
@@ -5891,47 +7669,50 @@
return false;
};
+ SpriteIcon.prototype.resize = function() {
+ this.scale = window.devicePixelRatio || 1;
+ this.elThumbnail.width = this.elTmp.width = this.scale * (68 + 4);
+ this.elThumbnail.height = this.elTmp.height = this.scale * (51 + 4);
+ this.update();
+ };
+
SpriteIcon.prototype.update = function() {
if (this.sprite.isStage) this.updateInfo();
var costume = this.sprite.costumes[this.sprite.costume];
if (costume === this.costume) return;
- this.costume = costume.loaded && costume;
+ this.costume = costume && costume.loaded;
var w = this.elThumbnail.width;
var h = this.elThumbnail.height;
this.context.clearRect(0, 0, w, h);
- if (!costume.loaded) return;
+ if (!costume || !costume.loaded) return;
- var cw = costume.canvas.width;
- var ch = costume.canvas.height;
- var scale = Math.min(1, (w - 4) / cw, (h - 4) / ch);
+ var source = costume.baseLayerTexture.baseTexture.source;
+ var cw = source.width;
+ var ch = source.height;
+ var scale = Math.min(this.scale, (w - 4) / cw, (h - 4) / ch);
var aw = scale * cw;
var ah = scale * ch;
var x = (w - aw)/2;
var y = (h - ah)/2;
this.elTmp.width = this.elTmp.width;
- this.tmpContext.drawImage(costume.canvas, x, y, aw, ah);
-
- var ps = [-1, 0, 1];
- for (var i = 0, l = ps.length; i < l; i++) {
- for (var j = 0; j < l; j++) {
- if (i !== j) {
- this.context.shadowOffsetX = 10000 + ps[i];
- this.context.shadowOffsetY = 10000 + ps[j];
- this.context.shadowColor = 'rgba(0, 0, 0, .1)';
- this.context.drawImage(this.elTmp, -10000, -10000);
- }
- }
- }
+ this.tmpContext.drawImage(source, x, y, aw, ah);
+
+ this.context.shadowBlur = 1.5 * this.scale;
+ this.context.shadowColor = 'rgba(0, 0, 0, .5)';
this.context.drawImage(this.elTmp, 0, 0);
};
+ SpriteIcon.prototype.updateName = function() {
+ this.elName.title = this.elName.textContent = this.sprite.name;
+ };
+
SpriteIcon.prototype.updateInfo = function() {
var len = this.sprite.costumes.length;
if (this.costumeCount !== len) {
this.costumeCount = len;
- this.elInfo.textContent = T(len === 1 ? '{count} backdrop' : '{count} backdrops', {count: len});
+ this.elInfo.textContent = _(len === 1 ? '{count} backdrop' : '{count} backdrops', {count: len});
}
};
@@ -5939,10 +7720,10 @@
function BackpackPanel(editor) {
this.editor = editor;
- this.el = el('backpack-panel');
- this.el.appendChild(this.elTitle = el('backpack-title'));
- this.elTitle.textContent = 'Backpack';
- this.el.appendChild(this.elContent = el('backpack-content'));
+ this.el = cl('backpack-panel', [
+ this.elTitle = cl('backpack-title', [_('Backpack')]),
+ this.elContent = cl('backpack-content'),
+ ]);
this.elTitle.addEventListener('click', this.toggle.bind(this));
}
@@ -5956,17 +7737,19 @@
this.editor = editor;
this.isOpen = false;
- this.el = el('tips-panel');
- this.el.appendChild(this.elTitle = el('tips-title'));
- this.elTitle.appendChild(this.elIcon = el('tips-icon'));
- this.elIcon.textContent = '?';
- this.elTitle.appendChild(this.elClose = el('tips-close-button'));
- this.elClose.textContent = 'x';
- this.elTitle.appendChild(this.elLabel = el('tips-label'));
- this.elLabel.textContent = T('Tips');
- this.elLabel.appendChild(this.elHome = el('tips-home'));
- this.el.appendChild(this.elContent = el('tips-content'));
- this.elContent.appendChild(this.elFrame = el('iframe', 'tips-frame'));
+ this.el = cl('tips-panel', [
+ this.elTitle = cl('tips-title', [
+ this.elIcon = cl('tips-icon', ['?']),
+ this.elClose = cl('tips-close-button', ['x']),
+ this.elLabel = cl('tips-label', [
+ _('Tips'),
+ this.elHome = cl('tips-home')
+ ])
+ ]),
+ this.elContent = cl('tips-content', [
+ this.elFrame = cl('iframe', 'tips-frame')
+ ])
+ ]);
this.el.addEventListener('click', this.open.bind(this));
this.elClose.addEventListener('click', this.close.bind(this));
@@ -6005,9 +7788,10 @@
function Dialog(title, content) {
- this.el = el('dialog Visual-no-select');
- this.el.appendChild(this.elTitle = el('dialog-title'));
- this.el.appendChild(this.elContent = content || el('dialog-content'));
+ this.el = cl('dialog Visual-no-select', [
+ this.elTitle = cl('dialog-title'),
+ this.elContent = content || cl('dialog-content')
+ ]);
if (content) content.classList.add('dialog-content');
this.el.addEventListener('keydown', this.keyDown.bind(this));
@@ -6084,7 +7868,7 @@
if (typeof button === 'function' || button == null) {
context = fn;
fn = button;
- button = T('OK');
+ button = _('OK');
}
var d = new Dialog(title, Dialog.content(
@@ -6100,13 +7884,13 @@
if (typeof yes === 'function' || yes == null) {
context = no;
fn = yes;
- no = T('Cancel');
- yes = T('OK');
+ no = _('Cancel');
+ yes = _('OK');
}
if (typeof no === 'function' || no == null) {
context = fn;
fn = no;
- no = T('Cancel');
+ no = _('Cancel');
}
var d = new Dialog(title, Dialog.content(
@@ -6126,20 +7910,20 @@
if (typeof value === 'function' || value == null) {
context = yes;
fn = value;
- no = T('Cancel');
- yes = T('OK');
+ no = _('Cancel');
+ yes = _('OK');
value = '';
}
if (typeof yes === 'function' || yes == null) {
context = no;
fn = yes;
- no = T('Cancel');
- yes = T('OK');
+ no = _('Cancel');
+ yes = _('OK');
}
if (typeof no === 'function' || no == null) {
context = fn;
fn = no;
- no = T('Cancel');
+ no = _('Cancel');
}
var field = new Dialog.Field(label, value);
@@ -6158,20 +7942,65 @@
return d;
};
+ var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
+
+ Dialog.camera = function(fn, context) {
+ if (Dialog.camera.current) {
+ Dialog.camera.current.cancel();
+ }
+ if (!getUserMedia) {
+ return Dialog.camera.current = Dialog.alert(_('Camera'), _("Your browser doesn't support the getUserMedia API, which is required for camera access."), _('Close'));
+ }
+ var video = el('video', {width: 320, height: 240, autoplay: true});
+ var d = new Dialog(_('Camera'), Dialog.content(
+ video,
+ Dialog.buttons(
+ [_('Save'), function() {d.commit()}],
+ [_('Close'), function() {d.cancel()}])));
+ d.goToFront = function() {
+ Dialog.prototype.goToFront.call(this);
+ video.play();
+ };
+ if (fn) {
+ d.oncommit = function() {
+ if (stream) {
+ var canvas = el('canvas', {width: video.width, height: video.height});
+ canvas.getContext('2d').drawImage(video, 0, 0);
+ fn.call(context, canvas);
+ }
+ d.oncancel();
+ };
+ d.oncancel = function() {
+ canceled = true;
+ video.pause();
+ if (stream) stream.stop();
+ };
+ }
+ var stream, canceled;
+ getUserMedia.call(navigator, {video: true}, function(s) {
+ video.src = URL.createObjectURL(stream = s);
+ if (canceled) d.oncancel();
+ }, function(err) {
+ video.parentNode.replaceChild(cl('dialog-label video-error', {
+ style: {width: video.width+'px', height: video.height+'px'}
+ }, [_('Could not access camera.')]), video);
+ });
+ return Dialog.camera.current = d;
+ };
+
Dialog.label = function(text) {
- var div = el('dialog-label');
- div.textContent = text;
- return div;
+ return cl('dialog-label', [text]);
};
Dialog.Field = function(label, value) {
this.value = '';
- this.el = el('label', 'dialog-label');
- this.el.textContent = label;
- this.field = el('input', 'dialog-field');
- if (value != null) this.field.value = value;
+ this.el = cl('label', 'dialog-label', [
+ label,
+ this.field = cl('input', 'dialog-field', {
+ value: value == null ? '' : value
+ })
+ ]);
this.field.addEventListener('input', this.change.bind(this));
- this.el.appendChild(this.field);
};
Dialog.Field.prototype.change = function() {
@@ -6179,19 +8008,16 @@
};
Dialog.Radio = function() {
- this.el = el('dialog-label');
+ this.el = cl('dialog-label');
this.radios = [];
this.labels = [];
this.values = [];
var a = this.args = slice.call(arguments);
for (var i = 0, l = a.length; i < l; i++) {
var s = a[i];
- var label = el('label', 'dialog-radio-label enabled');
- var radio = el('button', 'dialog-radio');
- radio.dataset.index = i;
+ var radio = cl('button', 'dialog-radio', {dataset: {index: i}});
+ var label = cl('label', 'dialog-radio-label enabled', [radio, s[0]]);
radio.addEventListener('click', this.click.bind(this, i));
- label.appendChild(radio);
- label.appendChild(document.createTextNode(s[0]));
this.el.appendChild(label);
this.labels.push(label);
this.radios.push(radio);
@@ -6209,11 +8035,7 @@
if (radio) {
radio.dataset.enabled = !!enabled;
var label = this.labels[i];
- if (enabled) {
- label.classList.add('enabled');
- } else {
- label.classList.remove('enabled');
- }
+ label.classList.toggle('enabled', !!enabled);
}
};
@@ -6233,21 +8055,18 @@
Dialog.CheckBox = function(label) {
this._enabled = true;
this.value = false;
- this.el = el('label', 'dialog-label dialog-check-box-label enabled');
- this.button = el('button', 'check-box');
+ this.el = cl('label', 'dialog-label dialog-check-box-label enabled', [
+ this.button = cl('button', 'check-box'),
+ label
+ ]);
this.button.addEventListener('click', this.click.bind(this));
- this.el.appendChild(this.button);
- this.el.appendChild(document.createTextNode(label));
};
Dialog.CheckBox.prototype.click = function(e) {
e.preventDefault();
if (!this._enabled) return;
- if (this.value = !this.value) {
- this.button.classList.add('checked');
- } else {
- this.button.classList.remove('checked');
- }
+ this.value = !this.value;
+ this.button.classList.toggle('checked', this.value);
if (this.onchange) this.onchange();
};
@@ -6255,37 +8074,27 @@
get: function() {return this._enabled},
set: function(value) {
this._enabled = value;
- if (value) {
- this.el.classList.add('enabled');
- } else {
- this.el.classList.remove('enabled');
- }
+ this.el.classList.toggle('enabled', !!value);
}
});
Dialog.CheckBox.prototype.onchange = null;
Dialog.line = function() {
- return el('dialog-separator');
+ return cl('dialog-separator');
};
Dialog.content = function() {
- var div = el('');
- var a = slice.call(arguments);
- for (var i = 0, l = a.length; i < l; i++) {
- div.appendChild(a[i]);
- }
- return div;
+ return el('div', slice.call(arguments));
};
Dialog.buttons = function() {
- var div = el('dialog-buttons');
+ var div = cl('dialog-buttons');
var a = slice.call(arguments);
for (var i = 0, l = a.length; i < l; i++) {
var b = a[i];
if (typeof b !== 'object') b = [b, b];
- var button = el('button', 'ui-button');
- button.textContent = b[0];
+ var button = cl('button', 'ui-button', [b[0]]);
div.appendChild(button);
if (b[1]) button.addEventListener('click', b[1]);
}
@@ -6294,19 +8103,25 @@
Dialog.prototype.keyDown = function(e) {
if (e.keyCode === 13) {
+ e.preventDefault();
this.commit();
}
if (e.keyCode === 27) {
+ e.preventDefault();
this.cancel();
}
};
Dialog.prototype.mouseDown = function(e) {
- if (e.target.tagName === 'INPUT' || e.target.tagName === 'BUTTON' || e.target.tagName === 'SELECT' || e.target.tagName === 'LABEL') return;
+ if (e.target.tagName === 'INPUT' || e.target.tagName === 'BUTTON' || e.target.tagName === 'SELECT' || e.target.tagName === 'LABEL' || e.target.tagName === 'A' || e.button !== 0) return;
this.dragX = this.x - e.clientX;
this.dragY = this.y - e.clientY;
document.addEventListener('mousemove', this.mouseMove);
document.addEventListener('mouseup', this.mouseUp);
+ this.goToFront();
+ };
+
+ Dialog.prototype.goToFront = function() {
document.body.appendChild(this.el);
};
@@ -6328,48 +8143,50 @@
window.editor = editor;
console.timeEnd('init');
- // var player = document.querySelector('.player');
- // var stagePanel = new StagePanel(new Stage());
- // stagePanel.showMouseCoords = false;
- // player.appendChild(stagePanel.el);
-
- // var flip = editor.elFlipButton;
- // var flipBack = document.querySelector('.flip-back');
-
- // var flipped = false;
- // function doFlip() {
- // var time = 1;
- // editor.el.style.WebkitTransition =
- // player.style.WebkitTransition = 'none';
- // editor.el.style.WebkitTransform =
- // player.style.WebkitTransform = 'none';
- // var ebb = editor.el.getBoundingClientRect();
- // var pbb = player.getBoundingClientRect();
- // var dx = ((pbb.right + pbb.left) - (ebb.right + ebb.left)) / 2;
- // var dy = ((pbb.bottom + pbb.top) - (ebb.bottom + ebb.top)) / 2;
- // var sx = pbb.width / ebb.width;
- // var sy = pbb.height / ebb.height;
- // if (flipped) {
- // editor.el.style.WebkitTransform = 'translate('+dx+'px,'+dy+'px) rotateY(180deg) scale('+sx+','+sy+')';
- // editor.el.offsetHeight;
- // player.offsetHeight;
- // editor.el.style.WebkitTransition =
- // player.style.WebkitTransition = '-webkit-transform '+time+'s, z-index '+time+'s';
- // editor.el.style.WebkitTransform = 'none';
- // player.style.WebkitTransform = 'translate('+(-dx)+'px,'+(-dy)+'px) rotateY(-180deg) scale('+(1/sx)+','+(1/sy)+')';
- // } else {
- // player.style.WebkitTransform = 'translate('+(-dx)+'px,'+(-dy)+'px) rotateY(-180deg) scale('+(1/sx)+','+(1/sy)+')';
- // editor.el.offsetHeight;
- // player.offsetHeight;
- // editor.el.style.WebkitTransition =
- // player.style.WebkitTransition = '-webkit-transform '+time+'s, z-index '+time+'s';
- // editor.el.style.WebkitTransform = 'translate('+dx+'px,'+dy+'px) rotateY(180deg) scale('+sx+','+sy+')';
- // player.style.WebkitTransform = 'none';
- // }
- // flipped = !flipped;
- // }
-
- // flip.addEventListener('click', doFlip);
- // flipBack.addEventListener('click', doFlip);
+ var flip = editor.elFlipButton;
+ var flipBack = document.querySelector('.flip-back');
+ var player = document.querySelector('.player');
+
+ var flipped = false;
+ function doFlip() {
+ var time = 1.2;
+ var ed = editor.el;
+ var es = editor.stagePanel.el;
+
+ ed.style.WebkitTransition = 'none';
+ ed.style.WebkitTransform = 'none';
+
+ var ebb = ed.getBoundingClientRect();
+ var sbb = es.getBoundingClientRect();
+ var pbb = player.getBoundingClientRect();
+ var dx = ((pbb.right + pbb.left) - (ebb.right + ebb.left)) / 2;
+ var dy = ((pbb.bottom + pbb.top) - (ebb.bottom + ebb.top)) / 2;
+ var sdx = ((ebb.right + ebb.left) - (sbb.right + sbb.left)) / 2;
+ var sdy = ((ebb.bottom + ebb.top) - (sbb.bottom + sbb.top)) / 2;
+ var sx = pbb.width / ebb.width;
+ var sy = pbb.height / ebb.height;
+
+ if (flipped) {
+ ed.style.WebkitTransform = 'translate('+dx+'px,'+dy+'px) scale('+sx+','+sy+')';
+ } else {
+ ed.style.WebkitTransform = 'none';
+ }
+ ed.offsetHeight;
+ ed.style.WebkitTransition =
+ es.style.WebkitTransition = '-webkit-transform '+time+'s, z-index '+time+'s';
+ ed.classList.toggle('stage-only', !flipped);
+ if (flipped) {
+ ed.style.WebkitTransform = 'none';
+ es.style.WebkitTransform = 'none';
+ es.style.WebkitTransform = 'translateZ(0)';
+ } else {
+ ed.style.WebkitTransform = 'translate('+dx+'px,'+dy+'px) scale('+sx+','+sy+')';
+ es.style.WebkitTransform = 'translate3d('+sdx+'px,'+sdy+'px,0) scale('+(1/sx)+','+(1/sy)+')';
+ }
+ flipped = !flipped;
+ }
+
+ flip.addEventListener('click', doFlip);
+ flipBack.addEventListener('click', doFlip);
}());
diff --git a/lib/visual b/lib/visual
index c1fbfe9..d3fe61b 160000
--- a/lib/visual
+++ b/lib/visual
@@ -1 +1 @@
-Subproject commit c1fbfe99266d9cfa9dd25f6eb2708a280608cd2e
+Subproject commit d3fe61b8be8fedd8d83b1af633d04335f759c285
diff --git a/library/backdrop/Insaniquarium Deluxe - Aquarium 1.png b/library/backdrop/Insaniquarium Deluxe - Aquarium 1.png
new file mode 100644
index 0000000..422a090
Binary files /dev/null and b/library/backdrop/Insaniquarium Deluxe - Aquarium 1.png differ
diff --git a/library/backdrop/Insaniquarium Deluxe - Aquarium 2.png b/library/backdrop/Insaniquarium Deluxe - Aquarium 2.png
new file mode 100644
index 0000000..61835ac
Binary files /dev/null and b/library/backdrop/Insaniquarium Deluxe - Aquarium 2.png differ
diff --git a/library/backdrop/Insaniquarium Deluxe - Aquarium 3.png b/library/backdrop/Insaniquarium Deluxe - Aquarium 3.png
new file mode 100644
index 0000000..8bd64ad
Binary files /dev/null and b/library/backdrop/Insaniquarium Deluxe - Aquarium 3.png differ
diff --git a/library/backdrop/Insaniquarium Deluxe - Aquarium 4.png b/library/backdrop/Insaniquarium Deluxe - Aquarium 4.png
new file mode 100644
index 0000000..cde31a4
Binary files /dev/null and b/library/backdrop/Insaniquarium Deluxe - Aquarium 4.png differ
diff --git a/library/backdrop/Insaniquarium Deluxe - Aquarium 5.png b/library/backdrop/Insaniquarium Deluxe - Aquarium 5.png
new file mode 100644
index 0000000..dc0b7e4
Binary files /dev/null and b/library/backdrop/Insaniquarium Deluxe - Aquarium 5.png differ
diff --git a/library/backdrop/Insaniquarium Deluxe - Aquarium 6.png b/library/backdrop/Insaniquarium Deluxe - Aquarium 6.png
new file mode 100644
index 0000000..ca8614a
Binary files /dev/null and b/library/backdrop/Insaniquarium Deluxe - Aquarium 6.png differ
diff --git a/library/backdrop/MGD_-0000000001.png b/library/backdrop/MGD_-0000000001.png
new file mode 100755
index 0000000..92ada1a
Binary files /dev/null and b/library/backdrop/MGD_-0000000001.png differ
diff --git a/library/backdrop/MGD_-0000000002.png b/library/backdrop/MGD_-0000000002.png
new file mode 100755
index 0000000..0d7b268
Binary files /dev/null and b/library/backdrop/MGD_-0000000002.png differ
diff --git a/library/backdrop/MGD_-0000000003.png b/library/backdrop/MGD_-0000000003.png
new file mode 100755
index 0000000..dc75375
Binary files /dev/null and b/library/backdrop/MGD_-0000000003.png differ
diff --git a/library/backdrop/MGD_-0000000004.png b/library/backdrop/MGD_-0000000004.png
new file mode 100755
index 0000000..2df49fb
Binary files /dev/null and b/library/backdrop/MGD_-0000000004.png differ
diff --git a/library/backdrop/MGD_-0000000005.png b/library/backdrop/MGD_-0000000005.png
new file mode 100755
index 0000000..f16cb44
Binary files /dev/null and b/library/backdrop/MGD_-0000000005.png differ
diff --git a/library/backdrop/MGD_-0000000006.png b/library/backdrop/MGD_-0000000006.png
new file mode 100755
index 0000000..ac28e09
Binary files /dev/null and b/library/backdrop/MGD_-0000000006.png differ
diff --git a/library/backdrop/MGD_-0000000007.png b/library/backdrop/MGD_-0000000007.png
new file mode 100755
index 0000000..741bf7c
Binary files /dev/null and b/library/backdrop/MGD_-0000000007.png differ
diff --git a/library/backdrop/MGD_-0000000008.png b/library/backdrop/MGD_-0000000008.png
new file mode 100755
index 0000000..3a5c76d
Binary files /dev/null and b/library/backdrop/MGD_-0000000008.png differ
diff --git a/library/backdrop/MGD_-0000000009.png b/library/backdrop/MGD_-0000000009.png
new file mode 100755
index 0000000..62ad79f
Binary files /dev/null and b/library/backdrop/MGD_-0000000009.png differ
diff --git a/library/backdrop/MGD_-0000000010.png b/library/backdrop/MGD_-0000000010.png
new file mode 100755
index 0000000..911fbb3
Binary files /dev/null and b/library/backdrop/MGD_-0000000010.png differ
diff --git a/library/backdrop/MGD_-0000000011.png b/library/backdrop/MGD_-0000000011.png
new file mode 100755
index 0000000..4413199
Binary files /dev/null and b/library/backdrop/MGD_-0000000011.png differ
diff --git a/library/backdrop/MGD_-0000000012.png b/library/backdrop/MGD_-0000000012.png
new file mode 100755
index 0000000..a25deed
Binary files /dev/null and b/library/backdrop/MGD_-0000000012.png differ
diff --git a/library/backdrop/MGD_-0000000013.png b/library/backdrop/MGD_-0000000013.png
new file mode 100755
index 0000000..b2a00c6
Binary files /dev/null and b/library/backdrop/MGD_-0000000013.png differ
diff --git a/library/backdrop/MGD_-0000000014.png b/library/backdrop/MGD_-0000000014.png
new file mode 100755
index 0000000..91a73a5
Binary files /dev/null and b/library/backdrop/MGD_-0000000014.png differ
diff --git a/library/backdrop/MGD_-0000000015.png b/library/backdrop/MGD_-0000000015.png
new file mode 100755
index 0000000..506e36b
Binary files /dev/null and b/library/backdrop/MGD_-0000000015.png differ
diff --git a/library/backdrop/MGD_-0000000016.png b/library/backdrop/MGD_-0000000016.png
new file mode 100755
index 0000000..049ff93
Binary files /dev/null and b/library/backdrop/MGD_-0000000016.png differ
diff --git a/library/backdrop/MGD_-0000000017.png b/library/backdrop/MGD_-0000000017.png
new file mode 100755
index 0000000..8aad08b
Binary files /dev/null and b/library/backdrop/MGD_-0000000017.png differ
diff --git a/library/backdrop/MGD_-0000000018.png b/library/backdrop/MGD_-0000000018.png
new file mode 100755
index 0000000..2b9c3a8
Binary files /dev/null and b/library/backdrop/MGD_-0000000018.png differ
diff --git a/library/backdrop/MGD_-0000000019.png b/library/backdrop/MGD_-0000000019.png
new file mode 100755
index 0000000..d184310
Binary files /dev/null and b/library/backdrop/MGD_-0000000019.png differ
diff --git a/library/backdrop/MGD_-0000000020.png b/library/backdrop/MGD_-0000000020.png
new file mode 100755
index 0000000..68686b3
Binary files /dev/null and b/library/backdrop/MGD_-0000000020.png differ
diff --git a/library/backdrop/MGD_-0000000021.png b/library/backdrop/MGD_-0000000021.png
new file mode 100755
index 0000000..36c5bf9
Binary files /dev/null and b/library/backdrop/MGD_-0000000021.png differ
diff --git a/library/backdrop/MGD_-0000000022.png b/library/backdrop/MGD_-0000000022.png
new file mode 100755
index 0000000..34d6395
Binary files /dev/null and b/library/backdrop/MGD_-0000000022.png differ
diff --git a/library/backdrop/MGD_-0000000023.png b/library/backdrop/MGD_-0000000023.png
new file mode 100755
index 0000000..ce354e6
Binary files /dev/null and b/library/backdrop/MGD_-0000000023.png differ
diff --git a/library/backdrop/MGD_-0000000024.png b/library/backdrop/MGD_-0000000024.png
new file mode 100755
index 0000000..7e88f7a
Binary files /dev/null and b/library/backdrop/MGD_-0000000024.png differ
diff --git a/library/backdrop/backdrop.json b/library/backdrop/backdrop.json
new file mode 100644
index 0000000..e02d19b
--- /dev/null
+++ b/library/backdrop/backdrop.json
@@ -0,0 +1,152 @@
+[
+ {
+ "FILE": "MGD_-0000000001.png",
+ "CLASS": "All backdropActive Outdoors City",
+ "NAME": "School "
+ },
+ {
+ "FILE": "MGD_-0000000002.png",
+ "CLASS": "All Indoors",
+ "NAME": "Hospital"
+ },
+ {
+ "FILE": "MGD_-0000000003.png",
+ "CLASS": "All Outdoors Nature",
+ "NAME": "Garden 3"
+ },
+ {
+ "FILE": "MGD_-0000000004.png",
+ "CLASS": "All Indoors",
+ "NAME": "Office"
+ },
+ {
+ "FILE": "MGD_-0000000005.png",
+ "CLASS": "All Outdoors City",
+ "NAME": "City 1"
+ },
+ {
+ "FILE": "MGD_-0000000006.png",
+ "CLASS": "All Outdoors City",
+ "NAME": "City 2"
+ },
+ {
+ "FILE": "MGD_-0000000007.png",
+ "CLASS": "All Indoors",
+ "NAME": "Bedroom 1"
+ },
+ {
+ "FILE": "MGD_-0000000008.png",
+ "CLASS": "All Indoors",
+ "NAME": "Bedroom 2"
+ },
+ {
+ "FILE": "MGD_-0000000009.png",
+ "CLASS": "All Indoors",
+ "NAME": "Bedroom 3"
+ },
+ {
+ "FILE": "MGD_-0000000010.png",
+ "CLASS": "All Indoors",
+ "NAME": "Kitchen 1"
+ },
+ {
+ "FILE": "MGD_-0000000011.png",
+ "CLASS": "All Indoors",
+ "NAME": "Kitchen 2"
+ },
+ {
+ "FILE": "MGD_-0000000012.png",
+ "CLASS": "All Indoors",
+ "NAME": "Bathroom"
+ },
+ {
+ "FILE": "MGD_-0000000013.png",
+ "CLASS": "All Outdoors City",
+ "NAME": "City 3"
+ },
+ {
+ "FILE": "MGD_-0000000014.png",
+ "CLASS": "All Outdoors City",
+ "NAME": "City 4"
+ },
+ {
+ "FILE": "MGD_-0000000015.png",
+ "CLASS": "All Outdoors City",
+ "NAME": "City 5"
+ },
+ {
+ "FILE": "MGD_-0000000016.png",
+ "CLASS": "All Outdoors City",
+ "NAME": "City 6"
+ },
+ {
+ "FILE": "MGD_-0000000017.png",
+ "CLASS": "All Outdoors Castle",
+ "NAME": "Castle 1"
+ },
+ {
+ "FILE": "MGD_-0000000018.png",
+ "CLASS": "All Outdoors Castle",
+ "NAME": "Castle 2"
+ },
+ {
+ "FILE": "MGD_-0000000019.png",
+ "CLASS": "All Indoors",
+ "NAME": "Classroom 1"
+ },
+ {
+ "FILE": "MGD_-0000000020.png",
+ "CLASS": "All Indoors",
+ "NAME": "Classroom 2"
+ },
+ {
+ "FILE": "MGD_-0000000021.png",
+ "CLASS": "All Indoors",
+ "NAME": "Hallway 1"
+ },
+ {
+ "FILE": "MGD_-0000000022.png",
+ "CLASS": "All Indoors",
+ "NAME": "Hallway 2"
+ },
+ {
+ "FILE": "MGD_-0000000023.png",
+ "CLASS": "All Outdoors Nature",
+ "NAME": "Garden 1"
+ },
+ {
+ "FILE": "MGD_-0000000024.png",
+ "CLASS": "All Outdoors Nature",
+ "NAME": "Garden 2"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Aquarium 1.png",
+ "CLASS": "All Underwater Nature",
+ "NAME": "Aquarium 1"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Aquarium 2.png",
+ "CLASS": "All Underwater Nature",
+ "NAME": "Aquarium 2"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Aquarium 3.png",
+ "CLASS": "All Underwater Nature",
+ "NAME": "Aquarium 3"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Aquarium 4.png",
+ "CLASS": "All Underwater Nature",
+ "NAME": "Aquarium 4"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Aquarium 5.png",
+ "CLASS": "All Underwater Nature",
+ "NAME": "Aquarium 5"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Aquarium 6.png",
+ "CLASS": "All Underwater Nature",
+ "NAME": "Aquarium 6"
+ }
+]
\ No newline at end of file
diff --git a/library/backdrop/backdrop.txt b/library/backdrop/backdrop.txt
new file mode 100644
index 0000000..ec540bd
--- /dev/null
+++ b/library/backdrop/backdrop.txt
@@ -0,0 +1,31 @@
+FILE, CLASS, NAME
+MGD_-0000000001.png, All backdropActive Outdoors City, School
+MGD_-0000000002.png, All Indoors, Hospital
+MGD_-0000000003.png, All Outdoors Nature, Garden 3
+MGD_-0000000004.png, All Indoors, Office
+MGD_-0000000005.png, All Outdoors City, City 1
+MGD_-0000000006.png, All Outdoors City, City 2
+MGD_-0000000007.png, All Indoors, Bedroom 1
+MGD_-0000000008.png, All Indoors, Bedroom 2
+MGD_-0000000009.png, All Indoors, Bedroom 3
+MGD_-0000000010.png, All Indoors, Kitchen 1
+MGD_-0000000011.png, All Indoors, Kitchen 2
+MGD_-0000000012.png, All Indoors, Bathroom
+MGD_-0000000013.png, All Outdoors City, City 3
+MGD_-0000000014.png, All Outdoors City, City 4
+MGD_-0000000015.png, All Outdoors City, City 5
+MGD_-0000000016.png, All Outdoors City, City 6
+MGD_-0000000017.png, All Outdoors Castle, Castle 1
+MGD_-0000000018.png, All Outdoors Castle, Castle 2
+MGD_-0000000019.png, All Indoors, Classroom 1
+MGD_-0000000020.png, All Indoors, Classroom 2
+MGD_-0000000021.png, All Indoors, Hallway 1
+MGD_-0000000022.png, All Indoors, Hallway 2
+MGD_-0000000023.png, All Outdoors Nature, Garden 1
+MGD_-0000000024.png, All Outdoors Nature, Garden 2
+Insaniquarium Deluxe - Aquarium 1.png, All Underwater Nature, Aquarium 1
+Insaniquarium Deluxe - Aquarium 2.png, All Underwater Nature, Aquarium 2
+Insaniquarium Deluxe - Aquarium 3.png, All Underwater Nature, Aquarium 3
+Insaniquarium Deluxe - Aquarium 4.png, All Underwater Nature, Aquarium 4
+Insaniquarium Deluxe - Aquarium 5.png, All Underwater Nature, Aquarium 5
+Insaniquarium Deluxe - Aquarium 6.png, All Underwater Nature, Aquarium 6
diff --git a/library/backdrop/backdropLibrary.html b/library/backdrop/backdropLibrary.html
new file mode 100644
index 0000000..376b896
--- /dev/null
+++ b/library/backdrop/backdropLibrary.html
@@ -0,0 +1,212 @@
+
+
+
+ Backdrop Library
+
+
+
+
+
+
+
+
+
+
X
+
+
+
+
+
+
+
+
+ School
+ Hospital
+ Garden 3
+ Office
+ City 1
+ City 2
+ Bedroom 1
+ Bedroom 2
+ Bedroom 3
+ Kitchen 1
+ Kitchen 2
+ Bathroom
+ City 3
+ City 4
+ City 5
+ City 6
+ Castle 1
+ Castle 2
+ Classroom 1
+ Classroom 2
+ Hallway 1
+ Hallway 2
+ Garden 1
+ Garden 2
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/backdrop/index.html b/library/backdrop/index.html
new file mode 100644
index 0000000..dce2bca
--- /dev/null
+++ b/library/backdrop/index.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+ Sound Library Modal Tester
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/backdrop/stage.png b/library/backdrop/stage.png
new file mode 100644
index 0000000..b395ac9
Binary files /dev/null and b/library/backdrop/stage.png differ
diff --git a/library/sounds/Alert-01.mp3 b/library/sounds/Alert-01.mp3
new file mode 100755
index 0000000..d265999
Binary files /dev/null and b/library/sounds/Alert-01.mp3 differ
diff --git a/library/sounds/Alert-02.mp3 b/library/sounds/Alert-02.mp3
new file mode 100755
index 0000000..7eaac76
Binary files /dev/null and b/library/sounds/Alert-02.mp3 differ
diff --git a/library/sounds/Alert-03.mp3 b/library/sounds/Alert-03.mp3
new file mode 100755
index 0000000..1b2ef8d
Binary files /dev/null and b/library/sounds/Alert-03.mp3 differ
diff --git a/library/sounds/Alert-04.mp3 b/library/sounds/Alert-04.mp3
new file mode 100755
index 0000000..9c69f75
Binary files /dev/null and b/library/sounds/Alert-04.mp3 differ
diff --git a/library/sounds/Alert-05.mp3 b/library/sounds/Alert-05.mp3
new file mode 100755
index 0000000..ad90808
Binary files /dev/null and b/library/sounds/Alert-05.mp3 differ
diff --git a/library/sounds/Alert-06.mp3 b/library/sounds/Alert-06.mp3
new file mode 100755
index 0000000..b403dab
Binary files /dev/null and b/library/sounds/Alert-06.mp3 differ
diff --git a/library/sounds/Alert-07.mp3 b/library/sounds/Alert-07.mp3
new file mode 100755
index 0000000..80cfb00
Binary files /dev/null and b/library/sounds/Alert-07.mp3 differ
diff --git a/library/sounds/Alert-08.mp3 b/library/sounds/Alert-08.mp3
new file mode 100755
index 0000000..d6add81
Binary files /dev/null and b/library/sounds/Alert-08.mp3 differ
diff --git a/library/sounds/Alert-09.mp3 b/library/sounds/Alert-09.mp3
new file mode 100755
index 0000000..ff550b0
Binary files /dev/null and b/library/sounds/Alert-09.mp3 differ
diff --git a/library/sounds/Alert-10.mp3 b/library/sounds/Alert-10.mp3
new file mode 100644
index 0000000..c84a92a
Binary files /dev/null and b/library/sounds/Alert-10.mp3 differ
diff --git a/library/sounds/Input-01.mp3 b/library/sounds/Input-01.mp3
new file mode 100755
index 0000000..6f71408
Binary files /dev/null and b/library/sounds/Input-01.mp3 differ
diff --git a/library/sounds/Input-02.mp3 b/library/sounds/Input-02.mp3
new file mode 100755
index 0000000..0873522
Binary files /dev/null and b/library/sounds/Input-02.mp3 differ
diff --git a/library/sounds/Input-03.mp3 b/library/sounds/Input-03.mp3
new file mode 100644
index 0000000..466ac82
Binary files /dev/null and b/library/sounds/Input-03.mp3 differ
diff --git a/library/sounds/Input-04a.mp3 b/library/sounds/Input-04a.mp3
new file mode 100644
index 0000000..8c3ce1a
Binary files /dev/null and b/library/sounds/Input-04a.mp3 differ
diff --git a/library/sounds/Input-04b.mp3 b/library/sounds/Input-04b.mp3
new file mode 100644
index 0000000..398e63d
Binary files /dev/null and b/library/sounds/Input-04b.mp3 differ
diff --git a/library/sounds/Input-05.mp3 b/library/sounds/Input-05.mp3
new file mode 100644
index 0000000..c8b7946
Binary files /dev/null and b/library/sounds/Input-05.mp3 differ
diff --git a/library/sounds/Input-06.mp3 b/library/sounds/Input-06.mp3
new file mode 100644
index 0000000..4147d60
Binary files /dev/null and b/library/sounds/Input-06.mp3 differ
diff --git a/library/sounds/Music-01.mp3 b/library/sounds/Music-01.mp3
new file mode 100755
index 0000000..620e01f
Binary files /dev/null and b/library/sounds/Music-01.mp3 differ
diff --git a/library/sounds/SciFi-01.mp3 b/library/sounds/SciFi-01.mp3
new file mode 100755
index 0000000..649e1b8
Binary files /dev/null and b/library/sounds/SciFi-01.mp3 differ
diff --git a/library/sounds/SciFi-02.mp3 b/library/sounds/SciFi-02.mp3
new file mode 100755
index 0000000..8cf7f2a
Binary files /dev/null and b/library/sounds/SciFi-02.mp3 differ
diff --git a/library/sounds/SciFi-03.mp3 b/library/sounds/SciFi-03.mp3
new file mode 100755
index 0000000..81c074f
Binary files /dev/null and b/library/sounds/SciFi-03.mp3 differ
diff --git a/library/sounds/SciFi-04.mp3 b/library/sounds/SciFi-04.mp3
new file mode 100755
index 0000000..c25d116
Binary files /dev/null and b/library/sounds/SciFi-04.mp3 differ
diff --git a/library/sounds/SciFi-05.mp3 b/library/sounds/SciFi-05.mp3
new file mode 100755
index 0000000..4ed032a
Binary files /dev/null and b/library/sounds/SciFi-05.mp3 differ
diff --git a/library/sounds/SciFi-06.mp3 b/library/sounds/SciFi-06.mp3
new file mode 100644
index 0000000..085410f
Binary files /dev/null and b/library/sounds/SciFi-06.mp3 differ
diff --git a/library/sounds/SciFi-07.mp3 b/library/sounds/SciFi-07.mp3
new file mode 100644
index 0000000..2dc76fa
Binary files /dev/null and b/library/sounds/SciFi-07.mp3 differ
diff --git a/library/sounds/Voice-Cartoon_Laugh-01.mp3 b/library/sounds/Voice-Cartoon_Laugh-01.mp3
new file mode 100755
index 0000000..8fcdb91
Binary files /dev/null and b/library/sounds/Voice-Cartoon_Laugh-01.mp3 differ
diff --git a/library/sounds/Voice-Coding_Power-01.mp3 b/library/sounds/Voice-Coding_Power-01.mp3
new file mode 100644
index 0000000..25c552e
Binary files /dev/null and b/library/sounds/Voice-Coding_Power-01.mp3 differ
diff --git a/library/sounds/Voice-Coding_Power-F-01.mp3 b/library/sounds/Voice-Coding_Power-F-01.mp3
new file mode 100644
index 0000000..12d58cc
Binary files /dev/null and b/library/sounds/Voice-Coding_Power-F-01.mp3 differ
diff --git a/library/sounds/Voice-Coding_Rainbow-01.mp3 b/library/sounds/Voice-Coding_Rainbow-01.mp3
new file mode 100755
index 0000000..c6246a0
Binary files /dev/null and b/library/sounds/Voice-Coding_Rainbow-01.mp3 differ
diff --git a/library/sounds/Voice-Coding_Rainbow-F-01.mp3 b/library/sounds/Voice-Coding_Rainbow-F-01.mp3
new file mode 100644
index 0000000..d2468dc
Binary files /dev/null and b/library/sounds/Voice-Coding_Rainbow-F-01.mp3 differ
diff --git a/library/sounds/Voice-Dan_Shiffman-01.mp3 b/library/sounds/Voice-Dan_Shiffman-01.mp3
new file mode 100755
index 0000000..b5de095
Binary files /dev/null and b/library/sounds/Voice-Dan_Shiffman-01.mp3 differ
diff --git a/library/sounds/Voice-Dan_Shiffman-F-01.mp3 b/library/sounds/Voice-Dan_Shiffman-F-01.mp3
new file mode 100644
index 0000000..85fb1e5
Binary files /dev/null and b/library/sounds/Voice-Dan_Shiffman-F-01.mp3 differ
diff --git a/library/sounds/Voice-Hello-01.mp3 b/library/sounds/Voice-Hello-01.mp3
new file mode 100755
index 0000000..a9c1b2d
Binary files /dev/null and b/library/sounds/Voice-Hello-01.mp3 differ
diff --git a/library/sounds/Voice-Hello-02.mp3 b/library/sounds/Voice-Hello-02.mp3
new file mode 100755
index 0000000..765b02c
Binary files /dev/null and b/library/sounds/Voice-Hello-02.mp3 differ
diff --git a/library/sounds/Voice-Hello-F-01.mp3 b/library/sounds/Voice-Hello-F-01.mp3
new file mode 100644
index 0000000..9f67bfb
Binary files /dev/null and b/library/sounds/Voice-Hello-F-01.mp3 differ
diff --git a/library/sounds/Woosh-Deep-01.mp3 b/library/sounds/Woosh-Deep-01.mp3
new file mode 100755
index 0000000..45aa91f
Binary files /dev/null and b/library/sounds/Woosh-Deep-01.mp3 differ
diff --git a/library/sounds/Woosh-Light-01.mp3 b/library/sounds/Woosh-Light-01.mp3
new file mode 100755
index 0000000..e72c777
Binary files /dev/null and b/library/sounds/Woosh-Light-01.mp3 differ
diff --git a/library/sounds/Woosh-Light-02.mp3 b/library/sounds/Woosh-Light-02.mp3
new file mode 100755
index 0000000..c4cf519
Binary files /dev/null and b/library/sounds/Woosh-Light-02.mp3 differ
diff --git a/library/sounds/miaow.mp3 b/library/sounds/miaow.mp3
new file mode 100755
index 0000000..4d94359
Binary files /dev/null and b/library/sounds/miaow.mp3 differ
diff --git a/library/sounds/purring.mp3 b/library/sounds/purring.mp3
new file mode 100755
index 0000000..d486576
Binary files /dev/null and b/library/sounds/purring.mp3 differ
diff --git a/library/sounds/siamese.mp3 b/library/sounds/siamese.mp3
new file mode 100755
index 0000000..a0cee5b
Binary files /dev/null and b/library/sounds/siamese.mp3 differ
diff --git a/library/sounds/sound.json b/library/sounds/sound.json
new file mode 100644
index 0000000..b1c5243
--- /dev/null
+++ b/library/sounds/sound.json
@@ -0,0 +1,192 @@
+[
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All soundActive Alert",
+ "NAME": "Alert-01 "
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Alert",
+ "NAME": "Alert-02"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Alert",
+ "NAME": "Alert-03"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Alert",
+ "NAME": "Alert-04"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Alert",
+ "NAME": "Alert-05"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Alert",
+ "NAME": "Alert-06"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Alert",
+ "NAME": "Alert-07"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Alert",
+ "NAME": "Alert-08"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Alert",
+ "NAME": "Alert-09"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Alert",
+ "NAME": "Alert-10"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Input",
+ "NAME": "Input-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Input",
+ "NAME": "Input-02"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Input",
+ "NAME": "Input-03"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Input",
+ "NAME": "Input-04a"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Input",
+ "NAME": "Input-04b"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Input",
+ "NAME": "Input-05"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Input",
+ "NAME": "Input-06"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Music",
+ "NAME": "Music-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All SciFi",
+ "NAME": "SciFi-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All SciFi",
+ "NAME": "SciFi-02"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All SciFi",
+ "NAME": "SciFi-03"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All SciFi",
+ "NAME": "SciFi-04"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All SciFi",
+ "NAME": "SciFi-05"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All SciFi",
+ "NAME": "SciFi-06"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All SciFi",
+ "NAME": "SciFi-07"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Voice",
+ "NAME": "Voice-Coding_Power-F-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Voice",
+ "NAME": "Voice-Coding_Rainbow-F-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Voice",
+ "NAME": "Voice-Dan_Shiffman-F-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Voice",
+ "NAME": "Voice-Hello-F-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Voice",
+ "NAME": "Voice-Cartoon_Laugh-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Voice",
+ "NAME": "Voice-Coding_Power-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Voice",
+ "NAME": "Voice-Coding_Rainbow-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Voice",
+ "NAME": "Voice-Dan_Shiffman-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Voice",
+ "NAME": "Voice-Hello-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Voice",
+ "NAME": "Voice-Hello-02"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Woosh",
+ "NAME": "Woosh-Deep-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Woosh",
+ "NAME": "Woosh-Light-01"
+ },
+ {
+ "FILE": "soundIcon.png",
+ "CLASS": "All Woosh",
+ "NAME": "Woosh-Light-02"
+ }
+]
\ No newline at end of file
diff --git a/library/sounds/sound.txt b/library/sounds/sound.txt
new file mode 100644
index 0000000..c8e1827
--- /dev/null
+++ b/library/sounds/sound.txt
@@ -0,0 +1,39 @@
+FILE,CLASS,NAME
+soundIcon.png,All soundActive Alert,Alert-01
+soundIcon.png,All Alert,Alert-02
+soundIcon.png,All Alert,Alert-03
+soundIcon.png,All Alert,Alert-04
+soundIcon.png,All Alert,Alert-05
+soundIcon.png,All Alert,Alert-06
+soundIcon.png,All Alert,Alert-07
+soundIcon.png,All Alert,Alert-08
+soundIcon.png,All Alert,Alert-09
+soundIcon.png,All Alert,Alert-10
+soundIcon.png,All Input,Input-01
+soundIcon.png,All Input,Input-02
+soundIcon.png,All Input,Input-03
+soundIcon.png,All Input,Input-04a
+soundIcon.png,All Input,Input-04b
+soundIcon.png,All Input,Input-05
+soundIcon.png,All Input,Input-06
+soundIcon.png,All Music,Music-01
+soundIcon.png,All SciFi,SciFi-01
+soundIcon.png,All SciFi,SciFi-02
+soundIcon.png,All SciFi,SciFi-03
+soundIcon.png,All SciFi,SciFi-04
+soundIcon.png,All SciFi,SciFi-05
+soundIcon.png,All SciFi,SciFi-06
+soundIcon.png,All SciFi,SciFi-07
+soundIcon.png,All Voice,Voice-Coding_Power-F-01
+soundIcon.png,All Voice,Voice-Coding_Rainbow-F-01
+soundIcon.png,All Voice,Voice-Dan_Shiffman-F-01
+soundIcon.png,All Voice,Voice-Hello-F-01
+soundIcon.png,All Voice,Voice-Cartoon_Laugh-01
+soundIcon.png,All Voice,Voice-Coding_Power-01
+soundIcon.png,All Voice,Voice-Coding_Rainbow-01
+soundIcon.png,All Voice,Voice-Dan_Shiffman-01
+soundIcon.png,All Voice,Voice-Hello-01
+soundIcon.png,All Voice,Voice-Hello-02
+soundIcon.png,All Woosh,Woosh-Deep-01
+soundIcon.png,All Woosh,Woosh-Light-01
+soundIcon.png,All Woosh,Woosh-Light-02
diff --git a/library/sounds/soundIcon.png b/library/sounds/soundIcon.png
new file mode 100644
index 0000000..2a0efad
Binary files /dev/null and b/library/sounds/soundIcon.png differ
diff --git a/library/sounds/soundLibrary.html b/library/sounds/soundLibrary.html
new file mode 100644
index 0000000..0c54816
--- /dev/null
+++ b/library/sounds/soundLibrary.html
@@ -0,0 +1,190 @@
+
+
+
+ Sound Library
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/sounds/yowl.mp3 b/library/sounds/yowl.mp3
new file mode 100755
index 0000000..db0331d
Binary files /dev/null and b/library/sounds/yowl.mp3 differ
diff --git a/library/sprite/AiharaRingo.png b/library/sprite/AiharaRingo.png
new file mode 100644
index 0000000..1dee94a
Binary files /dev/null and b/library/sprite/AiharaRingo.png differ
diff --git a/library/sprite/Hanahira - Amane Yuuki.png b/library/sprite/Hanahira - Amane Yuuki.png
new file mode 100644
index 0000000..62cfc41
Binary files /dev/null and b/library/sprite/Hanahira - Amane Yuuki.png differ
diff --git a/library/sprite/Hanahira - Kaori Hanemura.png b/library/sprite/Hanahira - Kaori Hanemura.png
new file mode 100644
index 0000000..2153d08
Binary files /dev/null and b/library/sprite/Hanahira - Kaori Hanemura.png differ
diff --git a/library/sprite/HouraisenRuna.png b/library/sprite/HouraisenRuna.png
new file mode 100644
index 0000000..ac0f1f0
Binary files /dev/null and b/library/sprite/HouraisenRuna.png differ
diff --git a/library/sprite/Insaniquarium Deluxe - Basket Ball 1.png b/library/sprite/Insaniquarium Deluxe - Basket Ball 1.png
new file mode 100644
index 0000000..cd1a1d2
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - Basket Ball 1.png differ
diff --git a/library/sprite/Insaniquarium Deluxe - Beach Ball 1.png b/library/sprite/Insaniquarium Deluxe - Beach Ball 1.png
new file mode 100644
index 0000000..19c108a
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - Beach Ball 1.png differ
diff --git a/library/sprite/Insaniquarium Deluxe - Crab 1.gif b/library/sprite/Insaniquarium Deluxe - Crab 1.gif
new file mode 100644
index 0000000..67644dd
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - Crab 1.gif differ
diff --git a/library/sprite/Insaniquarium Deluxe - Crab 1.png b/library/sprite/Insaniquarium Deluxe - Crab 1.png
new file mode 100644
index 0000000..e7e738a
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - Crab 1.png differ
diff --git a/library/sprite/Insaniquarium Deluxe - Mermaid 1.gif b/library/sprite/Insaniquarium Deluxe - Mermaid 1.gif
new file mode 100644
index 0000000..d74db10
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - Mermaid 1.gif differ
diff --git a/library/sprite/Insaniquarium Deluxe - Mermaid 1.png b/library/sprite/Insaniquarium Deluxe - Mermaid 1.png
new file mode 100644
index 0000000..f4464a3
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - Mermaid 1.png differ
diff --git a/library/sprite/Insaniquarium Deluxe - Soccer Ball 1.png b/library/sprite/Insaniquarium Deluxe - Soccer Ball 1.png
new file mode 100644
index 0000000..3d7a840
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - Soccer Ball 1.png differ
diff --git a/library/sprite/Insaniquarium Deluxe - Whiffle Ball 1.png b/library/sprite/Insaniquarium Deluxe - Whiffle Ball 1.png
new file mode 100644
index 0000000..a9234ab
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - Whiffle Ball 1.png differ
diff --git a/library/sprite/Insaniquarium Deluxe - fish1.gif b/library/sprite/Insaniquarium Deluxe - fish1.gif
new file mode 100644
index 0000000..7afe8ed
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - fish1.gif differ
diff --git a/library/sprite/Insaniquarium Deluxe - fish2.gif b/library/sprite/Insaniquarium Deluxe - fish2.gif
new file mode 100644
index 0000000..efdff0e
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - fish2.gif differ
diff --git a/library/sprite/Insaniquarium Deluxe - fish3.gif b/library/sprite/Insaniquarium Deluxe - fish3.gif
new file mode 100644
index 0000000..fafe253
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - fish3.gif differ
diff --git a/library/sprite/Insaniquarium Deluxe - hermit-crab.gif b/library/sprite/Insaniquarium Deluxe - hermit-crab.gif
new file mode 100644
index 0000000..f62a051
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - hermit-crab.gif differ
diff --git a/library/sprite/Insaniquarium Deluxe - jellyfish1.gif b/library/sprite/Insaniquarium Deluxe - jellyfish1.gif
new file mode 100644
index 0000000..0d68c85
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - jellyfish1.gif differ
diff --git a/library/sprite/Insaniquarium Deluxe - red-shark.gif b/library/sprite/Insaniquarium Deluxe - red-shark.gif
new file mode 100644
index 0000000..37d693d
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - red-shark.gif differ
diff --git a/library/sprite/Insaniquarium Deluxe - sea-horse.gif b/library/sprite/Insaniquarium Deluxe - sea-horse.gif
new file mode 100644
index 0000000..a1cee91
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - sea-horse.gif differ
diff --git a/library/sprite/Insaniquarium Deluxe - shark1.gif b/library/sprite/Insaniquarium Deluxe - shark1.gif
new file mode 100644
index 0000000..da66f57
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - shark1.gif differ
diff --git a/library/sprite/Insaniquarium Deluxe - turtle1.gif b/library/sprite/Insaniquarium Deluxe - turtle1.gif
new file mode 100644
index 0000000..4194ff6
Binary files /dev/null and b/library/sprite/Insaniquarium Deluxe - turtle1.gif differ
diff --git a/library/sprite/Kirishima.png b/library/sprite/Kirishima.png
new file mode 100644
index 0000000..5eba410
Binary files /dev/null and b/library/sprite/Kirishima.png differ
diff --git a/library/sprite/KitajimaKaede.png b/library/sprite/KitajimaKaede.png
new file mode 100644
index 0000000..c7b90b8
Binary files /dev/null and b/library/sprite/KitajimaKaede.png differ
diff --git a/library/sprite/OdaNanami.png b/library/sprite/OdaNanami.png
new file mode 100644
index 0000000..6565739
Binary files /dev/null and b/library/sprite/OdaNanami.png differ
diff --git a/library/sprite/Pac-Man POP 1 flip.png b/library/sprite/Pac-Man POP 1 flip.png
new file mode 100644
index 0000000..fedffd6
Binary files /dev/null and b/library/sprite/Pac-Man POP 1 flip.png differ
diff --git a/library/sprite/Pac-Man POP 1.png b/library/sprite/Pac-Man POP 1.png
new file mode 100644
index 0000000..c82d4cf
Binary files /dev/null and b/library/sprite/Pac-Man POP 1.png differ
diff --git a/library/sprite/Pac-Man POP 2.png b/library/sprite/Pac-Man POP 2.png
new file mode 100644
index 0000000..0ed0ba1
Binary files /dev/null and b/library/sprite/Pac-Man POP 2.png differ
diff --git a/library/sprite/Pac-Man POP 3.png b/library/sprite/Pac-Man POP 3.png
new file mode 100644
index 0000000..90d928d
Binary files /dev/null and b/library/sprite/Pac-Man POP 3.png differ
diff --git a/library/sprite/Pac-Man POP dog.png b/library/sprite/Pac-Man POP dog.png
new file mode 100644
index 0000000..cfb3cf6
Binary files /dev/null and b/library/sprite/Pac-Man POP dog.png differ
diff --git a/library/sprite/Pac-Man POP ghost flip.png b/library/sprite/Pac-Man POP ghost flip.png
new file mode 100644
index 0000000..3e77b88
Binary files /dev/null and b/library/sprite/Pac-Man POP ghost flip.png differ
diff --git a/library/sprite/Pac-Man POP ghost.png b/library/sprite/Pac-Man POP ghost.png
new file mode 100644
index 0000000..039a064
Binary files /dev/null and b/library/sprite/Pac-Man POP ghost.png differ
diff --git a/library/sprite/SuminoeTakako.png b/library/sprite/SuminoeTakako.png
new file mode 100644
index 0000000..cb3e8ee
Binary files /dev/null and b/library/sprite/SuminoeTakako.png differ
diff --git a/library/sprite/anime-running.gif b/library/sprite/anime-running.gif
new file mode 100644
index 0000000..4a9c3d5
Binary files /dev/null and b/library/sprite/anime-running.gif differ
diff --git a/library/sprite/anime_sitting.png b/library/sprite/anime_sitting.png
new file mode 100644
index 0000000..c33e60e
Binary files /dev/null and b/library/sprite/anime_sitting.png differ
diff --git a/library/sprite/boybluehair.png b/library/sprite/boybluehair.png
new file mode 100644
index 0000000..3fed405
Binary files /dev/null and b/library/sprite/boybluehair.png differ
diff --git a/library/sprite/boygreenhair.png b/library/sprite/boygreenhair.png
new file mode 100644
index 0000000..e70a17d
Binary files /dev/null and b/library/sprite/boygreenhair.png differ
diff --git a/library/sprite/cat.png b/library/sprite/cat.png
new file mode 100644
index 0000000..97e55a5
Binary files /dev/null and b/library/sprite/cat.png differ
diff --git a/library/sprite/cat.svg b/library/sprite/cat.svg
new file mode 100644
index 0000000..d449b3d
--- /dev/null
+++ b/library/sprite/cat.svg
@@ -0,0 +1,42 @@
+
\ No newline at end of file
diff --git a/library/sprite/cat_girl.png b/library/sprite/cat_girl.png
new file mode 100644
index 0000000..30d39a5
Binary files /dev/null and b/library/sprite/cat_girl.png differ
diff --git a/library/sprite/chibi_anime_boy_school_uniform.png b/library/sprite/chibi_anime_boy_school_uniform.png
new file mode 100644
index 0000000..60c625e
Binary files /dev/null and b/library/sprite/chibi_anime_boy_school_uniform.png differ
diff --git a/library/sprite/chibi_warlock.png b/library/sprite/chibi_warlock.png
new file mode 100644
index 0000000..3e2059c
Binary files /dev/null and b/library/sprite/chibi_warlock.png differ
diff --git a/library/sprite/costumeLibrary.html b/library/sprite/costumeLibrary.html
new file mode 100644
index 0000000..f3b2b08
--- /dev/null
+++ b/library/sprite/costumeLibrary.html
@@ -0,0 +1,216 @@
+
+
+
+ Sprite Library
+
+
+
+
+
+
+
+
X
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/sprite/die_face_1_T.png b/library/sprite/die_face_1_T.png
new file mode 100644
index 0000000..ee92a86
Binary files /dev/null and b/library/sprite/die_face_1_T.png differ
diff --git a/library/sprite/die_face_2_T.png b/library/sprite/die_face_2_T.png
new file mode 100644
index 0000000..5d09d14
Binary files /dev/null and b/library/sprite/die_face_2_T.png differ
diff --git a/library/sprite/die_face_3_T.png b/library/sprite/die_face_3_T.png
new file mode 100644
index 0000000..d7658ef
Binary files /dev/null and b/library/sprite/die_face_3_T.png differ
diff --git a/library/sprite/die_face_4_T.png b/library/sprite/die_face_4_T.png
new file mode 100644
index 0000000..16df172
Binary files /dev/null and b/library/sprite/die_face_4_T.png differ
diff --git a/library/sprite/die_face_5_T.png b/library/sprite/die_face_5_T.png
new file mode 100644
index 0000000..3040e2c
Binary files /dev/null and b/library/sprite/die_face_5_T.png differ
diff --git a/library/sprite/die_face_6_T.png b/library/sprite/die_face_6_T.png
new file mode 100644
index 0000000..4666a2e
Binary files /dev/null and b/library/sprite/die_face_6_T.png differ
diff --git a/library/sprite/formal1.png b/library/sprite/formal1.png
new file mode 100644
index 0000000..41042a8
Binary files /dev/null and b/library/sprite/formal1.png differ
diff --git a/library/sprite/formal2.png b/library/sprite/formal2.png
new file mode 100644
index 0000000..427b13c
Binary files /dev/null and b/library/sprite/formal2.png differ
diff --git a/library/sprite/formal4.png b/library/sprite/formal4.png
new file mode 100644
index 0000000..f53a353
Binary files /dev/null and b/library/sprite/formal4.png differ
diff --git a/library/sprite/formal5.png b/library/sprite/formal5.png
new file mode 100644
index 0000000..9136487
Binary files /dev/null and b/library/sprite/formal5.png differ
diff --git a/library/sprite/formal6.png b/library/sprite/formal6.png
new file mode 100644
index 0000000..e6faf17
Binary files /dev/null and b/library/sprite/formal6.png differ
diff --git a/library/sprite/formal7.png b/library/sprite/formal7.png
new file mode 100644
index 0000000..69880a5
Binary files /dev/null and b/library/sprite/formal7.png differ
diff --git a/library/sprite/index.html b/library/sprite/index.html
new file mode 100644
index 0000000..6188397
--- /dev/null
+++ b/library/sprite/index.html
@@ -0,0 +1,220 @@
+
+
+
+ Sprite Library
+
+
+
+
+
+
+Open Sprite Selector Modal
+
+
+
+
X
+
+
+
+
+
+
+
+
+ Ringo Aihara
+ Anime sitting
+ Boy blue hair
+ Boy green hair
+ Cat girl
+ Chibi anime boy
+ Chibi warlock
+ Formal 1
+ Formal 2
+ Formal 4
+ Formal 5
+ Runa Houraisen
+ Kirishima
+ Kaede Kitajima
+ Nanami Oda
+ Pacman POP 1
+ Pacman POP 2
+ Pacman POP 3
+ Pacman POP dog
+ Pacman POP ghost
+ Punk
+ Takako Suminoe
+ Amane Yuuki
+ Kaori Hanemura
+ Scratch cat
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/sprite/punk.png b/library/sprite/punk.png
new file mode 100644
index 0000000..3c25c85
Binary files /dev/null and b/library/sprite/punk.png differ
diff --git a/library/sprite/sprite.json b/library/sprite/sprite.json
new file mode 100644
index 0000000..2a450f1
--- /dev/null
+++ b/library/sprite/sprite.json
@@ -0,0 +1,257 @@
+[
+ {
+ "FILE": "AiharaRingo.png",
+ "CLASS": "All spriteActive Fantasy",
+ "NAME": "Ringo Aihara "
+ },
+ {
+ "FILE": "anime_sitting.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Anime sitting"
+ },
+ {
+ "FILE": "boybluehair.png",
+ "CLASS": "All Fantasy Walking",
+ "NAME": "Boy blue hair"
+ },
+ {
+ "FILE": "boygreenhair.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Boy green hair"
+ },
+ {
+ "FILE": "cat_girl.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Cat girl"
+ },
+ {
+ "FILE": "chibi_anime_boy_school_uniform.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Chibi anime boy"
+ },
+ {
+ "FILE": "chibi_warlock.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Chibi warlock"
+ },
+ {
+ "FILE": "formal1.png",
+ "CLASS": "All People Dress-Up",
+ "NAME": "Formal 1"
+ },
+ {
+ "FILE": "formal2.png",
+ "CLASS": "All People Dress-Up",
+ "NAME": "Formal 2"
+ },
+ {
+ "FILE": "formal4.png",
+ "CLASS": "All People Dress-Up",
+ "NAME": "Formal 4"
+ },
+ {
+ "FILE": "formal5.png",
+ "CLASS": "All People Dress-Up",
+ "NAME": "Formal 5"
+ },
+ {
+ "FILE": "formal6.png",
+ "CLASS": "All People Dress-Up",
+ "NAME": "Formal 6"
+ },
+ {
+ "FILE": "formal7.png",
+ "CLASS": "All People Dress-Up",
+ "NAME": "Formal 7"
+ },
+ {
+ "FILE": "HouraisenRuna.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Runa Houraisen"
+ },
+ {
+ "FILE": "Kirishima.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Kirishima"
+ },
+ {
+ "FILE": "KitajimaKaede.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Kaede Kitajima"
+ },
+ {
+ "FILE": "OdaNanami.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Nanami Oda"
+ },
+ {
+ "FILE": "Pac-Man POP 1.png",
+ "CLASS": "All Fantasy Things",
+ "NAME": "Pacman POP 1"
+ },
+ {
+ "FILE": "Pac-Man POP 1 flip.png",
+ "CLASS": "All Fantasy Things",
+ "NAME": "Pacman POP 1 flip"
+ },
+ {
+ "FILE": "Pac-Man POP 2.png",
+ "CLASS": "All Fantasy Things",
+ "NAME": "Pacman POP 2"
+ },
+ {
+ "FILE": "Pac-Man POP 3.png",
+ "CLASS": "All Fantasy Things",
+ "NAME": "Pacman POP 3"
+ },
+ {
+ "FILE": "Pac-Man POP dog.png",
+ "CLASS": "All Fantasy Walking Animals",
+ "NAME": "Pacman POP dog"
+ },
+ {
+ "FILE": "Pac-Man POP ghost.png",
+ "CLASS": "All Fantasy Things",
+ "NAME": "Pacman POP ghost"
+ },
+ {
+ "FILE": "Pac-Man POP ghost flip.png",
+ "CLASS": "All Fantasy Things",
+ "NAME": "Pacman POP ghost flip"
+ },
+ {
+ "FILE": "punk.png",
+ "CLASS": "All People",
+ "NAME": "Punk"
+ },
+ {
+ "FILE": "SuminoeTakako.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Takako Suminoe"
+ },
+ {
+ "FILE": "Hanahira - Amane Yuuki.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Amane Yuuki"
+ },
+ {
+ "FILE": "Hanahira - Kaori Hanemura.png",
+ "CLASS": "All Fantasy",
+ "NAME": "Kaori Hanemura"
+ },
+ {
+ "FILE": "cat.png",
+ "CLASS": "All Bitmap Fantasy Walking Animals",
+ "NAME": "Scratch cat"
+ },
+ {
+ "FILE": "die_face_1_T.png",
+ "CLASS": "All Things",
+ "NAME": "Die face red 1"
+ },
+ {
+ "FILE": "die_face_2_T.png",
+ "CLASS": "All Things",
+ "NAME": "Die face red 2"
+ },
+ {
+ "FILE": "die_face_3_T.png",
+ "CLASS": "All Things",
+ "NAME": "Die face red 3"
+ },
+ {
+ "FILE": "die_face_4_T.png",
+ "CLASS": "All Things",
+ "NAME": "Die face red 4"
+ },
+ {
+ "FILE": "die_face_5_T.png",
+ "CLASS": "All Things",
+ "NAME": "Die face red 5"
+ },
+ {
+ "FILE": "die_face_6_T.png",
+ "CLASS": "All Things",
+ "NAME": "Die face red 6"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Basket Ball 1.png",
+ "CLASS": "All Things",
+ "NAME": "Basketball"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Beach Ball 1.png",
+ "CLASS": "All Things",
+ "NAME": "Beachball"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Crab 1.gif",
+ "CLASS": "All Things Animals Fantasy Underwater",
+ "NAME": "Crab"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Mermaid 1.gif",
+ "CLASS": "All Things Fantasy Underwater",
+ "NAME": "Mermaid"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Soccer Ball 1.png",
+ "CLASS": "All Things",
+ "NAME": "Soccerball"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - Whiffle Ball 1.png",
+ "CLASS": "All Things",
+ "NAME": "Whiffleball"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - fish1.gif",
+ "CLASS": "All Things Animals Fantasy Underwater",
+ "NAME": "Fish 1"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - fish2.gif",
+ "CLASS": "All Things Animals Fantasy Underwater",
+ "NAME": "Fish 2"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - fish3.gif",
+ "CLASS": "All Things Animals Fantasy Underwater",
+ "NAME": "Fish 3"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - hermit-crab.gif",
+ "CLASS": "All Things Animals Fantasy Underwater",
+ "NAME": "Hermit crab"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - jellyfish1.gif",
+ "CLASS": "All Things Animals Fantasy Underwater",
+ "NAME": "Jellyfish"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - red-shark.gif",
+ "CLASS": "All Things Animals Fantasy Underwater",
+ "NAME": "Shark 2"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - sea-horse.gif",
+ "CLASS": "All Things Animals Fantasy Underwater",
+ "NAME": "Sea Horse"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - shark1.gif",
+ "CLASS": "All Things Animals Fantasy Underwater",
+ "NAME": "Shark 1"
+ },
+ {
+ "FILE": "anime-running.gif",
+ "CLASS": "All Fantasy People",
+ "NAME": "Girl running"
+ },
+ {
+ "FILE": "Insaniquarium Deluxe - turtle1.gif",
+ "CLASS": "All Things Animals Fantasy Underwater",
+ "NAME": "Turtle"
+ }
+]
\ No newline at end of file
diff --git a/library/sprite/sprite.txt b/library/sprite/sprite.txt
new file mode 100644
index 0000000..e1d9020
--- /dev/null
+++ b/library/sprite/sprite.txt
@@ -0,0 +1,52 @@
+FILE,CLASS,NAME
+AiharaRingo.png,All spriteActive Fantasy,Ringo Aihara
+anime_sitting.png,All Fantasy,Anime sitting
+boybluehair.png,All Fantasy Walking,Boy blue hair
+boygreenhair.png,All Fantasy,Boy green hair
+cat_girl.png,All Fantasy,Cat girl
+chibi_anime_boy_school_uniform.png,All Fantasy,Chibi anime boy
+chibi_warlock.png,All Fantasy,Chibi warlock
+formal1.png,All People Dress-Up,Formal 1
+formal2.png,All People Dress-Up,Formal 2
+formal4.png,All People Dress-Up,Formal 4
+formal5.png,All People Dress-Up,Formal 5
+formal6.png,All People Dress-Up,Formal 6
+formal7.png,All People Dress-Up,Formal 7
+HouraisenRuna.png,All Fantasy,Runa Houraisen
+Kirishima.png,All Fantasy,Kirishima
+KitajimaKaede.png,All Fantasy,Kaede Kitajima
+OdaNanami.png,All Fantasy,Nanami Oda
+Pac-Man POP 1.png,All Fantasy Things,Pacman POP 1
+Pac-Man POP 1 flip.png,All Fantasy Things,Pacman POP 1 flip
+Pac-Man POP 2.png,All Fantasy Things,Pacman POP 2
+Pac-Man POP 3.png,All Fantasy Things,Pacman POP 3
+Pac-Man POP dog.png,All Fantasy Walking Animals,Pacman POP dog
+Pac-Man POP ghost.png,All Fantasy Things,Pacman POP ghost
+Pac-Man POP ghost flip.png,All Fantasy Things,Pacman POP ghost flip
+punk.png,All People,Punk
+SuminoeTakako.png,All Fantasy,Takako Suminoe
+Hanahira - Amane Yuuki.png,All Fantasy,Amane Yuuki
+Hanahira - Kaori Hanemura.png,All Fantasy,Kaori Hanemura
+cat.png,All Bitmap Fantasy Walking Animals,Scratch cat
+die_face_1_T.png,All Things,Die face red 1
+die_face_2_T.png,All Things,Die face red 2
+die_face_3_T.png,All Things,Die face red 3
+die_face_4_T.png,All Things,Die face red 4
+die_face_5_T.png,All Things,Die face red 5
+die_face_6_T.png,All Things,Die face red 6
+Insaniquarium Deluxe - Basket Ball 1.png,All Things,Basketball
+Insaniquarium Deluxe - Beach Ball 1.png,All Things,Beachball
+Insaniquarium Deluxe - Crab 1.gif,All Things Animals Fantasy Underwater,Crab
+Insaniquarium Deluxe - Mermaid 1.gif,All Things Fantasy Underwater,Mermaid
+Insaniquarium Deluxe - Soccer Ball 1.png,All Things,Soccerball
+Insaniquarium Deluxe - Whiffle Ball 1.png,All Things,Whiffleball
+Insaniquarium Deluxe - fish1.gif,All Things Animals Fantasy Underwater,Fish 1
+Insaniquarium Deluxe - fish2.gif,All Things Animals Fantasy Underwater,Fish 2
+Insaniquarium Deluxe - fish3.gif,All Things Animals Fantasy Underwater,Fish 3
+Insaniquarium Deluxe - hermit-crab.gif,All Things Animals Fantasy Underwater,Hermit crab
+Insaniquarium Deluxe - jellyfish1.gif,All Things Animals Fantasy Underwater,Jellyfish
+Insaniquarium Deluxe - red-shark.gif,All Things Animals Fantasy Underwater,Shark 2
+Insaniquarium Deluxe - sea-horse.gif,All Things Animals Fantasy Underwater,Sea Horse
+Insaniquarium Deluxe - shark1.gif,All Things Animals Fantasy Underwater,Shark 1
+Insaniquarium Deluxe - turtle1.gif,All Things Animals Fantasy Underwater,Turtle
+anime-running.gif, All Fantasy People,Girl running
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index 4d356aa..44b5e05 100644
--- a/manifest.json
+++ b/manifest.json
@@ -4,7 +4,7 @@
"version": "0.1.0",
"app": {
"background": {
- "scripts": ["background.js"]
+ "scripts": ["lib/pixie/background.js"]
}
}
}
diff --git a/soundbank/Instr.js b/soundbank/Instr.js
new file mode 100755
index 0000000..0fb53d2
--- /dev/null
+++ b/soundbank/Instr.js
@@ -0,0 +1,108 @@
+// Copyright (C) 2013 Massachusetts Institute of Technology
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License version 2,
+// as published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+// Instr.js
+// Tim Mickel, 2013
+// Based entirely on the AS by John Maloney, April 2012
+//
+// This class interacts with IO to load Scratch instruments and drums.
+// The variable 'samples' is a dictionary of named sound buffers.
+// Call initSamples() to initialize 'samples' before using (during load).
+//
+// All instrument and drum samples were created for Scratch by:
+//
+// Paul Madden, paulmatthewmadden@yahoo.com
+//
+// Paul is an excellent sound designer and we appreciate all the effort
+// he put into this project.
+
+var Instr = function() {}
+
+Instr.samples = {};
+Instr.wavsLoaded = 0;
+
+Instr.wavs = {
+ 'AcousticGuitar_F3': 'instruments/AcousticGuitar_F3_22k.wav',
+ 'AcousticPiano_As3': 'instruments/AcousticPiano(5)_A#3_22k.wav',
+ 'AcousticPiano_C4': 'instruments/AcousticPiano(5)_C4_22k.wav',
+ 'AcousticPiano_G4': 'instruments/AcousticPiano(5)_G4_22k.wav',
+ 'AcousticPiano_F5': 'instruments/AcousticPiano(5)_F5_22k.wav',
+ 'AcousticPiano_C6': 'instruments/AcousticPiano(5)_C6_22k.wav',
+ 'AcousticPiano_Ds6': 'instruments/AcousticPiano(5)_D#6_22k.wav',
+ 'AcousticPiano_D7': 'instruments/AcousticPiano(5)_D7_22k.wav',
+ 'AltoSax_A3': 'instruments/AltoSax_A3_22K.wav',
+ 'AltoSax_C6': 'instruments/AltoSax(3)_C6_22k.wav',
+ 'Bassoon_C3': 'instruments/Bassoon_C3_22k.wav',
+ 'BassTrombone_A2_2': 'instruments/BassTrombone_A2(2)_22k.wav',
+ 'BassTrombone_A2_3': 'instruments/BassTrombone_A2(3)_22k.wav',
+ 'Cello_C2': 'instruments/Cello(3b)_C2_22k.wav',
+ 'Cello_As2': 'instruments/Cello(3)_A#2_22k.wav',
+ 'Choir_F3': 'instruments/Choir(4)_F3_22k.wav',
+ 'Choir_F4': 'instruments/Choir(4)_F4_22k.wav',
+ 'Choir_F5': 'instruments/Choir(4)_F5_22k.wav',
+ 'Clarinet_C4': 'instruments/Clarinet_C4_22k.wav',
+ 'ElectricBass_G1': 'instruments/ElectricBass(2)_G1_22k.wav',
+ 'ElectricGuitar_F3': 'instruments/ElectricGuitar(2)_F3(1)_22k.wav',
+ 'ElectricPiano_C2': 'instruments/ElectricPiano_C2_22k.wav',
+ 'ElectricPiano_C4': 'instruments/ElectricPiano_C4_22k.wav',
+ 'EnglishHorn_D4': 'instruments/EnglishHorn(1)_D4_22k.wav',
+ 'EnglishHorn_F3': 'instruments/EnglishHorn(1)_F3_22k.wav',
+ 'Flute_B5_1': 'instruments/Flute(3)_B5(1)_22k.wav',
+ 'Flute_B5_2': 'instruments/Flute(3)_B5(2)_22k.wav',
+ 'Marimba_C4': 'instruments/Marimba_C4_22k.wav',
+ 'MusicBox_C4': 'instruments/MusicBox_C4_22k.wav',
+ 'Organ_G2': 'instruments/Organ(2)_G2_22k.wav',
+ 'Pizz_A3': 'instruments/Pizz(2)_A3_22k.wav',
+ 'Pizz_E4': 'instruments/Pizz(2)_E4_22k.wav',
+ 'Pizz_G2': 'instruments/Pizz(2)_G2_22k.wav',
+ 'SteelDrum_D5': 'instruments/SteelDrum_D5_22k.wav',
+ 'SynthLead_C4': 'instruments/SynthLead(6)_C4_22k.wav',
+ 'SynthLead_C6': 'instruments/SynthLead(6)_C6_22k.wav',
+ 'SynthPad_A3': 'instruments/SynthPad(2)_A3_22k.wav',
+ 'SynthPad_C6': 'instruments/SynthPad(2)_C6_22k.wav',
+ 'TenorSax_C3': 'instruments/TenorSax(1)_C3_22k.wav',
+ 'Trombone_B3': 'instruments/Trombone_B3_22k.wav',
+ 'Trumpet_E5': 'instruments/Trumpet_E5_22k.wav',
+ 'Vibraphone_C3': 'instruments/Vibraphone_C3_22k.wav',
+ 'Violin_D4': 'instruments/Violin(2)_D4_22K.wav',
+ 'Violin_A4': 'instruments/Violin(3)_A4_22k.wav',
+ 'Violin_E5': 'instruments/Violin(3b)_E5_22k.wav',
+ 'WoodenFlute_C5': 'instruments/WoodenFlute_C5_22k.wav',
+ // Drums
+ 'BassDrum': 'drums/BassDrum(1b)_22k.wav',
+ 'Bongo': 'drums/Bongo_22k.wav',
+ 'Cabasa': 'drums/Cabasa(1)_22k.wav',
+ 'Clap': 'drums/Clap(1)_22k.wav',
+ 'Claves': 'drums/Claves(1)_22k.wav',
+ 'Conga': 'drums/Conga(1)_22k.wav',
+ 'Cowbell': 'drums/Cowbell(3)_22k.wav',
+ 'Crash': 'drums/Crash(2)_22k.wav',
+ 'Cuica': 'drums/Cuica(2)_22k.wav',
+ 'GuiroLong': 'drums/GuiroLong(1)_22k.wav',
+ 'GuiroShort': 'drums/GuiroShort(1)_22k.wav',
+ 'HiHatClosed': 'drums/HiHatClosed(1)_22k.wav',
+ 'HiHatOpen': 'drums/HiHatOpen(2)_22k.wav',
+ 'HiHatPedal': 'drums/HiHatPedal(1)_22k.wav',
+ 'Maracas': 'drums/Maracas(1)_22k.wav',
+ 'SideStick': 'drums/SideStick(1)_22k.wav',
+ 'SnareDrum': 'drums/SnareDrum(1)_22k.wav',
+ 'Tambourine': 'drums/Tambourine(3)_22k.wav',
+ 'Tom': 'drums/Tom(1)_22k.wav',
+ 'Triangle': 'drums/Triangle(1)_22k.wav',
+ 'Vibraslap': 'drums/Vibraslap(1)_22k.wav',
+ 'WoodBlock': 'drums/WoodBlock(1)_22k.wav'
+};
+
+Instr.wavCount = Object.keys(Instr.wavs).length;
diff --git a/soundbank/drums/BassDrum(1b)_22k.wav b/soundbank/drums/BassDrum(1b)_22k.wav
new file mode 100755
index 0000000..e63dbaf
Binary files /dev/null and b/soundbank/drums/BassDrum(1b)_22k.wav differ
diff --git a/soundbank/drums/Bongo_22k.wav b/soundbank/drums/Bongo_22k.wav
new file mode 100755
index 0000000..da620cf
Binary files /dev/null and b/soundbank/drums/Bongo_22k.wav differ
diff --git a/soundbank/drums/Cabasa(1)_22k.wav b/soundbank/drums/Cabasa(1)_22k.wav
new file mode 100755
index 0000000..733c8d7
Binary files /dev/null and b/soundbank/drums/Cabasa(1)_22k.wav differ
diff --git a/soundbank/drums/Clap(1)_22k.wav b/soundbank/drums/Clap(1)_22k.wav
new file mode 100755
index 0000000..88e3225
Binary files /dev/null and b/soundbank/drums/Clap(1)_22k.wav differ
diff --git a/soundbank/drums/Claves(1)_22k.wav b/soundbank/drums/Claves(1)_22k.wav
new file mode 100755
index 0000000..d197522
Binary files /dev/null and b/soundbank/drums/Claves(1)_22k.wav differ
diff --git a/soundbank/drums/Conga(1)_22k.wav b/soundbank/drums/Conga(1)_22k.wav
new file mode 100755
index 0000000..8dec6aa
Binary files /dev/null and b/soundbank/drums/Conga(1)_22k.wav differ
diff --git a/soundbank/drums/Cowbell(3)_22k.wav b/soundbank/drums/Cowbell(3)_22k.wav
new file mode 100755
index 0000000..f155936
Binary files /dev/null and b/soundbank/drums/Cowbell(3)_22k.wav differ
diff --git a/soundbank/drums/Crash(2)_22k.wav b/soundbank/drums/Crash(2)_22k.wav
new file mode 100755
index 0000000..bb37cd1
Binary files /dev/null and b/soundbank/drums/Crash(2)_22k.wav differ
diff --git a/soundbank/drums/Cuica(2)_22k.wav b/soundbank/drums/Cuica(2)_22k.wav
new file mode 100755
index 0000000..f1fdbb3
Binary files /dev/null and b/soundbank/drums/Cuica(2)_22k.wav differ
diff --git a/soundbank/drums/GuiroLong(1)_22k.wav b/soundbank/drums/GuiroLong(1)_22k.wav
new file mode 100755
index 0000000..e2aa462
Binary files /dev/null and b/soundbank/drums/GuiroLong(1)_22k.wav differ
diff --git a/soundbank/drums/GuiroShort(1)_22k.wav b/soundbank/drums/GuiroShort(1)_22k.wav
new file mode 100755
index 0000000..af1d3f5
Binary files /dev/null and b/soundbank/drums/GuiroShort(1)_22k.wav differ
diff --git a/soundbank/drums/HiHatClosed(1)_22k.wav b/soundbank/drums/HiHatClosed(1)_22k.wav
new file mode 100755
index 0000000..6bc43f1
Binary files /dev/null and b/soundbank/drums/HiHatClosed(1)_22k.wav differ
diff --git a/soundbank/drums/HiHatOpen(2)_22k.wav b/soundbank/drums/HiHatOpen(2)_22k.wav
new file mode 100755
index 0000000..2a46431
Binary files /dev/null and b/soundbank/drums/HiHatOpen(2)_22k.wav differ
diff --git a/soundbank/drums/HiHatPedal(1)_22k.wav b/soundbank/drums/HiHatPedal(1)_22k.wav
new file mode 100755
index 0000000..adf76d5
Binary files /dev/null and b/soundbank/drums/HiHatPedal(1)_22k.wav differ
diff --git a/soundbank/drums/Maracas(1)_22k.wav b/soundbank/drums/Maracas(1)_22k.wav
new file mode 100755
index 0000000..7b5f067
Binary files /dev/null and b/soundbank/drums/Maracas(1)_22k.wav differ
diff --git a/soundbank/drums/SideStick(1)_22k.wav b/soundbank/drums/SideStick(1)_22k.wav
new file mode 100755
index 0000000..38c2ead
Binary files /dev/null and b/soundbank/drums/SideStick(1)_22k.wav differ
diff --git a/soundbank/drums/SnareDrum(1)_22k.wav b/soundbank/drums/SnareDrum(1)_22k.wav
new file mode 100755
index 0000000..42f7ebb
Binary files /dev/null and b/soundbank/drums/SnareDrum(1)_22k.wav differ
diff --git a/soundbank/drums/Tambourine(3)_22k.wav b/soundbank/drums/Tambourine(3)_22k.wav
new file mode 100755
index 0000000..d6c93f4
Binary files /dev/null and b/soundbank/drums/Tambourine(3)_22k.wav differ
diff --git a/soundbank/drums/Tom(1)_22k.wav b/soundbank/drums/Tom(1)_22k.wav
new file mode 100755
index 0000000..39c4c52
Binary files /dev/null and b/soundbank/drums/Tom(1)_22k.wav differ
diff --git a/soundbank/drums/Triangle(1)_22k.wav b/soundbank/drums/Triangle(1)_22k.wav
new file mode 100755
index 0000000..7cca61c
Binary files /dev/null and b/soundbank/drums/Triangle(1)_22k.wav differ
diff --git a/soundbank/drums/Vibraslap(1)_22k.wav b/soundbank/drums/Vibraslap(1)_22k.wav
new file mode 100755
index 0000000..1b9ddfd
Binary files /dev/null and b/soundbank/drums/Vibraslap(1)_22k.wav differ
diff --git a/soundbank/drums/WoodBlock(1)_22k.wav b/soundbank/drums/WoodBlock(1)_22k.wav
new file mode 100755
index 0000000..a287e21
Binary files /dev/null and b/soundbank/drums/WoodBlock(1)_22k.wav differ
diff --git a/soundbank/instruments/AcousticGuitar_F3_22k.wav b/soundbank/instruments/AcousticGuitar_F3_22k.wav
new file mode 100755
index 0000000..ff614da
Binary files /dev/null and b/soundbank/instruments/AcousticGuitar_F3_22k.wav differ
diff --git a/soundbank/instruments/AcousticPiano(5)_A#3_22k.wav b/soundbank/instruments/AcousticPiano(5)_A#3_22k.wav
new file mode 100755
index 0000000..ca72f85
Binary files /dev/null and b/soundbank/instruments/AcousticPiano(5)_A#3_22k.wav differ
diff --git a/soundbank/instruments/AcousticPiano(5)_C4_22k.wav b/soundbank/instruments/AcousticPiano(5)_C4_22k.wav
new file mode 100755
index 0000000..5a6d0ab
Binary files /dev/null and b/soundbank/instruments/AcousticPiano(5)_C4_22k.wav differ
diff --git a/soundbank/instruments/AcousticPiano(5)_C6_22k.wav b/soundbank/instruments/AcousticPiano(5)_C6_22k.wav
new file mode 100755
index 0000000..5398720
Binary files /dev/null and b/soundbank/instruments/AcousticPiano(5)_C6_22k.wav differ
diff --git a/soundbank/instruments/AcousticPiano(5)_D#6_22k.wav b/soundbank/instruments/AcousticPiano(5)_D#6_22k.wav
new file mode 100755
index 0000000..203311a
Binary files /dev/null and b/soundbank/instruments/AcousticPiano(5)_D#6_22k.wav differ
diff --git a/soundbank/instruments/AcousticPiano(5)_D7_22k.wav b/soundbank/instruments/AcousticPiano(5)_D7_22k.wav
new file mode 100755
index 0000000..0d85198
Binary files /dev/null and b/soundbank/instruments/AcousticPiano(5)_D7_22k.wav differ
diff --git a/soundbank/instruments/AcousticPiano(5)_F5_22k.wav b/soundbank/instruments/AcousticPiano(5)_F5_22k.wav
new file mode 100755
index 0000000..8e878b9
Binary files /dev/null and b/soundbank/instruments/AcousticPiano(5)_F5_22k.wav differ
diff --git a/soundbank/instruments/AcousticPiano(5)_G4_22k.wav b/soundbank/instruments/AcousticPiano(5)_G4_22k.wav
new file mode 100755
index 0000000..338173d
Binary files /dev/null and b/soundbank/instruments/AcousticPiano(5)_G4_22k.wav differ
diff --git a/soundbank/instruments/AltoSax(3)_C6_22k.wav b/soundbank/instruments/AltoSax(3)_C6_22k.wav
new file mode 100755
index 0000000..4f9da2b
Binary files /dev/null and b/soundbank/instruments/AltoSax(3)_C6_22k.wav differ
diff --git a/soundbank/instruments/AltoSax_A3_22K.wav b/soundbank/instruments/AltoSax_A3_22K.wav
new file mode 100755
index 0000000..80fbb00
Binary files /dev/null and b/soundbank/instruments/AltoSax_A3_22K.wav differ
diff --git a/soundbank/instruments/BassTrombone_A2(2)_22k.wav b/soundbank/instruments/BassTrombone_A2(2)_22k.wav
new file mode 100755
index 0000000..5ec8ce1
Binary files /dev/null and b/soundbank/instruments/BassTrombone_A2(2)_22k.wav differ
diff --git a/soundbank/instruments/BassTrombone_A2(3)_22k.wav b/soundbank/instruments/BassTrombone_A2(3)_22k.wav
new file mode 100755
index 0000000..d2d0537
Binary files /dev/null and b/soundbank/instruments/BassTrombone_A2(3)_22k.wav differ
diff --git a/soundbank/instruments/Bassoon_C3_22k.wav b/soundbank/instruments/Bassoon_C3_22k.wav
new file mode 100755
index 0000000..543c546
Binary files /dev/null and b/soundbank/instruments/Bassoon_C3_22k.wav differ
diff --git a/soundbank/instruments/Cello(3)_A#2_22k.wav b/soundbank/instruments/Cello(3)_A#2_22k.wav
new file mode 100755
index 0000000..45737fe
Binary files /dev/null and b/soundbank/instruments/Cello(3)_A#2_22k.wav differ
diff --git a/soundbank/instruments/Cello(3b)_C2_22k.wav b/soundbank/instruments/Cello(3b)_C2_22k.wav
new file mode 100755
index 0000000..56a88bb
Binary files /dev/null and b/soundbank/instruments/Cello(3b)_C2_22k.wav differ
diff --git a/soundbank/instruments/Choir(4)_F3_22k.wav b/soundbank/instruments/Choir(4)_F3_22k.wav
new file mode 100755
index 0000000..022e492
Binary files /dev/null and b/soundbank/instruments/Choir(4)_F3_22k.wav differ
diff --git a/soundbank/instruments/Choir(4)_F4_22k.wav b/soundbank/instruments/Choir(4)_F4_22k.wav
new file mode 100755
index 0000000..70b71fa
Binary files /dev/null and b/soundbank/instruments/Choir(4)_F4_22k.wav differ
diff --git a/soundbank/instruments/Choir(4)_F5_22k.wav b/soundbank/instruments/Choir(4)_F5_22k.wav
new file mode 100755
index 0000000..7fe4f2d
Binary files /dev/null and b/soundbank/instruments/Choir(4)_F5_22k.wav differ
diff --git a/soundbank/instruments/Clarinet_C4_22k.wav b/soundbank/instruments/Clarinet_C4_22k.wav
new file mode 100755
index 0000000..d43371c
Binary files /dev/null and b/soundbank/instruments/Clarinet_C4_22k.wav differ
diff --git a/soundbank/instruments/ElectricBass(2)_G1_22k.wav b/soundbank/instruments/ElectricBass(2)_G1_22k.wav
new file mode 100755
index 0000000..af53685
Binary files /dev/null and b/soundbank/instruments/ElectricBass(2)_G1_22k.wav differ
diff --git a/soundbank/instruments/ElectricGuitar(2)_F3(1)_22k.wav b/soundbank/instruments/ElectricGuitar(2)_F3(1)_22k.wav
new file mode 100755
index 0000000..272b230
Binary files /dev/null and b/soundbank/instruments/ElectricGuitar(2)_F3(1)_22k.wav differ
diff --git a/soundbank/instruments/ElectricPiano_C2_22k.wav b/soundbank/instruments/ElectricPiano_C2_22k.wav
new file mode 100755
index 0000000..928899f
Binary files /dev/null and b/soundbank/instruments/ElectricPiano_C2_22k.wav differ
diff --git a/soundbank/instruments/ElectricPiano_C4_22k.wav b/soundbank/instruments/ElectricPiano_C4_22k.wav
new file mode 100755
index 0000000..476d52b
Binary files /dev/null and b/soundbank/instruments/ElectricPiano_C4_22k.wav differ
diff --git a/soundbank/instruments/EnglishHorn(1)_D4_22k.wav b/soundbank/instruments/EnglishHorn(1)_D4_22k.wav
new file mode 100755
index 0000000..99aaff7
Binary files /dev/null and b/soundbank/instruments/EnglishHorn(1)_D4_22k.wav differ
diff --git a/soundbank/instruments/EnglishHorn(1)_F3_22k.wav b/soundbank/instruments/EnglishHorn(1)_F3_22k.wav
new file mode 100755
index 0000000..8c789ea
Binary files /dev/null and b/soundbank/instruments/EnglishHorn(1)_F3_22k.wav differ
diff --git a/soundbank/instruments/Flute(3)_B5(1)_22k.wav b/soundbank/instruments/Flute(3)_B5(1)_22k.wav
new file mode 100755
index 0000000..2a45622
Binary files /dev/null and b/soundbank/instruments/Flute(3)_B5(1)_22k.wav differ
diff --git a/soundbank/instruments/Flute(3)_B5(2)_22k.wav b/soundbank/instruments/Flute(3)_B5(2)_22k.wav
new file mode 100755
index 0000000..e1089a9
Binary files /dev/null and b/soundbank/instruments/Flute(3)_B5(2)_22k.wav differ
diff --git a/soundbank/instruments/Marimba_C4_22k.wav b/soundbank/instruments/Marimba_C4_22k.wav
new file mode 100755
index 0000000..b60d3ee
Binary files /dev/null and b/soundbank/instruments/Marimba_C4_22k.wav differ
diff --git a/soundbank/instruments/MusicBox_C4_22k.wav b/soundbank/instruments/MusicBox_C4_22k.wav
new file mode 100755
index 0000000..ff04d2e
Binary files /dev/null and b/soundbank/instruments/MusicBox_C4_22k.wav differ
diff --git a/soundbank/instruments/Organ(2)_G2_22k.wav b/soundbank/instruments/Organ(2)_G2_22k.wav
new file mode 100755
index 0000000..a5be8eb
Binary files /dev/null and b/soundbank/instruments/Organ(2)_G2_22k.wav differ
diff --git a/soundbank/instruments/Pizz(2)_A3_22k.wav b/soundbank/instruments/Pizz(2)_A3_22k.wav
new file mode 100755
index 0000000..b696d71
Binary files /dev/null and b/soundbank/instruments/Pizz(2)_A3_22k.wav differ
diff --git a/soundbank/instruments/Pizz(2)_E4_22k.wav b/soundbank/instruments/Pizz(2)_E4_22k.wav
new file mode 100755
index 0000000..0b1e618
Binary files /dev/null and b/soundbank/instruments/Pizz(2)_E4_22k.wav differ
diff --git a/soundbank/instruments/Pizz(2)_G2_22k.wav b/soundbank/instruments/Pizz(2)_G2_22k.wav
new file mode 100755
index 0000000..f885cf8
Binary files /dev/null and b/soundbank/instruments/Pizz(2)_G2_22k.wav differ
diff --git a/soundbank/instruments/SteelDrum_D5_22k.wav b/soundbank/instruments/SteelDrum_D5_22k.wav
new file mode 100755
index 0000000..1488993
Binary files /dev/null and b/soundbank/instruments/SteelDrum_D5_22k.wav differ
diff --git a/soundbank/instruments/SynthLead(6)_C4_22k.wav b/soundbank/instruments/SynthLead(6)_C4_22k.wav
new file mode 100755
index 0000000..962a4b9
Binary files /dev/null and b/soundbank/instruments/SynthLead(6)_C4_22k.wav differ
diff --git a/soundbank/instruments/SynthLead(6)_C6_22k.wav b/soundbank/instruments/SynthLead(6)_C6_22k.wav
new file mode 100755
index 0000000..eaf72eb
Binary files /dev/null and b/soundbank/instruments/SynthLead(6)_C6_22k.wav differ
diff --git a/soundbank/instruments/SynthPad(2)_A3_22k.wav b/soundbank/instruments/SynthPad(2)_A3_22k.wav
new file mode 100755
index 0000000..28eb0ed
Binary files /dev/null and b/soundbank/instruments/SynthPad(2)_A3_22k.wav differ
diff --git a/soundbank/instruments/SynthPad(2)_C6_22k.wav b/soundbank/instruments/SynthPad(2)_C6_22k.wav
new file mode 100755
index 0000000..ca3cf18
Binary files /dev/null and b/soundbank/instruments/SynthPad(2)_C6_22k.wav differ
diff --git a/soundbank/instruments/TenorSax(1)_C3_22k.wav b/soundbank/instruments/TenorSax(1)_C3_22k.wav
new file mode 100755
index 0000000..e87c807
Binary files /dev/null and b/soundbank/instruments/TenorSax(1)_C3_22k.wav differ
diff --git a/soundbank/instruments/Trombone_B3_22k.wav b/soundbank/instruments/Trombone_B3_22k.wav
new file mode 100755
index 0000000..6d7c84a
Binary files /dev/null and b/soundbank/instruments/Trombone_B3_22k.wav differ
diff --git a/soundbank/instruments/Trumpet_E5_22k.wav b/soundbank/instruments/Trumpet_E5_22k.wav
new file mode 100755
index 0000000..f9bf603
Binary files /dev/null and b/soundbank/instruments/Trumpet_E5_22k.wav differ
diff --git a/soundbank/instruments/Vibraphone_C3_22k.wav b/soundbank/instruments/Vibraphone_C3_22k.wav
new file mode 100755
index 0000000..e38fa03
Binary files /dev/null and b/soundbank/instruments/Vibraphone_C3_22k.wav differ
diff --git a/soundbank/instruments/Violin(2)_D4_22K.wav b/soundbank/instruments/Violin(2)_D4_22K.wav
new file mode 100755
index 0000000..372cbe7
Binary files /dev/null and b/soundbank/instruments/Violin(2)_D4_22K.wav differ
diff --git a/soundbank/instruments/Violin(3)_A4_22k.wav b/soundbank/instruments/Violin(3)_A4_22k.wav
new file mode 100755
index 0000000..05b1029
Binary files /dev/null and b/soundbank/instruments/Violin(3)_A4_22k.wav differ
diff --git a/soundbank/instruments/Violin(3b)_E5_22k.wav b/soundbank/instruments/Violin(3b)_E5_22k.wav
new file mode 100755
index 0000000..cca94c5
Binary files /dev/null and b/soundbank/instruments/Violin(3b)_E5_22k.wav differ
diff --git a/soundbank/instruments/WoodenFlute_C5_22k.wav b/soundbank/instruments/WoodenFlute_C5_22k.wav
new file mode 100755
index 0000000..d21687b
Binary files /dev/null and b/soundbank/instruments/WoodenFlute_C5_22k.wav differ
diff --git a/vendor/libgif.js b/vendor/libgif.js
new file mode 100755
index 0000000..ac55e55
--- /dev/null
+++ b/vendor/libgif.js
@@ -0,0 +1,993 @@
+/*
+ SuperGif
+
+ Example usage:
+
+
+
+
+
+ Image tag attributes:
+
+ rel:animated_src - If this url is specified, it's loaded into the player instead of src.
+ This allows a preview frame to be shown until animated gif data is streamed into the canvas
+
+ rel:auto_play - Defaults to 1 if not specified. If set to zero, a call to the play() method is needed
+
+ Constructor options args
+
+ gif Required. The DOM element of an img tag.
+ loop_mode Optional. Setting this to false will force disable looping of the gif.
+ auto_play Optional. Same as the rel:auto_play attribute above, this arg overrides the img tag info.
+ max_width Optional. Scale images over max_width down to max_width. Helpful with mobile.
+ on_end Optional. Add a callback for when the gif reaches the end of a single loop (one iteration). The first argument passed will be the gif HTMLElement.
+ loop_delay Optional. The amount of time to pause (in ms) after each single loop (iteration).
+ draw_while_loading Optional. Determines whether the gif will be drawn to the canvas whilst it is loaded.
+ show_progress_bar Optional. Only applies when draw_while_loading is set to true.
+
+ Instance methods
+
+ // loading
+ load( callback ) Loads the gif specified by the src or rel:animated_src sttributie of the img tag into a canvas element and then calls callback if one is passed
+ load_url( src, callback ) Loads the gif file specified in the src argument into a canvas element and then calls callback if one is passed
+
+ // play controls
+ play - Start playing the gif
+ pause - Stop playing the gif
+ move_to(i) - Move to frame i of the gif
+ move_relative(i) - Move i frames ahead (or behind if i < 0)
+
+ // getters
+ get_canvas The canvas element that the gif is playing in. Handy for assigning event handlers to.
+ get_playing Whether or not the gif is currently playing
+ get_loading Whether or not the gif has finished loading/parsing
+ get_auto_play Whether or not the gif is set to play automatically
+ get_length The number of frames in the gif
+ get_current_frame The index of the currently displayed frame of the gif
+
+ For additional customization (viewport inside iframe) these params may be passed:
+ c_w, c_h - width and height of canvas
+ vp_t, vp_l, vp_ w, vp_h - top, left, width and height of the viewport
+
+ A bonus: few articles to understand what is going on
+ http://enthusiasms.org/post/16976438906
+ http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp
+ http://humpy77.deviantart.com/journal/Frame-Delay-Times-for-Animated-GIFs-214150546
+
+*/
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define([], factory);
+ } else if (typeof exports === 'object') {
+ module.exports = factory();
+ } else {
+ root.SuperGif = factory();
+ }
+}(this, function () {
+ // Generic functions
+ var bitsToNum = function (ba) {
+ return ba.reduce(function (s, n) {
+ return s * 2 + n;
+ }, 0);
+ };
+
+ var byteToBitArr = function (bite) {
+ var a = [];
+ for (var i = 7; i >= 0; i--) {
+ a.push( !! (bite & (1 << i)));
+ }
+ return a;
+ };
+
+ // Stream
+ /**
+ * @constructor
+ */
+ // Make compiler happy.
+ var Stream = function (data) {
+ this.data = data;
+ this.len = this.data.length;
+ this.pos = 0;
+
+ this.readByte = function () {
+ if (this.pos >= this.data.length) {
+ throw new Error('Attempted to read past end of stream.');
+ }
+ if (data instanceof Uint8Array)
+ return data[this.pos++];
+ else
+ return data.charCodeAt(this.pos++) & 0xFF;
+ };
+
+ this.readBytes = function (n) {
+ var bytes = [];
+ for (var i = 0; i < n; i++) {
+ bytes.push(this.readByte());
+ }
+ return bytes;
+ };
+
+ this.read = function (n) {
+ var s = '';
+ for (var i = 0; i < n; i++) {
+ s += String.fromCharCode(this.readByte());
+ }
+ return s;
+ };
+
+ this.readUnsigned = function () { // Little-endian.
+ var a = this.readBytes(2);
+ return (a[1] << 8) + a[0];
+ };
+ };
+
+ var lzwDecode = function (minCodeSize, data) {
+ // TODO: Now that the GIF parser is a bit different, maybe this should get an array of bytes instead of a String?
+ var pos = 0; // Maybe this streaming thing should be merged with the Stream?
+ var readCode = function (size) {
+ var code = 0;
+ for (var i = 0; i < size; i++) {
+ if (data.charCodeAt(pos >> 3) & (1 << (pos & 7))) {
+ code |= 1 << i;
+ }
+ pos++;
+ }
+ return code;
+ };
+
+ var output = [];
+
+ var clearCode = 1 << minCodeSize;
+ var eoiCode = clearCode + 1;
+
+ var codeSize = minCodeSize + 1;
+
+ var dict = [];
+
+ var clear = function () {
+ dict = [];
+ codeSize = minCodeSize + 1;
+ for (var i = 0; i < clearCode; i++) {
+ dict[i] = [i];
+ }
+ dict[clearCode] = [];
+ dict[eoiCode] = null;
+
+ };
+
+ var code;
+ var last;
+
+ while (true) {
+ last = code;
+ code = readCode(codeSize);
+
+ if (code === clearCode) {
+ clear();
+ continue;
+ }
+ if (code === eoiCode) break;
+
+ if (code < dict.length) {
+ if (last !== clearCode) {
+ dict.push(dict[last].concat(dict[code][0]));
+ }
+ }
+ else {
+ if (code !== dict.length) throw new Error('Invalid LZW code.');
+ dict.push(dict[last].concat(dict[last][0]));
+ }
+ output.push.apply(output, dict[code]);
+
+ if (dict.length === (1 << codeSize) && codeSize < 12) {
+ // If we're at the last code and codeSize is 12, the next code will be a clearCode, and it'll be 12 bits long.
+ codeSize++;
+ }
+ }
+
+ // I don't know if this is technically an error, but some GIFs do it.
+ //if (Math.ceil(pos / 8) !== data.length) throw new Error('Extraneous LZW bytes.');
+ return output;
+ };
+
+
+ // The actual parsing; returns an object with properties.
+ var parseGIF = function (st, handler) {
+ handler || (handler = {});
+
+ // LZW (GIF-specific)
+ var parseCT = function (entries) { // Each entry is 3 bytes, for RGB.
+ var ct = [];
+ for (var i = 0; i < entries; i++) {
+ ct.push(st.readBytes(3));
+ }
+ return ct;
+ };
+
+ var readSubBlocks = function () {
+ var size, data;
+ data = '';
+ do {
+ size = st.readByte();
+ data += st.read(size);
+ } while (size !== 0);
+ return data;
+ };
+
+ var parseHeader = function () {
+ var hdr = {};
+ hdr.sig = st.read(3);
+ hdr.ver = st.read(3);
+ if (hdr.sig !== 'GIF') throw new Error('Not a GIF file.'); // XXX: This should probably be handled more nicely.
+ hdr.width = st.readUnsigned();
+ hdr.height = st.readUnsigned();
+
+ var bits = byteToBitArr(st.readByte());
+ hdr.gctFlag = bits.shift();
+ hdr.colorRes = bitsToNum(bits.splice(0, 3));
+ hdr.sorted = bits.shift();
+ hdr.gctSize = bitsToNum(bits.splice(0, 3));
+
+ hdr.bgColor = st.readByte();
+ hdr.pixelAspectRatio = st.readByte(); // if not 0, aspectRatio = (pixelAspectRatio + 15) / 64
+ if (hdr.gctFlag) {
+ hdr.gct = parseCT(1 << (hdr.gctSize + 1));
+ }
+ handler.hdr && handler.hdr(hdr);
+ };
+
+ var parseExt = function (block) {
+ var parseGCExt = function (block) {
+ var blockSize = st.readByte(); // Always 4
+ var bits = byteToBitArr(st.readByte());
+ block.reserved = bits.splice(0, 3); // Reserved; should be 000.
+ block.disposalMethod = bitsToNum(bits.splice(0, 3));
+ block.userInput = bits.shift();
+ block.transparencyGiven = bits.shift();
+
+ block.delayTime = st.readUnsigned();
+
+ block.transparencyIndex = st.readByte();
+
+ block.terminator = st.readByte();
+
+ handler.gce && handler.gce(block);
+ };
+
+ var parseComExt = function (block) {
+ block.comment = readSubBlocks();
+ handler.com && handler.com(block);
+ };
+
+ var parsePTExt = function (block) {
+ // No one *ever* uses this. If you use it, deal with parsing it yourself.
+ var blockSize = st.readByte(); // Always 12
+ block.ptHeader = st.readBytes(12);
+ block.ptData = readSubBlocks();
+ handler.pte && handler.pte(block);
+ };
+
+ var parseAppExt = function (block) {
+ var parseNetscapeExt = function (block) {
+ var blockSize = st.readByte(); // Always 3
+ block.unknown = st.readByte(); // ??? Always 1? What is this?
+ block.iterations = st.readUnsigned();
+ block.terminator = st.readByte();
+ handler.app && handler.app.NETSCAPE && handler.app.NETSCAPE(block);
+ };
+
+ var parseUnknownAppExt = function (block) {
+ block.appData = readSubBlocks();
+ // FIXME: This won't work if a handler wants to match on any identifier.
+ handler.app && handler.app[block.identifier] && handler.app[block.identifier](block);
+ };
+
+ var blockSize = st.readByte(); // Always 11
+ block.identifier = st.read(8);
+ block.authCode = st.read(3);
+ switch (block.identifier) {
+ case 'NETSCAPE':
+ parseNetscapeExt(block);
+ break;
+ default:
+ parseUnknownAppExt(block);
+ break;
+ }
+ };
+
+ var parseUnknownExt = function (block) {
+ block.data = readSubBlocks();
+ handler.unknown && handler.unknown(block);
+ };
+
+ block.label = st.readByte();
+ switch (block.label) {
+ case 0xF9:
+ block.extType = 'gce';
+ parseGCExt(block);
+ break;
+ case 0xFE:
+ block.extType = 'com';
+ parseComExt(block);
+ break;
+ case 0x01:
+ block.extType = 'pte';
+ parsePTExt(block);
+ break;
+ case 0xFF:
+ block.extType = 'app';
+ parseAppExt(block);
+ break;
+ default:
+ block.extType = 'unknown';
+ parseUnknownExt(block);
+ break;
+ }
+ };
+
+ var parseImg = function (img) {
+ var deinterlace = function (pixels, width) {
+ // Of course this defeats the purpose of interlacing. And it's *probably*
+ // the least efficient way it's ever been implemented. But nevertheless...
+ var newPixels = new Array(pixels.length);
+ var rows = pixels.length / width;
+ var cpRow = function (toRow, fromRow) {
+ var fromPixels = pixels.slice(fromRow * width, (fromRow + 1) * width);
+ newPixels.splice.apply(newPixels, [toRow * width, width].concat(fromPixels));
+ };
+
+ // See appendix E.
+ var offsets = [0, 4, 2, 1];
+ var steps = [8, 8, 4, 2];
+
+ var fromRow = 0;
+ for (var pass = 0; pass < 4; pass++) {
+ for (var toRow = offsets[pass]; toRow < rows; toRow += steps[pass]) {
+ cpRow(toRow, fromRow)
+ fromRow++;
+ }
+ }
+
+ return newPixels;
+ };
+
+ img.leftPos = st.readUnsigned();
+ img.topPos = st.readUnsigned();
+ img.width = st.readUnsigned();
+ img.height = st.readUnsigned();
+
+ var bits = byteToBitArr(st.readByte());
+ img.lctFlag = bits.shift();
+ img.interlaced = bits.shift();
+ img.sorted = bits.shift();
+ img.reserved = bits.splice(0, 2);
+ img.lctSize = bitsToNum(bits.splice(0, 3));
+
+ if (img.lctFlag) {
+ img.lct = parseCT(1 << (img.lctSize + 1));
+ }
+
+ img.lzwMinCodeSize = st.readByte();
+
+ var lzwData = readSubBlocks();
+
+ img.pixels = lzwDecode(img.lzwMinCodeSize, lzwData);
+
+ if (img.interlaced) { // Move
+ img.pixels = deinterlace(img.pixels, img.width);
+ }
+
+ handler.img && handler.img(img);
+ };
+
+ var parseBlock = function () {
+ var block = {};
+ block.sentinel = st.readByte();
+
+ switch (String.fromCharCode(block.sentinel)) { // For ease of matching
+ case '!':
+ block.type = 'ext';
+ parseExt(block);
+ break;
+ case ',':
+ block.type = 'img';
+ parseImg(block);
+ break;
+ case ';':
+ block.type = 'eof';
+ handler.eof && handler.eof(block);
+ break;
+ default:
+ throw new Error('Unknown block: 0x' + block.sentinel.toString(16)); // TODO: Pad this with a 0.
+ }
+
+ if (block.type !== 'eof') setTimeout(parseBlock, 0);
+ };
+
+ var parse = function () {
+ parseHeader();
+ setTimeout(parseBlock, 0);
+ };
+
+ parse();
+ };
+
+ var SuperGif = function ( opts ) {
+ var options = {
+ //viewport position
+ vp_l: 0,
+ vp_t: 0,
+ vp_w: null,
+ vp_h: null,
+ //canvas sizes
+ c_w: null,
+ c_h: null
+ };
+ for (var i in opts ) { options[i] = opts[i] }
+ if (options.vp_w && options.vp_h) options.is_vp = true;
+
+ var stream;
+ var hdr;
+
+ var loadError = null;
+ var loading = false;
+
+ var transparency = null;
+ var delay = null;
+ var disposalMethod = null;
+ var disposalRestoreFromIdx = null;
+ var lastDisposalMethod = null;
+ var frame = null;
+ var lastImg = null;
+
+ var playing = true;
+ var forward = true;
+
+ var ctx_scaled = false;
+
+ var frames = [];
+ var frameOffsets = []; // elements have .x and .y properties
+
+ var gif = options.gif;
+ if (typeof options.auto_play == 'undefined')
+ options.auto_play = (!gif.getAttribute('rel:auto_play') || gif.getAttribute('rel:auto_play') == '1');
+
+ var onEndListener = (options.hasOwnProperty('on_end') ? options.on_end : null);
+ var loopDelay = (options.hasOwnProperty('loop_delay') ? options.loop_delay : 0);
+ var overrideLoopMode = (options.hasOwnProperty('loop_mode') ? options.loop_mode : 'auto');
+ var drawWhileLoading = (options.hasOwnProperty('draw_while_loading') ? options.draw_while_loading : true);
+ var showProgressBar = drawWhileLoading ? (options.hasOwnProperty('show_progress_bar') ? options.show_progress_bar : true) : false;
+ var progressBarHeight = (options.hasOwnProperty('progressbar_height') ? options.progressbar_height : 25);
+ var progressBarBackgroundColor = (options.hasOwnProperty('progressbar_background_color') ? options.progressbar_background_color : 'rgba(255,255,255,0.4)');
+ var progressBarForegroundColor = (options.hasOwnProperty('progressbar_foreground_color') ? options.progressbar_foreground_color : 'rgba(255,0,22,.8)');
+
+ var clear = function () {
+ transparency = null;
+ delay = null;
+ lastDisposalMethod = disposalMethod;
+ disposalMethod = null;
+ frame = null;
+ };
+
+ // XXX: There's probably a better way to handle catching exceptions when
+ // callbacks are involved.
+ var doParse = function () {
+ try {
+ parseGIF(stream, handler);
+ }
+ catch (err) {
+ doLoadError('parse');
+ }
+ };
+
+ var doText = function (text) {
+ toolbar.innerHTML = text; // innerText? Escaping? Whatever.
+ toolbar.style.visibility = 'visible';
+ };
+
+ var setSizes = function(w, h) {
+ canvas.width = w * get_canvas_scale();
+ canvas.height = h * get_canvas_scale();
+ toolbar.style.minWidth = ( w * get_canvas_scale() ) + 'px';
+
+ tmpCanvas.width = w;
+ tmpCanvas.height = h;
+ tmpCanvas.style.width = w + 'px';
+ tmpCanvas.style.height = h + 'px';
+ tmpCanvas.getContext('2d').setTransform(1, 0, 0, 1, 0, 0);
+ };
+
+ var setFrameOffset = function(frame, offset) {
+ if (!frameOffsets[frame]) {
+ frameOffsets[frame] = offset;
+ return;
+ }
+ if (typeof offset.x !== 'undefined') {
+ frameOffsets[frame].x = offset.x;
+ }
+ if (typeof offset.y !== 'undefined') {
+ frameOffsets[frame].y = offset.y;
+ }
+ };
+
+ var doShowProgress = function (pos, length, draw) {
+ if (draw && showProgressBar) {
+ var height = progressBarHeight;
+ var left, mid, top, width;
+ if (options.is_vp) {
+ if (!ctx_scaled) {
+ top = (options.vp_t + options.vp_h - height);
+ height = height;
+ left = options.vp_l;
+ mid = left + (pos / length) * options.vp_w;
+ width = canvas.width;
+ } else {
+ top = (options.vp_t + options.vp_h - height) / get_canvas_scale();
+ height = height / get_canvas_scale();
+ left = (options.vp_l / get_canvas_scale() );
+ mid = left + (pos / length) * (options.vp_w / get_canvas_scale());
+ width = canvas.width / get_canvas_scale();
+ }
+ //some debugging, draw rect around viewport
+ if (false) {
+ if (!ctx_scaled) {
+ var l = options.vp_l, t = options.vp_t;
+ var w = options.vp_w, h = options.vp_h;
+ } else {
+ var l = options.vp_l/get_canvas_scale(), t = options.vp_t/get_canvas_scale();
+ var w = options.vp_w/get_canvas_scale(), h = options.vp_h/get_canvas_scale();
+ }
+ ctx.rect(l,t,w,h);
+ ctx.stroke();
+ }
+ }
+ else {
+ top = (canvas.height - height) / (ctx_scaled ? get_canvas_scale() : 1);
+ mid = ((pos / length) * canvas.width) / (ctx_scaled ? get_canvas_scale() : 1);
+ width = canvas.width / (ctx_scaled ? get_canvas_scale() : 1 );
+ height /= ctx_scaled ? get_canvas_scale() : 1;
+ }
+
+ ctx.fillStyle = progressBarBackgroundColor;
+ ctx.fillRect(mid, top, width - mid, height);
+
+ ctx.fillStyle = progressBarForegroundColor;
+ ctx.fillRect(0, top, mid, height);
+ }
+ };
+
+ var doLoadError = function (originOfError) {
+ var drawError = function () {
+ ctx.fillStyle = 'black';
+ ctx.fillRect(0, 0, options.c_w ? options.c_w : hdr.width, options.c_h ? options.c_h : hdr.height);
+ ctx.strokeStyle = 'red';
+ ctx.lineWidth = 3;
+ ctx.moveTo(0, 0);
+ ctx.lineTo(options.c_w ? options.c_w : hdr.width, options.c_h ? options.c_h : hdr.height);
+ ctx.moveTo(0, options.c_h ? options.c_h : hdr.height);
+ ctx.lineTo(options.c_w ? options.c_w : hdr.width, 0);
+ ctx.stroke();
+ };
+
+ loadError = originOfError;
+ hdr = {
+ width: gif.width,
+ height: gif.height
+ }; // Fake header.
+ frames = [];
+ drawError();
+ };
+
+ var doHdr = function (_hdr) {
+ hdr = _hdr;
+ setSizes(hdr.width, hdr.height)
+ };
+
+ var doGCE = function (gce) {
+ pushFrame();
+ clear();
+ transparency = gce.transparencyGiven ? gce.transparencyIndex : null;
+ delay = gce.delayTime;
+ disposalMethod = gce.disposalMethod;
+ // We don't have much to do with the rest of GCE.
+ };
+
+ var pushFrame = function () {
+ if (!frame) return;
+ frames.push({
+ data: frame.getImageData(0, 0, hdr.width, hdr.height),
+ delay: delay
+ });
+ frameOffsets.push({ x: 0, y: 0 });
+ };
+
+ var doImg = function (img) {
+ if (!frame) frame = tmpCanvas.getContext('2d');
+
+ var currIdx = frames.length;
+
+ //ct = color table, gct = global color table
+ var ct = img.lctFlag ? img.lct : hdr.gct; // TODO: What if neither exists?
+
+ /*
+ Disposal method indicates the way in which the graphic is to
+ be treated after being displayed.
+
+ Values : 0 - No disposal specified. The decoder is
+ not required to take any action.
+ 1 - Do not dispose. The graphic is to be left
+ in place.
+ 2 - Restore to background color. The area used by the
+ graphic must be restored to the background color.
+ 3 - Restore to previous. The decoder is required to
+ restore the area overwritten by the graphic with
+ what was there prior to rendering the graphic.
+
+ Importantly, "previous" means the frame state
+ after the last disposal of method 0, 1, or 2.
+ */
+ if (currIdx > 0) {
+ if (lastDisposalMethod === 3) {
+ // Restore to previous
+ // If we disposed every frame including first frame up to this point, then we have
+ // no composited frame to restore to. In this case, restore to background instead.
+ if (disposalRestoreFromIdx !== null) {
+ frame.putImageData(frames[disposalRestoreFromIdx].data, 0, 0);
+ } else {
+ frame.clearRect(lastImg.leftPos, lastImg.topPos, lastImg.width, lastImg.height);
+ }
+ } else {
+ disposalRestoreFromIdx = currIdx - 1;
+ }
+
+ if (lastDisposalMethod === 2) {
+ // Restore to background color
+ // Browser implementations historically restore to transparent; we do the same.
+ // http://www.wizards-toolkit.org/discourse-server/viewtopic.php?f=1&t=21172#p86079
+ frame.clearRect(lastImg.leftPos, lastImg.topPos, lastImg.width, lastImg.height);
+ }
+ }
+ // else, Undefined/Do not dispose.
+ // frame contains final pixel data from the last frame; do nothing
+
+ //Get existing pixels for img region after applying disposal method
+ var imgData = frame.getImageData(img.leftPos, img.topPos, img.width, img.height);
+
+ //apply color table colors
+ img.pixels.forEach(function (pixel, i) {
+ // imgData.data === [R,G,B,A,R,G,B,A,...]
+ if (pixel !== transparency) {
+ imgData.data[i * 4 + 0] = ct[pixel][0];
+ imgData.data[i * 4 + 1] = ct[pixel][1];
+ imgData.data[i * 4 + 2] = ct[pixel][2];
+ imgData.data[i * 4 + 3] = 255; // Opaque.
+ }
+ });
+
+ frame.putImageData(imgData, img.leftPos, img.topPos);
+
+ if (!ctx_scaled) {
+ ctx.scale(get_canvas_scale(),get_canvas_scale());
+ ctx_scaled = true;
+ }
+
+ // We could use the on-page canvas directly, except that we draw a progress
+ // bar for each image chunk (not just the final image).
+ if (drawWhileLoading) {
+ ctx.drawImage(tmpCanvas, 0, 0);
+ drawWhileLoading = options.auto_play;
+ }
+
+ lastImg = img;
+ };
+
+ var player = (function () {
+ var i = -1;
+ var iterationCount = 0;
+
+ var showingInfo = false;
+ var pinned = false;
+
+ /**
+ * Gets the index of the frame "up next".
+ * @returns {number}
+ */
+ var getNextFrameNo = function () {
+ var delta = (forward ? 1 : -1);
+ return (i + delta + frames.length) % frames.length;
+ };
+
+ var stepFrame = function (amount) { // XXX: Name is confusing.
+ i = i + amount;
+
+ putFrame();
+ };
+
+ var step = (function () {
+ var stepping = false;
+
+ var completeLoop = function () {
+ if (onEndListener !== null)
+ onEndListener(gif);
+ iterationCount++;
+
+ if (overrideLoopMode !== false || iterationCount < 0) {
+ doStep();
+ } else {
+ stepping = false;
+ playing = false;
+ }
+ };
+
+ var doStep = function () {
+ stepping = playing;
+ if (!stepping) return;
+
+ stepFrame(1);
+ var delay = frames[i].delay * 10;
+ if (!delay) delay = 100; // FIXME: Should this even default at all? What should it be?
+
+ var nextFrameNo = getNextFrameNo();
+ if (nextFrameNo === 0) {
+ delay += loopDelay;
+ setTimeout(completeLoop, delay);
+ } else {
+ setTimeout(doStep, delay);
+ }
+ };
+
+ return function () {
+ if (!stepping) setTimeout(doStep, 0);
+ };
+ }());
+
+ var putFrame = function () {
+ var offset;
+ i = parseInt(i, 10);
+
+ if (i > frames.length - 1){
+ i = 0;
+ }
+
+ if (i < 0){
+ i = 0;
+ }
+
+ offset = frameOffsets[i];
+
+ tmpCanvas.getContext("2d").putImageData(frames[i].data, offset.x, offset.y);
+ ctx.globalCompositeOperation = "copy";
+ ctx.drawImage(tmpCanvas, 0, 0);
+ };
+
+ var play = function () {
+ playing = true;
+ step();
+ };
+
+ var pause = function () {
+ playing = false;
+ };
+
+
+ return {
+ init: function () {
+ if (loadError) return;
+
+ if ( ! (options.c_w && options.c_h) ) {
+ ctx.scale(get_canvas_scale(),get_canvas_scale());
+ }
+
+ if (options.auto_play) {
+ step();
+ }
+ else {
+ i = 0;
+ putFrame();
+ }
+ },
+ step: step,
+ play: play,
+ pause: pause,
+ playing: playing,
+ move_relative: stepFrame,
+ current_frame: function() { return i; },
+ length: function() { return frames.length },
+ move_to: function ( frame_idx ) {
+ i = frame_idx;
+ putFrame();
+ }
+ }
+ }());
+
+ var doDecodeProgress = function (draw) {
+ doShowProgress(stream.pos, stream.data.length, draw);
+ };
+
+ var doNothing = function () {};
+ /**
+ * @param{boolean=} draw Whether to draw progress bar or not; this is not idempotent because of translucency.
+ * Note that this means that the text will be unsynchronized with the progress bar on non-frames;
+ * but those are typically so small (GCE etc.) that it doesn't really matter. TODO: Do this properly.
+ */
+ var withProgress = function (fn, draw) {
+ return function (block) {
+ fn(block);
+ doDecodeProgress(draw);
+ };
+ };
+
+
+ var handler = {
+ hdr: withProgress(doHdr),
+ gce: withProgress(doGCE),
+ com: withProgress(doNothing),
+ // I guess that's all for now.
+ app: {
+ // TODO: Is there much point in actually supporting iterations?
+ NETSCAPE: withProgress(doNothing)
+ },
+ img: withProgress(doImg, true),
+ eof: function (block) {
+ //toolbar.style.display = '';
+ pushFrame();
+ doDecodeProgress(false);
+ if ( ! (options.c_w && options.c_h) ) {
+ canvas.width = hdr.width * get_canvas_scale();
+ canvas.height = hdr.height * get_canvas_scale();
+ }
+ player.init();
+ loading = false;
+ if (load_callback) {
+ load_callback(gif);
+ }
+
+ }
+ };
+
+ var init = function () {
+ var parent = gif.parentNode;
+
+ var div = document.createElement('div');
+ canvas = document.createElement('canvas');
+ ctx = canvas.getContext('2d');
+ toolbar = document.createElement('div');
+
+ tmpCanvas = document.createElement('canvas');
+
+ div.width = canvas.width = gif.width;
+ div.height = canvas.height = gif.height;
+ toolbar.style.minWidth = gif.width + 'px';
+
+ div.className = 'jsgif';
+ toolbar.className = 'jsgif_toolbar';
+ div.appendChild(canvas);
+ div.appendChild(toolbar);
+ //case where we are doing programatically and not DOM
+ if (parent===null) {
+ gif = div;
+ } else {
+ parent.insertBefore(div, gif);
+ parent.removeChild(gif);
+ }
+ if (options.c_w && options.c_h) setSizes(options.c_w, options.c_h);
+ initialized=true;
+ };
+
+ var get_canvas_scale = function() {
+ var scale;
+ if (options.max_width && hdr && hdr.width > options.max_width) {
+ scale = options.max_width / hdr.width;
+ }
+ else {
+ scale = 1;
+ }
+ return scale;
+ }
+
+ var canvas, ctx, toolbar, tmpCanvas;
+ var initialized = false;
+ var load_callback = false;
+
+ var load_setup = function(callback) {
+ if (loading) return false;
+ if (callback) load_callback = callback;
+ else load_callback = false;
+
+ loading = true;
+ frames = [];
+ clear();
+ disposalRestoreFromIdx = null;
+ lastDisposalMethod = null;
+ frame = null;
+ lastImg = null;
+
+ return true;
+ }
+
+ return {
+ // play controls
+ play: player.play,
+ pause: player.pause,
+ move_relative: player.move_relative,
+ move_to: player.move_to,
+
+ // getters for instance vars
+ get_playing : function() { return playing },
+ get_canvas : function() { return canvas },
+ get_canvas_scale : function() { return get_canvas_scale() },
+ get_loading : function() { return loading },
+ get_auto_play : function() { return options.auto_play },
+ get_length : function() { return player.length() },
+ get_current_frame: function() { return player.current_frame() },
+ load_url: function(src,callback){
+ if (!load_setup(callback)) return;
+
+ var h = new XMLHttpRequest();
+ // new browsers (XMLHttpRequest2-compliant)
+ h.open('GET', src, true);
+
+ if ('overrideMimeType' in h) {
+ h.overrideMimeType('text/plain; charset=x-user-defined');
+ }
+
+ // old browsers (XMLHttpRequest-compliant)
+ else if ('responseType' in h) {
+ h.responseType = 'arraybuffer';
+ }
+
+ // IE9 (Microsoft.XMLHTTP-compliant)
+ else {
+ h.setRequestHeader('Accept-Charset', 'x-user-defined');
+ }
+
+ h.onloadstart = function() {
+ // Wait until connection is opened to replace the gif element with a canvas to avoid a blank img
+ if (!initialized) init();
+ };
+ h.onload = function(e) {
+ if (this.status != 200) {
+ doLoadError('xhr - response');
+ }
+ // emulating response field for IE9
+ if (!('response' in this)) {
+ this.response = new VBArray(this.responseText).toArray().map(String.fromCharCode).join('');
+ }
+ var data = this.response;
+ if (data.toString().indexOf("ArrayBuffer") > 0) {
+ data = new Uint8Array(data);
+ }
+
+ stream = new Stream(data);
+ setTimeout(doParse, 0);
+ };
+ h.onprogress = function (e) {
+ if (e.lengthComputable) doShowProgress(e.loaded, e.total, true);
+ };
+ h.onerror = function() { doLoadError('xhr'); };
+ h.send();
+ },
+ load: function (callback) {
+ this.load_url(gif.getAttribute('rel:animated_src') || gif.src,callback);
+ },
+ load_raw: function(arr, callback) {
+ if (!load_setup(callback)) return;
+ if (!initialized) init();
+ stream = new Stream(arr);
+ setTimeout(doParse, 0);
+ },
+ set_frame_offset: setFrameOffset
+ };
+ };
+
+ return SuperGif;
+}));
+
+
diff --git a/vendor/pixi.min.js b/vendor/pixi.min.js
new file mode 100755
index 0000000..974c549
--- /dev/null
+++ b/vendor/pixi.min.js
@@ -0,0 +1,18 @@
+/**
+ * @license
+ * pixi.js - v2.2.7
+ * Copyright (c) 2012-2014, Mat Groves
+ * http://goodboydigital.com/
+ *
+ * Compiled: 2015-02-25
+ *
+ * pixi.js is licensed under the MIT License.
+ * http://www.opensource.org/licenses/mit-license.php
+ */
+(function(){var a=this,b=b||{};b.WEBGL_RENDERER=0,b.CANVAS_RENDERER=1,b.VERSION="v2.2.7",b.blendModes={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},b.scaleModes={DEFAULT:0,LINEAR:0,NEAREST:1},b._UID=0,"undefined"!=typeof Float32Array?(b.Float32Array=Float32Array,b.Uint16Array=Uint16Array,b.Uint32Array=Uint32Array,b.ArrayBuffer=ArrayBuffer):(b.Float32Array=Array,b.Uint16Array=Array),b.INTERACTION_FREQUENCY=30,b.AUTO_PREVENT_DEFAULT=!0,b.PI_2=2*Math.PI,b.RAD_TO_DEG=180/Math.PI,b.DEG_TO_RAD=Math.PI/180,b.RETINA_PREFIX="@2x",b.dontSayHello=!1,b.defaultRenderOptions={view:null,transparent:!1,antialias:!1,preserveDrawingBuffer:!1,resolution:1,clearBeforeRender:!0,autoResize:!1},b.sayHello=function(a){if(!b.dontSayHello){if(navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var c=["%c %c %c Pixi.js "+b.VERSION+" - "+a+" %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ ","background: #ff66a5","background: #ff66a5","color: #ff66a5; background: #030307;","background: #ff66a5","background: #ffc3dc","background: #ff66a5","color: #ff2424; background: #fff","color: #ff2424; background: #fff","color: #ff2424; background: #fff"];console.log.apply(console,c)}else window.console&&console.log("Pixi.js "+b.VERSION+" - http://www.pixijs.com/");b.dontSayHello=!0}},b.Point=function(a,b){this.x=a||0,this.y=b||0},b.Point.prototype.clone=function(){return new b.Point(this.x,this.y)},b.Point.prototype.set=function(a,b){this.x=a||0,this.y=b||(0!==b?this.x:0)},b.Point.prototype.constructor=b.Point,b.Rectangle=function(a,b,c,d){this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0},b.Rectangle.prototype.clone=function(){return new b.Rectangle(this.x,this.y,this.width,this.height)},b.Rectangle.prototype.contains=function(a,b){if(this.width<=0||this.height<=0)return!1;var c=this.x;if(a>=c&&a<=c+this.width){var d=this.y;if(b>=d&&b<=d+this.height)return!0}return!1},b.Rectangle.prototype.constructor=b.Rectangle,b.EmptyRectangle=new b.Rectangle(0,0,0,0),b.Polygon=function(a){if(a instanceof Array||(a=Array.prototype.slice.call(arguments)),a[0]instanceof b.Point){for(var c=[],d=0,e=a.length;e>d;d++)c.push(a[d].x,a[d].y);a=c}this.closed=!0,this.points=a},b.Polygon.prototype.clone=function(){var a=this.points.slice();return new b.Polygon(a)},b.Polygon.prototype.contains=function(a,b){for(var c=!1,d=this.points.length/2,e=0,f=d-1;d>e;f=e++){var g=this.points[2*e],h=this.points[2*e+1],i=this.points[2*f],j=this.points[2*f+1],k=h>b!=j>b&&(i-g)*(b-h)/(j-h)+g>a;k&&(c=!c)}return c},b.Polygon.prototype.constructor=b.Polygon,b.Circle=function(a,b,c){this.x=a||0,this.y=b||0,this.radius=c||0},b.Circle.prototype.clone=function(){return new b.Circle(this.x,this.y,this.radius)},b.Circle.prototype.contains=function(a,b){if(this.radius<=0)return!1;var c=this.x-a,d=this.y-b,e=this.radius*this.radius;return c*=c,d*=d,e>=c+d},b.Circle.prototype.getBounds=function(){return new b.Rectangle(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius)},b.Circle.prototype.constructor=b.Circle,b.Ellipse=function(a,b,c,d){this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0},b.Ellipse.prototype.clone=function(){return new b.Ellipse(this.x,this.y,this.width,this.height)},b.Ellipse.prototype.contains=function(a,b){if(this.width<=0||this.height<=0)return!1;var c=(a-this.x)/this.width,d=(b-this.y)/this.height;return c*=c,d*=d,1>=c+d},b.Ellipse.prototype.getBounds=function(){return new b.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},b.Ellipse.prototype.constructor=b.Ellipse,b.RoundedRectangle=function(a,b,c,d,e){this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0,this.radius=e||20},b.RoundedRectangle.prototype.clone=function(){return new b.RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)},b.RoundedRectangle.prototype.contains=function(a,b){if(this.width<=0||this.height<=0)return!1;var c=this.x;if(a>=c&&a<=c+this.width){var d=this.y;if(b>=d&&b<=d+this.height)return!0}return!1},b.RoundedRectangle.prototype.constructor=b.RoundedRectangle,b.Matrix=function(){this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0},b.Matrix.prototype.fromArray=function(a){this.a=a[0],this.b=a[1],this.c=a[3],this.d=a[4],this.tx=a[2],this.ty=a[5]},b.Matrix.prototype.toArray=function(a){this.array||(this.array=new b.Float32Array(9));var c=this.array;return a?(c[0]=this.a,c[1]=this.b,c[2]=0,c[3]=this.c,c[4]=this.d,c[5]=0,c[6]=this.tx,c[7]=this.ty,c[8]=1):(c[0]=this.a,c[1]=this.c,c[2]=this.tx,c[3]=this.b,c[4]=this.d,c[5]=this.ty,c[6]=0,c[7]=0,c[8]=1),c},b.Matrix.prototype.apply=function(a,c){return c=c||new b.Point,c.x=this.a*a.x+this.c*a.y+this.tx,c.y=this.b*a.x+this.d*a.y+this.ty,c},b.Matrix.prototype.applyInverse=function(a,c){c=c||new b.Point;var d=1/(this.a*this.d+this.c*-this.b);return c.x=this.d*d*a.x+-this.c*d*a.y+(this.ty*this.c-this.tx*this.d)*d,c.y=this.a*d*a.y+-this.b*d*a.x+(-this.ty*this.a+this.tx*this.b)*d,c},b.Matrix.prototype.translate=function(a,b){return this.tx+=a,this.ty+=b,this},b.Matrix.prototype.scale=function(a,b){return this.a*=a,this.d*=b,this.c*=a,this.b*=b,this.tx*=a,this.ty*=b,this},b.Matrix.prototype.rotate=function(a){var b=Math.cos(a),c=Math.sin(a),d=this.a,e=this.c,f=this.tx;return this.a=d*b-this.b*c,this.b=d*c+this.b*b,this.c=e*b-this.d*c,this.d=e*c+this.d*b,this.tx=f*b-this.ty*c,this.ty=f*c+this.ty*b,this},b.Matrix.prototype.append=function(a){var b=this.a,c=this.b,d=this.c,e=this.d;return this.a=a.a*b+a.b*d,this.b=a.a*c+a.b*e,this.c=a.c*b+a.d*d,this.d=a.c*c+a.d*e,this.tx=a.tx*b+a.ty*d+this.tx,this.ty=a.tx*c+a.ty*e+this.ty,this},b.Matrix.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},b.identityMatrix=new b.Matrix,b.DisplayObject=function(){this.position=new b.Point,this.scale=new b.Point(1,1),this.pivot=new b.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.buttonMode=!1,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this._interactive=!1,this.defaultCursor="pointer",this.worldTransform=new b.Matrix,this._sr=0,this._cr=1,this.filterArea=null,this._bounds=new b.Rectangle(0,0,1,1),this._currentBounds=null,this._mask=null,this._cacheAsBitmap=!1,this._cacheIsDirty=!1},b.DisplayObject.prototype.constructor=b.DisplayObject,Object.defineProperty(b.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(a){this._interactive=a,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(b.DisplayObject.prototype,"worldVisible",{get:function(){var a=this;do{if(!a.visible)return!1;a=a.parent}while(a);return!0}}),Object.defineProperty(b.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(a){this._mask&&(this._mask.isMask=!1),this._mask=a,this._mask&&(this._mask.isMask=!0)}}),Object.defineProperty(b.DisplayObject.prototype,"filters",{get:function(){return this._filters},set:function(a){if(a){for(var b=[],c=0;c=0&&b<=this.children.length)return a.parent&&a.parent.removeChild(a),a.parent=this,this.children.splice(b,0,a),this.stage&&a.setStageReference(this.stage),a;throw new Error(a+"addChildAt: The index "+b+" supplied is out of bounds "+this.children.length)},b.DisplayObjectContainer.prototype.swapChildren=function(a,b){if(a!==b){var c=this.getChildIndex(a),d=this.getChildIndex(b);if(0>c||0>d)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[c]=b,this.children[d]=a}},b.DisplayObjectContainer.prototype.getChildIndex=function(a){var b=this.children.indexOf(a);if(-1===b)throw new Error("The supplied DisplayObject must be a child of the caller");return b},b.DisplayObjectContainer.prototype.setChildIndex=function(a,b){if(0>b||b>=this.children.length)throw new Error("The supplied index is out of bounds");var c=this.getChildIndex(a);this.children.splice(c,1),this.children.splice(b,0,a)},b.DisplayObjectContainer.prototype.getChildAt=function(a){if(0>a||a>=this.children.length)throw new Error("getChildAt: Supplied index "+a+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[a]},b.DisplayObjectContainer.prototype.removeChild=function(a){var b=this.children.indexOf(a);if(-1!==b)return this.removeChildAt(b)},b.DisplayObjectContainer.prototype.removeChildAt=function(a){var b=this.getChildAt(a);return this.stage&&b.removeStageReference(),b.parent=void 0,this.children.splice(a,1),b},b.DisplayObjectContainer.prototype.removeChildren=function(a,b){var c=a||0,d="number"==typeof b?b:this.children.length,e=d-c;if(e>0&&d>=e){for(var f=this.children.splice(c,e),g=0;ga;a++)this.children[a].updateTransform()},b.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=b.DisplayObjectContainer.prototype.updateTransform,b.DisplayObjectContainer.prototype.getBounds=function(){if(0===this.children.length)return b.EmptyRectangle;for(var a,c,d,e=1/0,f=1/0,g=-1/0,h=-1/0,i=!1,j=0,k=this.children.length;k>j;j++){var l=this.children[j];l.visible&&(i=!0,a=this.children[j].getBounds(),e=ec?g:c,h=h>d?h:d)}if(!i)return b.EmptyRectangle;var m=this._bounds;return m.x=e,m.y=f,m.width=g-e,m.height=h-f,m},b.DisplayObjectContainer.prototype.getLocalBounds=function(){var a=this.worldTransform;this.worldTransform=b.identityMatrix;for(var c=0,d=this.children.length;d>c;c++)this.children[c].updateTransform();var e=this.getBounds();return this.worldTransform=a,e},b.DisplayObjectContainer.prototype.setStageReference=function(a){this.stage=a,this._interactive&&(this.stage.dirty=!0);for(var b=0,c=this.children.length;c>b;b++){var d=this.children[b];d.setStageReference(a)}},b.DisplayObjectContainer.prototype.removeStageReference=function(){for(var a=0,b=this.children.length;b>a;a++){var c=this.children[a];c.removeStageReference()}this._interactive&&(this.stage.dirty=!0),this.stage=null},b.DisplayObjectContainer.prototype._renderWebGL=function(a){if(this.visible&&!(this.alpha<=0)){if(this._cacheAsBitmap)return void this._renderCachedSprite(a);var b,c;if(this._mask||this._filters){for(this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),b=0,c=this.children.length;c>b;b++)this.children[b]._renderWebGL(a);a.spriteBatch.stop(),this._mask&&a.maskManager.popMask(this._mask,a),this._filters&&a.filterManager.popFilter(),a.spriteBatch.start()}else for(b=0,c=this.children.length;c>b;b++)this.children[b]._renderWebGL(a)}},b.DisplayObjectContainer.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha){if(this._cacheAsBitmap)return void this._renderCachedSprite(a);this._mask&&a.maskManager.pushMask(this._mask,a);for(var b=0,c=this.children.length;c>b;b++){var d=this.children[b];d._renderCanvas(a)}this._mask&&a.maskManager.popMask(a)}},b.Sprite=function(a){b.DisplayObjectContainer.call(this),this.anchor=new b.Point,this.texture=a||b.Texture.emptyTexture,this._width=0,this._height=0,this.tint=16777215,this.blendMode=b.blendModes.NORMAL,this.shader=null,this.texture.baseTexture.hasLoaded?this.onTextureUpdate():this.texture.on("update",this.onTextureUpdate.bind(this)),this.renderable=!0},b.Sprite.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Sprite.prototype.constructor=b.Sprite,Object.defineProperty(b.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(b.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),b.Sprite.prototype.setTexture=function(a){this.texture=a,this.cachedTint=16777215},b.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)},b.Sprite.prototype.getBounds=function(a){var b=this.texture.frame.width,c=this.texture.frame.height,d=b*(1-this.anchor.x),e=b*-this.anchor.x,f=c*(1-this.anchor.y),g=c*-this.anchor.y,h=a||this.worldTransform,i=h.a,j=h.b,k=h.c,l=h.d,m=h.tx,n=h.ty,o=-1/0,p=-1/0,q=1/0,r=1/0;if(0===j&&0===k)0>i&&(i*=-1),0>l&&(l*=-1),q=i*e+m,o=i*d+m,r=l*g+n,p=l*f+n;else{var s=i*e+k*g+m,t=l*g+j*e+n,u=i*d+k*g+m,v=l*g+j*d+n,w=i*d+k*f+m,x=l*f+j*d+n,y=i*e+k*f+m,z=l*f+j*e+n;q=q>s?s:q,q=q>u?u:q,q=q>w?w:q,q=q>y?y:q,r=r>t?t:r,r=r>v?v:r,r=r>x?x:r,r=r>z?z:r,o=s>o?s:o,o=u>o?u:o,o=w>o?w:o,o=y>o?y:o,p=t>p?t:p,p=v>p?v:p,p=x>p?x:p,p=z>p?z:p}var A=this._bounds;return A.x=q,A.width=o-q,A.y=r,A.height=p-r,this._currentBounds=A,A},b.Sprite.prototype._renderWebGL=function(a){if(this.visible&&!(this.alpha<=0)){var b,c;if(this._mask||this._filters){var d=a.spriteBatch;for(this._filters&&(d.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(d.stop(),a.maskManager.pushMask(this.mask,a),d.start()),d.render(this),b=0,c=this.children.length;c>b;b++)this.children[b]._renderWebGL(a);d.stop(),this._mask&&a.maskManager.popMask(this._mask,a),this._filters&&a.filterManager.popFilter(),d.start()}else for(a.spriteBatch.render(this),b=0,c=this.children.length;c>b;b++)this.children[b]._renderWebGL(a)}},b.Sprite.prototype._renderCanvas=function(a){if(!(this.visible===!1||0===this.alpha||this.texture.crop.width<=0||this.texture.crop.height<=0)){if(this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,a.context.globalCompositeOperation=b.blendModesCanvas[a.currentBlendMode]),this._mask&&a.maskManager.pushMask(this._mask,a),this.texture.valid){var c=this.texture.baseTexture.resolution/a.resolution;a.context.globalAlpha=this.worldAlpha,a.smoothProperty&&a.scaleMode!==this.texture.baseTexture.scaleMode&&(a.scaleMode=this.texture.baseTexture.scaleMode,a.context[a.smoothProperty]=a.scaleMode===b.scaleModes.LINEAR);var d=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,e=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height;a.roundPixels?(a.context.setTransform(this.worldTransform.a,this.worldTransform.b,this.worldTransform.c,this.worldTransform.d,this.worldTransform.tx*a.resolution|0,this.worldTransform.ty*a.resolution|0),d=0|d,e=0|e):a.context.setTransform(this.worldTransform.a,this.worldTransform.b,this.worldTransform.c,this.worldTransform.d,this.worldTransform.tx*a.resolution,this.worldTransform.ty*a.resolution),16777215!==this.tint?(this.cachedTint!==this.tint&&(this.cachedTint=this.tint,this.tintedTexture=b.CanvasTinter.getTintedTexture(this,this.tint)),a.context.drawImage(this.tintedTexture,0,0,this.texture.crop.width,this.texture.crop.height,d/c,e/c,this.texture.crop.width/c,this.texture.crop.height/c)):a.context.drawImage(this.texture.baseTexture.source,this.texture.crop.x,this.texture.crop.y,this.texture.crop.width,this.texture.crop.height,d/c,e/c,this.texture.crop.width/c,this.texture.crop.height/c)}for(var f=0,g=this.children.length;g>f;f++)this.children[f]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},b.Sprite.fromFrame=function(a){var c=b.TextureCache[a];if(!c)throw new Error('The frameId "'+a+'" does not exist in the texture cache'+this);return new b.Sprite(c)},b.Sprite.fromImage=function(a,c,d){var e=b.Texture.fromImage(a,c,d);return new b.Sprite(e)},b.SpriteBatch=function(a){b.DisplayObjectContainer.call(this),this.textureThing=a,this.ready=!1},b.SpriteBatch.prototype=Object.create(b.DisplayObjectContainer.prototype),b.SpriteBatch.prototype.constructor=b.SpriteBatch,b.SpriteBatch.prototype.initWebGL=function(a){this.fastSpriteBatch=new b.WebGLFastSpriteBatch(a),this.ready=!0},b.SpriteBatch.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},b.SpriteBatch.prototype._renderWebGL=function(a){!this.visible||this.alpha<=0||!this.children.length||(this.ready||this.initWebGL(a.gl),this.fastSpriteBatch.gl!==a.gl&&this.fastSpriteBatch.setContext(a.gl),a.spriteBatch.stop(),a.shaderManager.setShader(a.shaderManager.fastShader),this.fastSpriteBatch.begin(this,a),this.fastSpriteBatch.render(this),a.spriteBatch.start())},b.SpriteBatch.prototype._renderCanvas=function(a){if(this.visible&&!(this.alpha<=0)&&this.children.length){var b=a.context;b.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var c=this.worldTransform,d=!0,e=0;e=this.textures.length&&(this.gotoAndStop(this.textures.length-1),this.onComplete&&this.onComplete())}},b.MovieClip.fromFrames=function(a){for(var c=[],d=0;di;i++){for(j=0;m>j;j+=4)if(255!==k[n+j]){o=!0;break}if(o)break;n+=m}for(c.ascent=g-i,n=l-m,o=!1,i=h;i>g;i--){for(j=0;m>j;j+=4)if(255!==k[n+j]){o=!0;break}if(o)break;n-=m}c.descent=i-g,c.descent+=6,c.fontSize=c.ascent+c.descent,b.Text.fontPropertiesCache[a]=c}return c},b.Text.prototype.wordWrap=function(a){for(var b="",c=a.split("\n"),d=0;de?(g>0&&(b+="\n"),b+=f[g],e=this.style.wordWrapWidth-h):(e-=i,b+=" "+f[g])}d=2?parseInt(c[c.length-2],10):b.BitmapText.fonts[this.fontName].size,this.dirty=!0,this.tint=a.tint},b.BitmapText.prototype.updateText=function(){for(var a=b.BitmapText.fonts[this.fontName],c=new b.Point,d=null,e=[],f=0,g=[],h=0,i=this.fontSize/a.size,j=0;j=j;j++){var n=0;"right"===this.style.align?n=f-g[j]:"center"===this.style.align&&(n=(f-g[j])/2),m.push(n)}var o=this.children.length,p=e.length,q=this.tint||16777215;for(j=0;p>j;j++){var r=o>j?this.children[j]:this._pool.pop();r?r.setTexture(e[j].texture):r=new b.Sprite(e[j].texture),r.position.x=(e[j].position.x+m[e[j].line])*i,r.position.y=e[j].position.y*i,r.scale.x=r.scale.y=i,r.tint=q,r.parent||this.addChild(r)}for(;this.children.length>p;){var s=this.getChildAt(this.children.length-1);this._pool.push(s),this.removeChild(s)}this.textWidth=f*i,this.textHeight=(c.y+a.lineHeight)*i},b.BitmapText.prototype.updateTransform=function(){this.dirty&&(this.updateText(),this.dirty=!1),b.DisplayObjectContainer.prototype.updateTransform.call(this)},b.BitmapText.fonts={},b.InteractionData=function(){this.global=new b.Point,this.target=null,this.originalEvent=null},b.InteractionData.prototype.getLocalPosition=function(a,c){var d=a.worldTransform,e=this.global,f=d.a,g=d.c,h=d.tx,i=d.b,j=d.d,k=d.ty,l=1/(f*j+g*-i);return c=c||new b.Point,c.x=j*l*e.x+-g*l*e.y+(k*g-h*j)*l,c.y=f*l*e.y+-i*l*e.x+(-k*f+h*i)*l,c},b.InteractionData.prototype.constructor=b.InteractionData,b.InteractionManager=function(a){this.stage=a,this.mouse=new b.InteractionData,this.touches={},this.tempPoint=new b.Point,this.mouseoverEnabled=!0,this.pool=[],this.interactiveItems=[],this.interactionDOMElement=null,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onTouchCancel=this.onTouchCancel.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.last=0,this.currentCursorStyle="inherit",this.mouseOut=!1,this.resolution=1,this._tempPoint=new b.Point
+},b.InteractionManager.prototype.constructor=b.InteractionManager,b.InteractionManager.prototype.collectInteractiveSprite=function(a,b){for(var c=a.children,d=c.length,e=d-1;e>=0;e--){var f=c[e];f._interactive?(b.interactiveChildren=!0,this.interactiveItems.push(f),f.children.length>0&&this.collectInteractiveSprite(f,f)):(f.__iParent=null,f.children.length>0&&this.collectInteractiveSprite(f,b))}},b.InteractionManager.prototype.setTarget=function(a){this.target=a,this.resolution=a.resolution,null===this.interactionDOMElement&&this.setTargetDomElement(a.view)},b.InteractionManager.prototype.setTargetDomElement=function(a){this.removeEvents(),window.navigator.msPointerEnabled&&(a.style["-ms-content-zooming"]="none",a.style["-ms-touch-action"]="none"),this.interactionDOMElement=a,a.addEventListener("mousemove",this.onMouseMove,!0),a.addEventListener("mousedown",this.onMouseDown,!0),a.addEventListener("mouseout",this.onMouseOut,!0),a.addEventListener("touchstart",this.onTouchStart,!0),a.addEventListener("touchend",this.onTouchEnd,!0),a.addEventListener("touchleave",this.onTouchCancel,!0),a.addEventListener("touchcancel",this.onTouchCancel,!0),a.addEventListener("touchmove",this.onTouchMove,!0),window.addEventListener("mouseup",this.onMouseUp,!0)},b.InteractionManager.prototype.removeEvents=function(){this.interactionDOMElement&&(this.interactionDOMElement.style["-ms-content-zooming"]="",this.interactionDOMElement.style["-ms-touch-action"]="",this.interactionDOMElement.removeEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.removeEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.removeEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.removeEventListener("touchleave",this.onTouchCancel,!0),this.interactionDOMElement.removeEventListener("touchcancel",this.onTouchCancel,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onTouchMove,!0),this.interactionDOMElement=null,window.removeEventListener("mouseup",this.onMouseUp,!0))},b.InteractionManager.prototype.update=function(){if(this.target){var a=Date.now(),c=a-this.last;if(c=c*b.INTERACTION_FREQUENCY/1e3,!(1>c)){this.last=a;var d=0;this.dirty&&this.rebuildInteractiveGraph();var e=this.interactiveItems.length,f="inherit",g=!1;for(d=0;e>d;d++){var h=this.interactiveItems[d];h.__hit=this.hitTest(h,this.mouse),this.mouse.target=h,h.__hit&&!g?(h.buttonMode&&(f=h.defaultCursor),h.interactiveChildren||(g=!0),h.__isOver||(h.mouseover&&h.mouseover(this.mouse),h.__isOver=!0)):h.__isOver&&(h.mouseout&&h.mouseout(this.mouse),h.__isOver=!1)}this.currentCursorStyle!==f&&(this.currentCursorStyle=f,this.interactionDOMElement.style.cursor=f)}}},b.InteractionManager.prototype.rebuildInteractiveGraph=function(){this.dirty=!1;for(var a=this.interactiveItems.length,b=0;a>b;b++)this.interactiveItems[b].interactiveChildren=!1;this.interactiveItems=[],this.stage.interactive&&this.interactiveItems.push(this.stage),this.collectInteractiveSprite(this.stage,this.stage)},b.InteractionManager.prototype.onMouseMove=function(a){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=a;var b=this.interactionDOMElement.getBoundingClientRect();this.mouse.global.x=(a.clientX-b.left)*(this.target.width/b.width)/this.resolution,this.mouse.global.y=(a.clientY-b.top)*(this.target.height/b.height)/this.resolution;for(var c=this.interactiveItems.length,d=0;c>d;d++){var e=this.interactiveItems[d];e.mousemove&&e.mousemove(this.mouse)}},b.InteractionManager.prototype.onMouseDown=function(a){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=a,b.AUTO_PREVENT_DEFAULT&&this.mouse.originalEvent.preventDefault();for(var c=this.interactiveItems.length,d=this.mouse.originalEvent,e=2===d.button||3===d.which,f=e?"rightdown":"mousedown",g=e?"rightclick":"click",h=e?"__rightIsDown":"__mouseIsDown",i=e?"__isRightDown":"__isDown",j=0;c>j;j++){var k=this.interactiveItems[j];if((k[f]||k[g])&&(k[h]=!0,k.__hit=this.hitTest(k,this.mouse),k.__hit&&(k[f]&&k[f](this.mouse),k[i]=!0,!k.interactiveChildren)))break}},b.InteractionManager.prototype.onMouseOut=function(a){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=a;var b=this.interactiveItems.length;this.interactionDOMElement.style.cursor="inherit";for(var c=0;b>c;c++){var d=this.interactiveItems[c];d.__isOver&&(this.mouse.target=d,d.mouseout&&d.mouseout(this.mouse),d.__isOver=!1)}this.mouseOut=!0,this.mouse.global.x=-1e4,this.mouse.global.y=-1e4},b.InteractionManager.prototype.onMouseUp=function(a){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=a;for(var b=this.interactiveItems.length,c=!1,d=this.mouse.originalEvent,e=2===d.button||3===d.which,f=e?"rightup":"mouseup",g=e?"rightclick":"click",h=e?"rightupoutside":"mouseupoutside",i=e?"__isRightDown":"__isDown",j=0;b>j;j++){var k=this.interactiveItems[j];(k[g]||k[f]||k[h])&&(k.__hit=this.hitTest(k,this.mouse),k.__hit&&!c?(k[f]&&k[f](this.mouse),k[i]&&k[g]&&k[g](this.mouse),k.interactiveChildren||(c=!0)):k[i]&&k[h]&&k[h](this.mouse),k[i]=!1)}},b.InteractionManager.prototype.hitTest=function(a,c){var d=c.global;if(!a.worldVisible)return!1;a.worldTransform.applyInverse(d,this._tempPoint);var e,f=this._tempPoint.x,g=this._tempPoint.y;if(c.target=a,a.hitArea&&a.hitArea.contains)return a.hitArea.contains(f,g);if(a instanceof b.Sprite){var h,i=a.texture.frame.width,j=a.texture.frame.height,k=-i*a.anchor.x;if(f>k&&k+i>f&&(h=-j*a.anchor.y,g>h&&h+j>g))return!0}else if(a instanceof b.Graphics){var l=a.graphicsData;for(e=0;ee;e++){var o=a.children[e],p=this.hitTest(o,c);if(p)return c.target=a,!0}return!1},b.InteractionManager.prototype.onTouchMove=function(a){this.dirty&&this.rebuildInteractiveGraph();var b,c=this.interactionDOMElement.getBoundingClientRect(),d=a.changedTouches,e=0;for(e=0;ei;i++){var j=this.interactiveItems[i];if((j.touchstart||j.tap)&&(j.__hit=this.hitTest(j,g),j.__hit&&(j.touchstart&&j.touchstart(g),j.__isDown=!0,j.__touchData=j.__touchData||{},j.__touchData[f.identifier]=g,!j.interactiveChildren)))break}}},b.InteractionManager.prototype.onTouchEnd=function(a){this.dirty&&this.rebuildInteractiveGraph();for(var b=this.interactionDOMElement.getBoundingClientRect(),c=a.changedTouches,d=0;di;i++){var j=this.interactiveItems[i];j.__touchData&&j.__touchData[e.identifier]&&(j.__hit=this.hitTest(j,j.__touchData[e.identifier]),f.originalEvent=a,(j.touchend||j.tap)&&(j.__hit&&!g?(j.touchend&&j.touchend(f),j.__isDown&&j.tap&&j.tap(f),j.interactiveChildren||(g=!0)):j.__isDown&&j.touchendoutside&&j.touchendoutside(f),j.__isDown=!1),j.__touchData[e.identifier]=null)}this.pool.push(f),this.touches[e.identifier]=null}},b.InteractionManager.prototype.onTouchCancel=function(a){this.dirty&&this.rebuildInteractiveGraph();for(var b=this.interactionDOMElement.getBoundingClientRect(),c=a.changedTouches,d=0;di;i++){var j=this.interactiveItems[i];j.__touchData&&j.__touchData[e.identifier]&&(j.__hit=this.hitTest(j,j.__touchData[e.identifier]),f.originalEvent=a,j.touchcancel&&!g&&(j.touchcancel(f),j.interactiveChildren||(g=!0)),j.__isDown=!1,j.__touchData[e.identifier]=null)}this.pool.push(f),this.touches[e.identifier]=null}},b.Stage=function(a){b.DisplayObjectContainer.call(this),this.worldTransform=new b.Matrix,this.interactive=!0,this.interactionManager=new b.InteractionManager(this),this.dirty=!0,this.stage=this,this.stage.hitArea=new b.Rectangle(0,0,1e5,1e5),this.setBackgroundColor(a)},b.Stage.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Stage.prototype.constructor=b.Stage,b.Stage.prototype.setInteractionDelegate=function(a){this.interactionManager.setTargetDomElement(a)},b.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var a=0,b=this.children.length;b>a;a++)this.children[a].updateTransform();this.dirty&&(this.dirty=!1,this.interactionManager.dirty=!0),this.interactive&&this.interactionManager.update()},b.Stage.prototype.setBackgroundColor=function(a){this.backgroundColor=a||0,this.backgroundColorSplit=b.hex2rgb(this.backgroundColor);var c=this.backgroundColor.toString(16);c="000000".substr(0,6-c.length)+c,this.backgroundColorString="#"+c},b.Stage.prototype.getMousePosition=function(){return this.interactionManager.mouse.global},function(a){for(var b=0,c=["ms","moz","webkit","o"],d=0;d>16&255)/255,(a>>8&255)/255,(255&a)/255]},b.rgb2hex=function(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]},"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(){return function(a){function b(){for(var d=arguments.length,f=new Array(d);d--;)f[d]=arguments[d];return f=e.concat(f),c.apply(this instanceof b?this:a,f)}var c=this,d=arguments.length-1,e=[];if(d>0)for(e.length=d;d--;)e[d]=arguments[d+1];if("function"!=typeof c)throw new TypeError;return b.prototype=function f(a){return a&&(f.prototype=a),this instanceof f?void 0:new f}(c.prototype),b}}()),b.AjaxRequest=function(){var a=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];if(!window.ActiveXObject)return window.XMLHttpRequest?new window.XMLHttpRequest:!1;for(var b=0;b0&&0===(a&a-1))return a;for(var b=1;a>b;)b<<=1;return b},b.isPowerOfTwo=function(a,b){return a>0&&0===(a&a-1)&&b>0&&0===(b&b-1)},b.EventTarget={call:function(a){a&&(a=a.prototype||a,b.EventTarget.mixin(a))},mixin:function(a){a.listeners=function(a){return this._listeners=this._listeners||{},this._listeners[a]?this._listeners[a].slice():[]},a.emit=a.dispatchEvent=function(a,c){if(this._listeners=this._listeners||{},"object"==typeof a&&(c=a,a=a.type),c&&c.__isEventObject===!0||(c=new b.Event(this,a,c)),this._listeners&&this._listeners[a]){var d,e=this._listeners[a].slice(0),f=e.length,g=e[0];for(d=0;f>d;g=e[++d])if(g.call(this,c),c.stoppedImmediate)return this;if(c.stopped)return this}return this.parent&&this.parent.emit&&this.parent.emit.call(this.parent,a,c),this},a.on=a.addEventListener=function(a,b){return this._listeners=this._listeners||{},(this._listeners[a]=this._listeners[a]||[]).push(b),this},a.once=function(a,b){function c(){b.apply(d.off(a,c),arguments)}this._listeners=this._listeners||{};var d=this;return c._originalHandler=b,this.on(a,c)},a.off=a.removeEventListener=function(a,b){if(this._listeners=this._listeners||{},!this._listeners[a])return this;for(var c=this._listeners[a],d=b?c.length:0;d-->0;)(c[d]===b||c[d]._originalHandler===b)&&c.splice(d,1);return 0===c.length&&delete this._listeners[a],this},a.removeAllListeners=function(a){return this._listeners=this._listeners||{},this._listeners[a]?(delete this._listeners[a],this):this}}},b.Event=function(a,b,c){this.__isEventObject=!0,this.stopped=!1,this.stoppedImmediate=!1,this.target=a,this.type=b,this.data=c,this.content=c,this.timeStamp=Date.now()},b.Event.prototype.stopPropagation=function(){this.stopped=!0},b.Event.prototype.stopImmediatePropagation=function(){this.stoppedImmediate=!0},b.autoDetectRenderer=function(a,c,d){a||(a=800),c||(c=600);var e=function(){try{var a=document.createElement("canvas");return!!window.WebGLRenderingContext&&(a.getContext("webgl")||a.getContext("experimental-webgl"))}catch(b){return!1}}();return e?new b.WebGLRenderer(a,c,d):new b.CanvasRenderer(a,c,d)},b.autoDetectRecommendedRenderer=function(a,c,d){a||(a=800),c||(c=600);var e=function(){try{var a=document.createElement("canvas");return!!window.WebGLRenderingContext&&(a.getContext("webgl")||a.getContext("experimental-webgl"))}catch(b){return!1}}(),f=/Android/i.test(navigator.userAgent);return e&&!f?new b.WebGLRenderer(a,c,d):new b.CanvasRenderer(a,c,d)},b.PolyK={},b.PolyK.Triangulate=function(a){var c=!0,d=a.length>>1;if(3>d)return[];for(var e=[],f=[],g=0;d>g;g++)f.push(g);g=0;for(var h=d;h>3;){var i=f[(g+0)%h],j=f[(g+1)%h],k=f[(g+2)%h],l=a[2*i],m=a[2*i+1],n=a[2*j],o=a[2*j+1],p=a[2*k],q=a[2*k+1],r=!1;if(b.PolyK._convex(l,m,n,o,p,q,c)){r=!0;for(var s=0;h>s;s++){var t=f[s];if(t!==i&&t!==j&&t!==k&&b.PolyK._PointInTriangle(a[2*t],a[2*t+1],l,m,n,o,p,q)){r=!1;break}}}if(r)e.push(i,j,k),f.splice((g+1)%h,1),h--,g=0;else if(g++>3*h){if(!c)return null;for(e=[],f=[],g=0;d>g;g++)f.push(g);g=0,h=d,c=!1}}return e.push(f[0],f[1],f[2]),e},b.PolyK._PointInTriangle=function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return u>=0&&v>=0&&1>u+v},b.PolyK._convex=function(a,b,c,d,e,f,g){return(b-d)*(e-c)+(c-a)*(f-d)>=0===g},b.initDefaultShaders=function(){},b.CompileVertexShader=function(a,c){return b._CompileShader(a,c,a.VERTEX_SHADER)},b.CompileFragmentShader=function(a,c){return b._CompileShader(a,c,a.FRAGMENT_SHADER)},b._CompileShader=function(a,b,c){var d=b.join("\n"),e=a.createShader(c);return a.shaderSource(e,d),a.compileShader(e),a.getShaderParameter(e,a.COMPILE_STATUS)?e:(window.console.log(a.getShaderInfoLog(e)),null)},b.compileProgram=function(a,c,d){var e=b.CompileFragmentShader(a,d),f=b.CompileVertexShader(a,c),g=a.createProgram();return a.attachShader(g,f),a.attachShader(g,e),a.linkProgram(g),a.getProgramParameter(g,a.LINK_STATUS)||window.console.log("Could not initialise shaders"),g},b.PixiShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.textureCount=0,this.firstRun=!0,this.dirty=!0,this.attributes=[],this.init()},b.PixiShader.prototype.constructor=b.PixiShader,b.PixiShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc||b.PixiShader.defaultVertexSrc,this.fragmentSrc);a.useProgram(c),this.uSampler=a.getUniformLocation(c,"uSampler"),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.dimensions=a.getUniformLocation(c,"dimensions"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.aTextureCoord=a.getAttribLocation(c,"aTextureCoord"),this.colorAttribute=a.getAttribLocation(c,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute];for(var d in this.uniforms)this.uniforms[d].uniformLocation=a.getUniformLocation(c,d);this.initUniforms(),this.program=c},b.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var a,b=this.gl;for(var c in this.uniforms){a=this.uniforms[c];var d=a.type;"sampler2D"===d?(a._init=!1,null!==a.value&&this.initSampler2D(a)):"mat2"===d||"mat3"===d||"mat4"===d?(a.glMatrix=!0,a.glValueLength=1,"mat2"===d?a.glFunc=b.uniformMatrix2fv:"mat3"===d?a.glFunc=b.uniformMatrix3fv:"mat4"===d&&(a.glFunc=b.uniformMatrix4fv)):(a.glFunc=b["uniform"+d],a.glValueLength="2f"===d||"2i"===d?2:"3f"===d||"3i"===d?3:"4f"===d||"4i"===d?4:1)}},b.PixiShader.prototype.initSampler2D=function(a){if(a.value&&a.value.baseTexture&&a.value.baseTexture.hasLoaded){var b=this.gl;if(b.activeTexture(b["TEXTURE"+this.textureCount]),b.bindTexture(b.TEXTURE_2D,a.value.baseTexture._glTextures[b.id]),a.textureData){var c=a.textureData,d=c.magFilter?c.magFilter:b.LINEAR,e=c.minFilter?c.minFilter:b.LINEAR,f=c.wrapS?c.wrapS:b.CLAMP_TO_EDGE,g=c.wrapT?c.wrapT:b.CLAMP_TO_EDGE,h=c.luminance?b.LUMINANCE:b.RGBA;if(c.repeat&&(f=b.REPEAT,g=b.REPEAT),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,!!c.flipY),c.width){var i=c.width?c.width:512,j=c.height?c.height:2,k=c.border?c.border:0;b.texImage2D(b.TEXTURE_2D,0,h,i,j,k,h,b.UNSIGNED_BYTE,null)}else b.texImage2D(b.TEXTURE_2D,0,h,b.RGBA,b.UNSIGNED_BYTE,a.value.baseTexture.source);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,d),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,g)}b.uniform1i(a.uniformLocation,this.textureCount),a._init=!0,this.textureCount++}},b.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var a,c=this.gl;for(var d in this.uniforms)a=this.uniforms[d],1===a.glValueLength?a.glMatrix===!0?a.glFunc.call(c,a.uniformLocation,a.transpose,a.value):a.glFunc.call(c,a.uniformLocation,a.value):2===a.glValueLength?a.glFunc.call(c,a.uniformLocation,a.value.x,a.value.y):3===a.glValueLength?a.glFunc.call(c,a.uniformLocation,a.value.x,a.value.y,a.value.z):4===a.glValueLength?a.glFunc.call(c,a.uniformLocation,a.value.x,a.value.y,a.value.z,a.value.w):"sampler2D"===a.type&&(a._init?(c.activeTexture(c["TEXTURE"+this.textureCount]),a.value.baseTexture._dirty[c.id]?b.instances[c.id].updateTexture(a.value.baseTexture):c.bindTexture(c.TEXTURE_2D,a.value.baseTexture._glTextures[c.id]),c.uniform1i(a.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(a))},b.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},b.PixiShader.defaultVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"],b.PixiFastShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"],this.textureCount=0,this.init()},b.PixiFastShader.prototype.constructor=b.PixiFastShader,b.PixiFastShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.uSampler=a.getUniformLocation(c,"uSampler"),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.dimensions=a.getUniformLocation(c,"dimensions"),this.uMatrix=a.getUniformLocation(c,"uMatrix"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.aPositionCoord=a.getAttribLocation(c,"aPositionCoord"),this.aScale=a.getAttribLocation(c,"aScale"),this.aRotation=a.getAttribLocation(c,"aRotation"),this.aTextureCoord=a.getAttribLocation(c,"aTextureCoord"),this.colorAttribute=a.getAttribLocation(c,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute],this.program=c},b.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},b.StripShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * alpha;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;","}"],this.init()},b.StripShader.prototype.constructor=b.StripShader,b.StripShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.uSampler=a.getUniformLocation(c,"uSampler"),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.colorAttribute=a.getAttribLocation(c,"aColor"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.aTextureCoord=a.getAttribLocation(c,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord],this.translationMatrix=a.getUniformLocation(c,"translationMatrix"),this.alpha=a.getUniformLocation(c,"alpha"),this.program=c},b.StripShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},b.PrimitiveShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},b.PrimitiveShader.prototype.constructor=b.PrimitiveShader,b.PrimitiveShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.tintColor=a.getUniformLocation(c,"tint"),this.flipY=a.getUniformLocation(c,"flipY"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.colorAttribute=a.getAttribLocation(c,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=a.getUniformLocation(c,"translationMatrix"),this.alpha=a.getUniformLocation(c,"alpha"),this.program=c},b.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},b.ComplexPrimitiveShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"],this.init()},b.ComplexPrimitiveShader.prototype.constructor=b.ComplexPrimitiveShader,b.ComplexPrimitiveShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.tintColor=a.getUniformLocation(c,"tint"),this.color=a.getUniformLocation(c,"color"),this.flipY=a.getUniformLocation(c,"flipY"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=a.getUniformLocation(c,"translationMatrix"),this.alpha=a.getUniformLocation(c,"alpha"),this.program=c},b.ComplexPrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},b.WebGLGraphics=function(){},b.WebGLGraphics.renderGraphics=function(a,c){var d,e=c.gl,f=c.projection,g=c.offset,h=c.shaderManager.primitiveShader;a.dirty&&b.WebGLGraphics.updateGraphics(a,e);for(var i=a._webGL[e.id],j=0;j=6)if(h.points.length<12){g=b.WebGLGraphics.switchMode(d,0);var i=b.WebGLGraphics.buildPoly(h,g);i||(g=b.WebGLGraphics.switchMode(d,1),b.WebGLGraphics.buildComplexPoly(h,g))}else g=b.WebGLGraphics.switchMode(d,1),b.WebGLGraphics.buildComplexPoly(h,g);h.lineWidth>0&&(g=b.WebGLGraphics.switchMode(d,0),b.WebGLGraphics.buildLine(h,g))}else g=b.WebGLGraphics.switchMode(d,0),h.type===b.Graphics.RECT?b.WebGLGraphics.buildRectangle(h,g):h.type===b.Graphics.CIRC||h.type===b.Graphics.ELIP?b.WebGLGraphics.buildCircle(h,g):h.type===b.Graphics.RREC&&b.WebGLGraphics.buildRoundedRectangle(h,g);d.lastIndex++}for(e=0;e=q;q++)p=q/n,h=g(a,c,p),i=g(b,d,p),j=g(c,e,p),k=g(d,f,p),l=g(h,j,p),m=g(i,k,p),o.push(l,m);return o},b.WebGLGraphics.buildCircle=function(a,c){var d,e,f=a.shape,g=f.x,h=f.y;a.type===b.Graphics.CIRC?(d=f.radius,e=f.radius):(d=f.width,e=f.height);var i=40,j=2*Math.PI/i,k=0;if(a.fill){var l=b.hex2rgb(a.fillColor),m=a.fillAlpha,n=l[0]*m,o=l[1]*m,p=l[2]*m,q=c.points,r=c.indices,s=q.length/6;for(r.push(s),k=0;i+1>k;k++)q.push(g,h,n,o,p,m),q.push(g+Math.sin(j*k)*d,h+Math.cos(j*k)*e,n,o,p,m),r.push(s++,s++);r.push(s-1)
+}if(a.lineWidth){var t=a.points;for(a.points=[],k=0;i+1>k;k++)a.points.push(g+Math.sin(j*k)*d,h+Math.cos(j*k)*e);b.WebGLGraphics.buildLine(a,c),a.points=t}},b.WebGLGraphics.buildLine=function(a,c){var d=0,e=a.points;if(0!==e.length){if(a.lineWidth%2)for(d=0;dd;d++)l=e[2*(d-1)],m=e[2*(d-1)+1],n=e[2*d],o=e[2*d+1],p=e[2*(d+1)],q=e[2*(d+1)+1],r=-(m-o),s=l-n,F=Math.sqrt(r*r+s*s),r/=F,s/=F,r*=L,s*=L,t=-(o-q),u=n-p,F=Math.sqrt(t*t+u*u),t/=F,u/=F,t*=L,u*=L,x=-s+m-(-s+o),y=-r+n-(-r+l),z=(-r+l)*(-s+o)-(-r+n)*(-s+m),A=-u+q-(-u+o),B=-t+n-(-t+p),C=(-t+p)*(-u+o)-(-t+n)*(-u+q),D=x*B-A*y,Math.abs(D)<.1?(D+=10.1,G.push(n-r,o-s,O,P,Q,N),G.push(n+r,o+s,O,P,Q,N)):(j=(y*C-B*z)/D,k=(A*z-x*C)/D,E=(j-n)*(j-n)+(k-o)+(k-o),E>19600?(v=r-t,w=s-u,F=Math.sqrt(v*v+w*w),v/=F,w/=F,v*=L,w*=L,G.push(n-v,o-w),G.push(O,P,Q,N),G.push(n+v,o+w),G.push(O,P,Q,N),G.push(n-v,o-w),G.push(O,P,Q,N),J++):(G.push(j,k),G.push(O,P,Q,N),G.push(n-(j-n),o-(k-o)),G.push(O,P,Q,N)));for(l=e[2*(I-2)],m=e[2*(I-2)+1],n=e[2*(I-1)],o=e[2*(I-1)+1],r=-(m-o),s=l-n,F=Math.sqrt(r*r+s*s),r/=F,s/=F,r*=L,s*=L,G.push(n-r,o-s),G.push(O,P,Q,N),G.push(n+r,o+s),G.push(O,P,Q,N),H.push(K),d=0;J>d;d++)H.push(K++);H.push(K-1)}},b.WebGLGraphics.buildComplexPoly=function(a,c){var d=a.points.slice();if(!(d.length<6)){var e=c.indices;c.points=d,c.alpha=a.fillAlpha,c.color=b.hex2rgb(a.fillColor);for(var f,g,h=1/0,i=-1/0,j=1/0,k=-1/0,l=0;lf?f:h,i=f>i?f:i,j=j>g?g:j,k=g>k?g:k;d.push(h,j,i,j,i,k,h,k);var m=d.length/2;for(l=0;m>l;l++)e.push(l)}},b.WebGLGraphics.buildPoly=function(a,c){var d=a.points;if(!(d.length<6)){var e=c.points,f=c.indices,g=d.length/2,h=b.hex2rgb(a.fillColor),i=a.fillAlpha,j=h[0]*i,k=h[1]*i,l=h[2]*i,m=b.PolyK.Triangulate(d);if(!m)return!1;var n=e.length/6,o=0;for(o=0;oo;o++)e.push(d[2*o],d[2*o+1],j,k,l,i);return!0}},b.WebGLGraphics.graphicsDataPool=[],b.WebGLGraphicsData=function(a){this.gl=a,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0},b.WebGLGraphicsData.prototype.reset=function(){this.points=[],this.indices=[]},b.WebGLGraphicsData.prototype.upload=function(){var a=this.gl;this.glPoints=new b.Float32Array(this.points),a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.bufferData(a.ARRAY_BUFFER,this.glPoints,a.STATIC_DRAW),this.glIndicies=new b.Uint16Array(this.indices),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.glIndicies,a.STATIC_DRAW),this.dirty=!1},b.glContexts=[],b.instances=[],b.WebGLRenderer=function(a,c,d){if(d)for(var e in b.defaultRenderOptions)"undefined"==typeof d[e]&&(d[e]=b.defaultRenderOptions[e]);else d=b.defaultRenderOptions;b.defaultRenderer||(b.sayHello("webGL"),b.defaultRenderer=this),this.type=b.WEBGL_RENDERER,this.resolution=d.resolution,this.transparent=d.transparent,this.autoResize=d.autoResize||!1,this.preserveDrawingBuffer=d.preserveDrawingBuffer,this.clearBeforeRender=d.clearBeforeRender,this.width=a||800,this.height=c||600,this.view=d.view||document.createElement("canvas"),this.contextLostBound=this.handleContextLost.bind(this),this.contextRestoredBound=this.handleContextRestored.bind(this),this.view.addEventListener("webglcontextlost",this.contextLostBound,!1),this.view.addEventListener("webglcontextrestored",this.contextRestoredBound,!1),this._contextOptions={alpha:this.transparent,antialias:d.antialias,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:d.preserveDrawingBuffer},this.projection=new b.Point,this.offset=new b.Point(0,0),this.shaderManager=new b.WebGLShaderManager,this.spriteBatch=new b.WebGLSpriteBatch,this.maskManager=new b.WebGLMaskManager,this.filterManager=new b.WebGLFilterManager,this.stencilManager=new b.WebGLStencilManager,this.blendModeManager=new b.WebGLBlendModeManager,this.renderSession={},this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=this.maskManager,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,this.renderSession.renderer=this,this.renderSession.resolution=this.resolution,this.initContext(),this.mapBlendModes()},b.WebGLRenderer.prototype.constructor=b.WebGLRenderer,b.WebGLRenderer.prototype.initContext=function(){var a=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=a,!a)throw new Error("This browser does not support webGL. Try using the canvas renderer");this.glContextId=a.id=b.WebGLRenderer.glContextId++,b.glContexts[this.glContextId]=a,b.instances[this.glContextId]=this,a.disable(a.DEPTH_TEST),a.disable(a.CULL_FACE),a.enable(a.BLEND),this.shaderManager.setContext(a),this.spriteBatch.setContext(a),this.maskManager.setContext(a),this.filterManager.setContext(a),this.blendModeManager.setContext(a),this.stencilManager.setContext(a),this.renderSession.gl=this.gl,this.resize(this.width,this.height)},b.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){this.__stage!==a&&(a.interactive&&a.interactionManager.removeEvents(),this.__stage=a),a.updateTransform();var b=this.gl;a._interactive?a._interactiveEventsAdded||(a._interactiveEventsAdded=!0,a.interactionManager.setTarget(this)):a._interactiveEventsAdded&&(a._interactiveEventsAdded=!1,a.interactionManager.setTarget(this)),b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),this.clearBeforeRender&&(this.transparent?b.clearColor(0,0,0,0):b.clearColor(a.backgroundColorSplit[0],a.backgroundColorSplit[1],a.backgroundColorSplit[2],1),b.clear(b.COLOR_BUFFER_BIT)),this.renderDisplayObject(a,this.projection)}},b.WebGLRenderer.prototype.renderDisplayObject=function(a,c,d){this.renderSession.blendModeManager.setBlendMode(b.blendModes.NORMAL),this.renderSession.drawCount=0,this.renderSession.flipY=d?-1:1,this.renderSession.projection=c,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,d),a._renderWebGL(this.renderSession),this.spriteBatch.end()},b.WebGLRenderer.prototype.resize=function(a,b){this.width=a*this.resolution,this.height=b*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2/this.resolution,this.projection.y=-this.height/2/this.resolution},b.WebGLRenderer.prototype.updateTexture=function(a){if(a.hasLoaded){var c=this.gl;return a._glTextures[c.id]||(a._glTextures[c.id]=c.createTexture()),c.bindTexture(c.TEXTURE_2D,a._glTextures[c.id]),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultipliedAlpha),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a.source),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR:c.NEAREST),a.mipmap&&b.isPowerOfTwo(a.width,a.height)?(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR_MIPMAP_LINEAR:c.NEAREST_MIPMAP_NEAREST),c.generateMipmap(c.TEXTURE_2D)):c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR:c.NEAREST),a._powerOf2?(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.REPEAT),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.REPEAT)):(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE)),a._dirty[c.id]=!1,a._glTextures[c.id]}},b.WebGLRenderer.prototype.handleContextLost=function(a){a.preventDefault(),this.contextLost=!0},b.WebGLRenderer.prototype.handleContextRestored=function(){this.initContext();for(var a in b.TextureCache){var c=b.TextureCache[a].baseTexture;c._glTextures=[]}this.contextLost=!1},b.WebGLRenderer.prototype.destroy=function(){this.view.removeEventListener("webglcontextlost",this.contextLostBound),this.view.removeEventListener("webglcontextrestored",this.contextRestoredBound),b.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null},b.WebGLRenderer.prototype.mapBlendModes=function(){var a=this.gl;b.blendModesWebGL||(b.blendModesWebGL=[],b.blendModesWebGL[b.blendModes.NORMAL]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.ADD]=[a.SRC_ALPHA,a.DST_ALPHA],b.blendModesWebGL[b.blendModes.MULTIPLY]=[a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.SCREEN]=[a.SRC_ALPHA,a.ONE],b.blendModesWebGL[b.blendModes.OVERLAY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.DARKEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.LIGHTEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.COLOR_DODGE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.COLOR_BURN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.HARD_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.SOFT_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.DIFFERENCE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.EXCLUSION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.HUE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.SATURATION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.COLOR]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL[b.blendModes.LUMINOSITY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA])},b.WebGLRenderer.glContextId=0,b.WebGLBlendModeManager=function(){this.currentBlendMode=99999},b.WebGLBlendModeManager.prototype.constructor=b.WebGLBlendModeManager,b.WebGLBlendModeManager.prototype.setContext=function(a){this.gl=a},b.WebGLBlendModeManager.prototype.setBlendMode=function(a){if(this.currentBlendMode===a)return!1;this.currentBlendMode=a;var c=b.blendModesWebGL[this.currentBlendMode];return this.gl.blendFunc(c[0],c[1]),!0},b.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null},b.WebGLMaskManager=function(){},b.WebGLMaskManager.prototype.constructor=b.WebGLMaskManager,b.WebGLMaskManager.prototype.setContext=function(a){this.gl=a},b.WebGLMaskManager.prototype.pushMask=function(a,c){var d=c.gl;a.dirty&&b.WebGLGraphics.updateGraphics(a,d),a._webGL[d.id].data.length&&c.stencilManager.pushStencil(a,a._webGL[d.id].data[0],c)},b.WebGLMaskManager.prototype.popMask=function(a,b){var c=this.gl;b.stencilManager.popStencil(a,a._webGL[c.id].data[0],b)},b.WebGLMaskManager.prototype.destroy=function(){this.gl=null},b.WebGLStencilManager=function(){this.stencilStack=[],this.reverse=!0,this.count=0},b.WebGLStencilManager.prototype.setContext=function(a){this.gl=a},b.WebGLStencilManager.prototype.pushStencil=function(a,b,c){var d=this.gl;this.bindGraphics(a,b,c),0===this.stencilStack.length&&(d.enable(d.STENCIL_TEST),d.clear(d.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(b);var e=this.count;d.colorMask(!1,!1,!1,!1),d.stencilFunc(d.ALWAYS,0,255),d.stencilOp(d.KEEP,d.KEEP,d.INVERT),1===b.mode?(d.drawElements(d.TRIANGLE_FAN,b.indices.length-4,d.UNSIGNED_SHORT,0),this.reverse?(d.stencilFunc(d.EQUAL,255-e,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)):(d.stencilFunc(d.EQUAL,e,255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(b.indices.length-4)),this.reverse?d.stencilFunc(d.EQUAL,255-(e+1),255):d.stencilFunc(d.EQUAL,e+1,255),this.reverse=!this.reverse):(this.reverse?(d.stencilFunc(d.EQUAL,e,255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)):(d.stencilFunc(d.EQUAL,255-e,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)),d.drawElements(d.TRIANGLE_STRIP,b.indices.length,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL,e+1,255):d.stencilFunc(d.EQUAL,255-(e+1),255)),d.colorMask(!0,!0,!0,!0),d.stencilOp(d.KEEP,d.KEEP,d.KEEP),this.count++},b.WebGLStencilManager.prototype.bindGraphics=function(a,c,d){this._currentGraphics=a;var e,f=this.gl,g=d.projection,h=d.offset;1===c.mode?(e=d.shaderManager.complexPrimitiveShader,d.shaderManager.setShader(e),f.uniform1f(e.flipY,d.flipY),f.uniformMatrix3fv(e.translationMatrix,!1,a.worldTransform.toArray(!0)),f.uniform2f(e.projectionVector,g.x,-g.y),f.uniform2f(e.offsetVector,-h.x,-h.y),f.uniform3fv(e.tintColor,b.hex2rgb(a.tint)),f.uniform3fv(e.color,c.color),f.uniform1f(e.alpha,a.worldAlpha*c.alpha),f.bindBuffer(f.ARRAY_BUFFER,c.buffer),f.vertexAttribPointer(e.aVertexPosition,2,f.FLOAT,!1,8,0),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,c.indexBuffer)):(e=d.shaderManager.primitiveShader,d.shaderManager.setShader(e),f.uniformMatrix3fv(e.translationMatrix,!1,a.worldTransform.toArray(!0)),f.uniform1f(e.flipY,d.flipY),f.uniform2f(e.projectionVector,g.x,-g.y),f.uniform2f(e.offsetVector,-h.x,-h.y),f.uniform3fv(e.tintColor,b.hex2rgb(a.tint)),f.uniform1f(e.alpha,a.worldAlpha),f.bindBuffer(f.ARRAY_BUFFER,c.buffer),f.vertexAttribPointer(e.aVertexPosition,2,f.FLOAT,!1,24,0),f.vertexAttribPointer(e.colorAttribute,4,f.FLOAT,!1,24,8),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,c.indexBuffer))},b.WebGLStencilManager.prototype.popStencil=function(a,b,c){var d=this.gl;if(this.stencilStack.pop(),this.count--,0===this.stencilStack.length)d.disable(d.STENCIL_TEST);else{var e=this.count;this.bindGraphics(a,b,c),d.colorMask(!1,!1,!1,!1),1===b.mode?(this.reverse=!this.reverse,this.reverse?(d.stencilFunc(d.EQUAL,255-(e+1),255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)):(d.stencilFunc(d.EQUAL,e+1,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(b.indices.length-4)),d.stencilFunc(d.ALWAYS,0,255),d.stencilOp(d.KEEP,d.KEEP,d.INVERT),d.drawElements(d.TRIANGLE_FAN,b.indices.length-4,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL,e,255):d.stencilFunc(d.EQUAL,255-e,255)):(this.reverse?(d.stencilFunc(d.EQUAL,e+1,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)):(d.stencilFunc(d.EQUAL,255-(e+1),255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)),d.drawElements(d.TRIANGLE_STRIP,b.indices.length,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL,e,255):d.stencilFunc(d.EQUAL,255-e,255)),d.colorMask(!0,!0,!0,!0),d.stencilOp(d.KEEP,d.KEEP,d.KEEP)}},b.WebGLStencilManager.prototype.destroy=function(){this.stencilStack=null,this.gl=null},b.WebGLShaderManager=function(){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var a=0;ad;d+=6,e+=4)this.indices[d+0]=e+0,this.indices[d+1]=e+1,this.indices[d+2]=e+2,this.indices[d+3]=e+0,this.indices[d+4]=e+2,this.indices[d+5]=e+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.dirty=!0,this.textures=[],this.blendModes=[],this.shaders=[],this.sprites=[],this.defaultShader=new b.AbstractFilter(["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"])},b.WebGLSpriteBatch.prototype.setContext=function(a){this.gl=a,this.vertexBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertices,a.DYNAMIC_DRAW),this.currentBlendMode=99999;var c=new b.PixiShader(a);c.fragmentSrc=this.defaultShader.fragmentSrc,c.uniforms={},c.init(),this.defaultShader.shaders[a.id]=c},b.WebGLSpriteBatch.prototype.begin=function(a){this.renderSession=a,this.shader=this.renderSession.shaderManager.defaultShader,this.start()},b.WebGLSpriteBatch.prototype.end=function(){this.flush()},b.WebGLSpriteBatch.prototype.render=function(a){var b=a.texture;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=b.baseTexture);var c=b._uvs;if(c){var d,e,f,g,h=a.anchor.x,i=a.anchor.y;if(b.trim){var j=b.trim;e=j.x-h*j.width,d=e+b.crop.width,g=j.y-i*j.height,f=g+b.crop.height}else d=b.frame.width*(1-h),e=b.frame.width*-h,f=b.frame.height*(1-i),g=b.frame.height*-i;var k=4*this.currentBatchSize*this.vertSize,l=b.baseTexture.resolution,m=a.worldTransform,n=m.a/l,o=m.b/l,p=m.c/l,q=m.d/l,r=m.tx,s=m.ty,t=this.colors,u=this.positions;this.renderSession.roundPixels?(u[k]=n*e+p*g+r|0,u[k+1]=q*g+o*e+s|0,u[k+5]=n*d+p*g+r|0,u[k+6]=q*g+o*d+s|0,u[k+10]=n*d+p*f+r|0,u[k+11]=q*f+o*d+s|0,u[k+15]=n*e+p*f+r|0,u[k+16]=q*f+o*e+s|0):(u[k]=n*e+p*g+r,u[k+1]=q*g+o*e+s,u[k+5]=n*d+p*g+r,u[k+6]=q*g+o*d+s,u[k+10]=n*d+p*f+r,u[k+11]=q*f+o*d+s,u[k+15]=n*e+p*f+r,u[k+16]=q*f+o*e+s),u[k+2]=c.x0,u[k+3]=c.y0,u[k+7]=c.x1,u[k+8]=c.y1,u[k+12]=c.x2,u[k+13]=c.y2,u[k+17]=c.x3,u[k+18]=c.y3;var v=a.tint;t[k+4]=t[k+9]=t[k+14]=t[k+19]=(v>>16)+(65280&v)+((255&v)<<16)+(255*a.worldAlpha<<24),this.sprites[this.currentBatchSize++]=a}},b.WebGLSpriteBatch.prototype.renderTilingSprite=function(a){var c=a.tilingTexture;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=c.baseTexture),a._uvs||(a._uvs=new b.TextureUvs);var d=a._uvs;a.tilePosition.x%=c.baseTexture.width*a.tileScaleOffset.x,a.tilePosition.y%=c.baseTexture.height*a.tileScaleOffset.y;var e=a.tilePosition.x/(c.baseTexture.width*a.tileScaleOffset.x),f=a.tilePosition.y/(c.baseTexture.height*a.tileScaleOffset.y),g=a.width/c.baseTexture.width/(a.tileScale.x*a.tileScaleOffset.x),h=a.height/c.baseTexture.height/(a.tileScale.y*a.tileScaleOffset.y);d.x0=0-e,d.y0=0-f,d.x1=1*g-e,d.y1=0-f,d.x2=1*g-e,d.y2=1*h-f,d.x3=0-e,d.y3=1*h-f;var i=a.tint,j=(i>>16)+(65280&i)+((255&i)<<16)+(255*a.alpha<<24),k=this.positions,l=this.colors,m=a.width,n=a.height,o=a.anchor.x,p=a.anchor.y,q=m*(1-o),r=m*-o,s=n*(1-p),t=n*-p,u=4*this.currentBatchSize*this.vertSize,v=c.baseTexture.resolution,w=a.worldTransform,x=w.a/v,y=w.b/v,z=w.c/v,A=w.d/v,B=w.tx,C=w.ty;k[u++]=x*r+z*t+B,k[u++]=A*t+y*r+C,k[u++]=d.x0,k[u++]=d.y0,l[u++]=j,k[u++]=x*q+z*t+B,k[u++]=A*t+y*q+C,k[u++]=d.x1,k[u++]=d.y1,l[u++]=j,k[u++]=x*q+z*s+B,k[u++]=A*s+y*q+C,k[u++]=d.x2,k[u++]=d.y2,l[u++]=j,k[u++]=x*r+z*s+B,k[u++]=A*s+y*r+C,k[u++]=d.x3,k[u++]=d.y3,l[u++]=j,this.sprites[this.currentBatchSize++]=a},b.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a,c=this.gl;if(this.dirty){this.dirty=!1,c.activeTexture(c.TEXTURE0),c.bindBuffer(c.ARRAY_BUFFER,this.vertexBuffer),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a=this.defaultShader.shaders[c.id];var d=4*this.vertSize;c.vertexAttribPointer(a.aVertexPosition,2,c.FLOAT,!1,d,0),c.vertexAttribPointer(a.aTextureCoord,2,c.FLOAT,!1,d,8),c.vertexAttribPointer(a.colorAttribute,4,c.UNSIGNED_BYTE,!0,d,16)}if(this.currentBatchSize>.5*this.size)c.bufferSubData(c.ARRAY_BUFFER,0,this.vertices);else{var e=this.positions.subarray(0,4*this.currentBatchSize*this.vertSize);c.bufferSubData(c.ARRAY_BUFFER,0,e)}for(var f,g,h,i,j=0,k=0,l=null,m=this.renderSession.blendModeManager.currentBlendMode,n=null,o=!1,p=!1,q=0,r=this.currentBatchSize;r>q;q++){if(i=this.sprites[q],f=i.texture.baseTexture,g=i.blendMode,h=i.shader||this.defaultShader,o=m!==g,p=n!==h,(l!==f||o||p)&&(this.renderBatch(l,j,k),k=q,j=0,l=f,o&&(m=g,this.renderSession.blendModeManager.setBlendMode(m)),p)){n=h,a=n.shaders[c.id],a||(a=new b.PixiShader(c),a.fragmentSrc=n.fragmentSrc,a.uniforms=n.uniforms,a.init(),n.shaders[c.id]=a),this.renderSession.shaderManager.setShader(a),a.dirty&&a.syncUniforms();var s=this.renderSession.projection;c.uniform2f(a.projectionVector,s.x,s.y);var t=this.renderSession.offset;c.uniform2f(a.offsetVector,t.x,t.y)}j++}this.renderBatch(l,j,k),this.currentBatchSize=0}},b.WebGLSpriteBatch.prototype.renderBatch=function(a,b,c){if(0!==b){var d=this.gl;a._dirty[d.id]?this.renderSession.renderer.updateTexture(a):d.bindTexture(d.TEXTURE_2D,a._glTextures[d.id]),d.drawElements(d.TRIANGLES,6*b,d.UNSIGNED_SHORT,6*c*2),this.renderSession.drawCount++}},b.WebGLSpriteBatch.prototype.stop=function(){this.flush(),this.dirty=!0},b.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},b.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},b.WebGLFastSpriteBatch=function(a){this.vertSize=10,this.maxSize=6e3,this.size=this.maxSize;var c=4*this.size*this.vertSize,d=6*this.maxSize;this.vertices=new b.Float32Array(c),this.indices=new b.Uint16Array(d),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var e=0,f=0;d>e;e+=6,f+=4)this.indices[e+0]=f+0,this.indices[e+1]=f+1,this.indices[e+2]=f+2,this.indices[e+3]=f+0,this.indices[e+4]=f+2,this.indices[e+5]=f+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.currentBlendMode=0,this.renderSession=null,this.shader=null,this.matrix=null,this.setContext(a)},b.WebGLFastSpriteBatch.prototype.constructor=b.WebGLFastSpriteBatch,b.WebGLFastSpriteBatch.prototype.setContext=function(a){this.gl=a,this.vertexBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertices,a.DYNAMIC_DRAW)},b.WebGLFastSpriteBatch.prototype.begin=function(a,b){this.renderSession=b,this.shader=this.renderSession.shaderManager.fastShader,this.matrix=a.worldTransform.toArray(!0),this.start()},b.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},b.WebGLFastSpriteBatch.prototype.render=function(a){var b=a.children,c=b[0];if(c.texture._uvs){this.currentBaseTexture=c.texture.baseTexture,c.blendMode!==this.renderSession.blendModeManager.currentBlendMode&&(this.flush(),this.renderSession.blendModeManager.setBlendMode(c.blendMode));for(var d=0,e=b.length;e>d;d++)this.renderSprite(b[d]);this.flush()}},b.WebGLFastSpriteBatch.prototype.renderSprite=function(a){if(a.visible&&(a.texture.baseTexture===this.currentBaseTexture||(this.flush(),this.currentBaseTexture=a.texture.baseTexture,a.texture._uvs))){var b,c,d,e,f,g,h,i,j=this.vertices;if(b=a.texture._uvs,c=a.texture.frame.width,d=a.texture.frame.height,a.texture.trim){var k=a.texture.trim;f=k.x-a.anchor.x*k.width,e=f+a.texture.crop.width,h=k.y-a.anchor.y*k.height,g=h+a.texture.crop.height}else e=a.texture.frame.width*(1-a.anchor.x),f=a.texture.frame.width*-a.anchor.x,g=a.texture.frame.height*(1-a.anchor.y),h=a.texture.frame.height*-a.anchor.y;i=4*this.currentBatchSize*this.vertSize,j[i++]=f,j[i++]=h,j[i++]=a.position.x,j[i++]=a.position.y,j[i++]=a.scale.x,j[i++]=a.scale.y,j[i++]=a.rotation,j[i++]=b.x0,j[i++]=b.y1,j[i++]=a.alpha,j[i++]=e,j[i++]=h,j[i++]=a.position.x,j[i++]=a.position.y,j[i++]=a.scale.x,j[i++]=a.scale.y,j[i++]=a.rotation,j[i++]=b.x1,j[i++]=b.y1,j[i++]=a.alpha,j[i++]=e,j[i++]=g,j[i++]=a.position.x,j[i++]=a.position.y,j[i++]=a.scale.x,j[i++]=a.scale.y,j[i++]=a.rotation,j[i++]=b.x2,j[i++]=b.y2,j[i++]=a.alpha,j[i++]=f,j[i++]=g,j[i++]=a.position.x,j[i++]=a.position.y,j[i++]=a.scale.x,j[i++]=a.scale.y,j[i++]=a.rotation,j[i++]=b.x3,j[i++]=b.y3,j[i++]=a.alpha,this.currentBatchSize++,this.currentBatchSize>=this.size&&this.flush()}},b.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a=this.gl;if(this.currentBaseTexture._glTextures[a.id]||this.renderSession.renderer.updateTexture(this.currentBaseTexture,a),a.bindTexture(a.TEXTURE_2D,this.currentBaseTexture._glTextures[a.id]),this.currentBatchSize>.5*this.size)a.bufferSubData(a.ARRAY_BUFFER,0,this.vertices);else{var b=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);a.bufferSubData(a.ARRAY_BUFFER,0,b)}a.drawElements(a.TRIANGLES,6*this.currentBatchSize,a.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}},b.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},b.WebGLFastSpriteBatch.prototype.start=function(){var a=this.gl;a.activeTexture(a.TEXTURE0),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var b=this.renderSession.projection;a.uniform2f(this.shader.projectionVector,b.x,b.y),a.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var c=4*this.vertSize;a.vertexAttribPointer(this.shader.aVertexPosition,2,a.FLOAT,!1,c,0),a.vertexAttribPointer(this.shader.aPositionCoord,2,a.FLOAT,!1,c,8),a.vertexAttribPointer(this.shader.aScale,2,a.FLOAT,!1,c,16),a.vertexAttribPointer(this.shader.aRotation,1,a.FLOAT,!1,c,24),a.vertexAttribPointer(this.shader.aTextureCoord,2,a.FLOAT,!1,c,28),a.vertexAttribPointer(this.shader.colorAttribute,1,a.FLOAT,!1,c,36)},b.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},b.WebGLFilterManager.prototype.constructor=b.WebGLFilterManager,b.WebGLFilterManager.prototype.setContext=function(a){this.gl=a,this.texturePool=[],this.initShaderBuffers()},b.WebGLFilterManager.prototype.begin=function(a,b){this.renderSession=a,this.defaultShader=a.shaderManager.defaultShader;var c=this.renderSession.projection;this.width=2*c.x,this.height=2*-c.y,this.buffer=b},b.WebGLFilterManager.prototype.pushFilter=function(a){var c=this.gl,d=this.renderSession.projection,e=this.renderSession.offset;a._filterArea=a.target.filterArea||a.target.getBounds(),this.filterStack.push(a);var f=a.filterPasses[0];this.offsetX+=a._filterArea.x,this.offsetY+=a._filterArea.y;var g=this.texturePool.pop();g?g.resize(this.width,this.height):g=new b.FilterTexture(this.gl,this.width,this.height),c.bindTexture(c.TEXTURE_2D,g.texture);var h=a._filterArea,i=f.padding;h.x-=i,h.y-=i,h.width+=2*i,h.height+=2*i,h.x<0&&(h.x=0),h.width>this.width&&(h.width=this.width),h.y<0&&(h.y=0),h.height>this.height&&(h.height=this.height),c.bindFramebuffer(c.FRAMEBUFFER,g.frameBuffer),c.viewport(0,0,h.width,h.height),d.x=h.width/2,d.y=-h.height/2,e.x=-h.x,e.y=-h.y,c.colorMask(!0,!0,!0,!0),c.clearColor(0,0,0,0),c.clear(c.COLOR_BUFFER_BIT),a._glFilterTexture=g},b.WebGLFilterManager.prototype.popFilter=function(){var a=this.gl,c=this.filterStack.pop(),d=c._filterArea,e=c._glFilterTexture,f=this.renderSession.projection,g=this.renderSession.offset;if(c.filterPasses.length>1){a.viewport(0,0,d.width,d.height),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=d.height,this.vertexArray[2]=d.width,this.vertexArray[3]=d.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=d.width,this.vertexArray[7]=0,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=d.width/this.width,this.uvArray[5]=d.height/this.height,this.uvArray[6]=d.width/this.width,this.uvArray[7]=d.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray);var h=e,i=this.texturePool.pop();i||(i=new b.FilterTexture(this.gl,this.width,this.height)),i.resize(this.width,this.height),a.bindFramebuffer(a.FRAMEBUFFER,i.frameBuffer),a.clear(a.COLOR_BUFFER_BIT),a.disable(a.BLEND);for(var j=0;jB?B:A,c.beginPath(),c.moveTo(w,x+A),c.lineTo(w,x+z-A),c.quadraticCurveTo(w,x+z,w+A,x+z),c.lineTo(w+y-A,x+z),c.quadraticCurveTo(w+y,x+z,w+y,x+z-A),c.lineTo(w+y,x+A),c.quadraticCurveTo(w+y,x,w+y-A,x),c.lineTo(w+A,x),c.quadraticCurveTo(w,x,w,x+A),c.closePath(),(f.fillColor||0===f.fillColor)&&(c.globalAlpha=f.fillAlpha*d,c.fillStyle="#"+("00000"+(0|h).toString(16)).substr(-6),c.fill()),f.lineWidth&&(c.globalAlpha=f.lineAlpha*d,c.strokeStyle="#"+("00000"+(0|i).toString(16)).substr(-6),c.stroke())}}},b.CanvasGraphics.renderGraphicsMask=function(a,c){var d=a.graphicsData.length;if(0!==d){d>1&&(d=1,window.console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));for(var e=0;1>e;e++){var f=a.graphicsData[e],g=f.shape;if(f.type===b.Graphics.POLY){c.beginPath();var h=g.points;c.moveTo(h[0],h[1]);for(var i=1;iA?A:z,c.beginPath(),c.moveTo(v,w+z),c.lineTo(v,w+y-z),c.quadraticCurveTo(v,w+y,v+z,w+y),c.lineTo(v+x-z,w+y),c.quadraticCurveTo(v+x,w+y,v+x,w+y-z),c.lineTo(v+x,w+z),c.quadraticCurveTo(v+x,w,v+x-z,w),c.lineTo(v+z,w),c.quadraticCurveTo(v,w,v,w+z),c.closePath()}}}},b.CanvasGraphics.updateGraphicsTint=function(a){if(16777215!==a.tint)for(var b=(a.tint>>16&255)/255,c=(a.tint>>8&255)/255,d=(255&a.tint)/255,e=0;e>16&255)/255*b*255<<16)+((g>>8&255)/255*c*255<<8)+(255&g)/255*d*255,f._lineTint=((h>>16&255)/255*b*255<<16)+((h>>8&255)/255*c*255<<8)+(255&h)/255*d*255}},b.Graphics=function(){b.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=b.blendModes.NORMAL,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new b.Rectangle(0,0,1,1),this.dirty=!0,this.webGLDirty=!1,this.cachedSpriteDirty=!1},b.Graphics.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Graphics.prototype.constructor=b.Graphics,Object.defineProperty(b.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(a){this._cacheAsBitmap=a,this._cacheAsBitmap?this._generateCachedSprite():(this.destroyCachedSprite(),this.dirty=!0)}}),b.Graphics.prototype.lineStyle=function(a,c,d){if(this.lineWidth=a||0,this.lineColor=c||0,this.lineAlpha=arguments.length<3?1:d,this.currentPath){if(this.currentPath.shape.points.length)return this.drawShape(new b.Polygon(this.currentPath.shape.points.slice(-2))),this;this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha}return this},b.Graphics.prototype.moveTo=function(a,c){return this.drawShape(new b.Polygon([a,c])),this},b.Graphics.prototype.lineTo=function(a,b){return this.currentPath.shape.points.push(a,b),this.dirty=!0,this},b.Graphics.prototype.quadraticCurveTo=function(a,b,c,d){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var e,f,g=20,h=this.currentPath.shape.points;0===h.length&&this.moveTo(0,0);for(var i=h[h.length-2],j=h[h.length-1],k=0,l=1;g>=l;l++)k=l/g,e=i+(a-i)*k,f=j+(b-j)*k,h.push(e+(a+(c-a)*k-e)*k,f+(b+(d-b)*k-f)*k);return this.dirty=!0,this},b.Graphics.prototype.bezierCurveTo=function(a,b,c,d,e,f){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var g,h,i,j,k,l=20,m=this.currentPath.shape.points,n=m[m.length-2],o=m[m.length-1],p=0,q=1;l>=q;q++)p=q/l,g=1-p,h=g*g,i=h*g,j=p*p,k=j*p,m.push(i*n+3*h*p*a+3*g*j*c+k*e,i*o+3*h*p*b+3*g*j*d+k*f);return this.dirty=!0,this},b.Graphics.prototype.arcTo=function(a,b,c,d,e){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(a,b):this.moveTo(a,b);var f=this.currentPath.shape.points,g=f[f.length-2],h=f[f.length-1],i=h-b,j=g-a,k=d-b,l=c-a,m=Math.abs(i*l-j*k);if(1e-8>m||0===e)(f[f.length-2]!==a||f[f.length-1]!==b)&&f.push(a,b);else{var n=i*i+j*j,o=k*k+l*l,p=i*k+j*l,q=e*Math.sqrt(n)/m,r=e*Math.sqrt(o)/m,s=q*p/n,t=r*p/o,u=q*l+r*j,v=q*k+r*i,w=j*(r+s),x=i*(r+s),y=l*(q+t),z=k*(q+t),A=Math.atan2(x-v,w-u),B=Math.atan2(z-v,y-u);this.arc(u+a,v+b,e,A,B,j*k>l*i)}return this.dirty=!0,this},b.Graphics.prototype.arc=function(a,b,c,d,e,f){var g,h=a+Math.cos(d)*c,i=b+Math.sin(d)*c;if(this.currentPath?(g=this.currentPath.shape.points,0===g.length?g.push(h,i):(g[g.length-2]!==h||g[g.length-1]!==i)&&g.push(h,i)):(this.moveTo(h,i),g=this.currentPath.shape.points),d===e)return this;!f&&d>=e?e+=2*Math.PI:f&&e>=d&&(d+=2*Math.PI);var j=f?-1*(d-e):e-d,k=Math.abs(j)/(2*Math.PI)*40;if(0===j)return this;for(var l=j/(2*k),m=2*l,n=Math.cos(l),o=Math.sin(l),p=k-1,q=p%1/p,r=0;p>=r;r++){var s=r+q*r,t=l+d+m*s,u=Math.cos(t),v=-Math.sin(t);g.push((n*u+o*v)*c+a,(n*-v+o*u)*c+b)}return this.dirty=!0,this},b.Graphics.prototype.beginFill=function(a,b){return this.filling=!0,this.fillColor=a||0,this.fillAlpha=void 0===b?1:b,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},b.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},b.Graphics.prototype.drawRect=function(a,c,d,e){return this.drawShape(new b.Rectangle(a,c,d,e)),this},b.Graphics.prototype.drawRoundedRect=function(a,c,d,e,f){return this.drawShape(new b.RoundedRectangle(a,c,d,e,f)),this},b.Graphics.prototype.drawCircle=function(a,c,d){return this.drawShape(new b.Circle(a,c,d)),this},b.Graphics.prototype.drawEllipse=function(a,c,d,e){return this.drawShape(new b.Ellipse(a,c,d,e)),this},b.Graphics.prototype.drawPolygon=function(a){return a instanceof Array||(a=Array.prototype.slice.call(arguments)),this.drawShape(new b.Polygon(a)),this},b.Graphics.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[],this},b.Graphics.prototype.generateTexture=function(a,c){a=a||1;var d=this.getBounds(),e=new b.CanvasBuffer(d.width*a,d.height*a),f=b.Texture.fromCanvas(e.canvas,c);return f.baseTexture.resolution=a,e.context.scale(a,a),e.context.translate(-d.x,-d.y),b.CanvasGraphics.renderGraphics(this,e.context),f},b.Graphics.prototype._renderWebGL=function(a){if(this.visible!==!1&&0!==this.alpha&&this.isMask!==!0){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,void b.Sprite.prototype._renderWebGL.call(this._cachedSprite,a);if(a.spriteBatch.stop(),a.blendModeManager.setBlendMode(this.blendMode),this._mask&&a.maskManager.pushMask(this._mask,a),this._filters&&a.filterManager.pushFilter(this._filterBlock),this.blendMode!==a.spriteBatch.currentBlendMode){a.spriteBatch.currentBlendMode=this.blendMode;var c=b.blendModesWebGL[a.spriteBatch.currentBlendMode];a.spriteBatch.gl.blendFunc(c[0],c[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),b.WebGLGraphics.renderGraphics(this,a),this.children.length){a.spriteBatch.start();for(var d=0,e=this.children.length;e>d;d++)this.children[d]._renderWebGL(a);a.spriteBatch.stop()}this._filters&&a.filterManager.popFilter(),this._mask&&a.maskManager.popMask(this.mask,a),a.drawCount++,a.spriteBatch.start()}},b.Graphics.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha&&this.isMask!==!0){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.alpha=this.alpha,void b.Sprite.prototype._renderCanvas.call(this._cachedSprite,a);var c=a.context,d=this.worldTransform;this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,c.globalCompositeOperation=b.blendModesCanvas[a.currentBlendMode]),this._mask&&a.maskManager.pushMask(this._mask,a);var e=a.resolution;c.setTransform(d.a*e,d.b*e,d.c*e,d.d*e,d.tx*e,d.ty*e),b.CanvasGraphics.renderGraphics(this,c);for(var f=0,g=this.children.length;g>f;f++)this.children[f]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},b.Graphics.prototype.getBounds=function(a){if(this.isMask)return b.EmptyRectangle;this.dirty&&(this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1);var c=this._localBounds,d=c.x,e=c.width+c.x,f=c.y,g=c.height+c.y,h=a||this.worldTransform,i=h.a,j=h.b,k=h.c,l=h.d,m=h.tx,n=h.ty,o=i*e+k*g+m,p=l*g+j*e+n,q=i*d+k*g+m,r=l*g+j*d+n,s=i*d+k*f+m,t=l*f+j*d+n,u=i*e+k*f+m,v=l*f+j*e+n,w=o,x=p,y=o,z=p;return y=y>q?q:y,y=y>s?s:y,y=y>u?u:y,z=z>r?r:z,z=z>t?t:z,z=z>v?v:z,w=q>w?q:w,w=s>w?s:w,w=u>w?u:w,x=r>x?r:x,x=t>x?t:x,x=v>x?v:x,this._bounds.x=y,this._bounds.width=w-y,this._bounds.y=z,this._bounds.height=x-z,this._bounds},b.Graphics.prototype.updateLocalBounds=function(){var a=1/0,c=-1/0,d=1/0,e=-1/0;if(this.graphicsData.length)for(var f,g,h,i,j,k,l=0;lh?h:a,c=h+j>c?h+j:c,d=d>i?i:d,e=i+k>e?i+k:e;else if(n===b.Graphics.CIRC)h=f.x,i=f.y,j=f.radius+o/2,k=f.radius+o/2,a=a>h-j?h-j:a,c=h+j>c?h+j:c,d=d>i-k?i-k:d,e=i+k>e?i+k:e;else if(n===b.Graphics.ELIP)h=f.x,i=f.y,j=f.width+o/2,k=f.height+o/2,a=a>h-j?h-j:a,c=h+j>c?h+j:c,d=d>i-k?i-k:d,e=i+k>e?i+k:e;else{g=f.points;for(var p=0;ph-o?h-o:a,c=h+o>c?h+o:c,d=d>i-o?i-o:d,e=i+o>e?i+o:e}}else a=0,c=0,d=0,e=0;var q=this.boundsPadding;this._localBounds.x=a-q,this._localBounds.width=c-a+2*q,this._localBounds.y=d-q,this._localBounds.height=e-d+2*q},b.Graphics.prototype._generateCachedSprite=function(){var a=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(a.width,a.height);else{var c=new b.CanvasBuffer(a.width,a.height),d=b.Texture.fromCanvas(c.canvas);this._cachedSprite=new b.Sprite(d),this._cachedSprite.buffer=c,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-(a.x/a.width),this._cachedSprite.anchor.y=-(a.y/a.height),this._cachedSprite.buffer.context.translate(-a.x,-a.y),this.worldAlpha=1,b.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},b.Graphics.prototype.updateCachedSpriteTexture=function(){var a=this._cachedSprite,b=a.texture,c=a.buffer.canvas;b.baseTexture.width=c.width,b.baseTexture.height=c.height,b.crop.width=b.frame.width=c.width,b.crop.height=b.frame.height=c.height,a._width=c.width,a._height=c.height,b.baseTexture.dirty()},b.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},b.Graphics.prototype.drawShape=function(a){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null;var c=new b.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,a);return this.graphicsData.push(c),c.type===b.Graphics.POLY&&(c.shape.closed=this.filling,this.currentPath=c),this.dirty=!0,c},b.GraphicsData=function(a,b,c,d,e,f,g){this.lineWidth=a,this.lineColor=b,this.lineAlpha=c,this._lineTint=b,this.fillColor=d,this.fillAlpha=e,this._fillTint=d,this.fill=f,this.shape=g,this.type=g.type},b.Graphics.POLY=0,b.Graphics.RECT=1,b.Graphics.CIRC=2,b.Graphics.ELIP=3,b.Graphics.RREC=4,b.Polygon.prototype.type=b.Graphics.POLY,b.Rectangle.prototype.type=b.Graphics.RECT,b.Circle.prototype.type=b.Graphics.CIRC,b.Ellipse.prototype.type=b.Graphics.ELIP,b.RoundedRectangle.prototype.type=b.Graphics.RREC,b.Strip=function(a){b.DisplayObjectContainer.call(this),this.texture=a,this.uvs=new b.Float32Array([0,1,1,1,1,0,0,1]),this.vertices=new b.Float32Array([0,0,100,0,100,100,0,100]),this.colors=new b.Float32Array([1,1,1,1]),this.indices=new b.Uint16Array([0,1,2,3]),this.dirty=!0,this.blendMode=b.blendModes.NORMAL,this.canvasPadding=0,this.drawMode=b.Strip.DrawModes.TRIANGLE_STRIP},b.Strip.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Strip.prototype.constructor=b.Strip,b.Strip.prototype._renderWebGL=function(a){!this.visible||this.alpha<=0||(a.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(a),a.shaderManager.setShader(a.shaderManager.stripShader),this._renderStrip(a),a.spriteBatch.start())},b.Strip.prototype._initWebGL=function(a){var b=a.gl;this._vertexBuffer=b.createBuffer(),this._indexBuffer=b.createBuffer(),this._uvBuffer=b.createBuffer(),this._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,this._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,this.vertices,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,this._uvBuffer),b.bufferData(b.ARRAY_BUFFER,this.uvs,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,this._colorBuffer),b.bufferData(b.ARRAY_BUFFER,this.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,this.indices,b.STATIC_DRAW)},b.Strip.prototype._renderStrip=function(a){var c=a.gl,d=a.projection,e=a.offset,f=a.shaderManager.stripShader,g=this.drawMode===b.Strip.DrawModes.TRIANGLE_STRIP?c.TRIANGLE_STRIP:c.TRIANGLES;a.blendModeManager.setBlendMode(this.blendMode),c.uniformMatrix3fv(f.translationMatrix,!1,this.worldTransform.toArray(!0)),c.uniform2f(f.projectionVector,d.x,-d.y),c.uniform2f(f.offsetVector,-e.x,-e.y),c.uniform1f(f.alpha,this.worldAlpha),this.dirty?(this.dirty=!1,c.bindBuffer(c.ARRAY_BUFFER,this._vertexBuffer),c.bufferData(c.ARRAY_BUFFER,this.vertices,c.STATIC_DRAW),c.vertexAttribPointer(f.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this._uvBuffer),c.bufferData(c.ARRAY_BUFFER,this.uvs,c.STATIC_DRAW),c.vertexAttribPointer(f.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),this.texture.baseTexture._dirty[c.id]?a.renderer.updateTexture(this.texture.baseTexture):c.bindTexture(c.TEXTURE_2D,this.texture.baseTexture._glTextures[c.id]),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this._indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,this.indices,c.STATIC_DRAW)):(c.bindBuffer(c.ARRAY_BUFFER,this._vertexBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,this.vertices),c.vertexAttribPointer(f.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this._uvBuffer),c.vertexAttribPointer(f.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),this.texture.baseTexture._dirty[c.id]?a.renderer.updateTexture(this.texture.baseTexture):c.bindTexture(c.TEXTURE_2D,this.texture.baseTexture._glTextures[c.id]),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),c.drawElements(g,this.indices.length,c.UNSIGNED_SHORT,0)},b.Strip.prototype._renderCanvas=function(a){var c=a.context,d=this.worldTransform;a.roundPixels?c.setTransform(d.a,d.b,d.c,d.d,0|d.tx,0|d.ty):c.setTransform(d.a,d.b,d.c,d.d,d.tx,d.ty),this.drawMode===b.Strip.DrawModes.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(c):this._renderCanvasTriangles(c)},b.Strip.prototype._renderCanvasTriangleStrip=function(a){var b=this.vertices,c=this.uvs,d=b.length/2;this.count++;for(var e=0;d-2>e;e++){var f=2*e;this._renderCanvasDrawTriangle(a,b,c,f,f+2,f+4)}},b.Strip.prototype._renderCanvasTriangles=function(a){var b=this.vertices,c=this.uvs,d=this.indices,e=d.length;this.count++;for(var f=0;e>f;f+=3){var g=2*d[f],h=2*d[f+1],i=2*d[f+2];this._renderCanvasDrawTriangle(a,b,c,g,h,i)}},b.Strip.prototype._renderCanvasDrawTriangle=function(a,b,c,d,e,f){var g=this.texture.baseTexture.source,h=this.texture.width,i=this.texture.height,j=b[d],k=b[e],l=b[f],m=b[d+1],n=b[e+1],o=b[f+1],p=c[d]*h,q=c[e]*h,r=c[f]*h,s=c[d+1]*i,t=c[e+1]*i,u=c[f+1]*i;if(this.canvasPadding>0){var v=this.canvasPadding/this.worldTransform.a,w=this.canvasPadding/this.worldTransform.d,x=(j+k+l)/3,y=(m+n+o)/3,z=j-x,A=m-y,B=Math.sqrt(z*z+A*A);j=x+z/B*(B+v),m=y+A/B*(B+w),z=k-x,A=n-y,B=Math.sqrt(z*z+A*A),k=x+z/B*(B+v),n=y+A/B*(B+w),z=l-x,A=o-y,B=Math.sqrt(z*z+A*A),l=x+z/B*(B+v),o=y+A/B*(B+w)}a.save(),a.beginPath(),a.moveTo(j,m),a.lineTo(k,n),a.lineTo(l,o),a.closePath(),a.clip();var C=p*t+s*r+q*u-t*r-s*q-p*u,D=j*t+s*l+k*u-t*l-s*k-j*u,E=p*k+j*r+q*l-k*r-j*q-p*l,F=p*t*l+s*k*r+j*q*u-j*t*r-s*q*l-p*k*u,G=m*t+s*o+n*u-t*o-s*n-m*u,H=p*n+m*r+q*o-n*r-m*q-p*o,I=p*t*o+s*n*r+m*q*u-m*t*r-s*q*o-p*n*u;a.transform(D/C,G/C,E/C,H/C,F/C,I/C),a.drawImage(g,0,0),a.restore()},b.Strip.prototype.renderStripFlat=function(a){var b=this.context,c=a.vertices,d=c.length/2;this.count++,b.beginPath();for(var e=1;d-2>e;e++){var f=2*e,g=c[f],h=c[f+2],i=c[f+4],j=c[f+1],k=c[f+3],l=c[f+5];b.moveTo(g,j),b.lineTo(h,k),b.lineTo(i,l)}b.fillStyle="#FF0000",b.fill(),b.closePath()},b.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},b.Strip.prototype.getBounds=function(a){for(var c=a||this.worldTransform,d=c.a,e=c.b,f=c.c,g=c.d,h=c.tx,i=c.ty,j=-1/0,k=-1/0,l=1/0,m=1/0,n=this.vertices,o=0,p=n.length;p>o;o+=2){var q=n[o],r=n[o+1],s=d*q+f*r+h,t=g*r+e*q+i;l=l>s?s:l,m=m>t?t:m,j=s>j?s:j,k=t>k?t:k}if(l===-1/0||1/0===k)return b.EmptyRectangle;var u=this._bounds;return u.x=l,u.width=j-l,u.y=m,u.height=k-m,this._currentBounds=u,u},b.Strip.DrawModes={TRIANGLE_STRIP:0,TRIANGLES:1},b.Rope=function(a,c){b.Strip.call(this,a),this.points=c,this.vertices=new b.Float32Array(4*c.length),this.uvs=new b.Float32Array(4*c.length),this.colors=new b.Float32Array(2*c.length),this.indices=new b.Uint16Array(2*c.length),this.refresh()},b.Rope.prototype=Object.create(b.Strip.prototype),b.Rope.prototype.constructor=b.Rope,b.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=a[0],d=this.indices,e=this.colors;this.count-=.2,b[0]=0,b[1]=0,b[2]=0,b[3]=1,e[0]=1,e[1]=1,d[0]=0,d[1]=1;for(var f,g,h,i=a.length,j=1;i>j;j++)f=a[j],g=4*j,h=j/(i-1),j%2?(b[g]=h,b[g+1]=0,b[g+2]=h,b[g+3]=1):(b[g]=h,b[g+1]=0,b[g+2]=h,b[g+3]=1),g=2*j,e[g]=1,e[g+1]=1,g=2*j,d[g]=g,d[g+1]=g+1,c=f}},b.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var c,d=a[0],e={x:0,y:0};this.count-=.2;for(var f,g,h,i,j,k=this.vertices,l=a.length,m=0;l>m;m++)f=a[m],g=4*m,c=m1&&(h=1),i=Math.sqrt(e.x*e.x+e.y*e.y),j=this.texture.height/2,e.x/=i,e.y/=i,e.x*=j,e.y*=j,k[g]=f.x+e.x,k[g+1]=f.y+e.y,k[g+2]=f.x-e.x,k[g+3]=f.y-e.y,d=f;b.DisplayObjectContainer.prototype.updateTransform.call(this)}},b.Rope.prototype.setTexture=function(a){this.texture=a},b.TilingSprite=function(a,c,d){b.Sprite.call(this,a),this._width=c||100,this._height=d||100,this.tileScale=new b.Point(1,1),this.tileScaleOffset=new b.Point(1,1),this.tilePosition=new b.Point(0,0),this.renderable=!0,this.tint=16777215,this.blendMode=b.blendModes.NORMAL},b.TilingSprite.prototype=Object.create(b.Sprite.prototype),b.TilingSprite.prototype.constructor=b.TilingSprite,Object.defineProperty(b.TilingSprite.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a}}),Object.defineProperty(b.TilingSprite.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a}}),b.TilingSprite.prototype.setTexture=function(a){this.texture!==a&&(this.texture=a,this.refreshTexture=!0,this.cachedTint=16777215)},b.TilingSprite.prototype._renderWebGL=function(a){if(this.visible!==!1&&0!==this.alpha){var b,c;for(this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),!this.tilingTexture||this.refreshTexture?(this.generateTilingTexture(!0),this.tilingTexture&&this.tilingTexture.needsUpdate&&(a.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)):a.spriteBatch.renderTilingSprite(this),b=0,c=this.children.length;c>b;b++)this.children[b]._renderWebGL(a);
+a.spriteBatch.stop(),this._filters&&a.filterManager.popFilter(),this._mask&&a.maskManager.popMask(this._mask,a),a.spriteBatch.start()}},b.TilingSprite.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha){var c=a.context;this._mask&&a.maskManager.pushMask(this._mask,a),c.globalAlpha=this.worldAlpha;var d,e,f=this.worldTransform,g=a.resolution;if(c.setTransform(f.a*g,f.b*g,f.c*g,f.d*g,f.tx*g,f.ty*g),!this.__tilePattern||this.refreshTexture){if(this.generateTilingTexture(!1),!this.tilingTexture)return;this.__tilePattern=c.createPattern(this.tilingTexture.baseTexture.source,"repeat")}this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,c.globalCompositeOperation=b.blendModesCanvas[a.currentBlendMode]);var h=this.tilePosition,i=this.tileScale;for(h.x%=this.tilingTexture.baseTexture.width,h.y%=this.tilingTexture.baseTexture.height,c.scale(i.x,i.y),c.translate(h.x+this.anchor.x*-this._width,h.y+this.anchor.y*-this._height),c.fillStyle=this.__tilePattern,c.fillRect(-h.x,-h.y,this._width/i.x,this._height/i.y),c.scale(1/i.x,1/i.y),c.translate(-h.x+this.anchor.x*this._width,-h.y+this.anchor.y*this._height),this._mask&&a.maskManager.popMask(a),d=0,e=this.children.length;e>d;d++)this.children[d]._renderCanvas(a)}},b.TilingSprite.prototype.getBounds=function(){var a=this._width,b=this._height,c=a*(1-this.anchor.x),d=a*-this.anchor.x,e=b*(1-this.anchor.y),f=b*-this.anchor.y,g=this.worldTransform,h=g.a,i=g.b,j=g.c,k=g.d,l=g.tx,m=g.ty,n=h*d+j*f+l,o=k*f+i*d+m,p=h*c+j*f+l,q=k*f+i*c+m,r=h*c+j*e+l,s=k*e+i*c+m,t=h*d+j*e+l,u=k*e+i*d+m,v=-1/0,w=-1/0,x=1/0,y=1/0;x=x>n?n:x,x=x>p?p:x,x=x>r?r:x,x=x>t?t:x,y=y>o?o:y,y=y>q?q:y,y=y>s?s:y,y=y>u?u:y,v=n>v?n:v,v=p>v?p:v,v=r>v?r:v,v=t>v?t:v,w=o>w?o:w,w=q>w?q:w,w=s>w?s:w,w=u>w?u:w;var z=this._bounds;return z.x=x,z.width=v-x,z.y=y,z.height=w-y,this._currentBounds=z,z},b.TilingSprite.prototype.onTextureUpdate=function(){},b.TilingSprite.prototype.generateTilingTexture=function(a){if(this.texture.baseTexture.hasLoaded){var c,d,e=this.originalTexture||this.texture,f=e.frame,g=f.width!==e.baseTexture.width||f.height!==e.baseTexture.height,h=!1;if(a?(c=b.getNextPowerOfTwo(f.width),d=b.getNextPowerOfTwo(f.height),(f.width!==c||f.height!==d||e.baseTexture.width!==c||e.baseTexture.height||d)&&(h=!0)):g&&(e.trim?(c=e.trim.width,d=e.trim.height):(c=f.width,d=f.height),h=!0),h){var i;this.tilingTexture&&this.tilingTexture.isTiling?(i=this.tilingTexture.canvasBuffer,i.resize(c,d),this.tilingTexture.baseTexture.width=c,this.tilingTexture.baseTexture.height=d,this.tilingTexture.needsUpdate=!0):(i=new b.CanvasBuffer(c,d),this.tilingTexture=b.Texture.fromCanvas(i.canvas),this.tilingTexture.canvasBuffer=i,this.tilingTexture.isTiling=!0),i.context.drawImage(e.baseTexture.source,e.crop.x,e.crop.y,e.crop.width,e.crop.height,0,0,c,d),this.tileScaleOffset.x=f.width/c,this.tileScaleOffset.y=f.height/d}else this.tilingTexture&&this.tilingTexture.isTiling&&this.tilingTexture.destroy(!0),this.tileScaleOffset.x=1,this.tileScaleOffset.y=1,this.tilingTexture=e;this.refreshTexture=!1,this.originalTexture=this.texture,this.texture=this.tilingTexture,this.tilingTexture.baseTexture._powerOf2=!0}},b.TilingSprite.prototype.destroy=function(){b.Sprite.prototype.destroy.call(this),this.tileScale=null,this.tileScaleOffset=null,this.tilePosition=null,this.tilingTexture.destroy(!0),this.tilingTexture=null};var c={radDeg:180/Math.PI,degRad:Math.PI/180,temp:[],Float32Array:"undefined"==typeof Float32Array?Array:Float32Array,Uint16Array:"undefined"==typeof Uint16Array?Array:Uint16Array};c.BoneData=function(a,b){this.name=a,this.parent=b},c.BoneData.prototype={length:0,x:0,y:0,rotation:0,scaleX:1,scaleY:1,inheritScale:!0,inheritRotation:!0,flipX:!1,flipY:!1},c.SlotData=function(a,b){this.name=a,this.boneData=b},c.SlotData.prototype={r:1,g:1,b:1,a:1,attachmentName:null,additiveBlending:!1},c.IkConstraintData=function(a){this.name=a,this.bones=[]},c.IkConstraintData.prototype={target:null,bendDirection:1,mix:1},c.Bone=function(a,b,c){this.data=a,this.skeleton=b,this.parent=c,this.setToSetupPose()},c.Bone.yDown=!1,c.Bone.prototype={x:0,y:0,rotation:0,rotationIK:0,scaleX:1,scaleY:1,flipX:!1,flipY:!1,m00:0,m01:0,worldX:0,m10:0,m11:0,worldY:0,worldRotation:0,worldScaleX:1,worldScaleY:1,worldFlipX:!1,worldFlipY:!1,updateWorldTransform:function(){var a=this.parent;if(a)this.worldX=this.x*a.m00+this.y*a.m01+a.worldX,this.worldY=this.x*a.m10+this.y*a.m11+a.worldY,this.data.inheritScale?(this.worldScaleX=a.worldScaleX*this.scaleX,this.worldScaleY=a.worldScaleY*this.scaleY):(this.worldScaleX=this.scaleX,this.worldScaleY=this.scaleY),this.worldRotation=this.data.inheritRotation?a.worldRotation+this.rotationIK:this.rotationIK,this.worldFlipX=a.worldFlipX!=this.flipX,this.worldFlipY=a.worldFlipY!=this.flipY;else{var b=this.skeleton.flipX,d=this.skeleton.flipY;this.worldX=b?-this.x:this.x,this.worldY=d!=c.Bone.yDown?-this.y:this.y,this.worldScaleX=this.scaleX,this.worldScaleY=this.scaleY,this.worldRotation=this.rotationIK,this.worldFlipX=b!=this.flipX,this.worldFlipY=d!=this.flipY}var e=this.worldRotation*c.degRad,f=Math.cos(e),g=Math.sin(e);this.worldFlipX?(this.m00=-f*this.worldScaleX,this.m01=g*this.worldScaleY):(this.m00=f*this.worldScaleX,this.m01=-g*this.worldScaleY),this.worldFlipY!=c.Bone.yDown?(this.m10=-g*this.worldScaleX,this.m11=-f*this.worldScaleY):(this.m10=g*this.worldScaleX,this.m11=f*this.worldScaleY)},setToSetupPose:function(){var a=this.data;this.x=a.x,this.y=a.y,this.rotation=a.rotation,this.rotationIK=this.rotation,this.scaleX=a.scaleX,this.scaleY=a.scaleY,this.flipX=a.flipX,this.flipY=a.flipY},worldToLocal:function(a){var b=a[0]-this.worldX,d=a[1]-this.worldY,e=this.m00,f=this.m10,g=this.m01,h=this.m11;this.worldFlipX!=(this.worldFlipY!=c.Bone.yDown)&&(e=-e,h=-h);var i=1/(e*h-g*f);a[0]=b*e*i-d*g*i,a[1]=d*h*i-b*f*i},localToWorld:function(a){var b=a[0],c=a[1];a[0]=b*this.m00+c*this.m01+this.worldX,a[1]=b*this.m10+c*this.m11+this.worldY}},c.Slot=function(a,b){this.data=a,this.bone=b,this.setToSetupPose()},c.Slot.prototype={r:1,g:1,b:1,a:1,_attachmentTime:0,attachment:null,attachmentVertices:[],setAttachment:function(a){this.attachment=a,this._attachmentTime=this.bone.skeleton.time,this.attachmentVertices.length=0},setAttachmentTime:function(a){this._attachmentTime=this.bone.skeleton.time-a},getAttachmentTime:function(){return this.bone.skeleton.time-this._attachmentTime},setToSetupPose:function(){var a=this.data;this.r=a.r,this.g=a.g,this.b=a.b,this.a=a.a;for(var b=this.bone.skeleton.data.slots,c=0,d=b.length;d>c;c++)if(b[c]==a){this.setAttachment(a.attachmentName?this.bone.skeleton.getAttachmentBySlotIndex(c,a.attachmentName):null);break}}},c.IkConstraint=function(a,b){this.data=a,this.mix=a.mix,this.bendDirection=a.bendDirection,this.bones=[];for(var c=0,d=a.bones.length;d>c;c++)this.bones.push(b.findBone(a.bones[c].name));this.target=b.findBone(a.target.name)},c.IkConstraint.prototype={apply:function(){var a=this.target,b=this.bones;switch(b.length){case 1:c.IkConstraint.apply1(b[0],a.worldX,a.worldY,this.mix);break;case 2:c.IkConstraint.apply2(b[0],b[1],a.worldX,a.worldY,this.bendDirection,this.mix)}}},c.IkConstraint.apply1=function(a,b,d,e){var f=a.data.inheritRotation&&a.parent?a.parent.worldRotation:0,g=a.rotation,h=Math.atan2(d-a.worldY,b-a.worldX)*c.radDeg-f;a.rotationIK=g+(h-g)*e},c.IkConstraint.apply2=function(a,b,d,e,f,g){var h=b.rotation,i=a.rotation;if(!g)return b.rotationIK=h,void(a.rotationIK=i);var j,k,l=c.temp,m=a.parent;m?(l[0]=d,l[1]=e,m.worldToLocal(l),d=(l[0]-a.x)*m.worldScaleX,e=(l[1]-a.y)*m.worldScaleY):(d-=a.x,e-=a.y),b.parent==a?(j=b.x,k=b.y):(l[0]=b.x,l[1]=b.y,b.parent.localToWorld(l),a.worldToLocal(l),j=l[0],k=l[1]);var n=j*a.worldScaleX,o=k*a.worldScaleY,p=Math.atan2(o,n),q=Math.sqrt(n*n+o*o),r=b.data.length*b.worldScaleX,s=2*q*r;if(1e-4>s)return void(b.rotationIK=h+(Math.atan2(e,d)*c.radDeg-i-h)*g);var t=(d*d+e*e-q*q-r*r)/s;-1>t?t=-1:t>1&&(t=1);var u=Math.acos(t)*f,v=q+r*t,w=r*Math.sin(u),x=Math.atan2(e*v-d*w,d*v+e*w),y=(x-p)*c.radDeg-i;y>180?y-=360:-180>y&&(y+=360),a.rotationIK=i+y*g,y=(u+p)*c.radDeg-h,y>180?y-=360:-180>y&&(y+=360),b.rotationIK=h+(y+a.worldRotation-b.parent.worldRotation)*g},c.Skin=function(a){this.name=a,this.attachments={}},c.Skin.prototype={addAttachment:function(a,b,c){this.attachments[a+":"+b]=c},getAttachment:function(a,b){return this.attachments[a+":"+b]},_attachAll:function(a,b){for(var c in b.attachments){var d=c.indexOf(":"),e=parseInt(c.substring(0,d)),f=c.substring(d+1),g=a.slots[e];if(g.attachment&&g.attachment.name==f){var h=this.getAttachment(e,f);h&&g.setAttachment(h)}}}},c.Animation=function(a,b,c){this.name=a,this.timelines=b,this.duration=c},c.Animation.prototype={apply:function(a,b,c,d,e){d&&0!=this.duration&&(c%=this.duration,b%=this.duration);for(var f=this.timelines,g=0,h=f.length;h>g;g++)f[g].apply(a,b,c,e,1)},mix:function(a,b,c,d,e,f){d&&0!=this.duration&&(c%=this.duration,b%=this.duration);for(var g=this.timelines,h=0,i=g.length;i>h;h++)g[h].apply(a,b,c,e,f)}},c.Animation.binarySearch=function(a,b,c){var d=0,e=Math.floor(a.length/c)-2;if(!e)return c;for(var f=e>>>1;;){if(a[(f+1)*c]<=b?d=f+1:e=f,d==e)return(d+1)*c;f=d+e>>>1}},c.Animation.binarySearch1=function(a,b){var c=0,d=a.length-2;if(!d)return 1;for(var e=d>>>1;;){if(a[e+1]<=b?c=e+1:d=e,c==d)return c+1;e=c+d>>>1}},c.Animation.linearSearch=function(a,b,c){for(var d=0,e=a.length-c;e>=d;d+=c)if(a[d]>b)return d;return-1},c.Curves=function(){this.curves=[]},c.Curves.prototype={setLinear:function(a){this.curves[19*a]=0},setStepped:function(a){this.curves[19*a]=1},setCurve:function(a,b,c,d,e){var f=.1,g=f*f,h=g*f,i=3*f,j=3*g,k=6*g,l=6*h,m=2*-b+d,n=2*-c+e,o=3*(b-d)+1,p=3*(c-e)+1,q=b*i+m*j+o*h,r=c*i+n*j+p*h,s=m*k+o*l,t=n*k+p*l,u=o*l,v=p*l,w=19*a,x=this.curves;x[w++]=2;for(var y=q,z=r,A=w+19-1;A>w;w+=2)x[w]=y,x[w+1]=z,q+=s,r+=t,s+=u,t+=v,y+=q,z+=r},getCurvePercent:function(a,b){b=0>b?0:b>1?1:b;var c=this.curves,d=19*a,e=c[d];if(0===e)return b;if(1==e)return 0;d++;for(var f=0,g=d,h=d+19-1;h>d;d+=2)if(f=c[d],f>=b){var i,j;return d==g?(i=0,j=0):(i=c[d-2],j=c[d-1]),j+(c[d+1]-j)*(b-i)/(f-i)}var k=c[d-1];return k+(1-k)*(b-f)/(1-f)}},c.RotateTimeline=function(a){this.curves=new c.Curves(a),this.frames=[],this.frames.length=2*a},c.RotateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(a,b,c){a*=2,this.frames[a]=b,this.frames[a+1]=c},apply:function(a,b,d,e,f){var g=this.frames;if(!(d=g[g.length-2]){for(var i=h.data.rotation+g[g.length-1]-h.rotation;i>180;)i-=360;for(;-180>i;)i+=360;return void(h.rotation+=i*f)}var j=c.Animation.binarySearch(g,d,2),k=g[j-1],l=g[j],m=1-(d-l)/(g[j-2]-l);m=this.curves.getCurvePercent(j/2-1,m);for(var i=g[j+1]-k;i>180;)i-=360;for(;-180>i;)i+=360;for(i=h.data.rotation+(k+i*m)-h.rotation;i>180;)i-=360;for(;-180>i;)i+=360;h.rotation+=i*f}}},c.TranslateTimeline=function(a){this.curves=new c.Curves(a),this.frames=[],this.frames.length=3*a},c.TranslateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(a,b,c,d){a*=3,this.frames[a]=b,this.frames[a+1]=c,this.frames[a+2]=d},apply:function(a,b,d,e,f){var g=this.frames;if(!(d=g[g.length-3])return h.x+=(h.data.x+g[g.length-2]-h.x)*f,void(h.y+=(h.data.y+g[g.length-1]-h.y)*f);var i=c.Animation.binarySearch(g,d,3),j=g[i-2],k=g[i-1],l=g[i],m=1-(d-l)/(g[i+-3]-l);m=this.curves.getCurvePercent(i/3-1,m),h.x+=(h.data.x+j+(g[i+1]-j)*m-h.x)*f,h.y+=(h.data.y+k+(g[i+2]-k)*m-h.y)*f}}},c.ScaleTimeline=function(a){this.curves=new c.Curves(a),this.frames=[],this.frames.length=3*a},c.ScaleTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(a,b,c,d){a*=3,this.frames[a]=b,this.frames[a+1]=c,this.frames[a+2]=d},apply:function(a,b,d,e,f){var g=this.frames;if(!(d=g[g.length-3])return h.scaleX+=(h.data.scaleX*g[g.length-2]-h.scaleX)*f,void(h.scaleY+=(h.data.scaleY*g[g.length-1]-h.scaleY)*f);var i=c.Animation.binarySearch(g,d,3),j=g[i-2],k=g[i-1],l=g[i],m=1-(d-l)/(g[i+-3]-l);m=this.curves.getCurvePercent(i/3-1,m),h.scaleX+=(h.data.scaleX*(j+(g[i+1]-j)*m)-h.scaleX)*f,h.scaleY+=(h.data.scaleY*(k+(g[i+2]-k)*m)-h.scaleY)*f}}},c.ColorTimeline=function(a){this.curves=new c.Curves(a),this.frames=[],this.frames.length=5*a},c.ColorTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length/5},setFrame:function(a,b,c,d,e,f){a*=5,this.frames[a]=b,this.frames[a+1]=c,this.frames[a+2]=d,this.frames[a+3]=e,this.frames[a+4]=f},apply:function(a,b,d,e,f){var g=this.frames;if(!(d=g[g.length-5]){var l=g.length-1;h=g[l-3],i=g[l-2],j=g[l-1],k=g[l]}else{var m=c.Animation.binarySearch(g,d,5),n=g[m-4],o=g[m-3],p=g[m-2],q=g[m-1],r=g[m],s=1-(d-r)/(g[m-5]-r);s=this.curves.getCurvePercent(m/5-1,s),h=n+(g[m+1]-n)*s,i=o+(g[m+2]-o)*s,j=p+(g[m+3]-p)*s,k=q+(g[m+4]-q)*s}var t=a.slots[this.slotIndex];1>f?(t.r+=(h-t.r)*f,t.g+=(i-t.g)*f,t.b+=(j-t.b)*f,t.a+=(k-t.a)*f):(t.r=h,t.g=i,t.b=j,t.a=k)}}},c.AttachmentTimeline=function(a){this.curves=new c.Curves(a),this.frames=[],this.frames.length=a,this.attachmentNames=[],this.attachmentNames.length=a},c.AttachmentTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length},setFrame:function(a,b,c){this.frames[a]=b,this.attachmentNames[a]=c},apply:function(a,b,d){var e=this.frames;if(dd&&this.apply(a,b,Number.MAX_VALUE,null,0));b>d&&(b=-1);var f=d>=e[e.length-1]?e.length-1:c.Animation.binarySearch1(e,d)-1;if(!(e[f]d)this.apply(a,b,Number.MAX_VALUE,e,f),b=-1;else if(b>=g[h-1])return;if(!(d0&&g[i-1]==j;)i--}for(var k=this.events;h>i&&d>=g[i];i++)e.push(k[i])}}}},c.DrawOrderTimeline=function(a){this.frames=[],this.frames.length=a,this.drawOrders=[],this.drawOrders.length=a},c.DrawOrderTimeline.prototype={getFrameCount:function(){return this.frames.length},setFrame:function(a,b,c){this.frames[a]=b,this.drawOrders[a]=c},apply:function(a,b,d){var e=this.frames;if(!(d=e[e.length-1]?e.length-1:c.Animation.binarySearch1(e,d)-1;var g=a.drawOrder,h=a.slots,i=this.drawOrders[f];if(i)for(var j=0,k=i.length;k>j;j++)g[j]=a.slots[i[j]];else for(var j=0,k=h.length;k>j;j++)g[j]=h[j]}}},c.FfdTimeline=function(a){this.curves=new c.Curves(a),this.frames=[],this.frames.length=a,this.frameVertices=[],this.frameVertices.length=a},c.FfdTimeline.prototype={slotIndex:0,attachment:0,getFrameCount:function(){return this.frames.length},setFrame:function(a,b,c){this.frames[a]=b,this.frameVertices[a]=c},apply:function(a,b,d,e,f){var g=a.slots[this.slotIndex];if(g.attachment==this.attachment){var h=this.frames;if(!(d=h[h.length-1]){var l=i[h.length-1];if(1>f)for(var m=0;j>m;m++)k[m]+=(l[m]-k[m])*f;else for(var m=0;j>m;m++)k[m]=l[m]}else{var n=c.Animation.binarySearch1(h,d),o=h[n],p=1-(d-o)/(h[n-1]-o);p=this.curves.getCurvePercent(n-1,0>p?0:p>1?1:p);var q=i[n-1],r=i[n];if(1>f)for(var m=0;j>m;m++){var s=q[m];k[m]+=(s+(r[m]-s)*p-k[m])*f}else for(var m=0;j>m;m++){var s=q[m];k[m]=s+(r[m]-s)*p}}}}}},c.IkConstraintTimeline=function(a){this.curves=new c.Curves(a),this.frames=[],this.frames.length=3*a},c.IkConstraintTimeline.prototype={ikConstraintIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(a,b,c,d){a*=3,this.frames[a]=b,this.frames[a+1]=c,this.frames[a+2]=d},apply:function(a,b,d,e,f){var g=this.frames;if(!(d=g[g.length-3])return h.mix+=(g[g.length-2]-h.mix)*f,void(h.bendDirection=g[g.length-1]);var i=c.Animation.binarySearch(g,d,3),j=g[i+-2],k=g[i],l=1-(d-k)/(g[i+-3]-k);l=this.curves.getCurvePercent(i/3-1,l);var m=j+(g[i+1]-j)*l;h.mix+=(m-h.mix)*f,h.bendDirection=g[i+-1]}}},c.FlipXTimeline=function(a){this.curves=new c.Curves(a),this.frames=[],this.frames.length=2*a},c.FlipXTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(a,b,c){a*=2,this.frames[a]=b,this.frames[a+1]=c?1:0},apply:function(a,b,d){var e=this.frames;if(dd&&this.apply(a,b,Number.MAX_VALUE,null,0));b>d&&(b=-1);var f=(d>=e[e.length-2]?e.length:c.Animation.binarySearch(e,d,2))-2;e[f]d&&this.apply(a,b,Number.MAX_VALUE,null,0));b>d&&(b=-1);var f=(d>=e[e.length-2]?e.length:c.Animation.binarySearch(e,d,2))-2;e[f]c;c++)if(b[c].name==a)return b[c];return null},findBoneIndex:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].name==a)return c;return-1},findSlot:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].name==a)return slot[c];return null},findSlotIndex:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].name==a)return c;return-1},findSkin:function(a){for(var b=this.skins,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},findEvent:function(a){for(var b=this.events,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},findAnimation:function(a){for(var b=this.animations,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},findIkConstraint:function(a){for(var b=this.ikConstraints,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null}},c.Skeleton=function(a){this.data=a,this.bones=[];for(var b=0,d=a.bones.length;d>b;b++){var e=a.bones[b],f=e.parent?this.bones[a.bones.indexOf(e.parent)]:null;this.bones.push(new c.Bone(e,this,f))}this.slots=[],this.drawOrder=[];for(var b=0,d=a.slots.length;d>b;b++){var g=a.slots[b],h=this.bones[a.bones.indexOf(g.boneData)],i=new c.Slot(g,h);this.slots.push(i),this.drawOrder.push(i)}this.ikConstraints=[];for(var b=0,d=a.ikConstraints.length;d>b;b++)this.ikConstraints.push(new c.IkConstraint(a.ikConstraints[b],this));this.boneCache=[],this.updateCache()},c.Skeleton.prototype={x:0,y:0,skin:null,r:1,g:1,b:1,a:1,time:0,flipX:!1,flipY:!1,updateCache:function(){var a=this.ikConstraints,b=a.length,c=b+1,d=this.boneCache;d.length>c&&(d.length=c);for(var e=0,f=d.length;f>e;e++)d[e].length=0;for(;d.lengthe;e++){var i=h[e],j=i;do{for(var k=0;b>k;k++)for(var l=a[k],m=l.bones[0],n=l.bones[l.bones.length-1];;){if(j==n){d[k].push(i),d[k+1].push(i);continue a}if(n==m)break;n=n.parent}j=j.parent}while(j);g[g.length]=i}},updateWorldTransform:function(){for(var a=this.bones,b=0,c=a.length;c>b;b++){var d=a[b];d.rotationIK=d.rotation}for(var b=0,e=this.boneCache.length-1;;){for(var f=this.boneCache[b],g=0,h=f.length;h>g;g++)f[g].updateWorldTransform();if(b==e)break;this.ikConstraints[b].apply(),b++}},setToSetupPose:function(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()},setBonesToSetupPose:function(){for(var a=this.bones,b=0,c=a.length;c>b;b++)a[b].setToSetupPose();for(var d=this.ikConstraints,b=0,c=d.length;c>b;b++){var e=d[b];e.bendDirection=e.data.bendDirection,e.mix=e.data.mix}},setSlotsToSetupPose:function(){for(var a=this.slots,b=this.drawOrder,c=0,d=a.length;d>c;c++)b[c]=a[c],a[c].setToSetupPose(c)},getRootBone:function(){return this.bones.length?this.bones[0]:null},findBone:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return b[c];return null},findBoneIndex:function(a){for(var b=this.bones,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return c;return-1},findSlot:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return b[c];return null},findSlotIndex:function(a){for(var b=this.slots,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return c;return-1},setSkinByName:function(a){var b=this.data.findSkin(a);if(!b)throw"Skin not found: "+a;this.setSkin(b)},setSkin:function(a){if(a)if(this.skin)a._attachAll(this,this.skin);else for(var b=this.slots,c=0,d=b.length;d>c;c++){var e=b[c],f=e.data.attachmentName;if(f){var g=a.getAttachment(c,f);g&&e.setAttachment(g)}}this.skin=a},getAttachmentBySlotName:function(a,b){return this.getAttachmentBySlotIndex(this.data.findSlotIndex(a),b)},getAttachmentBySlotIndex:function(a,b){if(this.skin){var c=this.skin.getAttachment(a,b);if(c)return c}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(a,b):null},setAttachment:function(a,b){for(var c=this.slots,d=0,e=c.length;e>d;d++){var f=c[d];if(f.data.name==a){var g=null;if(b&&(g=this.getAttachmentBySlotIndex(d,b),!g))throw"Attachment not found: "+b+", for slot: "+a;return void f.setAttachment(g)}}throw"Slot not found: "+a},findIkConstraint:function(a){for(var b=this.ikConstraints,c=0,d=b.length;d>c;c++)if(b[c].data.name==a)return b[c];return null},update:function(a){this.time+=a}},c.EventData=function(a){this.name=a},c.EventData.prototype={intValue:0,floatValue:0,stringValue:null},c.Event=function(a){this.data=a},c.Event.prototype={intValue:0,floatValue:0,stringValue:null},c.AttachmentType={region:0,boundingbox:1,mesh:2,skinnedmesh:3},c.RegionAttachment=function(a){this.name=a,this.offset=[],this.offset.length=8,this.uvs=[],this.uvs.length=8},c.RegionAttachment.prototype={type:c.AttachmentType.region,x:0,y:0,rotation:0,scaleX:1,scaleY:1,width:0,height:0,r:1,g:1,b:1,a:1,path:null,rendererObject:null,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,setUVs:function(a,b,c,d,e){var f=this.uvs;e?(f[2]=a,f[3]=d,f[4]=a,f[5]=b,f[6]=c,f[7]=b,f[0]=c,f[1]=d):(f[0]=a,f[1]=d,f[2]=a,f[3]=b,f[4]=c,f[5]=b,f[6]=c,f[7]=d)},updateOffset:function(){var a=this.width/this.regionOriginalWidth*this.scaleX,b=this.height/this.regionOriginalHeight*this.scaleY,d=-this.width/2*this.scaleX+this.regionOffsetX*a,e=-this.height/2*this.scaleY+this.regionOffsetY*b,f=d+this.regionWidth*a,g=e+this.regionHeight*b,h=this.rotation*c.degRad,i=Math.cos(h),j=Math.sin(h),k=d*i+this.x,l=d*j,m=e*i+this.y,n=e*j,o=f*i+this.x,p=f*j,q=g*i+this.y,r=g*j,s=this.offset;s[0]=k-n,s[1]=m+l,s[2]=k-r,s[3]=q+l,s[4]=o-r,s[5]=q+p,s[6]=o-n,s[7]=m+p},computeVertices:function(a,b,c,d){a+=c.worldX,b+=c.worldY;var e=c.m00,f=c.m01,g=c.m10,h=c.m11,i=this.offset;d[0]=i[0]*e+i[1]*f+a,d[1]=i[0]*g+i[1]*h+b,d[2]=i[2]*e+i[3]*f+a,d[3]=i[2]*g+i[3]*h+b,d[4]=i[4]*e+i[5]*f+a,d[5]=i[4]*g+i[5]*h+b,d[6]=i[6]*e+i[7]*f+a,d[7]=i[6]*g+i[7]*h+b}},c.MeshAttachment=function(a){this.name=a},c.MeshAttachment.prototype={type:c.AttachmentType.mesh,vertices:null,uvs:null,regionUVs:null,triangles:null,hullLength:0,r:1,g:1,b:1,a:1,path:null,rendererObject:null,regionU:0,regionV:0,regionU2:0,regionV2:0,regionRotate:!1,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,edges:null,width:0,height:0,updateUVs:function(){var a=this.regionU2-this.regionU,b=this.regionV2-this.regionV,d=this.regionUVs.length;if(this.uvs&&this.uvs.length==d||(this.uvs=new c.Float32Array(d)),this.regionRotate)for(var e=0;d>e;e+=2)this.uvs[e]=this.regionU+this.regionUVs[e+1]*a,this.uvs[e+1]=this.regionV+b-this.regionUVs[e]*b;else for(var e=0;d>e;e+=2)this.uvs[e]=this.regionU+this.regionUVs[e]*a,this.uvs[e+1]=this.regionV+this.regionUVs[e+1]*b},computeWorldVertices:function(a,b,c,d){var e=c.bone;a+=e.worldX,b+=e.worldY;var f=e.m00,g=e.m01,h=e.m10,i=e.m11,j=this.vertices,k=j.length;c.attachmentVertices.length==k&&(j=c.attachmentVertices);for(var l=0;k>l;l+=2){var m=j[l],n=j[l+1];d[l]=m*f+n*g+a,d[l+1]=m*h+n*i+b}}},c.SkinnedMeshAttachment=function(a){this.name=a},c.SkinnedMeshAttachment.prototype={type:c.AttachmentType.skinnedmesh,bones:null,weights:null,uvs:null,regionUVs:null,triangles:null,hullLength:0,r:1,g:1,b:1,a:1,path:null,rendererObject:null,regionU:0,regionV:0,regionU2:0,regionV2:0,regionRotate:!1,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,edges:null,width:0,height:0,updateUVs:function(){var a=this.regionU2-this.regionU,b=this.regionV2-this.regionV,d=this.regionUVs.length;if(this.uvs&&this.uvs.length==d||(this.uvs=new c.Float32Array(d)),this.regionRotate)for(var e=0;d>e;e+=2)this.uvs[e]=this.regionU+this.regionUVs[e+1]*a,this.uvs[e+1]=this.regionV+b-this.regionUVs[e]*b;else for(var e=0;d>e;e+=2)this.uvs[e]=this.regionU+this.regionUVs[e]*a,this.uvs[e+1]=this.regionV+this.regionUVs[e+1]*b},computeWorldVertices:function(a,b,c,d){var e,f,g,h,i,j,k,l=c.bone.skeleton.bones,m=this.weights,n=this.bones,o=0,p=0,q=0,r=0,s=n.length;if(c.attachmentVertices.length)for(var t=c.attachmentVertices;s>p;o+=2){for(f=0,g=0,e=n[p++]+p;e>p;p++,q+=3,r+=2)h=l[n[p]],i=m[q]+t[r],j=m[q+1]+t[r+1],k=m[q+2],f+=(i*h.m00+j*h.m01+h.worldX)*k,g+=(i*h.m10+j*h.m11+h.worldY)*k;d[o]=f+a,d[o+1]=g+b}else for(;s>p;o+=2){for(f=0,g=0,e=n[p++]+p;e>p;p++,q+=3)h=l[n[p]],i=m[q],j=m[q+1],k=m[q+2],f+=(i*h.m00+j*h.m01+h.worldX)*k,g+=(i*h.m10+j*h.m11+h.worldY)*k;d[o]=f+a,d[o+1]=g+b}}},c.BoundingBoxAttachment=function(a){this.name=a,this.vertices=[]},c.BoundingBoxAttachment.prototype={type:c.AttachmentType.boundingbox,computeWorldVertices:function(a,b,c,d){a+=c.worldX,b+=c.worldY;for(var e=c.m00,f=c.m01,g=c.m10,h=c.m11,i=this.vertices,j=0,k=i.length;k>j;j+=2){var l=i[j],m=i[j+1];d[j]=l*e+m*f+a,d[j+1]=l*g+m*h+b}}},c.AnimationStateData=function(a){this.skeletonData=a,this.animationToMixTime={}},c.AnimationStateData.prototype={defaultMix:0,setMixByName:function(a,b,c){var d=this.skeletonData.findAnimation(a);if(!d)throw"Animation not found: "+a;var e=this.skeletonData.findAnimation(b);if(!e)throw"Animation not found: "+b;this.setMix(d,e,c)},setMix:function(a,b,c){this.animationToMixTime[a.name+":"+b.name]=c},getMix:function(a,b){var c=a.name+":"+b.name;return this.animationToMixTime.hasOwnProperty(c)?this.animationToMixTime[c]:this.defaultMix}},c.TrackEntry=function(){},c.TrackEntry.prototype={next:null,previous:null,animation:null,loop:!1,delay:0,time:0,lastTime:-1,endTime:0,timeScale:1,mixTime:0,mixDuration:0,mix:1,onStart:null,onEnd:null,onComplete:null,onEvent:null},c.AnimationState=function(a){this.data=a,this.tracks=[],this.events=[]},c.AnimationState.prototype={onStart:null,onEnd:null,onComplete:null,onEvent:null,timeScale:1,update:function(a){a*=this.timeScale;for(var b=0;b=0&&this.setCurrent(b,e)):!c.loop&&c.lastTime>=c.endTime&&this.clearTrack(b)}}},apply:function(a){for(var b=0;bf&&(d=f);var h=c.previous;if(h){var i=h.time;!h.loop&&i>h.endTime&&(i=h.endTime),h.animation.apply(a,i,i,h.loop,null);var j=c.mixTime/c.mixDuration*c.mix;j>=1&&(j=1,c.previous=null),c.animation.mix(a,c.lastTime,d,g,this.events,j)}else 1==c.mix?c.animation.apply(a,c.lastTime,d,g,this.events):c.animation.mix(a,c.lastTime,d,g,this.events,c.mix);for(var k=0,l=this.events.length;l>k;k++){var m=this.events[k];c.onEvent&&c.onEvent(b,m),this.onEvent&&this.onEvent(b,m)}if(g?e%f>d%f:f>e&&d>=f){var n=Math.floor(d/f);c.onComplete&&c.onComplete(b,n),this.onComplete&&this.onComplete(b,n)}c.lastTime=c.time}}},clearTracks:function(){for(var a=0,b=this.tracks.length;b>a;a++)this.clearTrack(a);this.tracks.length=0},clearTrack:function(a){if(!(a>=this.tracks.length)){var b=this.tracks[a];b&&(b.onEnd&&b.onEnd(a),this.onEnd&&this.onEnd(a),this.tracks[a]=null)}},_expandToIndex:function(a){if(a=this.tracks.length;)this.tracks.push(null);return null},setCurrent:function(a,b){var c=this._expandToIndex(a);if(c){var d=c.previous;c.previous=null,c.onEnd&&c.onEnd(a),this.onEnd&&this.onEnd(a),b.mixDuration=this.data.getMix(c.animation,b.animation),b.mixDuration>0&&(b.mixTime=0,b.previous=d&&c.mixTime/c.mixDuration<.5?d:c)}this.tracks[a]=b,b.onStart&&b.onStart(a),this.onStart&&this.onStart(a)},setAnimationByName:function(a,b,c){var d=this.data.skeletonData.findAnimation(b);if(!d)throw"Animation not found: "+b;return this.setAnimation(a,d,c)},setAnimation:function(a,b,d){var e=new c.TrackEntry;return e.animation=b,e.loop=d,e.endTime=b.duration,this.setCurrent(a,e),e},addAnimationByName:function(a,b,c,d){var e=this.data.skeletonData.findAnimation(b);if(!e)throw"Animation not found: "+b;return this.addAnimation(a,e,c,d)},addAnimation:function(a,b,d,e){var f=new c.TrackEntry;f.animation=b,f.loop=d,f.endTime=b.duration;var g=this._expandToIndex(a);if(g){for(;g.next;)g=g.next;g.next=f}else this.tracks[a]=f;return 0>=e&&(g?e+=g.endTime-this.data.getMix(g.animation,b):e=0),f.delay=e,f},getCurrent:function(a){return a>=this.tracks.length?null:this.tracks[a]}},c.SkeletonJson=function(a){this.attachmentLoader=a},c.SkeletonJson.prototype={scale:1,readSkeletonData:function(a,b){var d=new c.SkeletonData;d.name=b;var e=a.skeleton;e&&(d.hash=e.hash,d.version=e.spine,d.width=e.width||0,d.height=e.height||0);for(var f=a.bones,g=0,h=f.length;h>g;g++){var i=f[g],j=null;if(i.parent&&(j=d.findBone(i.parent),!j))throw"Parent bone not found: "+i.parent;var k=new c.BoneData(i.name,j);k.length=(i.length||0)*this.scale,k.x=(i.x||0)*this.scale,k.y=(i.y||0)*this.scale,k.rotation=i.rotation||0,k.scaleX=i.hasOwnProperty("scaleX")?i.scaleX:1,k.scaleY=i.hasOwnProperty("scaleY")?i.scaleY:1,k.inheritScale=i.hasOwnProperty("inheritScale")?i.inheritScale:!0,k.inheritRotation=i.hasOwnProperty("inheritRotation")?i.inheritRotation:!0,d.bones.push(k)}var l=a.ik;if(l)for(var g=0,h=l.length;h>g;g++){for(var m=l[g],n=new c.IkConstraintData(m.name),f=m.bones,o=0,p=f.length;p>o;o++){var q=d.findBone(f[o]);if(!q)throw"IK bone not found: "+f[o];n.bones.push(q)}if(n.target=d.findBone(m.target),!n.target)throw"Target bone not found: "+m.target;n.bendDirection=!m.hasOwnProperty("bendPositive")||m.bendPositive?1:-1,n.mix=m.hasOwnProperty("mix")?m.mix:1,d.ikConstraints.push(n)}for(var r=a.slots,g=0,h=r.length;h>g;g++){var s=r[g],k=d.findBone(s.bone);if(!k)throw"Slot bone not found: "+s.bone;var t=new c.SlotData(s.name,k),u=s.color;u&&(t.r=this.toColor(u,0),t.g=this.toColor(u,1),t.b=this.toColor(u,2),t.a=this.toColor(u,3)),t.attachmentName=s.attachment,t.additiveBlending=s.additive&&"true"==s.additive,d.slots.push(t)}var v=a.skins;for(var w in v)if(v.hasOwnProperty(w)){var x=v[w],y=new c.Skin(w);for(var z in x)if(x.hasOwnProperty(z)){var A=d.findSlotIndex(z),B=x[z];for(var C in B)if(B.hasOwnProperty(C)){var D=this.readAttachment(y,C,B[C]);D&&y.addAttachment(A,C,D)}}d.skins.push(y),"default"==y.name&&(d.defaultSkin=y)}var E=a.events;for(var F in E)if(E.hasOwnProperty(F)){var G=E[F],H=new c.EventData(F);H.intValue=G["int"]||0,H.floatValue=G["float"]||0,H.stringValue=G.string||null,d.events.push(H)}var I=a.animations;for(var J in I)I.hasOwnProperty(J)&&this.readAnimation(J,I[J],d);return d},readAttachment:function(a,b,d){b=d.name||b;var e=c.AttachmentType[d.type||"region"],f=d.path||b,g=this.scale;
+if(e==c.AttachmentType.region){var h=this.attachmentLoader.newRegionAttachment(a,b,f);if(!h)return null;h.path=f,h.x=(d.x||0)*g,h.y=(d.y||0)*g,h.scaleX=d.hasOwnProperty("scaleX")?d.scaleX:1,h.scaleY=d.hasOwnProperty("scaleY")?d.scaleY:1,h.rotation=d.rotation||0,h.width=(d.width||0)*g,h.height=(d.height||0)*g;var i=d.color;return i&&(h.r=this.toColor(i,0),h.g=this.toColor(i,1),h.b=this.toColor(i,2),h.a=this.toColor(i,3)),h.updateOffset(),h}if(e==c.AttachmentType.mesh){var j=this.attachmentLoader.newMeshAttachment(a,b,f);return j?(j.path=f,j.vertices=this.getFloatArray(d,"vertices",g),j.triangles=this.getIntArray(d,"triangles"),j.regionUVs=this.getFloatArray(d,"uvs",1),j.updateUVs(),i=d.color,i&&(j.r=this.toColor(i,0),j.g=this.toColor(i,1),j.b=this.toColor(i,2),j.a=this.toColor(i,3)),j.hullLength=2*(d.hull||0),d.edges&&(j.edges=this.getIntArray(d,"edges")),j.width=(d.width||0)*g,j.height=(d.height||0)*g,j):null}if(e==c.AttachmentType.skinnedmesh){var j=this.attachmentLoader.newSkinnedMeshAttachment(a,b,f);if(!j)return null;j.path=f;for(var k=this.getFloatArray(d,"uvs",1),l=this.getFloatArray(d,"vertices",1),m=[],n=[],o=0,p=l.length;p>o;){var q=0|l[o++];n[n.length]=q;for(var r=o+4*q;r>o;)n[n.length]=l[o],m[m.length]=l[o+1]*g,m[m.length]=l[o+2]*g,m[m.length]=l[o+3],o+=4}return j.bones=n,j.weights=m,j.triangles=this.getIntArray(d,"triangles"),j.regionUVs=k,j.updateUVs(),i=d.color,i&&(j.r=this.toColor(i,0),j.g=this.toColor(i,1),j.b=this.toColor(i,2),j.a=this.toColor(i,3)),j.hullLength=2*(d.hull||0),d.edges&&(j.edges=this.getIntArray(d,"edges")),j.width=(d.width||0)*g,j.height=(d.height||0)*g,j}if(e==c.AttachmentType.boundingbox){for(var s=this.attachmentLoader.newBoundingBoxAttachment(a,b),l=d.vertices,o=0,p=l.length;p>o;o++)s.vertices.push(l[o]*g);return s}throw"Unknown attachment type: "+e},readAnimation:function(a,b,d){var e=[],f=0,g=b.slots;for(var h in g)if(g.hasOwnProperty(h)){var i=g[h],j=d.findSlotIndex(h);for(var k in i)if(i.hasOwnProperty(k)){var l=i[k];if("color"==k){var m=new c.ColorTimeline(l.length);m.slotIndex=j;for(var n=0,o=0,p=l.length;p>o;o++){var q=l[o],r=q.color,s=this.toColor(r,0),t=this.toColor(r,1),u=this.toColor(r,2),v=this.toColor(r,3);m.setFrame(n,q.time,s,t,u,v),this.readCurve(m,n,q),n++}e.push(m),f=Math.max(f,m.frames[5*m.getFrameCount()-5])}else{if("attachment"!=k)throw"Invalid timeline type for a slot: "+k+" ("+h+")";var m=new c.AttachmentTimeline(l.length);m.slotIndex=j;for(var n=0,o=0,p=l.length;p>o;o++){var q=l[o];m.setFrame(n++,q.time,q.name)}e.push(m),f=Math.max(f,m.frames[m.getFrameCount()-1])}}}var w=b.bones;for(var x in w)if(w.hasOwnProperty(x)){var y=d.findBoneIndex(x);if(-1==y)throw"Bone not found: "+x;var z=w[x];for(var k in z)if(z.hasOwnProperty(k)){var l=z[k];if("rotate"==k){var m=new c.RotateTimeline(l.length);m.boneIndex=y;for(var n=0,o=0,p=l.length;p>o;o++){var q=l[o];m.setFrame(n,q.time,q.angle),this.readCurve(m,n,q),n++}e.push(m),f=Math.max(f,m.frames[2*m.getFrameCount()-2])}else if("translate"==k||"scale"==k){var m,A=1;"scale"==k?m=new c.ScaleTimeline(l.length):(m=new c.TranslateTimeline(l.length),A=this.scale),m.boneIndex=y;for(var n=0,o=0,p=l.length;p>o;o++){var q=l[o],B=(q.x||0)*A,C=(q.y||0)*A;m.setFrame(n,q.time,B,C),this.readCurve(m,n,q),n++}e.push(m),f=Math.max(f,m.frames[3*m.getFrameCount()-3])}else{if("flipX"!=k&&"flipY"!=k)throw"Invalid timeline type for a bone: "+k+" ("+x+")";var B="flipX"==k,m=B?new c.FlipXTimeline(l.length):new c.FlipYTimeline(l.length);m.boneIndex=y;for(var D=B?"x":"y",n=0,o=0,p=l.length;p>o;o++){var q=l[o];m.setFrame(n,q.time,q[D]||!1),n++}e.push(m),f=Math.max(f,m.frames[2*m.getFrameCount()-2])}}}var E=b.ik;for(var F in E)if(E.hasOwnProperty(F)){var G=d.findIkConstraint(F),l=E[F],m=new c.IkConstraintTimeline(l.length);m.ikConstraintIndex=d.ikConstraints.indexOf(G);for(var n=0,o=0,p=l.length;p>o;o++){var q=l[o],H=q.hasOwnProperty("mix")?q.mix:1,I=!q.hasOwnProperty("bendPositive")||q.bendPositive?1:-1;m.setFrame(n,q.time,H,I),this.readCurve(m,n,q),n++}e.push(m),f=Math.max(f,m.frames[3*m.frameCount-3])}var J=b.ffd;for(var K in J){var L=d.findSkin(K),i=J[K];for(h in i){var j=d.findSlotIndex(h),M=i[h];for(var N in M){var l=M[N],m=new c.FfdTimeline(l.length),O=L.getAttachment(j,N);if(!O)throw"FFD attachment not found: "+N;m.slotIndex=j,m.attachment=O;var P,Q=O.type==c.AttachmentType.mesh;P=Q?O.vertices.length:O.weights.length/3*2;for(var n=0,o=0,p=l.length;p>o;o++){var R,q=l[o];if(q.vertices){var S=q.vertices,R=[];R.length=P;var T=q.offset||0,U=S.length;if(1==this.scale)for(var V=0;U>V;V++)R[V+T]=S[V];else for(var V=0;U>V;V++)R[V+T]=S[V]*this.scale;if(Q)for(var W=O.vertices,V=0,U=R.length;U>V;V++)R[V]+=W[V]}else Q?R=O.vertices:(R=[],R.length=P);m.setFrame(n,q.time,R),this.readCurve(m,n,q),n++}e[e.length]=m,f=Math.max(f,m.frames[m.frameCount-1])}}}var X=b.drawOrder;if(X||(X=b.draworder),X){for(var m=new c.DrawOrderTimeline(X.length),Y=d.slots.length,n=0,o=0,p=X.length;p>o;o++){var Z=X[o],$=null;if(Z.offsets){$=[],$.length=Y;for(var V=Y-1;V>=0;V--)$[V]=-1;var _=Z.offsets,ab=[];ab.length=Y-_.length;for(var bb=0,cb=0,V=0,U=_.length;U>V;V++){var db=_[V],j=d.findSlotIndex(db.slot);if(-1==j)throw"Slot not found: "+db.slot;for(;bb!=j;)ab[cb++]=bb++;$[bb+db.offset]=bb++}for(;Y>bb;)ab[cb++]=bb++;for(var V=Y-1;V>=0;V--)-1==$[V]&&($[V]=ab[--cb])}m.setFrame(n++,Z.time,$)}e.push(m),f=Math.max(f,m.frames[m.getFrameCount()-1])}var eb=b.events;if(eb){for(var m=new c.EventTimeline(eb.length),n=0,o=0,p=eb.length;p>o;o++){var fb=eb[o],gb=d.findEvent(fb.name);if(!gb)throw"Event not found: "+fb.name;var hb=new c.Event(gb);hb.intValue=fb.hasOwnProperty("int")?fb["int"]:gb.intValue,hb.floatValue=fb.hasOwnProperty("float")?fb["float"]:gb.floatValue,hb.stringValue=fb.hasOwnProperty("string")?fb.string:gb.stringValue,m.setFrame(n++,fb.time,hb)}e.push(m),f=Math.max(f,m.frames[m.getFrameCount()-1])}d.animations.push(new c.Animation(a,e,f))},readCurve:function(a,b,c){var d=c.curve;d?"stepped"==d?a.curves.setStepped(b):d instanceof Array&&a.curves.setCurve(b,d[0],d[1],d[2],d[3]):a.curves.setLinear(b)},toColor:function(a,b){if(8!=a.length)throw"Color hexidecimal length must be 8, recieved: "+a;return parseInt(a.substring(2*b,2*b+2),16)/255},getFloatArray:function(a,b,d){var e=a[b],f=new c.Float32Array(e.length),g=0,h=e.length;if(1==d)for(;h>g;g++)f[g]=e[g];else for(;h>g;g++)f[g]=e[g]*d;return f},getIntArray:function(a,b){for(var d=a[b],e=new c.Uint16Array(d.length),f=0,g=d.length;g>f;f++)e[f]=0|d[f];return e}},c.Atlas=function(a,b){this.textureLoader=b,this.pages=[],this.regions=[];var d=new c.AtlasReader(a),e=[];e.length=4;for(var f=null;;){var g=d.readLine();if(null===g)break;if(g=d.trim(g),g.length)if(f){var h=new c.AtlasRegion;h.name=g,h.page=f,h.rotate="true"==d.readValue(),d.readTuple(e);var i=parseInt(e[0]),j=parseInt(e[1]);d.readTuple(e);var k=parseInt(e[0]),l=parseInt(e[1]);h.u=i/f.width,h.v=j/f.height,h.rotate?(h.u2=(i+l)/f.width,h.v2=(j+k)/f.height):(h.u2=(i+k)/f.width,h.v2=(j+l)/f.height),h.x=i,h.y=j,h.width=Math.abs(k),h.height=Math.abs(l),4==d.readTuple(e)&&(h.splits=[parseInt(e[0]),parseInt(e[1]),parseInt(e[2]),parseInt(e[3])],4==d.readTuple(e)&&(h.pads=[parseInt(e[0]),parseInt(e[1]),parseInt(e[2]),parseInt(e[3])],d.readTuple(e))),h.originalWidth=parseInt(e[0]),h.originalHeight=parseInt(e[1]),d.readTuple(e),h.offsetX=parseInt(e[0]),h.offsetY=parseInt(e[1]),h.index=parseInt(d.readValue()),this.regions.push(h)}else{f=new c.AtlasPage,f.name=g,2==d.readTuple(e)&&(f.width=parseInt(e[0]),f.height=parseInt(e[1]),d.readTuple(e)),f.format=c.Atlas.Format[e[0]],d.readTuple(e),f.minFilter=c.Atlas.TextureFilter[e[0]],f.magFilter=c.Atlas.TextureFilter[e[1]];var m=d.readValue();f.uWrap=c.Atlas.TextureWrap.clampToEdge,f.vWrap=c.Atlas.TextureWrap.clampToEdge,"x"==m?f.uWrap=c.Atlas.TextureWrap.repeat:"y"==m?f.vWrap=c.Atlas.TextureWrap.repeat:"xy"==m&&(f.uWrap=f.vWrap=c.Atlas.TextureWrap.repeat),b.load(f,g,this),this.pages.push(f)}else f=null}},c.Atlas.prototype={findRegion:function(a){for(var b=this.regions,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},dispose:function(){for(var a=this.pages,b=0,c=a.length;c>b;b++)this.textureLoader.unload(a[b].rendererObject)},updateUVs:function(a){for(var b=this.regions,c=0,d=b.length;d>c;c++){var e=b[c];e.page==a&&(e.u=e.x/a.width,e.v=e.y/a.height,e.rotate?(e.u2=(e.x+e.height)/a.width,e.v2=(e.y+e.width)/a.height):(e.u2=(e.x+e.width)/a.width,e.v2=(e.y+e.height)/a.height))}}},c.Atlas.Format={alpha:0,intensity:1,luminanceAlpha:2,rgb565:3,rgba4444:4,rgb888:5,rgba8888:6},c.Atlas.TextureFilter={nearest:0,linear:1,mipMap:2,mipMapNearestNearest:3,mipMapLinearNearest:4,mipMapNearestLinear:5,mipMapLinearLinear:6},c.Atlas.TextureWrap={mirroredRepeat:0,clampToEdge:1,repeat:2},c.AtlasPage=function(){},c.AtlasPage.prototype={name:null,format:null,minFilter:null,magFilter:null,uWrap:null,vWrap:null,rendererObject:null,width:0,height:0},c.AtlasRegion=function(){},c.AtlasRegion.prototype={page:null,name:null,x:0,y:0,width:0,height:0,u:0,v:0,u2:0,v2:0,offsetX:0,offsetY:0,originalWidth:0,originalHeight:0,index:0,rotate:!1,splits:null,pads:null},c.AtlasReader=function(a){this.lines=a.split(/\r\n|\r|\n/)},c.AtlasReader.prototype={index:0,trim:function(a){return a.replace(/^\s+|\s+$/g,"")},readLine:function(){return this.index>=this.lines.length?null:this.lines[this.index++]},readValue:function(){var a=this.readLine(),b=a.indexOf(":");if(-1==b)throw"Invalid line: "+a;return this.trim(a.substring(b+1))},readTuple:function(a){var b=this.readLine(),c=b.indexOf(":");if(-1==c)throw"Invalid line: "+b;for(var d=0,e=c+1;3>d;d++){var f=b.indexOf(",",e);if(-1==f)break;a[d]=this.trim(b.substr(e,f-e)),e=f+1}return a[d]=this.trim(b.substring(e)),d+1}},c.AtlasAttachmentLoader=function(a){this.atlas=a},c.AtlasAttachmentLoader.prototype={newRegionAttachment:function(a,b,d){var e=this.atlas.findRegion(d);if(!e)throw"Region not found in atlas: "+d+" (region attachment: "+b+")";var f=new c.RegionAttachment(b);return f.rendererObject=e,f.setUVs(e.u,e.v,e.u2,e.v2,e.rotate),f.regionOffsetX=e.offsetX,f.regionOffsetY=e.offsetY,f.regionWidth=e.width,f.regionHeight=e.height,f.regionOriginalWidth=e.originalWidth,f.regionOriginalHeight=e.originalHeight,f},newMeshAttachment:function(a,b,d){var e=this.atlas.findRegion(d);if(!e)throw"Region not found in atlas: "+d+" (mesh attachment: "+b+")";var f=new c.MeshAttachment(b);return f.rendererObject=e,f.regionU=e.u,f.regionV=e.v,f.regionU2=e.u2,f.regionV2=e.v2,f.regionRotate=e.rotate,f.regionOffsetX=e.offsetX,f.regionOffsetY=e.offsetY,f.regionWidth=e.width,f.regionHeight=e.height,f.regionOriginalWidth=e.originalWidth,f.regionOriginalHeight=e.originalHeight,f},newSkinnedMeshAttachment:function(a,b,d){var e=this.atlas.findRegion(d);if(!e)throw"Region not found in atlas: "+d+" (skinned mesh attachment: "+b+")";var f=new c.SkinnedMeshAttachment(b);return f.rendererObject=e,f.regionU=e.u,f.regionV=e.v,f.regionU2=e.u2,f.regionV2=e.v2,f.regionRotate=e.rotate,f.regionOffsetX=e.offsetX,f.regionOffsetY=e.offsetY,f.regionWidth=e.width,f.regionHeight=e.height,f.regionOriginalWidth=e.originalWidth,f.regionOriginalHeight=e.originalHeight,f},newBoundingBoxAttachment:function(a,b){return new c.BoundingBoxAttachment(b)}},c.SkeletonBounds=function(){this.polygonPool=[],this.polygons=[],this.boundingBoxes=[]},c.SkeletonBounds.prototype={minX:0,minY:0,maxX:0,maxY:0,update:function(a,b){var d=a.slots,e=d.length,f=a.x,g=a.y,h=this.boundingBoxes,i=this.polygonPool,j=this.polygons;h.length=0;for(var k=0,l=j.length;l>k;k++)i.push(j[k]);j.length=0;for(var k=0;e>k;k++){var m=d[k],n=m.attachment;if(n.type==c.AttachmentType.boundingbox){h.push(n);var o,p=i.length;p>0?(o=i[p-1],i.splice(p-1,1)):o=[],j.push(o),o.length=n.vertices.length,n.computeWorldVertices(f,g,m.bone,o)}}b&&this.aabbCompute()},aabbCompute:function(){for(var a=this.polygons,b=Number.MAX_VALUE,c=Number.MAX_VALUE,d=Number.MIN_VALUE,e=Number.MIN_VALUE,f=0,g=a.length;g>f;f++)for(var h=a[f],i=0,j=h.length;j>i;i+=2){var k=h[i],l=h[i+1];b=Math.min(b,k),c=Math.min(c,l),d=Math.max(d,k),e=Math.max(e,l)}this.minX=b,this.minY=c,this.maxX=d,this.maxY=e},aabbContainsPoint:function(a,b){return a>=this.minX&&a<=this.maxX&&b>=this.minY&&b<=this.maxY},aabbIntersectsSegment:function(a,b,c,d){var e=this.minX,f=this.minY,g=this.maxX,h=this.maxY;if(e>=a&&e>=c||f>=b&&f>=d||a>=g&&c>=g||b>=h&&d>=h)return!1;var i=(d-b)/(c-a),j=i*(e-a)+b;if(j>f&&h>j)return!0;if(j=i*(g-a)+b,j>f&&h>j)return!0;var k=(f-b)/i+a;return k>e&&g>k?!0:(k=(h-b)/i+a,k>e&&g>k?!0:!1)},aabbIntersectsSkeleton:function(a){return this.minXa.minX&&this.minYa.minY},containsPoint:function(a,b){for(var c=this.polygons,d=0,e=c.length;e>d;d++)if(this.polygonContainsPoint(c[d],a,b))return this.boundingBoxes[d];return null},intersectsSegment:function(a,b,c,d){for(var e=this.polygons,f=0,g=e.length;g>f;f++)if(e[f].intersectsSegment(a,b,c,d))return this.boundingBoxes[f];return null},polygonContainsPoint:function(a,b,c){for(var d=a.length,e=d-2,f=!1,g=0;d>g;g+=2){var h=a[g+1],i=a[e+1];if(c>h&&i>=c||c>i&&h>=c){var j=a[g];j+(c-h)/(i-h)*(a[e]-j)l;l+=2){var m=a[l],n=a[l+1],o=j*n-k*m,p=j-m,q=k-n,r=g*q-h*p,s=(i*p-g*o)/r;if((s>=j&&m>=s||s>=m&&j>=s)&&(s>=b&&d>=s||s>=d&&b>=s)){var t=(i*q-h*o)/r;if((t>=k&&n>=t||t>=n&&k>=t)&&(t>=c&&e>=t||t>=e&&c>=t))return!0}j=m,k=n}return!1},getPolygon:function(a){var b=this.boundingBoxes.indexOf(a);return-1==b?null:this.polygons[b]},getWidth:function(){return this.maxX-this.minX},getHeight:function(){return this.maxY-this.minY}},c.Bone.yDown=!0,b.AnimCache={},b.SpineTextureLoader=function(a,c){b.EventTarget.call(this),this.basePath=a,this.crossorigin=c,this.loadingCount=0},b.SpineTextureLoader.prototype=b.SpineTextureLoader,b.SpineTextureLoader.prototype.load=function(a,c){if(a.rendererObject=b.BaseTexture.fromImage(this.basePath+"/"+c,this.crossorigin),!a.rendererObject.hasLoaded){var d=this;++d.loadingCount,a.rendererObject.addEventListener("loaded",function(){--d.loadingCount,d.dispatchEvent({type:"loadedBaseTexture",content:d})})}},b.SpineTextureLoader.prototype.unload=function(a){a.destroy(!0)},b.Spine=function(a){if(b.DisplayObjectContainer.call(this),this.spineData=b.AnimCache[a],!this.spineData)throw new Error("Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader: "+a);this.skeleton=new c.Skeleton(this.spineData),this.skeleton.updateWorldTransform(),this.stateData=new c.AnimationStateData(this.spineData),this.state=new c.AnimationState(this.stateData),this.slotContainers=[];for(var d=0,e=this.skeleton.drawOrder.length;e>d;d++){var f=this.skeleton.drawOrder[d],g=f.attachment,h=new b.DisplayObjectContainer;if(this.slotContainers.push(h),this.addChild(h),g instanceof c.RegionAttachment){var i=g.rendererObject.name,j=this.createSprite(f,g);f.currentSprite=j,f.currentSpriteName=i,h.addChild(j)}else{if(!(g instanceof c.MeshAttachment))continue;var k=this.createMesh(f,g);f.currentMesh=k,f.currentMeshName=g.name,h.addChild(k)}}this.autoUpdate=!0},b.Spine.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Spine.prototype.constructor=b.Spine,Object.defineProperty(b.Spine.prototype,"autoUpdate",{get:function(){return this.updateTransform===b.Spine.prototype.autoUpdateTransform},set:function(a){this.updateTransform=a?b.Spine.prototype.autoUpdateTransform:b.DisplayObjectContainer.prototype.updateTransform}}),b.Spine.prototype.update=function(a){this.state.update(a),this.state.apply(this.skeleton),this.skeleton.updateWorldTransform();for(var d=this.skeleton.drawOrder,e=0,f=d.length;f>e;e++){var g=d[e],h=g.attachment,i=this.slotContainers[e];if(h){var j=h.type;if(j===c.AttachmentType.region){if(h.rendererObject&&(!g.currentSpriteName||g.currentSpriteName!==h.name)){var k=h.rendererObject.name;if(void 0!==g.currentSprite&&(g.currentSprite.visible=!1),g.sprites=g.sprites||{},void 0!==g.sprites[k])g.sprites[k].visible=!0;else{var l=this.createSprite(g,h);i.addChild(l)}g.currentSprite=g.sprites[k],g.currentSpriteName=k}var m=g.bone;i.position.x=m.worldX+h.x*m.m00+h.y*m.m01,i.position.y=m.worldY+h.x*m.m10+h.y*m.m11,i.scale.x=m.worldScaleX,i.scale.y=m.worldScaleY,i.rotation=-(g.bone.worldRotation*c.degRad),g.currentSprite.tint=b.rgb2hex([g.r,g.g,g.b])}else{if(j!==c.AttachmentType.skinnedmesh){i.visible=!1;continue}if(!g.currentMeshName||g.currentMeshName!==h.name){var n=h.name;if(void 0!==g.currentMesh&&(g.currentMesh.visible=!1),g.meshes=g.meshes||{},void 0!==g.meshes[n])g.meshes[n].visible=!0;else{var o=this.createMesh(g,h);i.addChild(o)}g.currentMesh=g.meshes[n],g.currentMeshName=n}h.computeWorldVertices(g.bone.skeleton.x,g.bone.skeleton.y,g,g.currentMesh.vertices)}i.visible=!0,i.alpha=g.a}else i.visible=!1}},b.Spine.prototype.autoUpdateTransform=function(){this.lastTime=this.lastTime||Date.now();var a=.001*(Date.now()-this.lastTime);this.lastTime=Date.now(),this.update(a),b.DisplayObjectContainer.prototype.updateTransform.call(this)},b.Spine.prototype.createSprite=function(a,d){var e=d.rendererObject,f=e.page.rendererObject,g=new b.Rectangle(e.x,e.y,e.rotate?e.height:e.width,e.rotate?e.width:e.height),h=new b.Texture(f,g),i=new b.Sprite(h),j=e.rotate?.5*Math.PI:0;return i.scale.set(e.width/e.originalWidth,e.height/e.originalHeight),i.rotation=j-d.rotation*c.degRad,i.anchor.x=i.anchor.y=.5,a.sprites=a.sprites||{},a.sprites[e.name]=i,i},b.Spine.prototype.createMesh=function(a,c){var d=c.rendererObject,e=d.page.rendererObject,f=new b.Texture(e),g=new b.Strip(f);return g.drawMode=b.Strip.DrawModes.TRIANGLES,g.canvasPadding=1.5,g.vertices=new b.Float32Array(c.uvs.length),g.uvs=c.uvs,g.indices=c.triangles,a.meshes=a.meshes||{},a.meshes[c.name]=g,g},b.BaseTextureCache={},b.BaseTextureCacheIdGenerator=0,b.BaseTexture=function(a,c){if(this.resolution=1,this.width=100,this.height=100,this.scaleMode=c||b.scaleModes.DEFAULT,this.hasLoaded=!1,this.source=a,this._UID=b._UID++,this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this._dirty=[!0,!0,!0,!0],a){if((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height)this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty();else{var d=this;this.source.onload=function(){d.hasLoaded=!0,d.width=d.source.naturalWidth||d.source.width,d.height=d.source.naturalHeight||d.source.height,d.dirty(),d.dispatchEvent({type:"loaded",content:d})},this.source.onerror=function(){d.dispatchEvent({type:"error",content:d})}}this.imageUrl=null,this._powerOf2=!1}},b.BaseTexture.prototype.constructor=b.BaseTexture,b.EventTarget.mixin(b.BaseTexture.prototype),b.BaseTexture.prototype.destroy=function(){this.imageUrl?(delete b.BaseTextureCache[this.imageUrl],delete b.TextureCache[this.imageUrl],this.imageUrl=null,navigator.isCocoonJS||(this.source.src="")):this.source&&this.source._pixiId&&delete b.BaseTextureCache[this.source._pixiId],this.source=null,this.unloadFromGPU()},b.BaseTexture.prototype.updateSourceImage=function(a){this.hasLoaded=!1,this.source.src=null,this.source.src=a},b.BaseTexture.prototype.dirty=function(){for(var a=0;a=0;a--){var c=this._glTextures[a],d=b.glContexts[a];d&&c&&d.deleteTexture(c)}this._glTextures.length=0,this.dirty()},b.BaseTexture.fromImage=function(a,c,d){var e=b.BaseTextureCache[a];if(void 0===c&&-1===a.indexOf("data:")&&(c=!0),!e){var f=new Image;c&&(f.crossOrigin=""),f.src=a,e=new b.BaseTexture(f,d),e.imageUrl=a,b.BaseTextureCache[a]=e,-1!==a.indexOf(b.RETINA_PREFIX+".")&&(e.resolution=2)}return e},b.BaseTexture.fromCanvas=function(a,c){a._pixiId||(a._pixiId="canvas_"+b.TextureCacheIdGenerator++);var d=b.BaseTextureCache[a._pixiId];return d||(d=new b.BaseTexture(a,c),b.BaseTextureCache[a._pixiId]=d),d},b.TextureCache={},b.FrameCache={},b.TextureCacheIdGenerator=0,b.Texture=function(a,c,d,e){this.noFrame=!1,c||(this.noFrame=!0,c=new b.Rectangle(0,0,1,1)),a instanceof b.Texture&&(a=a.baseTexture),this.baseTexture=a,this.frame=c,this.trim=e,this.valid=!1,this.requiresUpdate=!1,this._uvs=null,this.width=0,this.height=0,this.crop=d||new b.Rectangle(0,0,1,1),a.hasLoaded?(this.noFrame&&(c=new b.Rectangle(0,0,a.width,a.height)),this.setFrame(c)):a.addEventListener("loaded",this.onBaseTextureLoaded.bind(this))},b.Texture.prototype.constructor=b.Texture,b.EventTarget.mixin(b.Texture.prototype),b.Texture.prototype.onBaseTextureLoaded=function(){var a=this.baseTexture;a.removeEventListener("loaded",this.onLoaded),this.noFrame&&(this.frame=new b.Rectangle(0,0,a.width,a.height)),this.setFrame(this.frame),this.dispatchEvent({type:"update",content:this})},b.Texture.prototype.destroy=function(a){a&&this.baseTexture.destroy(),this.valid=!1},b.Texture.prototype.setFrame=function(a){if(this.noFrame=!1,this.frame=a,this.width=a.width,this.height=a.height,this.crop.x=a.x,this.crop.y=a.y,this.crop.width=a.width,this.crop.height=a.height,!this.trim&&(a.x+a.width>this.baseTexture.width||a.y+a.height>this.baseTexture.height))throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=a&&a.width&&a.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs()},b.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new b.TextureUvs);var a=this.crop,c=this.baseTexture.width,d=this.baseTexture.height;this._uvs.x0=a.x/c,this._uvs.y0=a.y/d,this._uvs.x1=(a.x+a.width)/c,this._uvs.y1=a.y/d,this._uvs.x2=(a.x+a.width)/c,this._uvs.y2=(a.y+a.height)/d,this._uvs.x3=a.x/c,this._uvs.y3=(a.y+a.height)/d},b.Texture.fromImage=function(a,c,d){var e=b.TextureCache[a];return e||(e=new b.Texture(b.BaseTexture.fromImage(a,c,d)),b.TextureCache[a]=e),e},b.Texture.fromFrame=function(a){var c=b.TextureCache[a];if(!c)throw new Error('The frameId "'+a+'" does not exist in the texture cache ');return c},b.Texture.fromCanvas=function(a,c){var d=b.BaseTexture.fromCanvas(a,c);return new b.Texture(d)},b.Texture.addTextureToCache=function(a,c){b.TextureCache[c]=a},b.Texture.removeTextureFromCache=function(a){var c=b.TextureCache[a];return delete b.TextureCache[a],delete b.BaseTextureCache[a],c},b.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},b.Texture.emptyTexture=new b.Texture(new b.BaseTexture),b.RenderTexture=function(a,c,d,e,f){if(this.width=a||100,this.height=c||100,this.resolution=f||1,this.frame=new b.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=new b.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.baseTexture=new b.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=e||b.scaleModes.DEFAULT,this.baseTexture.hasLoaded=!0,b.Texture.call(this,this.baseTexture,new b.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution)),this.renderer=d||b.defaultRenderer,this.renderer.type===b.WEBGL_RENDERER){var g=this.renderer.gl;this.baseTexture._dirty[g.id]=!1,this.textureBuffer=new b.FilterTexture(g,this.width,this.height,this.baseTexture.scaleMode),this.baseTexture._glTextures[g.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new b.Point(.5*this.width,.5*-this.height)}else this.render=this.renderCanvas,this.textureBuffer=new b.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this._updateUvs()},b.RenderTexture.prototype=Object.create(b.Texture.prototype),b.RenderTexture.prototype.constructor=b.RenderTexture,b.RenderTexture.prototype.resize=function(a,c,d){(a!==this.width||c!==this.height)&&(this.valid=a>0&&c>0,this.width=a,this.height=c,this.frame.width=this.crop.width=a*this.resolution,this.frame.height=this.crop.height=c*this.resolution,d&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===b.WEBGL_RENDERER&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},b.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===b.WEBGL_RENDERER&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},b.RenderTexture.prototype.renderWebGL=function(a,b,c){if(this.valid){var d=a.worldTransform;d.identity(),d.translate(0,2*this.projection.y),b&&d.append(b),d.scale(1,-1),a.worldAlpha=1;for(var e=a.children,f=0,g=e.length;g>f;f++)e[f].updateTransform();var h=this.renderer.gl;h.viewport(0,0,this.width*this.resolution,this.height*this.resolution),h.bindFramebuffer(h.FRAMEBUFFER,this.textureBuffer.frameBuffer),c&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(a,this.projection,this.textureBuffer.frameBuffer),this.renderer.spriteBatch.dirty=!0}},b.RenderTexture.prototype.renderCanvas=function(a,b,c){if(this.valid){var d=a.worldTransform;d.identity(),b&&d.append(b),a.worldAlpha=1;for(var e=a.children,f=0,g=e.length;g>f;f++)e[f].updateTransform();c&&this.textureBuffer.clear();var h=this.textureBuffer.context,i=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(a,h),this.renderer.resolution=i}},b.RenderTexture.prototype.getImage=function(){var a=new Image;return a.src=this.getBase64(),a},b.RenderTexture.prototype.getBase64=function(){return this.getCanvas().toDataURL()},b.RenderTexture.prototype.getCanvas=function(){if(this.renderer.type===b.WEBGL_RENDERER){var a=this.renderer.gl,c=this.textureBuffer.width,d=this.textureBuffer.height,e=new Uint8Array(4*c*d);a.bindFramebuffer(a.FRAMEBUFFER,this.textureBuffer.frameBuffer),a.readPixels(0,0,c,d,a.RGBA,a.UNSIGNED_BYTE,e),a.bindFramebuffer(a.FRAMEBUFFER,null);var f=new b.CanvasBuffer(c,d),g=f.context.getImageData(0,0,c,d);return g.data.set(e),f.context.putImageData(g,0,0),f.canvas}return this.textureBuffer.canvas},b.RenderTexture.tempMatrix=new b.Matrix,b.VideoTexture=function(a,c){if(!a)throw new Error("No video source element specified.");(a.readyState===a.HAVE_ENOUGH_DATA||a.readyState===a.HAVE_FUTURE_DATA)&&a.width&&a.height&&(a.complete=!0),b.BaseTexture.call(this,a,c),this.autoUpdate=!1,this.updateBound=this._onUpdate.bind(this),a.complete||(this._onCanPlay=this.onCanPlay.bind(this),a.addEventListener("canplay",this._onCanPlay),a.addEventListener("canplaythrough",this._onCanPlay),a.addEventListener("play",this.onPlayStart.bind(this)),a.addEventListener("pause",this.onPlayStop.bind(this)))},b.VideoTexture.prototype=Object.create(b.BaseTexture.prototype),b.VideoTexture.constructor=b.VideoTexture,b.VideoTexture.prototype._onUpdate=function(){this.autoUpdate&&(window.requestAnimationFrame(this.updateBound),this.dirty())},b.VideoTexture.prototype.onPlayStart=function(){this.autoUpdate||(window.requestAnimationFrame(this.updateBound),this.autoUpdate=!0)},b.VideoTexture.prototype.onPlayStop=function(){this.autoUpdate=!1},b.VideoTexture.prototype.onCanPlay=function(){"canplaythrough"===event.type&&(this.hasLoaded=!0,this.source&&(this.source.removeEventListener("canplay",this._onCanPlay),this.source.removeEventListener("canplaythrough",this._onCanPlay),this.width=this.source.videoWidth,this.height=this.source.videoHeight,this.__loaded||(this.__loaded=!0,this.dispatchEvent({type:"loaded",content:this}))))},b.VideoTexture.prototype.destroy=function(){this.source&&this.source._pixiId&&(b.BaseTextureCache[this.source._pixiId]=null,delete b.BaseTextureCache[this.source._pixiId],this.source._pixiId=null,delete this.source._pixiId),b.BaseTexture.prototype.destroy.call(this)},b.VideoTexture.baseTextureFromVideo=function(a,c){a._pixiId||(a._pixiId="video_"+b.TextureCacheIdGenerator++);var d=b.BaseTextureCache[a._pixiId];return d||(d=new b.VideoTexture(a,c),b.BaseTextureCache[a._pixiId]=d),d},b.VideoTexture.textureFromVideo=function(a,c){var d=b.VideoTexture.baseTextureFromVideo(a,c);return new b.Texture(d)},b.VideoTexture.fromUrl=function(a,c){var d=document.createElement("video");return d.src=a,d.autoPlay=!0,d.play(),b.VideoTexture.textureFromVideo(d,c)},b.AssetLoader=function(a,c){this.assetURLs=a,this.crossorigin=c,this.loadersByType={jpg:b.ImageLoader,jpeg:b.ImageLoader,png:b.ImageLoader,gif:b.ImageLoader,webp:b.ImageLoader,json:b.JsonLoader,atlas:b.AtlasLoader,anim:b.SpineLoader,xml:b.BitmapFontLoader,fnt:b.BitmapFontLoader}},b.EventTarget.mixin(b.AssetLoader.prototype),b.AssetLoader.prototype.constructor=b.AssetLoader,b.AssetLoader.prototype._getDataType=function(a){var b="data:",c=a.slice(0,b.length).toLowerCase();if(c===b){var d=a.slice(b.length),e=d.indexOf(",");if(-1===e)return null;var f=d.slice(0,e).split(";")[0];return f&&"text/plain"!==f.toLowerCase()?f.split("/").pop().toLowerCase():"txt"}return null},b.AssetLoader.prototype.load=function(){function a(a){b.onAssetLoaded(a.data.content)}var b=this;this.loadCount=this.assetURLs.length;for(var c=0;c0?a.addEventListener("loadedBaseTexture",function(a){a.content.content.loadingCount<=0&&o.onLoaded()}):o.onLoaded()},n.load()}else this.onLoaded()},b.JsonLoader.prototype.onLoaded=function(){this.loaded=!0,this.dispatchEvent({type:"loaded",content:this})},b.JsonLoader.prototype.onError=function(){this.dispatchEvent({type:"error",content:this})},b.AtlasLoader=function(a,b){this.url=a,this.baseUrl=a.replace(/[^\/]*$/,""),this.crossorigin=b,this.loaded=!1},b.AtlasLoader.constructor=b.AtlasLoader,b.EventTarget.mixin(b.AtlasLoader.prototype),b.AtlasLoader.prototype.load=function(){this.ajaxRequest=new b.AjaxRequest,this.ajaxRequest.onreadystatechange=this.onAtlasLoaded.bind(this),this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/json"),this.ajaxRequest.send(null)},b.AtlasLoader.prototype.onAtlasLoaded=function(){if(4===this.ajaxRequest.readyState)if(200===this.ajaxRequest.status||-1===window.location.href.indexOf("http")){this.atlas={meta:{image:[]},frames:[]};var a=this.ajaxRequest.responseText.split(/\r?\n/),c=-3,d=0,e=null,f=!1,g=0,h=0,i=this.onLoaded.bind(this);for(g=0;g0){if(f===g)this.atlas.meta.image.push(a[g]),d=this.atlas.meta.image.length-1,this.atlas.frames.push({}),c=-3;else if(c>0)if(c%7===1)null!=e&&(this.atlas.frames[d][e.name]=e),e={name:a[g],frame:{}};else{var j=a[g].split(" ");if(c%7===3)e.frame.x=Number(j[1].replace(",","")),e.frame.y=Number(j[2]);else if(c%7===4)e.frame.w=Number(j[1].replace(",","")),e.frame.h=Number(j[2]);else if(c%7===5){var k={x:0,y:0,w:Number(j[1].replace(",","")),h:Number(j[2])};k.w>e.frame.w||k.h>e.frame.h?(e.trimmed=!0,e.realSize=k):e.trimmed=!1}}c++}if(null!=e&&(this.atlas.frames[d][e.name]=e),this.atlas.meta.image.length>0){for(this.images=[],h=0;hthis.currentImageId?(this.currentImageId++,this.images[this.currentImageId].load()):(this.loaded=!0,this.emit("loaded",{content:this}))},b.AtlasLoader.prototype.onError=function(){this.emit("error",{content:this})},b.SpriteSheetLoader=function(a,b){this.url=a,this.crossorigin=b,this.baseUrl=a.replace(/[^\/]*$/,""),this.texture=null,this.frames={}},b.SpriteSheetLoader.prototype.constructor=b.SpriteSheetLoader,b.EventTarget.mixin(b.SpriteSheetLoader.prototype),b.SpriteSheetLoader.prototype.load=function(){var a=this,c=new b.JsonLoader(this.url,this.crossorigin);c.on("loaded",function(b){a.json=b.data.content.json,a.onLoaded()}),c.load()},b.SpriteSheetLoader.prototype.onLoaded=function(){this.emit("loaded",{content:this})},b.ImageLoader=function(a,c){this.texture=b.Texture.fromImage(a,c),this.frames=[]},b.ImageLoader.prototype.constructor=b.ImageLoader,b.EventTarget.mixin(b.ImageLoader.prototype),b.ImageLoader.prototype.load=function(){this.texture.baseTexture.hasLoaded?this.onLoaded():this.texture.baseTexture.on("loaded",this.onLoaded.bind(this))},b.ImageLoader.prototype.onLoaded=function(){this.emit("loaded",{content:this})},b.ImageLoader.prototype.loadFramedSpriteSheet=function(a,c,d){this.frames=[];for(var e=Math.floor(this.texture.width/a),f=Math.floor(this.texture.height/c),g=0,h=0;f>h;h++)for(var i=0;e>i;i++,g++){var j=new b.Texture(this.texture.baseTexture,{x:i*a,y:h*c,width:a,height:c});this.frames.push(j),d&&(b.TextureCache[d+"-"+g]=j)}this.load()},b.BitmapFontLoader=function(a,b){this.url=a,this.crossorigin=b,this.baseUrl=a.replace(/[^\/]*$/,""),this.texture=null},b.BitmapFontLoader.prototype.constructor=b.BitmapFontLoader,b.EventTarget.mixin(b.BitmapFontLoader.prototype),b.BitmapFontLoader.prototype.load=function(){this.ajaxRequest=new b.AjaxRequest,this.ajaxRequest.onreadystatechange=this.onXMLLoaded.bind(this),this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/xml"),this.ajaxRequest.send(null)},b.BitmapFontLoader.prototype.onXMLLoaded=function(){if(4===this.ajaxRequest.readyState&&(200===this.ajaxRequest.status||-1===window.location.protocol.indexOf("http"))){var a=this.ajaxRequest.responseXML;if(!a||/MSIE 9/i.test(navigator.userAgent)||navigator.isCocoonJS)if("function"==typeof window.DOMParser){var c=new DOMParser;a=c.parseFromString(this.ajaxRequest.responseText,"text/xml")}else{var d=document.createElement("div");d.innerHTML=this.ajaxRequest.responseText,a=d}var e=this.baseUrl+a.getElementsByTagName("page")[0].getAttribute("file"),f=new b.ImageLoader(e,this.crossorigin);this.texture=f.texture.baseTexture;var g={},h=a.getElementsByTagName("info")[0],i=a.getElementsByTagName("common")[0];g.font=h.getAttribute("face"),g.size=parseInt(h.getAttribute("size"),10),g.lineHeight=parseInt(i.getAttribute("lineHeight"),10),g.chars={};for(var j=a.getElementsByTagName("char"),k=0;ka;a++)this.shaders[a].dirty=!0},b.AlphaMaskFilter=function(a){b.AbstractFilter.call(this),this.passes=[this],a.baseTexture._powerOf2=!0,this.uniforms={mask:{type:"sampler2D",value:a},mapDimensions:{type:"2f",value:{x:1,y:5112}},dimensions:{type:"4fv",value:[0,0,0,0]}},a.baseTexture.hasLoaded?(this.uniforms.mask.value.x=a.width,this.uniforms.mask.value.y=a.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),a.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D mask;","uniform sampler2D uSampler;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {"," vec2 mapCords = vTextureCoord.xy;"," mapCords += (dimensions.zw + offset)/ dimensions.xy ;"," mapCords.y *= -1.0;"," mapCords.y += 1.0;"," mapCords *= dimensions.xy / mapDimensions;"," vec4 original = texture2D(uSampler, vTextureCoord);"," float maskAlpha = texture2D(mask, mapCords).r;"," original *= maskAlpha;"," gl_FragColor = original;","}"]},b.AlphaMaskFilter.prototype=Object.create(b.AbstractFilter.prototype),b.AlphaMaskFilter.prototype.constructor=b.AlphaMaskFilter,b.AlphaMaskFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.mask.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.mask.value.height,this.uniforms.mask.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(b.AlphaMaskFilter.prototype,"map",{get:function(){return this.uniforms.mask.value},set:function(a){this.uniforms.mask.value=a}}),b.ColorMatrixFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={matrix:{type:"mat4",value:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float invert;","uniform mat4 matrix;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * matrix;","}"]},b.ColorMatrixFilter.prototype=Object.create(b.AbstractFilter.prototype),b.ColorMatrixFilter.prototype.constructor=b.ColorMatrixFilter,Object.defineProperty(b.ColorMatrixFilter.prototype,"matrix",{get:function(){return this.uniforms.matrix.value},set:function(a){this.uniforms.matrix.value=a}}),b.GrayFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={gray:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform float gray;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);"," gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), gray);","}"]},b.GrayFilter.prototype=Object.create(b.AbstractFilter.prototype),b.GrayFilter.prototype.constructor=b.GrayFilter,Object.defineProperty(b.GrayFilter.prototype,"gray",{get:function(){return this.uniforms.gray.value},set:function(a){this.uniforms.gray.value=a}}),b.DisplacementFilter=function(a){b.AbstractFilter.call(this),this.passes=[this],a.baseTexture._powerOf2=!0,this.uniforms={displacementMap:{type:"sampler2D",value:a},scale:{type:"2f",value:{x:30,y:30}},offset:{type:"2f",value:{x:0,y:0}},mapDimensions:{type:"2f",value:{x:1,y:5112}},dimensions:{type:"4fv",value:[0,0,0,0]}},a.baseTexture.hasLoaded?(this.uniforms.mapDimensions.value.x=a.width,this.uniforms.mapDimensions.value.y=a.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),a.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D displacementMap;","uniform sampler2D uSampler;","uniform vec2 scale;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {"," vec2 mapCords = vTextureCoord.xy;"," mapCords += (dimensions.zw + offset)/ dimensions.xy ;"," mapCords.y *= -1.0;"," mapCords.y += 1.0;"," vec2 matSample = texture2D(displacementMap, mapCords).xy;"," matSample -= 0.5;"," matSample *= scale;"," matSample /= mapDimensions;"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + matSample.x, vTextureCoord.y + matSample.y));"," gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb, 1.0);"," vec2 cord = vTextureCoord;","}"]},b.DisplacementFilter.prototype=Object.create(b.AbstractFilter.prototype),b.DisplacementFilter.prototype.constructor=b.DisplacementFilter,b.DisplacementFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.displacementMap.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.displacementMap.value.height,this.uniforms.displacementMap.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(b.DisplacementFilter.prototype,"map",{get:function(){return this.uniforms.displacementMap.value},set:function(a){this.uniforms.displacementMap.value=a}}),Object.defineProperty(b.DisplacementFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(a){this.uniforms.scale.value=a}}),Object.defineProperty(b.DisplacementFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(a){this.uniforms.offset.value=a}}),b.PixelateFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"1f",value:0},dimensions:{type:"4fv",value:new b.Float32Array([1e4,100,10,10])},pixelSize:{type:"2f",value:{x:10,y:10}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec2 testDim;","uniform vec4 dimensions;","uniform vec2 pixelSize;","uniform sampler2D uSampler;","void main(void) {"," vec2 coord = vTextureCoord;"," vec2 size = dimensions.xy/pixelSize;"," vec2 color = floor( ( vTextureCoord * size ) ) / size + pixelSize/dimensions.xy * 0.5;"," gl_FragColor = texture2D(uSampler, color);","}"]},b.PixelateFilter.prototype=Object.create(b.AbstractFilter.prototype),b.PixelateFilter.prototype.constructor=b.PixelateFilter,Object.defineProperty(b.PixelateFilter.prototype,"size",{get:function(){return this.uniforms.pixelSize.value},set:function(a){this.dirty=!0,this.uniforms.pixelSize.value=a}}),b.BlurXFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," vec4 sum = vec4(0.0);"," sum += texture2D(uSampler, vec2(vTextureCoord.x - 4.0*blur, vTextureCoord.y)) * 0.05;"," sum += texture2D(uSampler, vec2(vTextureCoord.x - 3.0*blur, vTextureCoord.y)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x - 2.0*blur, vTextureCoord.y)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x - blur, vTextureCoord.y)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + blur, vTextureCoord.y)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;"," gl_FragColor = sum;","}"]},b.BlurXFilter.prototype=Object.create(b.AbstractFilter.prototype),b.BlurXFilter.prototype.constructor=b.BlurXFilter,Object.defineProperty(b.BlurXFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.dirty=!0,this.uniforms.blur.value=1/7e3*a}}),b.BlurYFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," vec4 sum = vec4(0.0);"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 4.0*blur)) * 0.05;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 3.0*blur)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 2.0*blur)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - blur)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + blur)) * 0.15;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;"," sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;"," gl_FragColor = sum;","}"]},b.BlurYFilter.prototype=Object.create(b.AbstractFilter.prototype),b.BlurYFilter.prototype.constructor=b.BlurYFilter,Object.defineProperty(b.BlurYFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),b.BlurFilter=function(){this.blurXFilter=new b.BlurXFilter,this.blurYFilter=new b.BlurYFilter,this.passes=[this.blurXFilter,this.blurYFilter]},b.BlurFilter.prototype=Object.create(b.AbstractFilter.prototype),b.BlurFilter.prototype.constructor=b.BlurFilter,Object.defineProperty(b.BlurFilter.prototype,"blur",{get:function(){return this.blurXFilter.blur},set:function(a){this.blurXFilter.blur=this.blurYFilter.blur=a}}),Object.defineProperty(b.BlurFilter.prototype,"blurX",{get:function(){return this.blurXFilter.blur},set:function(a){this.blurXFilter.blur=a}}),Object.defineProperty(b.BlurFilter.prototype,"blurY",{get:function(){return this.blurYFilter.blur},set:function(a){this.blurYFilter.blur=a}}),b.InvertFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float invert;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);"," gl_FragColor.rgb = mix( (vec3(1)-gl_FragColor.rgb) * gl_FragColor.a, gl_FragColor.rgb, 1.0 - invert);","}"]},b.InvertFilter.prototype=Object.create(b.AbstractFilter.prototype),b.InvertFilter.prototype.constructor=b.InvertFilter,Object.defineProperty(b.InvertFilter.prototype,"invert",{get:function(){return this.uniforms.invert.value},set:function(a){this.uniforms.invert.value=a}}),b.SepiaFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={sepia:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float sepia;","uniform sampler2D uSampler;","const mat3 sepiaMatrix = mat3(0.3588, 0.7044, 0.1368, 0.2990, 0.5870, 0.1140, 0.2392, 0.4696, 0.0912);","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);"," gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb * sepiaMatrix, sepia);","}"]},b.SepiaFilter.prototype=Object.create(b.AbstractFilter.prototype),b.SepiaFilter.prototype.constructor=b.SepiaFilter,Object.defineProperty(b.SepiaFilter.prototype,"sepia",{get:function(){return this.uniforms.sepia.value},set:function(a){this.uniforms.sepia.value=a}}),b.TwistFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={radius:{type:"1f",value:.5},angle:{type:"1f",value:5},offset:{type:"2f",value:{x:.5,y:.5}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float radius;","uniform float angle;","uniform vec2 offset;","void main(void) {"," vec2 coord = vTextureCoord - offset;"," float distance = length(coord);"," if (distance < radius) {"," float ratio = (radius - distance) / radius;"," float angleMod = ratio * ratio * angle;"," float s = sin(angleMod);"," float c = cos(angleMod);"," coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);"," }"," gl_FragColor = texture2D(uSampler, coord+offset);","}"]},b.TwistFilter.prototype=Object.create(b.AbstractFilter.prototype),b.TwistFilter.prototype.constructor=b.TwistFilter,Object.defineProperty(b.TwistFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(a){this.dirty=!0,this.uniforms.offset.value=a}}),Object.defineProperty(b.TwistFilter.prototype,"radius",{get:function(){return this.uniforms.radius.value},set:function(a){this.dirty=!0,this.uniforms.radius.value=a}}),Object.defineProperty(b.TwistFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(a){this.dirty=!0,this.uniforms.angle.value=a}}),b.ColorStepFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={step:{type:"1f",value:5}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform float step;","void main(void) {"," vec4 color = texture2D(uSampler, vTextureCoord);"," color = floor(color * step) / step;"," gl_FragColor = color;","}"]},b.ColorStepFilter.prototype=Object.create(b.AbstractFilter.prototype),b.ColorStepFilter.prototype.constructor=b.ColorStepFilter,Object.defineProperty(b.ColorStepFilter.prototype,"step",{get:function(){return this.uniforms.step.value},set:function(a){this.uniforms.step.value=a}}),b.DotScreenFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={scale:{type:"1f",value:1},angle:{type:"1f",value:5},dimensions:{type:"4fv",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float angle;","uniform float scale;","float pattern() {"," float s = sin(angle), c = cos(angle);"," vec2 tex = vTextureCoord * dimensions.xy;"," vec2 point = vec2("," c * tex.x - s * tex.y,"," s * tex.x + c * tex.y"," ) * scale;"," return (sin(point.x) * sin(point.y)) * 4.0;","}","void main() {"," vec4 color = texture2D(uSampler, vTextureCoord);"," float average = (color.r + color.g + color.b) / 3.0;"," gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);","}"]},b.DotScreenFilter.prototype=Object.create(b.AbstractFilter.prototype),b.DotScreenFilter.prototype.constructor=b.DotScreenFilter,Object.defineProperty(b.DotScreenFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(a){this.dirty=!0,this.uniforms.scale.value=a}}),Object.defineProperty(b.DotScreenFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(a){this.dirty=!0,this.uniforms.angle.value=a}}),b.CrossHatchFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {"," float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);"," gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);"," if (lum < 1.00) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," if (lum < 0.75) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," if (lum < 0.50) {"," if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }"," if (lum < 0.3) {"," if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {"," gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);"," }"," }","}"]},b.CrossHatchFilter.prototype=Object.create(b.AbstractFilter.prototype),b.CrossHatchFilter.prototype.constructor=b.CrossHatchFilter,Object.defineProperty(b.CrossHatchFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(a){this.uniforms.blur.value=1/7e3*a}}),b.RGBSplitFilter=function(){b.AbstractFilter.call(this),this.passes=[this],this.uniforms={red:{type:"2f",value:{x:20,y:20}},green:{type:"2f",value:{x:-20,y:20}},blue:{type:"2f",value:{x:20,y:-20}},dimensions:{type:"4fv",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec2 red;","uniform vec2 green;","uniform vec2 blue;","uniform vec4 dimensions;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/dimensions.xy).r;"," gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/dimensions.xy).g;"," gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/dimensions.xy).b;"," gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;","}"]},b.RGBSplitFilter.prototype=Object.create(b.AbstractFilter.prototype),b.RGBSplitFilter.prototype.constructor=b.RGBSplitFilter,Object.defineProperty(b.RGBSplitFilter.prototype,"red",{get:function(){return this.uniforms.red.value},set:function(a){this.uniforms.red.value=a}}),Object.defineProperty(b.RGBSplitFilter.prototype,"green",{get:function(){return this.uniforms.green.value},set:function(a){this.uniforms.green.value=a}}),Object.defineProperty(b.RGBSplitFilter.prototype,"blue",{get:function(){return this.uniforms.blue.value},set:function(a){this.uniforms.blue.value=a}}),"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=b),exports.PIXI=b):"undefined"!=typeof define&&define.amd?define(b):a.PIXI=b}).call(this);
\ No newline at end of file