1
\$\begingroup\$

I am working on a game that uses simple 2d vector graphics. I want a tool that will let me visually draw things like arbitrary polygons by placing points.

A perfect tool would present a grid that I could scale larger or smaller (ie: the window is 10 units across or the window is 20 units across). It would let me draw a polygon on this grid, and will tell me, simply, the coordinates of each point.

It would be great if this tool could then export a file format that was something like

0, 5
3, -2
0, 0
-3, -2

For bonus points, it would be great to be able to assign other attributes to each point. In the end, this will get passed to OpenGL, so things like color and opacity could possibly be used.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Well, Flash, Illustrator and so on allow you to draw vectors while snapping to a grid. You could then export as SVG and do some processing on the SVG data, but be warned, I've heard it said that the SVG specification is nightmare.

Why not write your own? Seems really straightforward to do, from what you've said. Set up your onscreen grid according to the scaling the user has specified. Do some simple math, on mouse release, to see what the closest point on the on-screen grid is, and snap to that. I would write this in something like Adobe AIR (Flash for desktop) since Flash supports easy-to-use vector drawing in code. While normal Flash can't access the file system, AIR can, so you can just write your CSV-like file to disk. You could write each vertex as something like

[x, y, (metadata1, metadata2, ...)]

...to elaborate on your example.

You could even use a bit of Flex for the UI part of it, if you wanted to go that far. Sounds like a good FOSS project in fact -- although I don't doubt there are similar things out there, somewhere.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ You could also use a "image map" editor (for drawing/editing HTML image maps), since they simply generate a list of vertex coordinates. There's no way to add metadata there however. \$\endgroup\$
    – bummzack
    Commented Aug 21, 2011 at 12:00
  • \$\begingroup\$ Yep good point bummzack. \$\endgroup\$
    – Engineer
    Commented Aug 21, 2011 at 12:22
  • \$\begingroup\$ Yeah, I have been considering doing this. Though I will probably use Python and Pyglet, since I am already working in that. \$\endgroup\$ Commented Aug 21, 2011 at 15:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .