projekty
/
imago.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
better error plotter
[imago.git]
/
manual.py
diff --git
a/manual.py
b/manual.py
index
1d06035
..
a4e94f7
100644
(file)
--- a/
manual.py
+++ b/
manual.py
@@
-1,7
+1,7
@@
"""Manual grid selection module"""
import pygame
"""Manual grid selection module"""
import pygame
-import Image
, Image
Draw
+import ImageDraw
from math import atan, sin, cos, pi, sqrt, acos, copysign
class UserQuitError(Exception):
from math import atan, sin, cos, pi, sqrt, acos, copysign
class UserQuitError(Exception):
@@
-14,8
+14,8
@@
class Screen:
pygame.display.set_caption("Imago manual mode")
self._screen = pygame.display.get_surface()
pygame.display.set_caption("Imago manual mode")
self._screen = pygame.display.get_surface()
- def display_picture(self, im):
- pg_img = pygame.image.frombuffer(im
.tostring(), im.size, im
.mode)
+ def display_picture(self, im
g
):
+ pg_img = pygame.image.frombuffer(im
g.tostring(), img.size, img
.mode)
self._screen.blit(pg_img, (0,0))
pygame.display.flip()
self._screen.blit(pg_img, (0,0))
pygame.display.flip()
@@
-31,7
+31,7
@@
def find_lines(im_orig):
hoshi = lambda c: draw.ellipse((c[0] - 1, c[1] - 1, c[0] + 1, c[1] + 1),
fill=(255, 64, 64))
corners = []
hoshi = lambda c: draw.ellipse((c[0] - 1, c[1] - 1, c[0] + 1, c[1] + 1),
fill=(255, 64, 64))
corners = []
- color
=
(64, 64, 255)
+ color
=
(64, 64, 255)
line_width = 1
lines_r = []
line_width = 1
lines_r = []
@@
-65,8
+65,8
@@
def find_lines(im_orig):
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])))
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],
- [l2ad(l
[0], l[1]
, im.size) for l in l_hor]]
+ lines_r = [[l2ad(l, im.size) for l in l_vert],
+ [l2ad(l, im.size) for l in l_hor]]
screen.display_picture(im)
clock.tick(15)
screen.display_picture(im)
clock.tick(15)
@@
-94,8
+94,8
@@
def _lines(corners, n):
c = intersection(line(x[0], corners[2]), line(corners[1], corners[3]))
d = intersection(line(corners[0], corners[3]), line(corners[1], corners[2]))
if d:
c = intersection(line(x[0], corners[2]), line(corners[1], corners[3]))
d = intersection(line(corners[0], corners[3]), line(corners[1], corners[2]))
if d:
- l = (intersection(line(corners[0], corners[1]), line(c,d)),
- intersection(line(corners[2], corners[3]), line(c,d)))
+ l = (intersection(line(corners[0], corners[1]), line(c,
d)),
+ intersection(line(corners[2], corners[3]), line(c,
d)))
else:
lx = line(c, (c[0] + corners[0][0] - corners[3][0],
c[1] + corners[0][1] - corners[3][1]))
else:
lx = line(c, (c[0] + corners[0][0] - corners[3][0],
c[1] + corners[0][1] - corners[3][1]))
@@
-139,7
+139,7
@@
def intersection(p, q):
return (int(round(float(q[1] * p[2] - p[1] * q[2]) / det)),
int(round(float(p[0] * q[2] - q[0] * p[2]) / det)))
return (int(round(float(q[1] * p[2] - p[1] * q[2]) / det)),
int(round(float(p[0] * q[2] - q[0] * p[2]) / det)))
-def l2ad(
a, b
, size):
+def l2ad(
(a, b)
, size):
if (a[0] - b[0]) == 0:
angle = pi / 2
else:
if (a[0] - b[0]) == 0:
angle = pi / 2
else: