### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: Polygon Coordinates on a SnapTo Grid: Some New Features Added  (Read 1335 times)

#### Boleeman

• Hero Member
• Posts: 641
##### Polygon Coordinates on a SnapTo Grid: Some New Features Added
« on: August 24, 2024, 11:44:09 am »
I tried to make a Polygon Coordinates on a SnapTo Grid

I worked out how to record the coordinates in a TMemo, calculate the area and label the centroid of each closed polygon..
Hmm, just realized that the area is not being calculated correctly for some shapes.  (see attached png)

Had troubles resizing the grid dynamically for MinX and MaxY.

Also a bit confused on how to automatically move the X-Axis and Y-axis when the TspinEdit range values are changed.

Maybe it may be better to put the grid on a TImage or a TPaintbox.

Also how to show lines as the mouse cursor is moved, without extra fragment lines?

« Last Edit: August 29, 2024, 12:34:58 pm by Boleeman »

#### Boleeman

• Hero Member
• Posts: 641
##### Re: Polygon Coordinates on a SnapTo Grid: Grid and Auto. Axis Movement Problems
« Reply #1 on: August 29, 2024, 09:58:36 am »
The Area and the Centroid point locations are now working correctly.

Now how to shift the location of the axes dynamically?
« Last Edit: August 29, 2024, 10:02:35 am by Boleeman »

#### Boleeman

• Hero Member
• Posts: 641
##### Re: Polygon Coordinates on a SnapTo Grid: Grid and Auto. Axis Movement Problems
« Reply #2 on: August 29, 2024, 12:30:39 pm »
Added a TCheckbox that selects whether to list the side lengths of each polygon.

I  also thought about a moveable axes feature.

Perhaps use a double mouse click on the grid to select a new origin.
Then auto re-draw the new axes lines and renumber them.

Also thought about a handy new feature:

Make the Form of theprogram partially transparent, so that one can trace a map of something underneath it.
Or
Possibly use a TBgrabmp to add transparency
« Last Edit: August 29, 2024, 12:49:54 pm by Boleeman »