{"id":16218203,"url":"https://github.com/quasilyte/ebitengine-graphics","last_synced_at":"2025-03-19T10:31:00.596Z","repository":{"id":220930498,"uuid":"752590158","full_name":"quasilyte/ebitengine-graphics","owner":"quasilyte","description":"A package implementing Graphics primitives for gscene package","archived":false,"fork":false,"pushed_at":"2024-04-22T15:31:06.000Z","size":43,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-30T07:19:33.708Z","etag":null,"topics":["ebiten","ebitengine","gamedev","go","golang","graphics","gscene","library","primitives","rendering","shapes","sprite","text"],"latest_commit_sha":null,"homepage":"","language":"Go","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/quasilyte.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-02-04T09:45:32.000Z","updated_at":"2024-05-01T12:16:45.892Z","dependencies_parsed_at":"2024-05-01T12:16:34.365Z","dependency_job_id":"ec421d12-e48e-42b8-990f-738b3be436cf","html_url":"https://github.com/quasilyte/ebitengine-graphics","commit_stats":null,"previous_names":["quasilyte/gscene-graphics","quasilyte/ebitengine-graphics"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Febitengine-graphics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Febitengine-graphics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Febitengine-graphics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2Febitengine-graphics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quasilyte","download_url":"https://codeload.github.com/quasilyte/ebitengine-graphics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243982239,"owners_count":20378607,"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":["ebiten","ebitengine","gamedev","go","golang","graphics","gscene","library","primitives","rendering","shapes","sprite","text"],"created_at":"2024-10-10T11:48:52.095Z","updated_at":"2025-03-19T10:31:00.344Z","avatar_url":"https://github.com/quasilyte.png","language":"Go","readme":"# ebitengine-graphics\n\n![Build Status](https://github.com/quasilyte/ebitengine-graphics/workflows/Go/badge.svg)\n[![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/quasilyte/ebitengine-graphics)](https://pkg.go.dev/mod/github.com/quasilyte/ebitengine-graphics)\n\n## Overview\n\nA package implementing various graphics primitives like Sprite for [Ebitengine](https://github.com/hajimehoshi/ebiten/).\n\nIt works the best in combination with [gscene package](https://github.com/quasilyte/gscene), but can be used without it.\n\nGraphical objects list:\n\n* Sprite\n* Line, DottedLine, Texture Line\n* Circle (supports dashed style)\n* Rect\n* Label\n* Container\n* Canvas\n* Easier shader-based drawing (ShaderObject)\n\n\u003e Missing some graphical object? [Tell us about it](https://github.com/quasilyte/ebitengine-graphics/issues/new).\n\nIt also supports a basic camera and layers implementation.\n\n## Installation\n\n```bash\ngo get github.com/quasilyte/ebitengine-graphics\n```\n\n## Quick Start\n\nThe most useful type of this package is `Sprite`, but it's tricky to demonstrate its usage without assets. This is a quick start section, it's intended to be as slim as possible.\n\nYou can use this library without [gscene](https://github.com/quasilyte/gscene):\n\n```go\npackage main\n\nimport (\n\t\"github.com/hajimehoshi/ebiten/v2\"\n\tgraphics \"github.com/quasilyte/ebitengine-graphics\"\n\t\"github.com/quasilyte/gmath\"\n)\n\nfunc main() {\n\tebiten.SetWindowSize(640, 480)\n\tif err := ebiten.RunGame(newExampleGame()); err != nil {\n\t\tpanic(err)\n\t}\n}\n\ntype exampleGame struct {\n\tpos           gmath.Vec\n\tinitialized   bool\n\tobjects       []drawable\n}\n\ntype drawable interface {\n\tDraw(screen *ebiten.Image)\n}\n\nfunc newExampleGame() *exampleGame {\n\treturn \u0026exampleGame{\n\t\tpos:           gmath.Vec{X: 32, Y: 32},\n\t}\n}\n\nfunc (g *exampleGame) Layout(outsideWidth, outsideHeight int) (int, int) {\n\treturn 640, 480\n}\n\nfunc (g *exampleGame) Draw(screen *ebiten.Image) {\n\tfor _, o := range g.objects {\n\t\to.Draw(screen)\n\t}\n}\n\nfunc (g *exampleGame) Update() error {\n\tif !g.initialized {\n\t\tg.Init()\n\t\tg.initialized = true\n\t}\n\n\tg.pos = g.pos.Add(gmath.Vec{X: 1, Y: 2})\n\treturn nil\n}\n\nfunc (g *exampleGame) Init() {\n\t{\n\t\tfrom := gmath.Pos{Base: \u0026g.pos}\n\t\tto := gmath.Pos{Offset: gmath.Vec{X: 128, Y: 64}}\n\t\tl := graphics.NewLine(from, to)\n\t\tl.SetWidth(2)\n\t\tl.SetColorScale(graphics.ColorScaleFromRGBA(200, 100, 100, 255))\n\t\tg.objects = append(g.objects, l)\n\t}\n\n\t{\n\t\tr := graphics.NewRect(32, 32)\n\t\tr.Pos.Base = \u0026g.pos\n\t\tr.SetFillColorScale(graphics.RGB(0xAABB00))\n\t\tr.SetOutlineColorScale(graphics.RGB(0x0055ff))\n\t\tr.SetOutlineWidth(2)\n\t\tg.objects = append(g.objects, r)\n\t}\n}\n```\n\nWith `gscene` it's even easier (showing only relevant part):\n\n```go\nfunc (c *exampleController) Init(scene *gscene.SimpleRootScene) {\n\t{\n\t\tfrom := gmath.Pos{Base: \u0026g.pos}\n\t\tto := gmath.Pos{Offset: gmath.Vec{X: 128, Y: 64}}\n\t\tl := graphics.NewLine(from, to)\n\t\tl.SetWidth(2)\n\t\tl.SetColorScale(graphics.ColorScaleFromRGBA(200, 100, 100, 255))\n\t\tscene.AddGraphics(l)\n\t}\n\n\t{\n\t\tr := graphics.NewRect(32, 32)\n\t\tr.Pos.Base = \u0026g.pos\n\t\tr.SetFillColorScale(graphics.RGB(0xAABB00))\n\t\tr.SetOutlineColorScale(graphics.RGB(0x0055ff))\n\t\tr.SetOutlineWidth(2)\n\t\tscene.AddGraphics(r)\n\t}\n}\n```\n\nNote that we can add the graphical object directly to the scene. The scene will manage their `Draw` calls as well as their lifetimes (based on graphical objects being disposed or not).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasilyte%2Febitengine-graphics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquasilyte%2Febitengine-graphics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasilyte%2Febitengine-graphics/lists"}