31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/interactive.rb', line 31
def mouseMoved(p)
p = {:x => p.getX(), :y => p.getY()}
@old_points ||= []
@points_to_highlight ||= []
original_point = @screen.original(p)
closest_point = @index.nearest([original_point[:x], original_point[:y]])
closest = @screen.points[closest_point[:id]]
return if closest.nil?
closest_onscreen_point = @screen.transformed(closest)
distance = (closest_onscreen_point[:x] - p[:x])**2 + (closest_onscreen_point[:y] - p[:y])**2
if distance > 14.0
@points_to_highlight = []
redraw
return
end
@points_to_highlight = [{:original => closest, :mapped => closest_onscreen_point}]
@screen.write(closest)
redraw
end
|