# Axis and diagonal snap in Move action.

For some clonning task it would be useful to make snap to axis x or y or diagonal when moving image. For example I need clone image to next frame: I begin move (then see that I move image with some vertical displace), then I press shift key and my image snap to x axis (jump to x axis - mouse Y_coord not taken for move action.), then I release mouse button and image finish it's movement. X or Y snap easy for implementation. You analyze x and y mouse offset and which absolute value is higher, then use this coord. snap. For example: Mouse_X_offset=205 pixel, mouse_Y_offset=-406, then 406>205 and we need to turn on Y_snap (if user press shift key). If you would make and diagonal_snap too, there is some differences in algorithm. There is 3 ways when you compare absolute values of x and y mouse coordinates:

if 1,732 <= abs(x/y) : snap_x
elif 0,577<=abs(x/y)<1,732: snap_diagonal
elif 0<=abs(x/y)<0,577: snap_y

snap_x: move only with x coord, y=always same
snap_y: move only with y coord, x=alway same
snap_diagonal:
if abs(x)>abs(y):
if y>0: y=abs(x)
else: y=-1*abs(x)
else:
if x>0: x=abs(y)
else: x=-1*abs(y)

That's all I asking for. Thanks for reading, hope it will help.