Hi dennishea,
I had a look at your program and have some questions and suggestions.
Questions:
- what is the main purpose of the program ?
- do you want bitmap graphics or vector graphics, in the second case don't you need scaling with zoom and unzoom ?
- still in the second do you want to have closed surfaces, then they could be solid or hollow ?
Suggestions:
Data structure, for vector graphics:
You could have a structure like:
- a list of points
with the coordinates x,y
- a list of lines
with Type and Data depending on the type
Ex:
Type: Line Data: 1st point index, 2nd point index not the coordinates !
Type: Arc1 Data: center point index, radius, angle1, angle2
Type: Arc2 Data: 1st point index, 2nd point index, radius
Type: Arc3 Data: 1st point index, 2nd point index, 3rd point index
- a list of surfaces
with Type and Data depending on the type, solid or hollow
Ex:
Type: Rectangle Data: upper left point index, lower right point index
the two other points are calculated (angle if you want to rotate it)
Type: Circle1 Data: center point index, radius
Type: Sector1 Data: radius1 line index, radius2 line index, arc index
Type: General Data: number of lines, line indexes
Advantage:
If you have a line with segments the end point of a segment and the beginning point of the next segment is the same point. If you change the coordinates of that point both segments will be changed and the surface too.
A rectangle can be defined by 2 points (and angle) or 4 lines.
in the first case if you change the coordinates of one point both lines should be changed.
in the second case it's not really a rectangle but a special case of a General surface, if you change the coordinates of one point it will no longer be a rectangle.
I hope this is understandable!
Program:
As a user I would prefer having buttons in a toolbox instead of the menu it gives a better overview of the possibilities and active functions.
For the circle it would be interesting to be able to move the mouse for the radius, and display the circle in function of the mouse position and with the MouseUp event set the final values. Same for rectangle and ellipse.
For the grid I would suggest you to use a variable for the grid width instead of a number so if once you want to change it you just change the variable value and the rest is automatic, otherwise you would have to change x times the number.
To calculate the radius you don't need to use the Max and Min functions, a power of two is always positive.
Your routine to draw the arcs is only valid for small radiuses, with a radius of 100 the arc becomes a dotted line. Colin9876's routine is more universal in setting the angle step to the inverse of the radius.
In the drawing routines it would be more universal to transmit variables instead of dealing with the textbox contents in the routine.
Ex: DrawLine(x1, y1, x2, y2, col)
I put some of these suggestions in the joined program.
Best regards and good luck !