summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDante Catalfamo2020-07-03 14:43:05 -0400
committerDante Catalfamo2020-07-03 14:43:05 -0400
commit472e81a2b713e6149af4e56e4046c1aa6a9c1812 (patch)
tree1c3c2e94ffaa289732f320329546c01f4aa84fe1
parentb7373ab119bf73ead274d34b2696ddedb1deb416 (diff)
downloadhomepage-472e81a2b713e6149af4e56e4046c1aa6a9c1812.tar.gz
homepage-472e81a2b713e6149af4e56e4046c1aa6a9c1812.tar.bz2
homepage-472e81a2b713e6149af4e56e4046c1aa6a9c1812.zip
Add braille
-rw-r--r--braille.js67
-rw-r--r--index.html38
-rw-r--r--lambda.js (renamed from script.js)0
3 files changed, 89 insertions, 16 deletions
diff --git a/braille.js b/braille.js
new file mode 100644
index 0000000..8d94db7
--- /dev/null
+++ b/braille.js
@@ -0,0 +1,67 @@
+"use strict";
+
+const OUTHEIGHT = 20;
+const OUTWIDTH = 2 * OUTHEIGHT;
+const HEIGHT = 3 * OUTHEIGHT;
+const WIDTH = 2 * OUTWIDTH;
+const BRAILLE = [
+ "⠀", "⠁", "⠂", "⠃", "⠄", "⠅", "⠆", "⠇", "⠈", "⠉", "⠊", "⠋", "⠌", "⠍", "⠎", "⠏",
+ "⠐", "⠑", "⠒", "⠓", "⠔", "⠕", "⠖", "⠗", "⠘", "⠙", "⠚", "⠛", "⠜", "⠝", "⠞", "⠟",
+ "⠠", "⠡", "⠢", "⠣", "⠤", "⠥", "⠦", "⠧", "⠨", "⠩", "⠪", "⠫", "⠬", "⠭", "⠮", "⠯",
+ "⠰", "⠱", "⠲", "⠳", "⠴", "⠵", "⠶", "⠷", "⠸", "⠹", "⠺", "⠻", "⠼", "⠽", "⠾", "⠿",
+];
+
+let board = new Array(HEIGHT);
+for (let i = 0; i < HEIGHT; i++) {
+ board[i] = new Array(WIDTH);
+}
+
+function render(board) {
+ const out = new Array(OUTHEIGHT);
+ for (let i = 0; i < OUTHEIGHT; i++) {
+ out[i] = new Array(OUTWIDTH);
+ }
+ for (let y = 0; y < HEIGHT; y += 3) {
+ for (let x = 0; x < WIDTH; x += 2) {
+ let outx = x/2;
+ let outy = y/3;
+ let tl = board[y][x] ? 1 : 0;
+ let ml = board[y+1][x] ? 1 : 0;
+ let bl = board[y+2][x] ? 1 : 0;
+ let tr = board[y][x+1] ? 1 : 0;
+ let mr = board[y+1][x+1] ? 1 : 0;
+ let br = board[y+2][x+1] ? 1 : 0;
+ let idx = tl*1 + ml*2 + bl*4 + tr*8 + mr*16 + br*32;
+ let char = BRAILLE[idx];
+ out[outy][outx] = char;
+ }
+ }
+ return out.reduce((a, r) => a + r.reduce((a2, c) => a2 + c) + "\n", "");
+}
+
+function renderFunction(board, fun, frame) {
+ for (let y = 0; y < HEIGHT; y++) {
+ for (let x = 0; x < WIDTH; x++) {
+ board[y][x] = fun(x, y, frame) ? true : null;
+ }
+ }
+ return render(board);
+}
+
+function fun(x, y, frame) {
+ const l = HEIGHT / 3;
+ const m1 = Math.abs(y+frame) % l;
+ const m2 = Math.abs(y-frame) % l;
+ return x == m1 ||
+ x == m2 ||
+ x/2 == m1 + l/2 ||
+ x/2 == m2 + l/2 ||
+ x == m1 + 3*l ||
+ x == m2 + 3*l;
+}
+
+const br = document.getElementById("braille");
+let frame = HEIGHT;
+const interval = setInterval(() => {
+ br.innerHTML = renderFunction(board, fun, frame++);
+}, 50);
diff --git a/index.html b/index.html
index 5dce83d..a995095 100644
--- a/index.html
+++ b/index.html
@@ -7,34 +7,38 @@
<title>lambda.cx home</title>
<style>
body {
- background: black;
- font-family: monospace;
+ background: black;
+ color: white;
+ font-family: monospace;
+ }
+ #braille {
+ line-height: .92;
}
.bigguy {
- display: flex;
+ display: flex;
}
.lambda {
- font-family: Andale Mono, monospace;
- font-size: 12px;
- display: inline-block;
+ font-family: Andale Mono, monospace;
+ font-size: 12px;
+ display: inline-block;
}
.linkbox {
- display: flex;
- align-items: center;
- justify-content: center;
- flex: 1;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex: 1;
}
.links {
- font-size: 16px;
- display: inline-block;
+ font-size: 16px;
+ display: inline-block;
}
.links > span {
color: white;
}
@media only screen and (max-width: 440px) {
- .bigguy {
- display: block;
- }
+ .bigguy {
+ display: block;
+ }
}
</style>
</head>
@@ -42,12 +46,14 @@
<div class="bigguy">
<pre class="lambda"></pre>
<div class="linkbox">
+ <pre id="braille"></pre>
<div class="links">
<span>==&gt; </span><a href="https://blog.lambda.cx">blog</a><br/>
<span>==&gt; </span><a href="https://github.com/dantecatalfamo">github</a>
</div>
</div>
</div>
- <script src="script.js"></script>
+ <script src="lambda.js"></script>
+ <script src="braille.js"></script>
</body>
</html>
diff --git a/script.js b/lambda.js
index 85037c3..85037c3 100644
--- a/script.js
+++ b/lambda.js