I have a webpage where I integrated p5 and sketch.js for a canvas animation.
The page tries to download arbitrary tar-files every now and then and I can't figure out why.
I disabled CCapture and all the keystrokes that seem to trigger a download.
Any ideas why this is happening?
[edit] as per request
Files are downloaded from here:
<script src="https://Unpkg.com/ccapture.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.10.2/p5.js"></script>
And this is the code:
var DEBUG = false; // Set this to false before capturing
var ENK = [85.5, 85.7, 86.6, 87.7, 88.5]; //ENK Werte aus der Studie
var WNK = [89.6, 89.8, 90.3, 91.0, 91.8]; //WNK Werte aus der Studie
var DURATION = 100// In frames / 2
var TRANSITION_DURATION =1000; // In frames
var STEPS = 20;
var COUNT;
var C;
var ns = [0.004, 0.003, 0.004]; // NOISE SCALES array // Ausgangswert Noise Scale
var transition = { oX: ns[0], oY: ns[1], tX: ns[0], tY: ns[1], t: 0, ing: false }; //Smooth transition/Positionsänderung
var look = 0;
var phase;
var capturer, cnvs;
// SETUP wird nur einmal abgerufen und bleibt deshalb immer gleich
function setup() {
var moodImageDiv = document.getElementById('moodImage');
var canvas = createCanvas(moodImageDiv.offsetWidth, moodImageDiv.offsetHeight);
canvas.parent('moodImage');
//setupCCapture(); // Uncomment this to set up capturing
C = {
bg1: color(69, 6, 19),
bg2: color(150, 0, 60), // Hintergrund Farbe Bordeaux
bg3: color(240, 70,107),
a: color(245, 60, 105),
b: color(140, 40, 135), //Linien Farben
c: color(255, 70, 107),
d: color(145, 30, 100)
};
background(0);
strokeWeight(0.5);
noFill();
COUNT = round(width * 1.5 / STEPS);
changeLook(0); // Uncomment this to start with Look #1 instead of #0
}
// UPDATE wird immer wieder aufgerufen
function update() {
phase = frameCount / 2; // deklarierung in der Funktion
if (transition.ing) {
transition.t++; // increment um 1
if (transition.t < TRANSITION_DURATION) {
ns[0] = lerp(transition.oX, transition.tX, transition.t / TRANSITION_DURATION);
ns[1] = lerp(transition.oY, transition.tY, transition.t / TRANSITION_DURATION);
} else {
transition.ing = false;
transition.t = 0;
}
}
if (phase % DURATION == 0 && !DEBUG) {
var nextLook = (look + 1 <= ENK.length-2) ? look + 1 : 1;
changeLook(nextLook);
}
}
// DRAW wird immer wieder aufgerufen
function draw() {
update();
drawBackground();
var col;
// Hier Datenänderung, durch Farbwechsel?
// Linienmenge, evt in Variable packen und mit je nach Phase spielen (5,10,15,20)
for (var y = 0; y < height; y += 10) {
col = lerpColor(C.a, C.b, y / height);
drawPerlinCurve(width + 50, y, phase, col);
}
// ..oder du kreeierst einen zweiten for-loop (Daten)
for (var z = 2; z < height; z += 8) {
// col = lerpColor( color(60, 90, 255), color(255, 70, 107), z / height);
col = lerpColor(C.c, C.d, z / height);
drawPerlinCurve(width + 50, z, phase, col);
}
capture();
}
// KEYPRESSED
function keyPressed() {
if (keyCode === RIGHT_ARROW) {
changeLook(look + 1);
if (look === 0) changeLook(1);
}
if (keyCode === LEFT_ARROW) {
changeLook(look - 1);
}
if (keyCode === ENTER) {
//save('pix.tiff');
}
}
// CHANGE LOOK
function changeLook( id ) {
var x, y;
if (id > 0 && id <= ENK.length-2) {
x = ENK[id] - ENK[id-1];
y = WNK[id-1] - ENK[id-1];
} else {
if (DEBUG) console.log(`No Look #${id} found!`);
ns[0] = 0.004;
ns[1] = 0.003;
id = 0;
}
if (x && y) {
// if (DEBUG) console.log(`${x} : ${y}`);
transition.tX = map(x, -0.09, 2.1, 0.002, 0.009);
transition.tY = map(y, 3.7, 7.1, 0.002, 0.009);
startTransition();
if (DEBUG) console.log(`X: ${ns[0]}, Y: ${ns[1]}`);
}
look = id;
if (DEBUG) console.log(`New Look! #${id}`);
}
// DRAW BACKGROUND
function drawBackground() {
push();
drawGradientBackground(0, 0, windowWidth, windowHeight, C.bg1, C.bg2);
//drawGradientBackground(0,0, windowHeight, windowWidth, windowHeight, C.bg2, C.bg3);
pop();
}
// DRAW GRADIENT BACKGROUND
function drawGradientBackground( x, y, w, h, c1, c2 ) {
noFill();
for (var i = y; i <= y + h; i++) { // Variable innerhalb der Funktion
var inter = map(i, y, y + h, 0, 0); //Variable innerhalb der Funktion
var c = lerpColor(C.bg1, C.bg2, inter); // Variable innerhalb der Funktion
stroke(c);
line(x, i, x + w, i);
}
}
// DRAW PERLIN CURVE
function drawPerlinCurve( x, y, phase, myColour ) {
push();
stroke(myColour);
beginShape();
for (var i = 0; i < COUNT; i++) {
curveVertex(x, y);
var angle = 2 * PI * noise(x * ns[0], y * ns[1], phase * ns[2]);
x += cos(angle) * STEPS;
y += sin(angle) * STEPS;
}
endShape();
pop();
}
// START TRANSITION
function startTransition() {
transition.oX = ns[0];
transition.oY = ns[1];
transition.t = 0;
transition.ing = true;
}