Snapping To Pixels In Wxpython
I am creating a simple GUI to record points which are clicked on the image, using wxpython. However, i would like the click to be snapped to certain points on the image. Please sug
Solution 1:
The easiest to snap to a fixed scale grid is with something like:
snap_x = scale * round(x / scale)
snap_y = scale * round(y / scale)
where scale is the size of your grid, eg 10 pixels.
If the points are nonuniformly distributed, then find the closest based on the distance (or the square of the distance for efficiency reasons).
Solution 2:
You might have a look at wxPython's Object Graphics Library. The documentation's a little sparse but the Diagram class has direct support for snapping to grids; take a look at the wxPython Demo's Miscellaneous->OGL section for some ideas to get started. I'm in the middle of a project w. OGL right now - it's great for what it does but like I said I find the documentation a little thin.
Post a Comment for "Snapping To Pixels In Wxpython"