{"id":15061032,"url":"https://github.com/phasereditor2d/phasereditor2d-roundedrectanglegraphics-plugin","last_synced_at":"2026-02-07T20:31:05.392Z","repository":{"id":57701935,"uuid":"495326195","full_name":"PhaserEditor2D/phasereditor2d-roundedRectangleGraphics-plugin","owner":"PhaserEditor2D","description":"A Phaser Editor 2D plugin with support for a rounded rectangle graphics object.","archived":false,"fork":false,"pushed_at":"2022-06-01T14:14:19.000Z","size":393,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-21T12:47:52.140Z","etag":null,"topics":["graphics","phaser","phaser-editor-2d","plugin","rounded-rectangle"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/PhaserEditor2D.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}},"created_at":"2022-05-23T08:43:06.000Z","updated_at":"2024-05-29T13:16:18.000Z","dependencies_parsed_at":"2022-09-26T22:30:28.031Z","dependency_job_id":null,"html_url":"https://github.com/PhaserEditor2D/phasereditor2d-roundedRectangleGraphics-plugin","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/PhaserEditor2D%2Fphasereditor2d-roundedRectangleGraphics-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fphasereditor2d-roundedRectangleGraphics-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fphasereditor2d-roundedRectangleGraphics-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhaserEditor2D%2Fphasereditor2d-roundedRectangleGraphics-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PhaserEditor2D","download_url":"https://codeload.github.com/PhaserEditor2D/phasereditor2d-roundedRectangleGraphics-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243701311,"owners_count":20333616,"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":["graphics","phaser","phaser-editor-2d","plugin","rounded-rectangle"],"created_at":"2024-09-24T23:08:29.240Z","updated_at":"2026-02-07T20:31:05.364Z","avatar_url":"https://github.com/PhaserEditor2D.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RoundedRectangleGraphics plugin for Phaser Editor 2D\n\nThis repository contains the RoundedRectangleGraphics plugin for Phaser Editor 2D v3.\n\nIt requires the version `v3.33.2` (or newer) of the editor.\n\n## Install\n\nThe plugin is distributed as a NodeJS package:\n\n```bash\n$ npm i --save-dev phasereditor2d-roundedrectanglegraphics-plugin\n```\n\nIt is important that you install the package as a development dependency (`--save-dev`), because Phaser Editor 2D only searches for plugins in that section. Also, the `package.json` file should be in the root of the project.\n\n## Creating a RoundedRectangleGraphics object\n\nFor creating a RoundedRectangleGraphics object, you can drag the **RoundedRectangleGraphics** type from the **Built-In** section of the **Blocks** view and drop it in the scene.\n\nBy default, it shows a white rectangle:\n\n![Create object](images/create-roundedRectangle.jpeg)\n\n## RoundedRectangleGraphics parameters  \n\nA RoundedRectangleGraphics object is similar to the Rectangle game object. It has size, background, stroke, in addition to specific properties, like radius, and shadow.\n\nThe shadow is part of the bound of the object, it means, if you increase the shadow offset, the background of the object decreases.\n\n![RoundedRectangleGraphics properties](images/properties.jpeg)\n\nThere are other properties common to the RenderTexture object, like those in the sections Transform, Origin, Visible, etc...\n\n## Size manipulators\n\nYou can resize the RoundedRectangle object with the **Size Tool**. Press the `Z` key or select this tool in the context menu **Tools** \u003e **Resize Tool**.\n\n![Resize tool](images/size-tool.png)\n\n## Code generation\n\nThe RoundedRectangleGraphics object is not available in the Phaser built-in API. Phaser Editor 2D uses an internal implementation of this object, and provides the source code of a RoundedRectangleGraphics game object that you can use in your project.\n\nTo get the source code of the RoundedRectangleGraphics game object, execute the command **Rounded Rectangle Graphics: Create User Files**:\n\n![Create rounded rectangle files command](images/create-files-commands.jpeg)\n\nYou can open the Command Palette in the main menu or by pressing the `Ctrl+K` keys.\n\nLook you there are four different commands:\n\n* For creating JavaScript files as ES modules.\n* For creating simple JavaScript files.\n* For creating TypeScript files as ES modules.\n* For creating simple TypeScript files.\n\nThese commands create a series of files with the source code of the RoundedRectangleGraphics class. The files are copied in the folder selected in the **Files** view.\n\n![Rounded rectangle user files](images/api-files.jpeg)\n\nThe files are following:\n\n### `RoundedRectangleGraphics.ts`\n \nContains the implementation of the RoundedRectangleGraphics game object. It extends the Phaser class: `Phaser.GameObjects.Graphics`.\n\nYou can create a new instance like this:\n\n```javascript\nconst obj = new RoundedRectangleGraphics(scene, 10, 10, 100, 100);\nscene.add.existing(obj);\n```\n\n### `registerRoundedRectangleGraphicsFactory.ts`\n\nContains the `registerRoundedRectangleGraphicsFactory()` function. \n\nYou should use it for registering a `GameObjectFactory` method. It allows you creating new RoundedRectangle objects like this: \n\n```javascript\nconst obj = this.add.roundedRectangleGraphics(10, 10, 100, 100);\n```\nBefore, you need to register the factory:\n\n```javascript\n\nconst game = new Phaser.Game(...);\n...\nregisterRoundedRectangleGraphicsFactory();\n...\n```\n\n### `roundedRectangleGraphics.d.ts`\n\nContains the TypeScript definitions. Maybe you should move it to the `types` folder of your project. Or you should configure the `tsconfig.json` file finding the definitions.\n\n### `drawRoundedRectangle.ts`\n\nContains the `drawRoundedRectangle` function. It is a routine for drawing a rounded rectangle in a graphics object.\n\n### Code customization\n\nYou are free to change the code of the generated RoundedRectangleGraphics files, however, take in consideration that the scene's code generated by the editor uses always the same public interface of the RoundedRectangleGraphics object.\n\n### The RoundedRectangleImage class\n\nIn addition, you can create a **RoundedRectangleImage** game object. It is an image object but with a texture that is generated in the fly. It contains a `redraw()` method that draws a rounded rectangle into an offline graphics object, and use that graphics as a new texture for the image.\n\nI recommend using this implementation of the rounded rectangle if you have a different rounded rectangle objects but with the same properties. This way, the different objects share the same texture, getting a much better rendering performance.\n\n![Create rounded rectangle image object](./images/create-rounded-rectangle-image.jpeg)\n\nFor using the RoundedRectangleImage object, you should register its factory:\n\n```javascript\n\nconst game = new Phaser.Game(...);\n...\nregisterRoundedRectangleImageFactory();\n...\n```\n\nTake a look to the `RoundedRectangleImage.ts` and `registerRoundedRectangleImageFactory.ts` user files.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphasereditor2d%2Fphasereditor2d-roundedrectanglegraphics-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphasereditor2d%2Fphasereditor2d-roundedrectanglegraphics-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphasereditor2d%2Fphasereditor2d-roundedrectanglegraphics-plugin/lists"}