-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvalentine.html
100 lines (83 loc) · 3.25 KB
/
valentine.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="lib/p5.min.js"></script>
<script src="lib/p5.dom.min.js"></script>
<script src="lib/p5.sound.min.js"></script>
<script src="lib/rita-full.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css?family=Gochi+Hand');
</style>
<link rel="stylesheet" href="./valentines/valentines.css" />
<!-- <link
href="https://fonts.googleapis.com/css?family=Fjalla+One"
rel="stylesheet"
/> -->
<title>Algotines</title>
<link rel="icon" href="./valentines/clickers/3.png" type="image/x-icon"/>
<script>
//text generator stuff
var lines, markov, data1;
function preload() {
data1 = loadStrings('valentines/DATA.TXT');
}
function setup() { // keep it in setup because data needs to finish loading before we make markov
// create a markov model w' n=4
markov = new RiMarkov(2);
lines = ["click to (re)generate!"];
// load text into the model
markov.loadText(data1.join(' '));
message = markov.generateSentences(1).join(' ');
document.getElementById("text").innerHTML = message
}
// end text gen stuff
const numRats = 9;
var message = "";
const numBackgrounds = 5;
backgroundIndex = Math.floor(Math.random() * numBackgrounds) + 1
backgroundPath = "url(./valentines/backgrounds/" + backgroundIndex + ".png)"
ratIndex = Math.floor(Math.random() * numRats) + 1
ratPath = "./valentines/rats/" + ratIndex + ".png"
window.onload = () => {
document.getElementById("pic").src = ratPath
document.body.style.backgroundImage = backgroundPath
}
const numHearts = 4;
window.addEventListener('click', e => {
let heart = document.createElement('img');
heart.classList.add("heart")
heart.src = "./valentines/clickers/" + (Math.floor((Math.random() * numHearts)) + 1) + ".png";
heart.style.position = 'absolute';
heart.style.left = e.pageX - 15;
heart.style.top = e.pageY - 15;
heart.style.width = '30px';
document.body.append(heart);
});
window.addEventListener('keydown', e => {
if (e.keyCode == 32){
regenerate();
}
});
function regenerate() {
message = markov.generateSentences(1).join(' ');
document.getElementById("text").innerHTML = message;
backgroundIndex = Math.floor(Math.random() * numBackgrounds) + 1
backgroundPath = "url(./valentines/backgrounds/" + backgroundIndex + ".png)"
ratIndex = Math.floor(Math.random() * numRats) + 1
ratPath = "./valentines/rats/" + ratIndex + ".png"
document.getElementById("pic").src = ratPath
document.body.style.backgroundImage = backgroundPath
const hearts = document.getElementsByClassName("heart")
for (let i = 0; i < hearts.length; i++) {
hearts[i].style.display = "none";
}
}
</script>
</head>
<body>
<div id="text-container">
<img id="pic"></img>
<div id="text"></div>
<div id="signature">love, algorat</div>
</div>
<div id="regen-button" onclick="regenerate()">regene<b><i>rat</i></b>e</div>
</body>