snapping

A pythonic way how to find if a value is between two values in a list

Having a sorted list and some random value, I would like to find in which range the value is. List goes like this: [0, 5, 10, 15, 20] And value is, say 8. The standard way would be to either go from start until we hit value that is bigger than ours (like in the example below), or to perform binary search. grid = [0, 5, 10, 15, 20] va...

Finding the closest grid coordinate to the mouse position with javascript/jQuery

What I'm trying to do is make a grid of invisible coordinates on the page equally spaced. I then want a <div> to be placed at whatever grid coordinate is closest to the pointer when onclick is triggered. Here's the rough idea: I have the tracking of the mouse coordinates and the placing of the <div> worked out fine. What I'm stuck wit...

WPF: drawing own cursor - nontrivial problem

i need to implement a cursor with some very specific features: it has to be animated because after n seconds it automatically clicks - so the animation is feedback for the user when the click will happen it has to snap to some of our controls it has to work outside of our application the approaches so far: render my WPF-control i...