{"id":13524691,"url":"https://github.com/swalrus1/center","last_synced_at":"2025-04-01T03:32:22.247Z","repository":{"id":144685339,"uuid":"218564867","full_name":"swalrus1/center","owner":"swalrus1","description":"Align content to center with this simple library for LÖVE","archived":false,"fork":false,"pushed_at":"2022-04-11T10:08:01.000Z","size":45,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-20T09:42:47.006Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swalrus1.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}},"created_at":"2019-10-30T15:51:51.000Z","updated_at":"2024-05-13T02:23:51.000Z","dependencies_parsed_at":"2023-07-23T06:30:20.311Z","dependency_job_id":null,"html_url":"https://github.com/swalrus1/center","commit_stats":null,"previous_names":["swalrus1/center"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swalrus1%2Fcenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swalrus1%2Fcenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swalrus1%2Fcenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swalrus1%2Fcenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swalrus1","download_url":"https://codeload.github.com/swalrus1/center/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246578533,"owners_count":20799847,"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-01T06:01:12.498Z","updated_at":"2025-04-01T03:32:21.966Z","avatar_url":"https://github.com/swalrus1.png","language":"Lua","funding_links":[],"categories":["Drawing"],"sub_categories":[],"readme":"# center\nCenter is a simple library that dynamically aligns content to the center of game window.\n\n\u003cimg src=\"https://github.com/S-Walrus/center/blob/master/screenshots/center.png?raw=true\" width=\"256\"\u003e\n\n## Setup\n\n```lua\nlocal center = require \"center\"\n\ncenter:setupScreen(600, 400)\n\nfunction love.draw()\n  center:start()\n  \n  -- draw here\n  \n  center:finish()\nend\n\nfunction love.resize(width, height)\n  center:resize(width, height)\nend\n```\n\n## API\n\n### setupScreen\n```lua\ncenter:setupScreen(width, height)\n```\nInitializes Center\n\n### apply\n```lua\ncenter:apply()\n```\nApplies changes.\n\nThis function is responsible for the whole alignment process, so any function (except for `setupScreen` and `resize`) will not make sense without `apply()` after it.\n\n### setMaxWidth\n```lua\ncenter:setMaxWidth(width)\n```\nWidth of the content **won't be greater** than specified value (default value is 0, that means that there is no boundaries).\n\n### setMaxHeight\n```lua\ncenter:setMaxHeight(height)\n```\nWorks the same as the previous one.\n\n### setMaxRelativeWidth\n```lua\ncenter:setMaxRelativeWidth(width)\n```\nThe **relative** width of the content (actual width / available width) **won't be greater** than specified value (default value is 0, that means that there is no relative boundaries).\n\n### setMaxRelativeHeight\n```lua\ncenter:setMaxRelativeHeight(height)\n```\nWorks the same as the previous one.\n\n### setBorders\n```lua\ncenter:setBorders(t, r, b, l)\n```\nSpecify the available area for the content.\nEach argument represents how far the content should be placed from each side from top to left clockwise.\nThe content is aligned to the center of **this** area.\n\n*For better understanding, illustrations will be added soon*\n\n### start, finish\n\n```lua\nfunction love.draw()\n  center:start()\n  \n  -- draw here\n  \n  center:finish()\nend\n```\nThis pair of functions is supposed to be called once inside `love.draw()`. Any rendering after `center.finish()` affect the default canvas, so you can draw UI or anything else.\n\n### toGame\n\n```lua\ncenter:toGame(x, y)\n```\nReturn position of a point in aligned coordinate system insead of default one.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswalrus1%2Fcenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswalrus1%2Fcenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswalrus1%2Fcenter/lists"}