Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

ArtemkaKun/polygon-editor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polygon Editor

animated

About

Polygon Editor is a desktop application designed for game developers to create and edit 2D polygon shapes to be used as colliders in their games. Compatible with Linux systems (only ⚠️), it's built using the V programming language and V UI framework, offering a fast and lightweight tool. This project is open-source and is licensed under the MIT license.

Key Features

  • Sprite and Polygon loading: Load sprites (PNG) and existing polygons (JSON) for editing.
  • Polygon drawing: Draw polygons on the loaded sprite by adding points with left mouse clicks.
  • Point modification: Modify polygons by moving the points around.
  • Point deletion: Remove points from the polygon via right-click.
  • Status indications: Display status messages like "Polygon saved", "Sprite opened", etc.

Dependencies

Usage

  1. Begin by selecting a sprite that will serve as your reference for creating a polygon. You can do this by navigating to File... then selecting Open sprite file.
  2. After your sprite is loaded, create a new polygon file. This can be done by going to File... and choosing Create new polygon.
  3. You can now start shaping your polygon. Left-click with your mouse to add points. If you need to remove points, a right-click will do the trick. To reposition a point, simply press and hold the left mouse button and drag the point to your desired location.
  4. Once you're satisfied with your polygon, ensure to save your work. Navigate to File... and then Save polygon. Your polygon will now be safely stored for future use or modification.

User Interface

The UI consists of a panel bar at the top and a viewport. The panel bar includes a "File..." button that provides a dropdown menu with options for opening and saving sprites and polygons. The viewport displays the loaded sprite and the drawn polygon.

Export

Export polygons as JSON files (Polygon structure from v-2d-polygon-colliders library). Each point is represented by an object (Position structure from v-2d-transform library) with x and y properties for its coordinates.

Note

It's crucial to remember that these point positions are not based on global coordinates, but rather they exist within the local space of the sprite used as a reference. This means that their position is defined relative to the origin point of the sprite, rather than the overall coordinate system. See Local to Global and Global to Local conversions examples.

{
   "points":[
      {
         "Vector":{
            "x":0.05,
            "y":4.05
         }
      },
      {
         "Vector":{
            "x":1.0,
            "y":2.0
         }
      },
      {
         "Vector":{
            "x":3.05,
            "y":0.0
         }
      }
   ]
}

Future Enhancements

  • Dynamic zoom
  • Undo/redo functionality
  • Pixel precision grid

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Donations

If you like this project, please consider donating to me or the V language project. Your donations will help me to continue to develop this project and the V language.

More about my projects

Subscribe to my Mastodon account to find more info about my projects.