{"id":15016081,"url":"https://github.com/essentialgg/elementa","last_synced_at":"2025-05-15T22:12:24.719Z","repository":{"id":37978885,"uuid":"211431780","full_name":"EssentialGG/Elementa","owner":"EssentialGG","description":"A simple, declarative GUI library for Minecraft","archived":false,"fork":false,"pushed_at":"2025-04-10T12:29:40.000Z","size":3803,"stargazers_count":387,"open_issues_count":22,"forks_count":34,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-15T22:12:14.638Z","etag":null,"topics":["animation","drawing","graphics","minecraft","minecraft-forge"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EssentialGG.png","metadata":{"files":{"readme":"README-java.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":"2019-09-28T02:24:28.000Z","updated_at":"2025-05-13T16:32:42.000Z","dependencies_parsed_at":"2024-01-17T15:52:32.728Z","dependency_job_id":"8b887e36-53e2-4ba7-84a8-3e7b1d4b5008","html_url":"https://github.com/EssentialGG/Elementa","commit_stats":{"total_commits":1047,"total_committers":27,"mean_commits":38.77777777777778,"dds":0.7507163323782235,"last_synced_commit":"ddd0c435994a7e5095c5904f7839491d3208fd9c"},"previous_names":["sk1erllc/elementa"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EssentialGG%2FElementa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EssentialGG%2FElementa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EssentialGG%2FElementa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EssentialGG%2FElementa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EssentialGG","download_url":"https://codeload.github.com/EssentialGG/Elementa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254430335,"owners_count":22069909,"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":["animation","drawing","graphics","minecraft","minecraft-forge"],"created_at":"2024-09-24T19:48:22.944Z","updated_at":"2025-05-15T22:12:24.665Z","avatar_url":"https://github.com/EssentialGG.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Components\n\nAll the drawing in Elementa is done via UIComponents. There is a root component named `Window`\nthat MUST be in the hierarchy of all components, thus making it the top of the component tree. \nAll components have exactly `1` parent, and all components have `0-n` children.\n\nTo create a component, simply instantiate an existing implementation such as `UIBlock`, \nor extend `UIComponent` yourself.\n\n```java\n// Manually create and store a window instance. The Window is the entry point for Elementa's event system,\n// in that you must call events on the window instance manually, the most common of which would be Window#draw.\n// This call must be made every frame or else the library will never render your components. If your Gui extends\n// Elementa's WindowScreen, this step will already be done and a window will be provided.\nWindow window = new Window();\n\n// Here we are creating an instance of one of the simplest components available, a UIBlock.\n// Next, we have to add it to our hierarchy in some way, and in this instance we want it to be\n// a child of the Window. Now that it is in the hierarchy, it will be drawn when we render our Window.\nUIComponent box = new UIBlock().setChildOf(window);\n```\n\n## Constraints\n\nAll components have a set of constraints that determine its X/Y position, width/height, and color.\nThe default set of constraints sets a component's x, y, width, height to be 0, and color to be Color.WHITE.\n\nA key thing to realize with these components is that everything is relative to its parent. When we\ncenter a component, it will be in the center of its _direct_ parent, whether it is the Window or\nperhaps another UIBlock.\n\nThis also showcases exactly how declarative the library is. Our code is saying that we would like our box\nto be in the center of our parent, and that is all we need to do. No code to figure out how to position it there,\nno code to calculate. We simply describe exactly what we want, and Elementa will do the rest for you.\n\n```java\nUIComponent box = new UIBlock()\n    .setX(new CenterConstraint())\n    .setY(new PixelConstraint(10f))\n    .setWidth(new PixelConstraint(0f))\n    .setHeight(new PixelConstraint(36f));\n```\n\n## Effects\n\nAdditionally, a component can have a list of effects, special modifiers that can affect the rendering of\na component or its children. One of the most common effects is the `ScissorEffect`. When enabled for\nan arbitrary component, this effect restricts all of its children to be drawn inside its own boundaries.\nAnything drawn outside that area will simply be cut off. Any component that is not a child (direct or indirect)\nof the component where the effect is enabled will not have their rendering affected.\n\n```java\nUIComponent box = new UIBlock().enableEffect(new ScissorEffect());\n```\n\n## Animations\n\nElementa also provides a strong animation API. When you make an animation, you set all the\nnew constraints you would like to animate to, as well as the length (and optionally, delay)\nof the animation.\n\nWhen animating, you have a wide variety of animation strategies (algorithms) to choose from, and you can\nof course implement more yourself. All the built-in animation strategies come from\nthe `Animations` enum.\n\n```java\nAnimatingConstraints anim = box.makeAnimation();\nanim.setWidthAnimation(Animations.OUT_EXP, 0.5f, new ChildBasedSizeConstraint(2f));\nanim.onCompleteRunnable(() -\u003e {\n    // Trigger new animation or anything.\n});\nbox.animateTo(anim);\n``` \n\n## Basic Events\n\nElementa also provides some basic events that can run your animations, or anything else of your choosing.\n\n```java\n// Runs a single time when the mouse moves from a state of not hovering to hovering.\nbox.onMouseEnterRunnable(() -\u003e {\n    // Animate, set color, run business logic, etc.\n    // Animate, set color, etc.\n    \n});\n\nAnimatingConstraints anim = box.makeAnimation();\nanim.setWidthAnimation(Animations.OUT_EXP, 0.5f, new ChildBasedSizeConstraint(2f));\n// This will run when the animation is complete.\n// If this animation had multiple \"animation components\",\n// this would trigger when they were all complete.\nanim.onCompleteRunnable(() -\u003e {\n    // Trigger new animation or anything.\n});\nbox.animateTo(anim);\n```\n\nThere are many more events than solely those two, and they can be found throughout `UIComponent`.\nKeep in mind that all events stem from the Window component, and events must be manually\ncalled on the Window. For example, in order to receive an `onMouseClick` event,\nyou MUST call Window#mouseClick. In a GuiScreen, this would be done by overriding the `mouseClicked`\nmethod.\n\n## All together\n\nThis is a basic excerpt of code from an Elementa GUI. To see a more fleshed out\nexample, look to the `JavaTestGui` class.\n\n```java\npublic class TestGui extends WindowScreen {\n    UIComponent box = new UIBlock()\n        .setX(new CenterConstraint())\n        .setY(new PixelConstraint(10f))\n        .setWidth(new PixelConstraint(0f))\n        .setHeight(new PixelConstraint(36f))\n        .setChildOf(getWindow())\n        .enableEffect(new ScissorEffect());\n\n    public TestGui() {\n        box.onMouseEnterRunnable(() -\u003e {\n            // Animate, set color, etc.\n            AnimatingConstraints anim = box.makeAnimation();\n            anim.setWidthAnimation(Animations.OUT_EXP, 0.5f, new ChildBasedSizeConstraint(2f));\n            anim.onCompleteRunnable(() -\u003e {\n                // Trigger new animation or anything.\n            });\n            box.animateTo(anim);\n        });\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fessentialgg%2Felementa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fessentialgg%2Felementa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fessentialgg%2Felementa/lists"}