{"id":18773642,"url":"https://github.com/errorstream/levers","last_synced_at":"2025-12-14T00:30:20.507Z","repository":{"id":229266665,"uuid":"776270427","full_name":"errorStream/Levers","owner":"errorStream","description":"Drawing primitives for use in unity editor UIs.","archived":false,"fork":false,"pushed_at":"2024-11-01T18:54:17.000Z","size":8500,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-29T08:41:35.512Z","etag":null,"topics":["canvas","editor","graphics","gui","imgui","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","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/errorStream.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-03-23T03:33:26.000Z","updated_at":"2024-11-01T18:54:20.000Z","dependencies_parsed_at":"2024-03-26T08:32:44.351Z","dependency_job_id":"15e02d20-9291-4228-96f5-de096399682d","html_url":"https://github.com/errorStream/Levers","commit_stats":null,"previous_names":["errorstream/levers"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errorStream%2FLevers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errorStream%2FLevers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errorStream%2FLevers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/errorStream%2FLevers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/errorStream","download_url":"https://codeload.github.com/errorStream/Levers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239680985,"owners_count":19679509,"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":["canvas","editor","graphics","gui","imgui","unity"],"created_at":"2024-11-07T19:34:43.426Z","updated_at":"2025-12-14T00:30:20.471Z","avatar_url":"https://github.com/errorStream.png","language":"C#","readme":"\u003ca name=\"readme-top\"\u003e\u003c/a\u003e\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/errorStream/levers\"\u003e\n    \u003cimg src=\"images/logo.png\" alt=\"Logo\" width=\"80\" height=\"80\"\u003e\n  \u003c/a\u003e\n\n\u003ch3 align=\"center\"\u003eLevers\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    Drawing primitives for use in unity editor UIs.\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/errorStream/levers/wiki\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/errorStream/levers/releases\"\u003eDownload\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/errorStream/levers/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/errorStream/levers/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#who-is-this-for\"\u003eWho is this for?\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#dependencies\"\u003eDependencies\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#roadmap\"\u003eRoadmap\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#acknowledgments\"\u003eAcknowledgments\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\n\n![Levers Screen Shot](images/screenshot.png)\n![Pong Demo](images/pong.gif)\n\nLevers is a library of drawing primitives for use in Unity editor\nscripts, in other words it's designed as a more flexible, featureful,\nand API consistent version of Handles.\n\nThe library was designed to have an API in the vein of HTML5 canvas or\nSkia. It provides a series of shape primitives which can be filled\nand/or stroked. These primitives include things like circles, squares,\nstars, Bezier curves, etc. It conforms to IMGui design where it is\nredrawn during the UI repaint phase each update.\n\n### Who is this for?\n\nThis library is targeted towards people who are developing unity assets which\nneed editor UIs for interacting with them which require greater\ncustomization than that which the built-in libraries provide, or for people\ndeveloping such UIs for internal tools for their own projects.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\nTo get started with this library install the package through the unity package manager.\n\n### Dependencies\n\nThe only dependency is a compatible Unity editor.\n\n### Installation\n\n1. Clone this repo or download a tar ball of the package through releases\n2. Open a Unity project you want to install the library into\n3. Under Window in the top menu open Package Manager\n4. Click the plus in the top left.\n   - If you cloned the repo\n     1. Click \"Add Package From Disk\"\n     2. Navigate to the package.json file and select it\n   - If you downloaded the package through releases\n     3. Click \"Add Package From Tarball\"\n     4. Navigate to the `.tgz` file and select it\n   - If you want to install directly from a git url\n     1. Click \"Add Package from git URL\"\n     2. Paste in a git url. This is available from the Code dropdown\n        in the top right. In this case it would be\n        https://github.com/errorStream/Levers.git\n     3. Click \"Add\"\n5. (Optional) Open the Samples area and click \"Import\" by the samples to bring in some example code\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\n\nLevers can be used like any other unity editor UI library. This\nexample demonstrates a common approach where you reserve an area of\nsize 500x400 with GUI layout and draw a green shape inside it. Notice\nthat positions are specified in screen space, so you have to offset\neach position to the start of the reserved Rect.\n\n```csharp\nusing UnityEngine;\nusing UnityEditor;\nusing Levers;\n\n[CustomEditor(typeof(YourComponent))]\npublic class YourComponentEditor : Editor\n{\n    public override void OnInspectorGUI()\n    {\n        // Reserve an area to draw in\n        var position = GUILayoutUtility.GetRect(500, 40); \n        // Create a new path starting at the top left corner\n        var path = new Path2D(new Vector2(position.x + 7, position.y + 37));\n        // Add lines to the path to define an area to fill\n        path.LineTo(new Vector2(position.x + 47, position.y + 2));\n        path.LineTo(new Vector2(position.x + 112, position.y + 57));\n        path.LineTo(new Vector2(position.x + 22, position.y + 57));\n        path.LineTo(new Vector2(position.x + 87, position.y + 2));\n        path.LineTo(new Vector2(position.x + 127, position.y + 37));\n        // Fill the path with a green color\n        Draw.Fill = Color.green;\n        // Don't stroke the outline\n        Draw.Stroke = Color.clear;\n        // Draw the path\n        Draw.Path(path);\n    }\n}\n```\n\nLevers supports `GUI.matrix`, which means to save typing we can offset\nall draws positions by the top left corner of the reserved block.\n\n```csharp\nusing UnityEngine;\nusing UnityEditor;\nusing Levers;\n\n[CustomEditor(typeof(YourComponent))]\npublic class YourComponentEditor : Editor\n{\n    public override void OnInspectorGUI()\n    {\n        var position = GUILayoutUtility.GetRect(500, 40);\n        // Store the original matrix\n        var originalMatrix = GUI.matrix;\n        // Add transformation to the matrix to move the path to the top left corner of the rect\n        GUI.matrix = Matrix4x4.Translate(position.min) * originalMatrix;\n        var path = new Path2D(new Vector2(7, 37));\n        path.LineTo(new Vector2(47, 2));\n        path.LineTo(new Vector2(112, 57));\n        path.LineTo(new Vector2(22, 57));\n        path.LineTo(new Vector2(87, 2));\n        path.LineTo(new Vector2(127, 37));\n        Draw.Fill = Color.green;\n        Draw.Stroke = Color.clear;\n        Draw.Path(path);\n        // Restore the original matrix\n        GUI.matrix = originalMatrix;\n    }\n}\n```\n\nAn even easier way is to use `GUI.BeginGroup`, which modifies\n`GUI.matrix` and makes a clipping area to prevent your code from\ndrawing outside the reserved block.\n\n```csharp\nusing UnityEngine;\nusing UnityEditor;\nusing Levers;\n\n[CustomEditor(typeof(YourComponent))]\npublic class YourComponentEditor : Editor\n{\n    public override void OnInspectorGUI()\n    {\n        // Define group in the reserved space\n        GUI.BeginGroup(GUILayoutUtility.GetRect(500, 40));\n        var path = new Path2D(new Vector2(7, 37));\n        path.LineTo(new Vector2(47, 2));\n        path.LineTo(new Vector2(112, 57));\n        path.LineTo(new Vector2(22, 57));\n        path.LineTo(new Vector2(87, 2));\n        path.LineTo(new Vector2(127, 37));\n        Draw.Fill = Color.green;\n        Draw.Stroke = Color.clear;\n        Draw.Path(path);\n        // End group\n        GUI.EndGroup();\n    }\n}\n```\n\nDrawing settings are defined by modifying static properties of the\ndraw class. If you want to break up your drawing code into functions,\nyou probably want to return the draw settings to a default state\ntemporarily. This can be done with `Draw.PushState()` and\n`Draw.PopState()`, which puts a new settings frame on the stack with\ndefault settings and which can be modified through the `Draw` class\nproperties, this can then be popped to restore the original\nproperties.\n\n```csharp\nusing UnityEngine;\nusing UnityEditor;\nusing Levers;\n\n[CustomEditor(typeof(YourComponent))]\npublic class YourComponentEditor : Editor\n{\n    private static void DrawRedDot()\n    {\n        // Push draw settings state frame with default settings\n        Draw.PushState();\n        // Set fill color of current draw settings state frame\n        Draw.Fill = Color.red;\n        Draw.Circle(20, 20, 20);\n        // Restore draw settings state from before the PushState call\n        Draw.PopState();\n    }\n    \n    public override void OnInspectorGUI()\n    {\n        GUI.BeginGroup(GUILayoutUtility.GetRect(500, 40));\n        var path = new Path2D(new Vector2(7, 37));\n        path.LineTo(new Vector2(47, 2));\n        path.LineTo(new Vector2(112, 57));\n        path.LineTo(new Vector2(22, 57));\n        path.LineTo(new Vector2(87, 2));\n        path.LineTo(new Vector2(127, 37));\n        Draw.Fill = Color.green;\n        Draw.Stroke = Color.clear;\n        Draw.Path(path);\n        DrawRedDot();\n        GUI.EndGroup();\n    }\n}\n```\n\n![Your Component Screenshot](images/your_component_screenshot.png)\n\n_For more examples, see the Samples in the unity package or the `Samples~` directory of this repository_\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- ROADMAP --\u003e\n## Roadmap\n\n- [x] Basic shapes\n- [x] Clipping Rect\n- [x] Matrix support\n- [x] Texture fill\n- [x] Fill rules\n- [x] Path2D\n- [x] Simple anti-aliasing\n- [ ] More drawing options\n  - [ ] More stroke joins\n  - [ ] Texture stroke fill\n  - [ ] Multi-sample anti aliasing\n  - [ ] Multiple sub-paths in a single path\n  - [ ] More shape primitives\n  - [ ] Data visualization helpers\n  - [ ] Event handling\n  - [ ] Partial overriding states\n- [ ] Find and fix edge cases\n- [ ] Test on more Unity versions\n\nSee the [open issues](https://github.com/errorStream/levers/issues)\nfor a full list of proposed features (and known issues).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nIf you have a suggestion that would make this better, please fork the\nrepo and create a pull request. You can also simply open an issue with\nthe tag \"enhancement\".\n\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the MIT License. See `LICENSE.txt` for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nErrorStream - [itch.io profile](https://errorstream.itch.io) - errorstream@amequus.com\n\nProject Link: [https://github.com/errorStream/levers](https://github.com/errorStream/levers)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- ACKNOWLEDGMENTS --\u003e\n## Acknowledgments\n\n* [Going deep with IMGUI and Editor customization | Unity\n  Blog](https://blog.unity.com/engine-platform/imgui-and-editor-customization) :\n  The best introduction to Unitys IMGui system that I have found. I\n  recommend you read this to understand the design philosophy of the\n  core IMGui system which I designed this library in consideration of.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[product-screenshot]: images/screenshot.png\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferrorstream%2Flevers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferrorstream%2Flevers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferrorstream%2Flevers/lists"}