// var CS2_elem = document.registerElement('CS2');
// var ctx_svg = document.body.appendChild(new CS2_elem(500,500));
// ctx_svg.id = "ctx_svg"
var lignes_logo = 10;
if (1 || navigator.userAgent.indexOf("Firefox") > 0) {
burger_barbo_ctx.strokeStyle = 'rgba(100,100,100,0.05)';
burger_barbo_ctx.lineWidth = .2;
ctx.strokeStyle = 'rgba(100,100,100,0.1)';
ctx.lineWidth = .2;
mobile_logo_ctx.strokeStyle = 'rgba(100,100,100,0.1)';
mobile_logo_ctx.lineWidth = .2;
lignes_logo = 4;
} else {
burger_barbo_ctx.strokeStyle = 'rgba(0,0,0,0.01)';
burger_barbo_ctx.lineWidth = .15;
ctx.strokeStyle = 'rgba(0,0,0,0.01)';
ctx.lineWidth = .15; //.15; HAHA
mobile_logo_ctx.strokeStyle = 'rgba(0,0,0,0.01)';
mobile_logo_ctx.lineWidth = .15;
}
logo = document.getElementById("barbo");
function randn_bm() {
var u = 0, v = 0;
while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
while(v === 0) v = Math.random();
let num = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v );
num = num / 10.0 + 0.5; // Translate to 0 -> 1
if (num > 1 || num < 0) return randn_bm(); // resample between 0 and 1
return num;
}
function run() {
counter++;
rw = destinationCanvas.width;
rh = destinationCanvas.height;
logo_pos = logo.getBoundingClientRect();
if (init == 0) {
if (counter>10) {
init = 1;
} else {
for (let overlaps = 0; overlaps < lignes_logo; overlaps += 1) {
ctx.quadraticCurveTo(Math.random()*100,Math.random()*100,randn_bm()*100,randn_bm()*100);
// ctx.quadraticCurveTo(Math.random()*100,Math.random()*100,Math.random()*95,Math.random()*95);
// ctx.quadraticCurveTo(randn_bm()*100,randn_bm()*100,Math.random()*95,Math.random()*95);
ctx.stroke();
mobile_logo_ctx.quadraticCurveTo(Math.random()*mobile_logo_canvas.width/2,Math.random()*mobile_logo_canvas.height/2,randn_bm()*mobile_logo_canvas.width/2,randn_bm()*mobile_logo_canvas.height/2);
// ctx.quadraticCurveTo(Math.random()*100,Math.random()*100,Math.random()*95,Math.random()*95);
// ctx.quadraticCurveTo(randn_bm()*100,randn_bm()*100,Math.random()*95,Math.random()*95);
mobile_logo_ctx.stroke();
console.log(333)
}
for (let index = 0; index < 3; index += 1) {
burger_barbo_ctx.moveTo(Math.random()*50,Math.random()*burger_spacing+index*burger_spacing,randn_bm()*50,randn_bm()*burger_spacing+index*burger_spacing);
for (let overlaps = 0; overlaps < 3; overlaps += 1) {
burger_barbo_ctx.quadraticCurveTo(Math.random()*50,Math.random()*burger_spacing+index*burger_spacing,randn_bm()*50,randn_bm()*burger_spacing+index*burger_spacing);
burger_barbo_ctx.stroke();
}
}
ctx_bg.quadraticCurveTo(Math.random()*rw,Math.random()*rh,Math.random()*(rw+2000)-1000.,Math.random()*(rh+2000)-1000);
ctx_bg.stroke();
}
} else {
if (counter>30) { //30
counter = 0
if (Math.random() < .1) {
ctx_bg.strokeStyle = 'rgba(255,255,255,0.5)';
} else {
ctx_bg.strokeStyle = 'rgba(10,0,0,0.275)';
}
ctx_bg.beginPath();
//attracteur
if (Math.random()< .1) {
ctx_bg.quadraticCurveTo((randn_bm()*500)+(logo_pos.x)-200,randn_bm()*500+(logo_pos.y)-200,randn_bm()*500+(logo_pos.x)-200,randn_bm()*500+(logo_pos.y)-200);
}
ctx_bg.quadraticCurveTo(Math.random()*(rw+2000)-1000,Math.random()*(rh+2000)-1000,Math.random()*(rw+2000)-1000.,Math.random()*(rh+2000)-1000);
ctx_bg.stroke();
// document.body.style.background = "url(" + destinationCanvas.toDataURL() + ")";
}
}
window.requestAnimationFrame(run);
}
function setupScrollCanvas(canvas, factor=1) {
var dpr = window.devicePixelRatio || 1;
var rect = canvas.getBoundingClientRect();
canvas.width = rect.width * dpr * factor;
// WORKS ON DESKTOP; TWICE TOO LONG ON MOBILE (dpr??)
canvas.height = (document.body.scrollHeight+100) * dpr * factor;
// canvas.height = (document.body.scrollHeight) * dpr * factor;
canvas.style.width = rect.width * factor;
canvas.style.height = (document.body.scrollHeight+100) * factor;
// canvas.style.height = (document.body.scrollHeight) * factor;
var ctx = canvas.getContext('2d');
ctx.scale(dpr, dpr);
return ctx;
}
function setupCanvas(canvas, factor=1) {
// Get the device pixel ratio, falling back to 1.
var dpr = window.devicePixelRatio || 1;
// Get the size of the canvas in CSS pixels.
var rect = canvas.getBoundingClientRect();
// Give the canvas pixel dimensions of their CSS
// size * the device pixel ratio.
canvas.width = rect.width * dpr * factor;
canvas.height = rect.height * dpr * factor;
canvas.style.width = rect.width * factor;
canvas.style.height = rect.height * factor;
var ctx = canvas.getContext('2d');
// Scale all drawing operations by the dpr, so you
// don't have to worry about the difference.
ctx.scale(dpr, dpr);
return ctx;
}
window.requestAnimationFrame(run);
-->