{"id":13726672,"url":"https://github.com/ambientlight/bs-pixi","last_synced_at":"2026-01-31T21:02:47.766Z","repository":{"id":36052206,"uuid":"220315535","full_name":"ambientlight/bs-pixi","owner":"ambientlight","description":"BuckleScript bindings for PixiJS v5","archived":false,"fork":false,"pushed_at":"2023-01-05T00:41:15.000Z","size":570,"stargazers_count":15,"open_issues_count":12,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T12:52:28.523Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Reason","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/ambientlight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-07T19:40:27.000Z","updated_at":"2023-04-30T11:32:46.000Z","dependencies_parsed_at":"2023-01-16T12:26:33.491Z","dependency_job_id":null,"html_url":"https://github.com/ambientlight/bs-pixi","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ambientlight%2Fbs-pixi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ambientlight%2Fbs-pixi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ambientlight%2Fbs-pixi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ambientlight%2Fbs-pixi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ambientlight","download_url":"https://codeload.github.com/ambientlight/bs-pixi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239841730,"owners_count":19705980,"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":[],"created_at":"2024-08-03T01:03:16.336Z","updated_at":"2026-01-31T21:02:42.736Z","avatar_url":"https://github.com/ambientlight.png","language":"Reason","funding_links":[],"categories":["Reason"],"sub_categories":[],"readme":"[![STATUS](https://github.com/ambientlight/bs-pixi/workflows/Deploy%20Docs/badge.svg)](https://github.com/ambientlight/bs-pixi/actions)\n[![VERSION](https://img.shields.io/npm/v/bs-pixi)](https://www.npmjs.com/package/bs-pixi)\n[![LICENSE](https://img.shields.io/github/license/ambientlight/bs-pixi?t)](https://github.com/ambientlight/bs-pixi/blob/master/LICENSE)\n[![ISSUES](https://img.shields.io/github/issues/ambientlight/bs-pixi)](https://github.com/ambientlight/bs-pixi/issues)\n\n# bs-pixi\nBuckleScript bindings for [PixiJS v6](https://github.com/pixijs/pixi.js) (Work in progress)\n\nRefer to [documentation](https://ambientlight.github.io/bs-pixi) for existing coverage.\n\n## Installation\n\n```bash\nnpm install bs-pixi\n```\n\nAnd add `bs-pixi` into `bs-dependencies` in your project `bsconfig.json`.\n\n## About Bindings\n\n[PIXI.js](https://github.com/pixijs) relies heavily on inheritance, which in the context of bucklescript bindings is often realized via [functors](https://reasonml.github.io/docs/en/module#module-functions-functors) where module containing subclass functionality would \"spread\" the implementation of the ancestor module (closest is mixin) - see [Extending Modules](https://reasonml.github.io/docs/en/module#extending-modules). This is often referred to as **implementation inheritance**. One example is in [bs-webapi-incubator](https://github.com/reasonml-community/bs-webapi-incubator#implementation-inheritance). In addition to this approach here we bind directly to javascript classes via bucklescript supported `class type` bindings, with most apis accepting all structural subtypes:\n\n```ocaml\n[@bs.send]\nexternal addChild: (Js.t(#C.displayObject), ~child: Js.t(#C.displayObject as 'a)) =\u003e Js.t('a) = \"addChild\";\n```\n\n`#` denotes structural subtype, so when we see `Js.t(#C.displayObjects)` we can feed any js object types that are structural subtypes of displayObject directly without upcasting to a type which is defined in a module where `addChild` is defined. Also this allows us to utilize both functional as well as object apis for the same functionality like:\n\n```ocaml\nlet point = PIXI.Point.create(~x=1.0, ~y=5.0, ());\nlet x = point##x;\nlet x = point |. PIXI.Point.getX;\n```\n\nAlthough using object methods for anything slightly more complex as simple accessors is not really practical, as `[@bs]` class object methods do not support currying, labeled and optional parameters, feel free to use it if you feel comfortable with it, as in next example.\n\n## Example\n\n```reason\nopen PIXI;\n\nlet app = Application.create(~options=Application.createApplicationOptions(\n  ~width=800.,\n  ~height=600.,\n  ~backgroundColor=int_of_string(\"0x1099bb\"),\n  ~resolution=DomRe.window |. Obj.magic |. Js.Dict.unsafeGet(\"devicePixelRatio\"), ()), \n  ());\n\nWebapi.Dom.document \n|\u003e Webapi.Dom.Document.asHtmlDocument \n|. Belt.Option.flatMap(document =\u003e document |\u003e Webapi.Dom.HtmlDocument.body)\n|. Belt.Option.map(body =\u003e body |\u003e Webapi.Dom.Element.appendChild(app##view))\n|\u003e ignore;\n\nlet container = Container.create();\n\napp \n|. Application.getStage \n|. Container.addChild(container);\n\n// Create a new texture\nlet texture = Texture.from(~source=`String(\"https://pixijs.io/examples/examples/assets/bunny.png\"), ());\n\n// Create a 5x5 grid of bunnies\nBelt.Array.range(0, 24)\n|. Belt.Array.forEach(i =\u003e {\n  let bunny = Sprite.create(texture);\n  bunny##anchor##set(0.5, 0.5);\n  bunny |. Sprite.setX(float_of_int((i mod 5) * 40));\n  bunny |. Sprite.setY(floor(float_of_int(i) /. 5.) *. 40.);\n  container |. Container.addChild(bunny) |\u003e ignore;\n});\n\ncontainer |. Container.setX(app##screen##width /. 2.);\ncontainer |. Container.setY(app##screen##height /. 2.);\n\n// Center bunny sprite in local container coordinates\ncontainer##pivot##x #= (container##width /. 2.);\ncontainer##pivot##y #= (container##height /. 2.);\n\n// Listen for animate update\napp\n|. Application.getTicker\n|. Ticker.add(delta =\u003e {\n  // rotate the container!\n  // use delta to create frame-independent transform\n  container |. Container.setRotation(container##rotation -. 0.01 *. delta);\n}, ());\n```\n\nAlso make sure to **CHECK OUT** other [examples](https://github.com/ambientlight/bs-pixi/tree/master/examples).\n\n## Contributing\n\nAny contribution is greatly appreciated. Take a look at [CONTRIBUTING.md](https://github.com/ambientlight/bs-pixi/blob/master/CONTRIBUTING.md). Feel free to reach out in [issues](https://github.com/ambientlight/bs-pixi/issues) for any questions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fambientlight%2Fbs-pixi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fambientlight%2Fbs-pixi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fambientlight%2Fbs-pixi/lists"}