Reposition fps graphic, randomize cycles button

This commit is contained in:
2017-08-12 22:41:13 -04:00
parent 1b5c8261cf
commit 329b211d1c
3 changed files with 27 additions and 4 deletions

View File

@@ -513,6 +513,14 @@ function redistributeCycles (points, oldCycleDuration, cycleDuration) {
return points;
}
function randomizeCycles (points, cycleDuration) {
/* Assigns every point a new random cycle start */
for (var i = 0; i < points.original.length; i++) {
points.target[i][3] = randomInt(0, cycleDuration - 1);
}
return points;
}
/* DRAW FUNCTIONS */
function drawPolygon (polygon, points, counter, tweeningFns) {
@@ -721,7 +729,8 @@ function loopStart () {
};
fpsGraphic = new window.PIXI.Text('0', {font: '25px monospace', fill: 'yellow'});
fpsGraphic.x = 0;
fpsGraphic.anchor = new window.PIXI.Point(1, 0);
fpsGraphic.x = screenWidth - 1;
fpsGraphic.y = 0;
if (fpsEnabled) {
@@ -899,6 +908,11 @@ window.onload = function () {
toggleControls();
}, false);
document.getElementById('randomize-cycles').addEventListener('click', function () {
randomizeCycles(polygonPoints, cycleDuration);
return false;
}, false);
var timeRange, timeInput;
timeRange = document.getElementsByName('timeRange')[0];
timeRange.value = cycleDuration;