├── .gitignore ├── README.md ├── bml ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── TODO.md ├── examples │ ├── checkerboard.buf │ ├── circle.bml │ ├── closing_circle.bml │ ├── fractal_noise.bml │ ├── img │ │ ├── checkerboard.png │ │ ├── circle.png │ │ ├── closing_circle_rocket.gif │ │ ├── fractal_noise.png │ │ ├── invert_rocket.png │ │ ├── mandelbrot.png │ │ ├── projected_julia.gif │ │ ├── quadrant_rocket.png │ │ ├── rocket.png │ │ ├── sample_rocket.png │ │ └── sawtooth.gif │ ├── invert.bml │ ├── mandelbrot.bml │ ├── mod_sawtooth.bml │ ├── projected_julia.bml │ ├── quadrant.bml │ └── sample.bml └── src │ ├── ast.rs │ ├── lib.rs │ ├── logger.rs │ ├── macro.rs │ ├── main.rs │ ├── parser.rs │ ├── preprocessor.rs │ ├── scanner.rs │ ├── token.rs │ └── token_type.rs └── slackbot ├── package-lock.json ├── package.json ├── src ├── Domains.ts └── app.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | log.txt 3 | tmp 4 | build 5 | **/target 6 | 7 | # vi swapfiles 8 | *.swp 9 | *.swo 10 | 11 | # any scattered pngs/gifs that aren't examples 12 | *.png 13 | !bml/examples/img/*.png 14 | 15 | *.gif 16 | !bml/examples/img/*.gif 17 | 18 | # critical json files 19 | auth.json 20 | domains.json 21 | 22 | .DS_Store 23 | .vscode -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bml 2 | 3 | BML, or "Buffer Manipulation Language", is an interpreter for programatically processing or generating images/gifs using a simple, easy-to-learn C-like language. 4 | 5 | ## Repo structure 6 | 7 | This repository is a monorepo for BML and the BML runtime itself (in `/bml`) and a Slack Bot (`/slackbot`) which interfaces with BML. 8 | 9 | For trying out BML, usage is documented in `/bml/README.md`. -------------------------------------------------------------------------------- /bml/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "adler" 7 | version = "1.0.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 10 | 11 | [[package]] 12 | name = "adler32" 13 | version = "1.2.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" 16 | 17 | [[package]] 18 | name = "ahash" 19 | version = "0.7.6" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 22 | dependencies = [ 23 | "getrandom", 24 | "once_cell", 25 | "version_check", 26 | ] 27 | 28 | [[package]] 29 | name = "atty" 30 | version = "0.2.14" 31 | source = "registry+https://github.com/rust-lang/crates.io-index" 32 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 33 | dependencies = [ 34 | "hermit-abi", 35 | "libc", 36 | "winapi", 37 | ] 38 | 39 | [[package]] 40 | name = "autocfg" 41 | version = "1.0.1" 42 | source = "registry+https://github.com/rust-lang/crates.io-index" 43 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" 44 | 45 | [[package]] 46 | name = "bitflags" 47 | version = "1.3.2" 48 | source = "registry+https://github.com/rust-lang/crates.io-index" 49 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 50 | 51 | [[package]] 52 | name = "bml" 53 | version = "1.0.1" 54 | dependencies = [ 55 | "colored", 56 | "image", 57 | "lasso", 58 | "rayon", 59 | ] 60 | 61 | [[package]] 62 | name = "bytemuck" 63 | version = "1.7.3" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "439989e6b8c38d1b6570a384ef1e49c8848128f5a97f3914baef02920842712f" 66 | 67 | [[package]] 68 | name = "byteorder" 69 | version = "1.4.3" 70 | source = "registry+https://github.com/rust-lang/crates.io-index" 71 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 72 | 73 | [[package]] 74 | name = "cfg-if" 75 | version = "1.0.0" 76 | source = "registry+https://github.com/rust-lang/crates.io-index" 77 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 78 | 79 | [[package]] 80 | name = "color_quant" 81 | version = "1.1.0" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" 84 | 85 | [[package]] 86 | name = "colored" 87 | version = "2.0.0" 88 | source = "registry+https://github.com/rust-lang/crates.io-index" 89 | checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" 90 | dependencies = [ 91 | "atty", 92 | "lazy_static", 93 | "winapi", 94 | ] 95 | 96 | [[package]] 97 | name = "crc32fast" 98 | version = "1.3.0" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" 101 | dependencies = [ 102 | "cfg-if", 103 | ] 104 | 105 | [[package]] 106 | name = "crossbeam-channel" 107 | version = "0.5.1" 108 | source = "registry+https://github.com/rust-lang/crates.io-index" 109 | checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" 110 | dependencies = [ 111 | "cfg-if", 112 | "crossbeam-utils", 113 | ] 114 | 115 | [[package]] 116 | name = "crossbeam-deque" 117 | version = "0.8.1" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" 120 | dependencies = [ 121 | "cfg-if", 122 | "crossbeam-epoch", 123 | "crossbeam-utils", 124 | ] 125 | 126 | [[package]] 127 | name = "crossbeam-epoch" 128 | version = "0.9.5" 129 | source = "registry+https://github.com/rust-lang/crates.io-index" 130 | checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" 131 | dependencies = [ 132 | "cfg-if", 133 | "crossbeam-utils", 134 | "lazy_static", 135 | "memoffset", 136 | "scopeguard", 137 | ] 138 | 139 | [[package]] 140 | name = "crossbeam-utils" 141 | version = "0.8.5" 142 | source = "registry+https://github.com/rust-lang/crates.io-index" 143 | checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" 144 | dependencies = [ 145 | "cfg-if", 146 | "lazy_static", 147 | ] 148 | 149 | [[package]] 150 | name = "deflate" 151 | version = "0.8.6" 152 | source = "registry+https://github.com/rust-lang/crates.io-index" 153 | checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174" 154 | dependencies = [ 155 | "adler32", 156 | "byteorder", 157 | ] 158 | 159 | [[package]] 160 | name = "either" 161 | version = "1.6.1" 162 | source = "registry+https://github.com/rust-lang/crates.io-index" 163 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" 164 | 165 | [[package]] 166 | name = "getrandom" 167 | version = "0.2.3" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" 170 | dependencies = [ 171 | "cfg-if", 172 | "libc", 173 | "wasi", 174 | ] 175 | 176 | [[package]] 177 | name = "gif" 178 | version = "0.11.3" 179 | source = "registry+https://github.com/rust-lang/crates.io-index" 180 | checksum = "c3a7187e78088aead22ceedeee99779455b23fc231fe13ec443f99bb71694e5b" 181 | dependencies = [ 182 | "color_quant", 183 | "weezl", 184 | ] 185 | 186 | [[package]] 187 | name = "hashbrown" 188 | version = "0.11.2" 189 | source = "registry+https://github.com/rust-lang/crates.io-index" 190 | checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 191 | dependencies = [ 192 | "ahash", 193 | ] 194 | 195 | [[package]] 196 | name = "hermit-abi" 197 | version = "0.1.19" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 200 | dependencies = [ 201 | "libc", 202 | ] 203 | 204 | [[package]] 205 | name = "image" 206 | version = "0.23.14" 207 | source = "registry+https://github.com/rust-lang/crates.io-index" 208 | checksum = "24ffcb7e7244a9bf19d35bf2883b9c080c4ced3c07a9895572178cdb8f13f6a1" 209 | dependencies = [ 210 | "bytemuck", 211 | "byteorder", 212 | "color_quant", 213 | "gif", 214 | "jpeg-decoder", 215 | "num-iter", 216 | "num-rational", 217 | "num-traits", 218 | "png", 219 | "scoped_threadpool", 220 | "tiff", 221 | ] 222 | 223 | [[package]] 224 | name = "jpeg-decoder" 225 | version = "0.1.22" 226 | source = "registry+https://github.com/rust-lang/crates.io-index" 227 | checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2" 228 | dependencies = [ 229 | "rayon", 230 | ] 231 | 232 | [[package]] 233 | name = "lasso" 234 | version = "0.6.0" 235 | source = "registry+https://github.com/rust-lang/crates.io-index" 236 | checksum = "aeb7b21a526375c5ca55f1a6dfd4e1fad9fa4edd750f530252a718a44b2608f0" 237 | dependencies = [ 238 | "hashbrown", 239 | ] 240 | 241 | [[package]] 242 | name = "lazy_static" 243 | version = "1.4.0" 244 | source = "registry+https://github.com/rust-lang/crates.io-index" 245 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 246 | 247 | [[package]] 248 | name = "libc" 249 | version = "0.2.112" 250 | source = "registry+https://github.com/rust-lang/crates.io-index" 251 | checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" 252 | 253 | [[package]] 254 | name = "memoffset" 255 | version = "0.6.5" 256 | source = "registry+https://github.com/rust-lang/crates.io-index" 257 | checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" 258 | dependencies = [ 259 | "autocfg", 260 | ] 261 | 262 | [[package]] 263 | name = "miniz_oxide" 264 | version = "0.3.7" 265 | source = "registry+https://github.com/rust-lang/crates.io-index" 266 | checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" 267 | dependencies = [ 268 | "adler32", 269 | ] 270 | 271 | [[package]] 272 | name = "miniz_oxide" 273 | version = "0.4.4" 274 | source = "registry+https://github.com/rust-lang/crates.io-index" 275 | checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" 276 | dependencies = [ 277 | "adler", 278 | "autocfg", 279 | ] 280 | 281 | [[package]] 282 | name = "num-integer" 283 | version = "0.1.44" 284 | source = "registry+https://github.com/rust-lang/crates.io-index" 285 | checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" 286 | dependencies = [ 287 | "autocfg", 288 | "num-traits", 289 | ] 290 | 291 | [[package]] 292 | name = "num-iter" 293 | version = "0.1.42" 294 | source = "registry+https://github.com/rust-lang/crates.io-index" 295 | checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" 296 | dependencies = [ 297 | "autocfg", 298 | "num-integer", 299 | "num-traits", 300 | ] 301 | 302 | [[package]] 303 | name = "num-rational" 304 | version = "0.3.2" 305 | source = "registry+https://github.com/rust-lang/crates.io-index" 306 | checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" 307 | dependencies = [ 308 | "autocfg", 309 | "num-integer", 310 | "num-traits", 311 | ] 312 | 313 | [[package]] 314 | name = "num-traits" 315 | version = "0.2.14" 316 | source = "registry+https://github.com/rust-lang/crates.io-index" 317 | checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" 318 | dependencies = [ 319 | "autocfg", 320 | ] 321 | 322 | [[package]] 323 | name = "num_cpus" 324 | version = "1.13.0" 325 | source = "registry+https://github.com/rust-lang/crates.io-index" 326 | checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" 327 | dependencies = [ 328 | "hermit-abi", 329 | "libc", 330 | ] 331 | 332 | [[package]] 333 | name = "once_cell" 334 | version = "1.9.0" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" 337 | 338 | [[package]] 339 | name = "png" 340 | version = "0.16.8" 341 | source = "registry+https://github.com/rust-lang/crates.io-index" 342 | checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6" 343 | dependencies = [ 344 | "bitflags", 345 | "crc32fast", 346 | "deflate", 347 | "miniz_oxide 0.3.7", 348 | ] 349 | 350 | [[package]] 351 | name = "rayon" 352 | version = "1.5.1" 353 | source = "registry+https://github.com/rust-lang/crates.io-index" 354 | checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" 355 | dependencies = [ 356 | "autocfg", 357 | "crossbeam-deque", 358 | "either", 359 | "rayon-core", 360 | ] 361 | 362 | [[package]] 363 | name = "rayon-core" 364 | version = "1.9.1" 365 | source = "registry+https://github.com/rust-lang/crates.io-index" 366 | checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" 367 | dependencies = [ 368 | "crossbeam-channel", 369 | "crossbeam-deque", 370 | "crossbeam-utils", 371 | "lazy_static", 372 | "num_cpus", 373 | ] 374 | 375 | [[package]] 376 | name = "scoped_threadpool" 377 | version = "0.1.9" 378 | source = "registry+https://github.com/rust-lang/crates.io-index" 379 | checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" 380 | 381 | [[package]] 382 | name = "scopeguard" 383 | version = "1.1.0" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 386 | 387 | [[package]] 388 | name = "tiff" 389 | version = "0.6.1" 390 | source = "registry+https://github.com/rust-lang/crates.io-index" 391 | checksum = "9a53f4706d65497df0c4349241deddf35f84cee19c87ed86ea8ca590f4464437" 392 | dependencies = [ 393 | "jpeg-decoder", 394 | "miniz_oxide 0.4.4", 395 | "weezl", 396 | ] 397 | 398 | [[package]] 399 | name = "version_check" 400 | version = "0.9.3" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" 403 | 404 | [[package]] 405 | name = "wasi" 406 | version = "0.10.2+wasi-snapshot-preview1" 407 | source = "registry+https://github.com/rust-lang/crates.io-index" 408 | checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 409 | 410 | [[package]] 411 | name = "weezl" 412 | version = "0.1.5" 413 | source = "registry+https://github.com/rust-lang/crates.io-index" 414 | checksum = "d8b77fdfd5a253be4ab714e4ffa3c49caf146b4de743e97510c0656cf90f1e8e" 415 | 416 | [[package]] 417 | name = "winapi" 418 | version = "0.3.9" 419 | source = "registry+https://github.com/rust-lang/crates.io-index" 420 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 421 | dependencies = [ 422 | "winapi-i686-pc-windows-gnu", 423 | "winapi-x86_64-pc-windows-gnu", 424 | ] 425 | 426 | [[package]] 427 | name = "winapi-i686-pc-windows-gnu" 428 | version = "0.4.0" 429 | source = "registry+https://github.com/rust-lang/crates.io-index" 430 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 431 | 432 | [[package]] 433 | name = "winapi-x86_64-pc-windows-gnu" 434 | version = "0.4.0" 435 | source = "registry+https://github.com/rust-lang/crates.io-index" 436 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 437 | -------------------------------------------------------------------------------- /bml/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bml" 3 | version = "1.0.1" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | image = "0.23.14" 10 | lasso = "0.6.0" 11 | colored = "2.0.0" 12 | rayon = "1.5" -------------------------------------------------------------------------------- /bml/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Prof. Sucrose 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bml/README.md: -------------------------------------------------------------------------------- 1 | # bml 2 | 3 | BML, or "Buffer Manipulation Language," is a preprocessor and runtime for basic but programmatic image manipulation. 4 | 5 | ## Building 6 | 7 | BML uses Rust, and can be built or run using `cargo`, which can be installed using [rustup](https://rustup.rs/). 8 | 9 | For *nix users, you can download the `/bml` subdir with: 10 | ```bash 11 | git clone https://github.com/profsucrose/bml _bml && mv _bml/bml . && rm -rf _bml 12 | ``` 13 | 14 | And then to build, run 15 | 16 | ```bash 17 | cargo run --release 18 | ``` 19 | 20 | while in the directory, or use `cargo build --release` and run the built binary in `./target/release/bml`. 21 | 22 | Although building in release mode is not necessary, it is highly recommended for improved performance. 23 | 24 | ## Usage 25 | 26 | When running BML, there are three primary options: 27 | 28 | ```./bml eval ``` 29 | 30 | Which will simply evaluate the given script and print the `return`-ed result. 31 | 32 | ```./bml process [output_path]``` 33 | 34 | Which will process a given image through a given script. If `` is specified and greater than 1, a gif will be generated instead of a static image. The output will be written to an automatically determined path, or alternatively write to `output_path` instead if valid. 35 | 36 | ```bml new