From 51de33c2b55e9669958067e0522557399857392f Mon Sep 17 00:00:00 2001 From: lqdev Date: Sun, 18 Feb 2024 00:29:58 +0100 Subject: [PATCH] graphical output in code blocks --- content/programming/blog/tairu.tree | 15 +- content/treehouse/sandbox.tree | 133 ++++++++++++++++++ crates/treehouse/src/cli/generate.rs | 58 ++++++-- crates/treehouse/src/cli/mod.rs | 2 + crates/treehouse/src/main.rs | 2 + static/css/main.css | 15 ++ static/js/components/literate-programming.js | 38 +++++ .../components/literate-programming/eval.js | 48 +++++++ .../components/literate-programming/worker.js | 48 +------ static/js/sandbox.js | 16 +++ static/js/test.js | 0 template/{tree.hbs => _tree.hbs} | 1 - template/sandbox.hbs | 32 +++++ 13 files changed, 351 insertions(+), 57 deletions(-) create mode 100644 content/treehouse/sandbox.tree create mode 100644 static/js/components/literate-programming/eval.js create mode 100644 static/js/sandbox.js create mode 100644 static/js/test.js rename template/{tree.hbs => _tree.hbs} (99%) create mode 100644 template/sandbox.hbs diff --git a/content/programming/blog/tairu.tree b/content/programming/blog/tairu.tree index c02d3a8..731cc33 100644 --- a/content/programming/blog/tairu.tree +++ b/content/programming/blog/tairu.tree @@ -40,7 +40,7 @@ styles = ["tairu.css"] % id = "01HPJ8GHDEC0Z334M04MTNADV9" - - for each tile, we can assign a bitset of cardinal directions like so: + - for each tile we can assign a bitset of cardinal directions, based on which tiles it should connect to - like so: E | SE | S | SW | W | NW | N | NE ``` + % id = "01HPWJB4Y0NMP35M9138DV3P8W" - with the lookup table generated, we are now able to prepare a tile strip like before - except now it's even more tedious work arranging the pieces together :ralsei_dead: anyways I spent like 20 minutes doing that by hand, and now we have a neat tile strip just like before, except way longer: ![horizontal tile strip of 47 8x8 pixel metal tiles][pic:01HPW47SHMSVAH7C0JR9HWXWCM] + % id = "01HPWJB4Y0J3DHQV5F9GD3VNQ8" - now let's hook it up to our tileset renderer! TODO literate program. % template = true + id = "01HPWJB4Y00ARHBGDF2HTQQ4SD" - with the capability to render with 47-tile tilesets, our examples suddenly look a whole lot better! + + % id = "01HPWJB4Y5ER6SAQZ17ZFH8RK7" + - `Sketch` is an API for drawing things using HTML ``. + + % id = "01HPWJB4Y5MRKCXRNSRFG7PVP5" + - the act of creating a `Sketch` using `new` causes a new `` to be created. + + % id = "01HPWJB4Y5HZG6QH5N6N2Q9Z99" + - this `` can be accessed using the sketch's `canvas` field, and the canvas's 2D drawing context is accessible using the `ctx` field. + + % id = "01HPWJB4Y5ANS55R32X7GJP1N7" + - this API wraps a lower-level message-passing API which is used to communicate with the main page, to let it set things like the sandbox `