1
2
3
4
5
6
7
8
9
10
11
12
|
// The minimun amount of time Poe's hexes take to reach their new screen position
const MinMovementTime = 0.8;
// The amount of variation to the time Poe's hexes take to reach their new position
// (in seconds)
const MovementVariation = 0.9;
const colors = ["#db2923", "#eb7436", "#e3c815"];
const opacities = ["0.3", "0.2", "0.1"];
function getRandomTransform() {
const scale = (Math.random() * 8 + 3) / 20;
const x = Math.random() * 50 - 25;
const y = Math.random() * 50 - 25;
|
<
<
<
<
<
|
1
2
3
4
5
6
7
|
const colors = ["#db2923", "#eb7436", "#e3c815"];
const opacities = ["0.3", "0.2", "0.1"];
function getRandomTransform() {
const scale = (Math.random() * 8 + 3) / 20;
const x = Math.random() * 50 - 25;
const y = Math.random() * 50 - 25;
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
PoeModel.mood = "breathing";
var PoeViewController = clone(StorkHtmlView);
// How much variation there is in Poe's hexes' screen position movement delay (seconds)
PoeViewController.movementDelayVariance = 0.4;
PoeViewController.breathingDurationMin = 2;
PoeViewController.breathingDurationVariance = 3;
PoeViewController.breathingDelayVariance = 1.0;
// HTML prototype element for a Poe
PoeViewController.bodypartProto = null;
|
>
>
>
>
>
>
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
PoeModel.mood = "breathing";
var PoeViewController = clone(StorkHtmlView);
// How much variation there is in Poe's hexes' screen position movement delay (seconds)
PoeViewController.movementDelayVariance = 0.4;
// The minimun amount of time Poe's body parts take to reach their new
// screen position
PoeViewController.movementMinDuration = 0.8;
// The amount of variation to the time Poe's hexes take to reach their new position
// (in seconds)
PoeViewController.movementVariance = 0.9;
PoeViewController.breathingDurationMin = 2;
PoeViewController.breathingDurationVariance = 3;
PoeViewController.breathingDelayVariance = 1.0;
// HTML prototype element for a Poe
PoeViewController.bodypartProto = null;
|
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
}
PoeViewController.breathingTransitionDelay = function() {
let delay = Math.random() * this.breathingDelayVariance;
return delay + "s";
}
PoeViewController.attach = function(parent) {
this.superMethod(PoeViewController.attach, "attach", parent);
this.breathingElements = [];
this.locatorElements = [];
if ( (this.model != null) && (this.bodypartProto != null) &&
(this.bodyArea != null) ) {
console.debug(this.model);
console.debug(this.model.getProperty("bodypartNum"));
for (i=0; i < this.model.getProperty("bodypartNum"); i++) {
let locatorElement =
cloneNodeSetIDs(this.bodypartProto, "PoeBody-", i);
if (!this.bodypartID) {
throw new Error("Body part sub ID was not set for Poe body.");
}
let breathingElement =
getElementFromStorkID(locatorElement, "PoeBody-",
this.bodypartID,
i);
breathingElement.style.opacity = "0.5";
breathingElement.style.top = i * 10 + "px";
breathingElement.style.left = i * 10 + "px";
breathingElement.style.transitionDelay =
this.breathingTransitionDelay();
breathingElement.style.transitionDuration =
(Math.random() * this.breathingDurationVariance +
this.breathingDurationMin) + "s";
parent.appendChild(locatorElement);
this.locatorElements.push(locatorElement);
this.breathingElements.push(breathingElement);
this.breathBody();
// This is here to cause some breathing animation more rapidly
// than the regular interval below it.
setTimeout(() => {
this.breathBody();
setInterval(() => {
this.breathBody();
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
<
|
|
>
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
}
PoeViewController.breathingTransitionDelay = function() {
let delay = Math.random() * this.breathingDelayVariance;
return delay + "s";
}
PoeViewController.setPosition = function(left, top) {
for (i=0; i < this.locatorElements.length; i++) {
let el = this.locatorElements[i];
el.style.left = left;
el.style.top = top;
}
};
PoeViewController.attach = function(parent) {
this.superMethod(PoeViewController.attach, "attach", parent);
this.breathingElements = [];
this.locatorElements = [];
if ( (this.model != null) && (this.bodypartProto != null) &&
(this.bodyArea != null) ) {
console.debug(this.model);
console.debug(this.model.getProperty("bodypartNum"));
for (i=0; i < this.model.getProperty("bodypartNum"); i++) {
let locatorElement =
cloneNodeSetIDs(this.bodypartProto, "PoeBody-", i);
console.debug(Math.random() * this.movementDelayVariance + "s");
locatorElement.style.transitionDelay =
Math.random() * this.movementDelayVariance + "s";
locatorElement.style.transitionDuration =
(Math.random() * this.movementVariance +
this.movementDurationMin) + "s";
console.debug(locatorElement);
console.debug(locatorElement.style.transitionDelay);
console.debug(locatorElement.style.transitionProperty);
if (!this.bodypartID) {
throw new Error("Body part sub ID was not set for Poe body.");
}
let breathingElement =
getElementFromStorkID(locatorElement, "PoeBody-",
this.bodypartID,
i);
//breathingElement.style.top = i * 10 + "px";
//breathingElement.style.left = i * 10 + "px";
breathingElement.style.transitionDelay =
this.breathingTransitionDelay();
breathingElement.style.transitionDuration =
(Math.random() * this.breathingDurationVariance +
this.breathingDurationMin) + "s";
parent.appendChild(locatorElement);
this.locatorElements.push(locatorElement);
this.breathingElements.push(breathingElement);
// Set up some initial breath positions
this.breathBody();
// This is here to cause some breathing animation more rapidly
// than the regular interval below it.
setTimeout(() => {
this.breathBody();
setInterval(() => {
this.breathBody();
|