From dba5f262646f2afed9079bf331f9d877657bb36c Mon Sep 17 00:00:00 2001 From: Pavel Date: Tue, 19 Oct 2021 23:05:56 +0200 Subject: [PATCH] update convert_coordinate in editor.py --- alrys/editor.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/alrys/editor.py b/alrys/editor.py index f654430..584f467 100644 --- a/alrys/editor.py +++ b/alrys/editor.py @@ -174,30 +174,26 @@ def motion(event): def convert_coordinate(x): i = int(x) f = x % 1 - if f < 0.25: f = 0.1 - elif f < 0.5: f = 0.3 - elif f < 0.75: f = 0.5 - elif f < 0.9: f = 0.7 - else: f = 0.9 - return i + f + if f < 0.5: return i, 1 + else: return i + 1, -1 def append_step(event): global text, cell_w, cell_h x, y = (event.x - 1) / cell_w, (event.y - 1) / cell_h if x >= 146 or y >= 91: return - x = convert_coordinate(x) - y = convert_coordinate(y) + x, a = convert_coordinate(x) + y, b = convert_coordinate(y) text.edit_separator() - text.insert('end', '%7.3f 0 %6.3f 0\n' % (x, y)) + text.insert('end', '%7.3f %2d %6.3f %2d\n' % (x, a, y, b)) def insert_step(event): global text, cell_w, cell_h x, y = (event.x - 1) / cell_w, (event.y - 1) / cell_h if x >= 146 or y >= 91: return - x = convert_coordinate(x) - y = convert_coordinate(y) + x, a = convert_coordinate(x) + y, b = convert_coordinate(y) text.edit_separator() - text.insert('insert linestart', '%7.3f 0 %6.3f 0\n' % (x, y)) + text.insert('insert linestart', '%7.3f %2d %6.3f %2d\n' % (x, a, y, b)) def select_all(event): global text