{"_id":"@bernhardfritz/flatland","_rev":"6-d8d987094769565528250af11ea55517","name":"@bernhardfritz/flatland","dist-tags":{"latest":"0.4.0"},"versions":{"0.1.0":{"name":"@bernhardfritz/flatland","version":"0.1.0","keywords":["2d","go","webassembly","webgl2"],"license":"MIT","_id":"@bernhardfritz/flatland@0.1.0","maintainers":[{"name":"bernhardfritz","email":"bernhard.e.fritz@gmail.com"}],"homepage":"https://pkg.go.dev/github.com/bernhardfritz/flatland","bugs":{"url":"https://github.com/bernhardfritz/flatland/issues"},"dist":{"shasum":"a899f8f12b091717f5b4283fb31aeacc43157980","tarball":"https://registry.npmjs.org/@bernhardfritz/flatland/-/flatland-0.1.0.tgz","fileCount":6,"integrity":"sha512-a0f4ZDlkXBkANF14f/JcX+BVCGMnxF5lV565/oudCiQuICg/ejr6ae2qzUiuWSWxla1MMXH0oSyrmtdeaI5jbA==","signatures":[{"sig":"MEQCICj49dxduOSg1uPU8bh0XKQV9tDml3BcmGVZYoKcfLPmAiBFDwqOCGwM6+Lqn4qKSb8GBwsJSqS1KwlQBWWGUbvEdA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@bernhardfritz%2fflatland@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":28668},"type":"module","module":"./dist/flatland.js","exports":{".":{"import":"./dist/flatland.js"},"./vite-plugin":{"import":"./dist/vite-plugin-flatland.js"}},"gitHead":"3545aa734d4bb72c481eb208081cb93fe687bae6","scripts":{"build":"tsc && vite build && cp vite-plugin-flatland.js dist/"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:fd6f5a15-e775-494e-a047-76e69da126d5"}},"repository":{"url":"git+https://github.com/bernhardfritz/flatland.git","type":"git"},"_npmVersion":"11.16.0","description":"A simple 2D graphics library","directories":{},"_nodeVersion":"24.18.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^7.3.1","typescript":"~5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/flatland_0.1.0_1785614878313_0.3745915189700546","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@bernhardfritz/flatland","version":"0.2.0","keywords":["2d","go","webassembly","webgl2"],"license":"MIT","_id":"@bernhardfritz/flatland@0.2.0","maintainers":[{"name":"bernhardfritz","email":"bernhard.e.fritz@gmail.com"}],"homepage":"https://pkg.go.dev/github.com/bernhardfritz/flatland","bugs":{"url":"https://github.com/bernhardfritz/flatland/issues"},"dist":{"shasum":"a7091b2926487a4b670b6b3711ff6c12d7720822","tarball":"https://registry.npmjs.org/@bernhardfritz/flatland/-/flatland-0.2.0.tgz","fileCount":6,"integrity":"sha512-d/Zy0aAV6a5TYvkg+a9w9UW5gta50pj3SW5z2SA/A/iAKMfDWQ/ZuVVyG0j5Tn6aOx9riU/oyrT370nedhr6kA==","signatures":[{"sig":"MEUCIQD6sUXTC27O3sEFNCCzCeUoGs1jk1S2+B9wyoz3+QnysQIgOLv4edS0QYwGBSGa5gQgOo/yWdxO8SiZA3amFe9OlpI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@bernhardfritz%2fflatland@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":30054},"type":"module","module":"./dist/flatland.js","exports":{".":{"import":"./dist/flatland.js"},"./vite-plugin":{"import":"./dist/vite-plugin-flatland.js"}},"gitHead":"177f31304ceaac869eaea2613caf746f04a1a76f","scripts":{"build":"tsc && vite build && cp vite-plugin-flatland.js dist/"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:fd6f5a15-e775-494e-a047-76e69da126d5"}},"repository":{"url":"git+https://github.com/bernhardfritz/flatland.git","type":"git"},"_npmVersion":"11.17.0","description":"A simple 2D graphics library","directories":{},"_nodeVersion":"24.19.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^7.3.1","typescript":"~5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/flatland_0.2.0_1786303309436_0.3415917193526177","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@bernhardfritz/flatland","version":"0.3.0","keywords":["2d","go","webassembly","webgl2"],"license":"MIT","_id":"@bernhardfritz/flatland@0.3.0","maintainers":[{"name":"bernhardfritz","email":"bernhard.e.fritz@gmail.com"}],"homepage":"https://pkg.go.dev/github.com/bernhardfritz/flatland","bugs":{"url":"https://github.com/bernhardfritz/flatland/issues"},"dist":{"shasum":"549dbdcf474ca2e8b9cea0e3b854bf409cbf9c82","tarball":"https://registry.npmjs.org/@bernhardfritz/flatland/-/flatland-0.3.0.tgz","fileCount":6,"integrity":"sha512-a7DtL61af5Koz1fa3Z9JLiY+04Dfrgm3a6IVedFf0eIjLyqedWPNcQvME5q4iQsrGGuaw7rcdhNtS4UxBtxbgg==","signatures":[{"sig":"MEUCIQDSzsRSjybiHoLFqtbYuJvmW5GQo7BUqZQNI6X/1rVAFwIgbbWhod8/qZDyg/0IbvT40OV/BhDzVunhDQ14R3aL5mM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@bernhardfritz%2fflatland@0.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":31372},"type":"module","module":"./dist/flatland.js","exports":{".":{"import":"./dist/flatland.js"},"./vite-plugin":{"import":"./dist/vite-plugin-flatland.js"}},"gitHead":"2beefae0ac0812098a7e69e22e1aba8bb6b1857d","scripts":{"build":"tsc && vite build && cp vite-plugin-flatland.js dist/"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:fd6f5a15-e775-494e-a047-76e69da126d5"}},"repository":{"url":"git+https://github.com/bernhardfritz/flatland.git","type":"git"},"_npmVersion":"11.17.0","description":"A simple 2D graphics library","directories":{},"_nodeVersion":"24.19.0","_hasShrinkwrap":false,"devDependencies":{"vite":"^7.3.1","typescript":"~5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/flatland_0.3.0_1788206404868_0.5189235483242436","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@bernhardfritz/flatland","description":"A simple 2D graphics library","keywords":["2d","go","webassembly","webgl2"],"version":"0.4.0","homepage":"https://pkg.go.dev/github.com/bernhardfritz/flatland","bugs":{"url":"https://github.com/bernhardfritz/flatland/issues"},"license":"MIT","type":"module","module":"./dist/flatland.js","exports":{".":{"import":"./dist/flatland.js"},"./vite-plugin":{"import":"./dist/vite-plugin-flatland.js"}},"scripts":{"build":"tsc && vite build && cp vite-plugin-flatland.js dist/"},"devDependencies":{"typescript":"~5.9.3","vite":"^7.3.1"},"repository":{"type":"git","url":"git+https://github.com/bernhardfritz/flatland.git"},"gitHead":"7710bd0065d9b16960a05268d1c097b3345689d7","_id":"@bernhardfritz/flatland@0.4.0","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-zgY8eVBWyVgsZLtmeExlelFPWVDOv8fBgMBS6Hz3nE9UzKA71wqgNFeFno5H6JtYHfFeBFy7wumq3wKC+spsiA==","shasum":"8e52688e39c9367fc942ff29528792ea592fa81e","tarball":"https://registry.npmjs.org/@bernhardfritz/flatland/-/flatland-0.4.0.tgz","fileCount":6,"unpackedSize":35288,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@bernhardfritz%2fflatland@0.4.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEJ3qxbt0ijCuxsbfVPMe1xdz0VOIjJLaDIianmM/LLLAiEA85Bw/A0cbZpXJlhIu3FKnzxGPoWYfJEORaQA9BGsSZ8="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:fd6f5a15-e775-494e-a047-76e69da126d5"}},"directories":{},"maintainers":[{"name":"bernhardfritz","email":"bernhard.e.fritz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/flatland_0.4.0_1788979628479_0.017987917211474302"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-01T19:25:41.237Z","modified":"2026-09-09T18:47:08.952Z","0.0.0":"2026-08-01T19:25:41.593Z","0.1.0":"2026-08-01T20:07:58.466Z","0.2.0":"2026-08-09T19:21:49.587Z","0.3.0":"2026-08-31T20:00:05.045Z","0.4.0":"2026-09-09T18:47:08.620Z"},"bugs":{"url":"https://github.com/bernhardfritz/flatland/issues"},"license":"MIT","homepage":"https://pkg.go.dev/github.com/bernhardfritz/flatland","keywords":["2d","go","webassembly","webgl2"],"repository":{"type":"git","url":"git+https://github.com/bernhardfritz/flatland.git"},"description":"A simple 2D graphics library","maintainers":[{"name":"bernhardfritz","email":"bernhard.e.fritz@gmail.com"}],"readme":"# flatland\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/bernhardfritz/flatland.svg)](https://pkg.go.dev/github.com/bernhardfritz/flatland)\n[![NPM Version](https://img.shields.io/npm/v/%40bernhardfritz%2Fflatland)](https://www.npmjs.com/package/@bernhardfritz/flatland)\n\n<a href=\"https://pkg.go.dev/github.com/bernhardfritz/flatland\"><img src=\"./gamer.svg\" alt=\"Gopher holding a gamepad\" width=\"128\" align=\"right\"></a>\n\n**A minimal 2D graphics library for Go that runs in the browser using WebAssembly and WebGL.**\n\nFlatland is designed to make browser-based 2D graphics feel familiar to Go developers. Its API is intentionally small and you don't need to know JavaScript, WebGL or other web technologies to get started.\n\n[Examples](https://pkg.go.dev/github.com/bernhardfritz/flatland/examples) &middot;\n[API documentation](https://pkg.go.dev/github.com/bernhardfritz/flatland) &middot;\n[Start from template](https://github.com/bernhardfritz/flatland-template/generate)\n\n## Prerequisites\n\n- [Docker Engine](https://docs.docker.com/engine/install)\n- VS Code with [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension installed\n\n## Quick start\n\nThe easiest way to get started is with the [flatland template](https://github.com/bernhardfritz/flatland-template/generate) which provides the setup needed to build and run a Go/WebAssembly application.\n\nYou can also try it immediately in GitHub Codespaces:\n\n[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/bernhardfritz/flatland-template?quickstart=1)\n\n## Example\n\n<p align=\"center\">\n\t<img src=\"./bouncing-dvd-logo.gif\" alt=\"Bouncing DVD logo\">\n</p>\n\n```go\n// This example renders a bouncing DVD logo. It loads an embedded image,\n// updates its position every frame and changes its color whenever it hits the\n// edge of the screen.\npackage main\n\nimport (\n\t\"embed\"\n\t\"image/color\"\n\t\"math/rand/v2\"\n\n\tfl \"github.com/bernhardfritz/flatland\"\n)\n\ntype Vec2 struct {\n\tX float64\n\tY float64\n}\n\n//go:embed resources/*\nvar ASSETS embed.FS\n\nfunc init() {\n\tfl.AddFileSystem(ASSETS)\n}\n\nfunc main() {\n\tdvdLogo := fl.LoadTexture(\"resources/DVD_video_logo.png\")\n\tposition := Vec2{0, 0}\n\tvelocity := Vec2{0.2, 0.2}\n\tcolor := randomColor()\n\n\tanimate := func() {\n\t\tfl.ClearBackground(0, 0, 0, 255)\n\t\tfl.SetTintColor(color.R, color.G, color.B, color.A)\n\t\tfl.DrawTexture2f(dvdLogo, position.X, position.Y)\n\n\t\tposition.X += velocity.X * fl.DeltaTime\n\t\tposition.Y += velocity.Y * fl.DeltaTime\n\n\t\tif position.X+dvdLogo.Width >= fl.Width {\n\t\t\tvelocity.X = -velocity.X\n\t\t\tposition.X = fl.Width - dvdLogo.Width\n\t\t\tcolor = randomColor()\n\t\t} else if position.X <= 0 {\n\t\t\tvelocity.X = -velocity.X\n\t\t\tposition.X = 0\n\t\t\tcolor = randomColor()\n\t\t}\n\n\t\tif position.Y+dvdLogo.Height >= fl.Height {\n\t\t\tvelocity.Y = -velocity.Y\n\t\t\tposition.Y = fl.Height - dvdLogo.Height\n\t\t\tcolor = randomColor()\n\t\t} else if position.Y <= 0 {\n\t\t\tvelocity.Y = -velocity.Y\n\t\t\tposition.Y = 0\n\t\t\tcolor = randomColor()\n\t\t}\n\t}\n\n\tfl.SetAnimationLoop(animate)\n}\n\nfunc randUint8() uint8 {\n\treturn uint8(rand.Uint32())\n}\n\nfunc randomColor() color.RGBA {\n\treturn color.RGBA{randUint8(), randUint8(), randUint8(), 255}\n}\n```\n\n## Features\n\n- 2D rendering with WebGL\n- Go → WebAssembly\n- Textures and texture regions\n- Filled rectangles\n- Monospaced text rendering\n- 2D transformations\n- Keyboard and mouse input\n- Frame-based animation with delta time\n- Embedded asset support\n- Minimal API designed for Go developers\n\n## API overview\n\n| Category  | Functions                                                                                                                                                                                                                                                                                                                                                        |\n| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Rendering | [DrawRectangle](https://pkg.go.dev/github.com/bernhardfritz/flatland#DrawRectangle), [DrawTexture2f](https://pkg.go.dev/github.com/bernhardfritz/flatland#DrawTexture2f), [DrawTexture4f](https://pkg.go.dev/github.com/bernhardfritz/flatland#DrawTexture4f), [DrawTexture8f](https://pkg.go.dev/github.com/bernhardfritz/flatland#DrawTexture8f), [DrawText](https://pkg.go.dev/github.com/bernhardfritz/flatland#DrawText) |\n| Animation | [SetAnimationLoop](https://pkg.go.dev/github.com/bernhardfritz/flatland#SetAnimationLoop), `DeltaTime`                                                                                                                                                                                                                                                           |\n| Input     | [IsKeyPressed](https://pkg.go.dev/github.com/bernhardfritz/flatland#IsKeyPressed), [IsMouseButtonPressed](https://pkg.go.dev/github.com/bernhardfritz/flatland#IsMouseButtonPressed), `MouseX`, `MouseY`                                                                                                                                                         |\n| Graphics  | [ClearBackground](https://pkg.go.dev/github.com/bernhardfritz/flatland#ClearBackground), [SetTintColor](https://pkg.go.dev/github.com/bernhardfritz/flatland#SetTintColor), [SetTransform](https://pkg.go.dev/github.com/bernhardfritz/flatland#SetTransform)                                                                                                    |\n| Assets    | [LoadTexture](https://pkg.go.dev/github.com/bernhardfritz/flatland#LoadTexture), [LoadFont](https://pkg.go.dev/github.com/bernhardfritz/flatland#LoadFont), [AddFileSystem](https://pkg.go.dev/github.com/bernhardfritz/flatland#AddFileSystem)                                                                                                                                                                                    |\n| Canvas    | `Width`, `Height`                                                                                                                                                                                                                                                                                                                                                |\n\n## License\n\nFlatland is [MIT licensed](./LICENSE).\n","readmeFilename":"README.md"}