bugs in manual mode fixed
[imago.git] / manual.py
index f774c7b..c7f8e2b 100644 (file)
--- a/manual.py
+++ b/manual.py
@@ -32,7 +32,7 @@ def find_lines(im_orig):
                  fill=(255, 64, 64))
     corners = []
     color=(64, 64, 255)
-    line_width = 2
+    line_width = 1
     lines_r = []
 
     while not done:
@@ -71,10 +71,10 @@ def find_lines(im_orig):
                                    (corners[1], corners[2])]
                         l_hor += [(corners[0], corners[1]),
                                    (corners[2], corners[3])]
-                        l_vert = sorted(l_vert)
-                        l_hor = sorted(l_hor)
-                        for i in [3, 8, 14]:
-                            for j in [3, 8, 14]:
+                        l_vert.sort()
+                        l_hor.sort()
+                        for i in [3, 9, 15]:
+                            for j in [3, 9, 15]:
                                 hoshi(intersection(line(l_vert[i][0], l_vert[i][1]),
                                                    line(l_hor[j][0], l_hor[j][1])))
                         lines_r = [[l2ad(l[0], l[1], im.size) for l in l_vert], 
@@ -139,6 +139,11 @@ def l2ad(a, b, size):
         q = float(a[1] - b[1]) / (a[0] - b[0])
         angle = atan(q)
 
+    if angle < 0:
+        angle += pi
+    if angle > pi:
+        angle -= pi
+
     distance = (((a[0] - (size[0] / 2)) * sin(angle)) + 
                 ((a[1] - (size[1] / 2)) * - cos(angle)))
     return (angle, distance)