{"id":18715862,"url":"https://github.com/davidbuchanan314/boiga","last_synced_at":"2025-04-12T13:13:13.437Z","repository":{"id":37074713,"uuid":"390167205","full_name":"DavidBuchanan314/boiga","owner":"DavidBuchanan314","description":"A Python library enabling ergonomic Scratch 3.0 code generation.","archived":false,"fork":false,"pushed_at":"2023-05-14T23:55:54.000Z","size":292,"stargazers_count":36,"open_issues_count":1,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-12T13:13:08.473Z","etag":null,"topics":["boiga","codegen","python","python3","scratch","scratch3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DavidBuchanan314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-28T00:46:11.000Z","updated_at":"2025-02-22T23:03:32.000Z","dependencies_parsed_at":"2024-11-07T13:10:33.738Z","dependency_job_id":"bd82fe3f-0c2d-4ef9-baff-4893db20a3cb","html_url":"https://github.com/DavidBuchanan314/boiga","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidBuchanan314%2Fboiga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidBuchanan314%2Fboiga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidBuchanan314%2Fboiga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidBuchanan314%2Fboiga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DavidBuchanan314","download_url":"https://codeload.github.com/DavidBuchanan314/boiga/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571863,"owners_count":21126522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boiga","codegen","python","python3","scratch","scratch3"],"created_at":"2024-11-07T13:10:30.606Z","updated_at":"2025-04-12T13:13:13.430Z","avatar_url":"https://github.com/DavidBuchanan314.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# boiga\n\nBoiga is a Python library enabling ergonomic Scratch 3.0 code generation.\n\nHave you ever attempted to author advanced or accelerated algorithms in Scratch? It's not much fun - you might end up making miles of mouse movements for even the most miniscule of modifications.\n\nBoiga (ab)uses Python's operator overloading, to write Scratch expressions with intuitive(ish) Python syntax. We expose a simple AST representation, making it easy to write custom code generators and macros.\n\nSee the examples directory for... examples. Further usage examples can be seen in my [Scratch Cryptography Library](https://github.com/DavidBuchanan314/scratch-cryptography-library).\n\nSee also: [scratch-vscode](https://github.com/DavidBuchanan314/scratch-vscode) - A vscode extension that lets you preview Scratch projects right in your editor, with live reload.\n\n## Project Status:\n\nIt's a working prototype. Not all blocks are supported, but you can use this to write non-trivial scratch projects.\nIf you plan to actually use this for something, you might want to make a copy of the code - I'll probably be making lots of breaking changes as I implement more features.\n\n## Features:\n- Scratch .sb3 code generation.\n- Very basic AST optimisation (e.g. constant folding)\n- Optional inlining of \"custom blocks\".\n- Some bitwise operators.\n- 0-indexed lists.\n\n## TODO\n- Documentation (sorry lol - for now, just look at the examples)\n- Static allocation of \"sub-lists\" within lists\n- Dynamic allocation of space within lists (i.e. malloc)?\n- For both of the above, we can pass indices around like pointers\n\n## Building Examples:\n\n```sh\npython3 -m examples\n```\n\nNOTE: Requires Python 3.10 or above!\n\n[`examples/helloworld.py`](https://github.com/DavidBuchanan314/boiga/blob/main/examples/helloworld.py) looks like this:\n\n```python\nfrom boiga import *\n\nproject = Project()\n\ncat = project.new_sprite(\"Scratch Cat\")\ncat.add_costume(\"scratchcat\", \"examples/assets/scratchcat.svg\", center=(48, 50))\n\ncat.on_flag([\n\tSay(\"Hello, world!\"),\n])\n\nproject.save(\"examples/out/Boiga Examples: Hello World.sb3\")\n```\n\nWhich compiles to the following scratch project:\n\n\u003cimg width=\"1019\" alt=\"image\" src=\"https://user-images.githubusercontent.com/13520633/174166081-4aa1f495-ac20-411d-aa53-0546c55339bd.png\"\u003e\n\nObviously, it's probably easier to write programs like that using the drag-and-drop interface. Conversely, [`examples/branflakes.py`](https://github.com/DavidBuchanan314/boiga/blob/main/examples/branflakes.py) implements a brainf\\*ck to Scratch compiler, which compiles a \"99 bottles of beer\" program into the following:\n\n\u003cimg width=\"256\" alt=\"image\" src=\"https://user-images.githubusercontent.com/13520633/174167667-56332085-44df-4768-a718-bfa00ab798ce.png\"\u003e\n\nThis is just a preview, the whole script doesn't even come close to fitting in a single screenshot! You can see the full scratch code [here](https://scratch.mit.edu/projects/677776603/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidbuchanan314%2Fboiga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidbuchanan314%2Fboiga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidbuchanan314%2Fboiga/lists"}