{"id":26600724,"url":"https://github.com/haoyu234/buju","last_synced_at":"2025-04-09T16:23:41.500Z","repository":{"id":258926164,"uuid":"864913611","full_name":"haoyu234/buju","owner":"haoyu234","description":"buju (布局) is a simple layout engine, based on layout.h","archived":false,"fork":false,"pushed_at":"2024-10-24T13:52:04.000Z","size":109,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-25T01:13:16.758Z","etag":null,"topics":["layout-engine","nim"],"latest_commit_sha":null,"homepage":"https://htmlpreview.github.io/?https://github.com/haoyu234/buju/blob/main/assets/demo.html","language":"JavaScript","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/haoyu234.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":"2024-09-29T14:01:26.000Z","updated_at":"2024-10-24T13:52:08.000Z","dependencies_parsed_at":"2024-10-26T09:39:14.018Z","dependency_job_id":"7856380d-a803-447c-855c-1f37559ef7d0","html_url":"https://github.com/haoyu234/buju","commit_stats":null,"previous_names":["haoyu234/buju"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoyu234%2Fbuju","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoyu234%2Fbuju/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoyu234%2Fbuju/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haoyu234%2Fbuju/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haoyu234","download_url":"https://codeload.github.com/haoyu234/buju/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065930,"owners_count":21042002,"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":["layout-engine","nim"],"created_at":"2025-03-23T18:34:06.639Z","updated_at":"2025-04-09T16:23:41.494Z","avatar_url":"https://github.com/haoyu234.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# buju\n\nbuju (布局) is a simple layout engine, it is a Nim port of [layout.h](https://github.com/randrew/layout).\nIt has fixed several bugs left over from the original implementation and optimized the performance of some functions.\n\n```nim\nimport buju\n\nvar l = default(Layout)\n\nlet root = l.node()\nl.setSize(root, vec2(50, 50))\n\ntemplate alignBox(n, flags) =\n  let n = l.node()\n  l.setSize(n, vec2(10, 10))\n  l.setLayoutFlags(n, flags)\n  l.insertChild(root, n)\n\n# |2|4|3|\n# |5|7|6|\n# |8|10|9|\n\nalignBox(node2, LayoutTop or LayoutLeft)\nalignBox(node3, LayoutTop or LayoutRight)\nalignBox(node4, LayoutTop)\n\nalignBox(node5, LayoutLeft)\nalignBox(node6, LayoutRight)\nalignBox(node7, 0)\n\nalignBox(node8, LayoutBottom or LayoutLeft)\nalignBox(node9, LayoutBottom or LayoutRight)\nalignBox(node10, LayoutBottom)\n\nl.compute(root)\n\ncheck l.computed(node2) == vec4(0, 0, 10, 10)\ncheck l.computed(node3) == vec4(40, 0, 10, 10)\ncheck l.computed(node4) == vec4(20, 0, 10, 10)\n\ncheck l.computed(node5) == vec4(0, 20, 10, 10)\ncheck l.computed(node6) == vec4(40, 20, 10, 10)\ncheck l.computed(node7) == vec4(20, 20, 10, 10)\n\ncheck l.computed(node8) == vec4(0, 40, 10, 10)\ncheck l.computed(node9) == vec4(40, 40, 10, 10)\ncheck l.computed(node10) == vec4(20, 40, 10, 10)\n\n```\n\nThe [online editor](https://htmlpreview.github.io/?https://github.com/haoyu234/buju/blob/main/assets/demo.html) is in `assets/demo.html`, and here is the output:\n![assets/demo.png](https://github.com/haoyu234/buju/raw/main/assets/demo.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaoyu234%2Fbuju","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaoyu234%2Fbuju","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaoyu234%2Fbuju/lists"}