fix for reduced resource consumption that backfired on fast devices

This commit is contained in:
Gavin McDonald
2019-02-12 23:38:55 +00:00
parent c65a06a4ae
commit d893e6c003
4 changed files with 3799 additions and 20 deletions

28
package-lock.json generated
View File

@@ -2309,12 +2309,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -2329,17 +2331,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@@ -2456,7 +2461,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@@ -2468,6 +2474,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -2482,6 +2489,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -2489,12 +2497,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -2513,6 +2523,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -2593,7 +2604,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@@ -2605,6 +2617,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@@ -2726,6 +2739,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",

File diff suppressed because one or more lines are too long

View File

@@ -3,6 +3,9 @@ import FPS from './fps.js';
const ONE_SECOND = 1000;
const PRESS_RIPPLE = ONE_SECOND / 3;
const INTERACTION_WINDOW = 100;
const IDLE_DRAW_DELAY = 100;
const DEFAULTS = {
board: Tessellate.BOARD_STYLES.HEX,
style: Tessellate.DRAW_STYLES.FILL,
@@ -275,6 +278,7 @@ class Demo {
0, // tiles
0, // pips
0, // mines
0, // drawDelay
];
Tessellate.Shapes.background(context, height, width, {
@@ -303,15 +307,13 @@ class Demo {
Tessellate.TILES[cell.tileStyle][cell.drawStyle](context, scale, pixelPoint.getX(), pixelPoint.getY(), cell);
});
// Tessellate.funky.forEach(this.mines, cell => {
// this.counts[2] += 1;
// const pixelPoint = this.tessellate.tileToPixel(cell);
// Tessellate.Shapes.mine(context, scale, pixelPoint.getX(), pixelPoint.getY());
// });
const drawDelay = moved || this.ripples.length || (now - interacted) < INTERACTION_WINDOW ? 0 : IDLE_DRAW_DELAY;
this.counts[3] = drawDelay;
this.fps.frame(now, lastNow, this.counts);
return interacted || moved || this.ripples.length ? 0 : 100;
return drawDelay;
}
}

View File

@@ -93,6 +93,8 @@ export class Tessellate {
'remap',
].map(method => {this[method] = this[method].bind(this)});
this.interacted = Date.now();
this.checkSettings(settings);
this.sketch = new Sketch({
@@ -152,7 +154,7 @@ export class Tessellate {
const tile = this.cartographer.pixelToTile(point);
const mapTile = this.cartographer.teleport(tile);
this.interacted = true;
this.interacted = Date.now();
this.settings.tap({
event,
@@ -169,6 +171,7 @@ export class Tessellate {
const mapTile = this.cartographer.teleport(tile);
this.interacted = true;
this.interacted = Date.now();
let tap = {
event,
@@ -187,6 +190,7 @@ export class Tessellate {
const mapTile = this.cartographer.teleport(tile);
this.interacted = true;
this.interacted = Date.now();
this.settings.pressStart({
event,
@@ -202,6 +206,7 @@ export class Tessellate {
const mapTile = this.cartographer.teleport(tile);
this.interacted = true;
this.interacted = Date.now();
this.settings.press({
event,
@@ -212,10 +217,12 @@ export class Tessellate {
}
move (event) {
this.interacted = Date.now();
return this.cartographer.move(event);
}
zoom (event) {
this.interacted = Date.now();
this.cartographer.zoom(event);
}
@@ -231,9 +238,9 @@ export class Tessellate {
this.lastLocation = this.lastLocation || {};
const currentLocation = utils.extend({
scale: this.cartographer.getScale(),
originX: this.cartographer.getOriginX(),
originY: this.cartographer.getOriginY(),
scaleOrig: this.cartographer.getScale(),
}, corners);
const changed = funky.reduce(currentLocation, (same, val, key) => same || this.lastLocation[key] !== val, false);
@@ -266,9 +273,6 @@ export class Tessellate {
lowerRightY: height
};
const interacted = this.interacted;
this.interacted = false;
const moved = this.newLocation(corners);
this.locationSets = moved ? this.getLocationSets(corners) : this.locationSets;
@@ -281,8 +285,8 @@ export class Tessellate {
lastNow: context.lastUTC,
now: context.utc,
interacted,
moved,
interacted: this.interacted,
locationSets: this.locationSets,
});
}