-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #394 from DishpitDev/staging
fuck it yolo merge to mommy
- Loading branch information
Showing
4 changed files
with
125 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
let vol = new Tone.Volume(-12).toDestination(); | ||
|
||
let redOsc = new Tone.Oscillator({ | ||
frequency: 523.25, | ||
type: "sine", | ||
}).connect(vol); | ||
|
||
let blueOsc = new Tone.Oscillator({ | ||
frequency: 523.25, | ||
type: "sine", | ||
}).connect(vol); | ||
|
||
function randomFloat(from, to) { | ||
return from + Math.random() * (to - from); | ||
} | ||
|
||
function changeFreq(osc) { | ||
osc.frequency.rampTo(randomFloat(100, 1000), 0); | ||
} | ||
|
||
function changeFreqs() { | ||
changeFreq(redOsc); | ||
changeFreq(blueOsc); | ||
} | ||
|
||
function randomiseRect(classname) { | ||
var rect = document.querySelector("." + classname); | ||
if (!rect) { | ||
console.warn(`Element with class ${classname} not found`); | ||
return; | ||
} | ||
var rect = document.querySelector("." + classname); | ||
let xpos = randomFloat(0, window.innerWidth); | ||
let ypos = randomFloat(0, window.innerHeight); | ||
let width = randomFloat(1, window.innerWidth - xpos); | ||
let height = randomFloat(1, window.innerHeight - ypos); | ||
|
||
let st = `top:${ypos}px;left:${xpos}px;width:${width}px;height:${height}px;`; | ||
rect.setAttribute("style", st); | ||
} | ||
|
||
function randomiseRects() { | ||
randomiseRect("red"); | ||
randomiseRect("blue"); | ||
} | ||
|
||
function syncAudioAndVisual() { | ||
changeFreqs(); | ||
randomiseRects(); | ||
} | ||
|
||
const mainloop = new Tone.Loop((time) => { | ||
syncAudioAndVisual(); | ||
}, "1b").start(0); | ||
|
||
document.addEventListener("DOMContentLoaded", function () { | ||
// i fucking hate the interaction requierment for autoplay stuff ,its so annoying IDC if it improves user experience i want stuff to play wheneveri want it to play!!!!!!!!! | ||
var p = document.querySelector("p"); | ||
|
||
document.addEventListener("click", () => { | ||
p.remove(); | ||
Tone.start(); | ||
redOsc.start(); | ||
blueOsc.start(); | ||
Tone.getTransport().start(); | ||
}); | ||
}); | ||
|
||
window.addEventListener("unload", () => { | ||
redOsc.stop(); | ||
blueOsc.stop(); | ||
Tone.getTransport().stop(); | ||
Tone.stop(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.limb { | ||
position: absolute; | ||
width: 100px; | ||
height: 100px; | ||
} | ||
|
||
.red { | ||
background-color: red; | ||
} | ||
|
||
.blue { | ||
background-color: blue; | ||
top: 200px; | ||
left: 241px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Webdriver Torso</title> | ||
<!-- <script type="module" src="/webdrivertorso/assets/index-1k6tbnXe.js"></script> | ||
<link rel="stylesheet" href="/webdrivertorso/assets/index-CIGsSOx4.css"> --> | ||
<script src="http://unpkg.com/tone"></script> | ||
<script src="assets/main.js"></script> | ||
<link rel="stylesheet" href="assets/style.css" /> | ||
</head> | ||
<body> | ||
<p>Click anywhere on the page to begin.</p> | ||
<div class="limb blue"></div> | ||
<div class="limb red"></div> | ||
</body> | ||
</html> |