Log In  

Cart #ratasiyoja-3 | 2021-10-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

This is WIP of a line-based polygon editing tool for pico.

It's very simple and is meant to help you design polygons faster and export them to use with code later.

Some features:

  • Click-click with your mouse to create new vertices and link them together
  • X: New Polygon
  • H: Help
  • G: Enable or disable magnetic grid
  • U: Unlimited undo
  • R: Unlimited redo(!)
  • S:16x16 preview
  • E: Export to lua arrays of polygons (need to run pico8 from the terminal to get the text output)
local poly = {
  {
    {25,43},
    {40,34},
    {47,50},
    {68,44},
    {59,69},
    {88,71},
    {81,95},
    {101,104},
    {72,122},
    {68,90},
    {34,85},
    {48,56},
    {21,57},
  },
  {
    {22,65},
    {39,63},
    {32,77},
    {22,81},
    {23,76},
    {18,76},
    {20,71},
    {13,68},
  }
}

That's it for now as it seems it's almost doing what I need now.

P#96152 2021-08-17 20:41 ( Edited 2021-10-15 21:30)

(took me forever to find that space closes current shape - why not x/c?)

Got that error:

P#96154 2021-08-17 21:17

@freds72, that's a good suggestion for x/c

You probably got the error because you hit space twice, didn't you?

P#96155 2021-08-17 21:27

@freds72 Both issues are fixed :)

  • X replaces [spc] to create a new poly
  • [fix/crash] Creating multiple empty polys is now ignored at poly insertion
P#96157 2021-08-17 21:39

I rewrote most of the polygon generation code because it was messy. It's much better now.
I also use the same code to paint and export polys and added a redo feature.

The cart also boots with the help screen.

Cart #ratasiyoja-3 | 2021-10-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

What's missing?

  • Load/save functions that work nicely
  • Filled polygons
  • Palette editor
  • Customizable preview
P#98718 2021-10-15 21:28

@Oct, I would be very interested in seeing you do filled polygons. That is something I would find difficult to write. Gold star to you for encouragement.

P#98725 2021-10-15 23:31 ( Edited 2021-10-15 23:32)

@dw817
Filled polygons, you say? (for my next large project)

P#98760 2021-10-16 23:24

Took me longer than @ChristopherD (you know, 1st implem, bugs, more bugs, no more bugs), but, I'm close right?

Next up, a palette selector and more cleanup. Also, the refresh rate slows down quickly (interested in any of @ChristopherD tricks there ;))...

I use a basic scanline algorithm FWIW

P#98825 2021-10-18 20:09 ( Edited 2021-10-18 20:09)

@Oct I doubt mine was done any faster than yours. I had already done that for my project; just posted to share is all.

I have no idea what you're doing, so I can't give you any specific tricks/advice. That said, I also found refresh rate slowed down as I drew more polygons. I got a big boost in performance by caching the lines calculated by the scanline algorithm when I closed a polygon. _draw() only draws cached lines, never from the algorithm.

P#98838 2021-10-18 23:22

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 13:00:08 | 0.082s | Q:29