Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A Simple Vector Editor

0.00/5 (No votes)
5 Jun 2002 1  
A simeple editor to make my polygon class a bit more usable.

Introduction

This is a little toy project I did because we had an application that required a number of simple images described as vectors. This was the editor I created to allow me to create and modify these simple images. The output files can be included as resources and used by my Polygon Drawing Class. (Actually, the polygon class is not used in this application, because I created it before I created the polygon class).

I thought it would provide an interesting example of programming techniques, and in any case it makes my polygon class a bit more usable.

The idea is that there is a 100 �100 grid, with origin in the center at 0,0 and coordinates ranging �50, and all images are drawn within this grid. They may be scaled later. There are controls for scaling and rotating the image. 

The use is fairly obvious for the most part. The standard file menu allows you to create, save, or open vector files. The vector is stored as a vertex list. There are two arrow keys next to the image list that allow you to rearrange the points.

The points are editable; clicking twice (not double-clicking) on a point makes it directly editable. The effects will be seen when you hit Enter or select out of the item.

There are four arrows that modify the list by adding or subtracting 1 from the x or y axis to move the image left, right, up, or down.

You can type in a new point and click the Add button, and it will be added following the current selection (if there is no selection, it is added at the end of the list).

Clicking the mouse in the drawing will transfer the mouse coordinates to the input box. Double-clicking the mouse in the drawing will also perform an Add operation. What I do is click in the approximate areas I want, then clean it up doing hand-editing. Nothing deep, but it greatly simplified the creation of a number of scalable "icons" for a graphical representation of moving objects.

Selecting a point in the point list will highlight that point in the drawing with a small red circle. The Delete button deletes the currently selected point. File | New deletes all the points.

Here's a little submarine icon I drew in about seven minutes. It is shown rotated 20�. Note the small red circle at the bottom that represents the highlighted point. I turned the grid off to get a clearer image.

The views expressed in these essays are those of the author, and in no way represent, nor are they endorsed by, Microsoft.

Send mail to newcomer@flounder.com with questions or comments about this web site.
Copyright � 2001 All Rights Reserved

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here