{"id":21141589,"url":"https://github.com/bjornbytes/lutil","last_synced_at":"2025-12-18T06:03:52.261Z","repository":{"id":25307332,"uuid":"28733903","full_name":"bjornbytes/lutil","owner":"bjornbytes","description":null,"archived":false,"fork":false,"pushed_at":"2015-01-03T03:35:17.000Z","size":108,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T01:35:33.380Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bjornbytes.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}},"created_at":"2015-01-03T03:35:04.000Z","updated_at":"2024-11-06T03:30:44.000Z","dependencies_parsed_at":"2022-07-25T12:32:03.309Z","dependency_job_id":null,"html_url":"https://github.com/bjornbytes/lutil","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornbytes%2Flutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornbytes%2Flutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornbytes%2Flutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjornbytes%2Flutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjornbytes","download_url":"https://codeload.github.com/bjornbytes/lutil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695481,"owners_count":21146956,"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-11-20T07:32:12.614Z","updated_at":"2025-12-18T06:03:47.224Z","avatar_url":"https://github.com/bjornbytes.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"lutil\n=====\n\nMy Lua utility file.\n\nClass\n---\n\nLutil provides a very lightweight class system.  Here's how you use it:\n\n    -- Declare a class\n    local Cat = class()\n    \n    Cat.sound = 'meow'\n\n    function Cat:speak()\n      print(self.sound)\n    end\n\n    function Cat:purr()\n      print('purr')\n    end\n\n    -- Inheritance\n    local Lion = extend(Cat)\n    Lion.sound = 'rawr'\n\n    -- Constructors\n    function Lion:init(name)\n      self.name = name\n    end\n\n    -- Instantiation\n    local simba = Lion('simba') -- or new(Lion, 'simba')\n    print(simba.name)\n    simba:speak()\n    simba:purr()\n\nMath\n---\n\n- `math.sign(x)` returns the sign of `x` (-1, 0, or 1).\n- `math.round(x)` rounds `x` to the nearest whole number away from zero.\n- `math.clamp(x, min, max)` clamps `x` between `min` and `max`.\n- `math.lerp(x1, x2, z)` linearly interpolates between `x1` and `x2`.  For example, passing in `.5` for `z` will return a value halfway between `x1` and `x2`.\n- `math.anglerp(d1, d2, z)` linearly interpolates between two angles (in radians).\n- `math.dx(length, direction)` returns the x-component of a vector with length `length` and direction `direction` (in radians).\n- `math.dy(length, direction)` returns the y-component of a vector with length `length` and direction `direction` (in radians).\n- `math.distance(x1, y1, x2, y2)` returns the distance between two points.\n- `math.direction(x1, y1, x2, y2)` returns the direction between to points (in radians).\n- `math.vector(x1, y1, x2, y2)` returns the distance and direction between two points.\n- `math.inside(px, py, rx, ry, w, h)` returns true if the point (`px`, `py`) is inside the rectangle with the top-left corner located at (`rx`, `ry`), width equal to `rw` and height equal to `rh`.\n- `math.anglediff(d1, d2)` returns the difference between two angles (in radians).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjornbytes%2Flutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjornbytes%2Flutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjornbytes%2Flutil/lists"}