-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.js
More file actions
43 lines (29 loc) · 1.16 KB
/
renderer.js
File metadata and controls
43 lines (29 loc) · 1.16 KB
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
$('input[type=range]').on('input', function () {
$(this).trigger('change');
});
$(".bit_range").change(function() {
let value = $(this).val();
$(`.${$(this).attr("name")}_display`).text(value);
updateTotalBits();
updateCharactersLeft();
})
$("#text").on("input", () => {
updateCharactersLeft();
});
let updateTotalBits = () => {
const r = parseInt($("#bit_R").val());
const g = parseInt($("#bit_G").val());
const b = parseInt($("#bit_B").val());
$("#bits-total").text(r + g + b);
}
let updateCharactersLeft = () => {
const pixels = parseInt($("#pixels-total").text());
const rNumberOfBits = parseInt(document.getElementById("bit_R").value);
const gNumberOfBits = parseInt(document.getElementById("bit_G").value);
const bNumberOfBits = parseInt(document.getElementById("bit_B").value);
const charactersTotal = pixels / (8 / (rNumberOfBits + gNumberOfBits + bNumberOfBits));
const textLength = document.getElementById("text").value.length;
console.log()
const charactersLeft = Math.floor(charactersTotal - textLength);
document.getElementById("characters-left").innerText = charactersLeft;
}