Drawing on a panel

NetStorm

Member
Licensed User
Longtime User
Hey,

I have loaded a file of coordinates in to my app and drawn it on to a panel. It has drawn it to the top left corner and is rather small in conjunnction with the coordinates.

Is there a way I can zoom to fit the drawing on the panel, so that the drawing is larger than the coordinates make it, basically a zoom to fit?

Thanks for any help. Much appreciated.

Regards,

Dan.
 
You must be more precise.
The panel coordinates are pixels, the upper left corner's coordinates are 0, 0.
What kind of coordinates are you speeking of ?
What are the min, max values of the coordinates ?
What is the size of the panel ?

Best regards.
 
Upvote 0
Simplistically to fill the panel:

Get your maximum x coord value - call this MaxX
Get your maximum y coord value - call this MaxY

Get the panel Width (its x value) - call this DisplayX
Get the panel height (its y value) - call this DisplayY

ScaleX = DisplayX / MaxX
ScaleY = DisplayY / MaxY

then scale each coordinate pair with x*ScaleX, y*ScaleY

To maintain aspect ratio you can use

Code: Copy
If ScaleX > ScaleY Then

ScaleX = ScaleY

Else

ScaleY = ScaleX 

End If
 
Upvote 0
Attached you find a small test program that shows you how to do it.

Best regards.
 

Attachments

  • Graphics.zip
    Graphics.zip
    6.6 KB · Views: 677
  • Graphics.jpg
    Graphics.jpg
    17.9 KB · Views: 706
Upvote 0
Thanks alot! Still doesn't seem to fill he panel but is bigger than it was. I'll keep working at it, see if I can make it work.
 
Upvote 0
Back
Top