X-Git-Url: http://git.tomasm.cz/imago.git/blobdiff_plain/10466a9c920f1d67bf85d85af671bcb8e5fbd533..ecb0ef2b5ea477ee170ce083f59d2200af7117a2:/intrsc.py?ds=sidebyside diff --git a/intrsc.py b/intrsc.py index cead665..00165b1 100644 --- a/intrsc.py +++ b/intrsc.py @@ -1,7 +1,7 @@ -from math import sin, cos, tan +from math import cos, tan from operator import itemgetter -import Image, ImageDraw +import ImageDraw def board(image, lines, show_all, do_something): intersections = intersections_from_angl_dist(lines, image.size) @@ -14,12 +14,12 @@ def board(image, lines, show_all, do_something): if show_all: do_something(image_g, "intersections") - board = [] + board_r = [] for line in intersections: - board.append([stone_color(image, intersection) for intersection in + board_r.append([stone_color(image, intersection) for intersection in line]) - return board + return board_r def intersections_from_angl_dist(lines, size, get_all=False): intersections = [] @@ -27,7 +27,8 @@ def intersections_from_angl_dist(lines, size, get_all=False): line = [] for (angl2, dist2) in sorted(lines[0], key=itemgetter(1)): if abs(angl1 - angl2) > 0.4: - x = - ((dist2 / cos(angl2)) - (dist1 / cos(angl1))) / (tan(angl1) - tan(angl2)) + x = (- ((dist2 / cos(angl2)) - (dist1 / cos(angl1))) + / (tan(angl1) - tan(angl2))) y = (tan(angl1) * x) - (dist1 / cos(angl1)) if get_all or (-size[0] / 2 < x < size[0] / 2 and -size[1] / 2 < y < size[1] / 2):