diff --git a/scripts/demo1.py b/scripts/demo1.py index 2e7ae70..7e3a5c0 100755 --- a/scripts/demo1.py +++ b/scripts/demo1.py @@ -31,13 +31,14 @@ origin_y = 0 current_x = 0 current_y = 0 -def rubberband_rectangle(x, y, down, up) +def rubberband_rectangle(x, y, down, up): + global current_x, current_y hdc.text_color = YELLOW hdc.rop2 = upiwin.R2_XORPEN if not down: hdc.rectangle(min(origin_x, current_x), min(origin_y, current_y), max(origin_x, current_x), max(origin_y, current_y)) - current_x = x; - current_y = y; + current_x = x + current_y = y if not up: hdc.rectangle(min(origin_x, current_x), min(origin_y, current_y), max(origin_x, current_x), max(origin_y, current_y)) @@ -49,9 +50,10 @@ def rubberband_rectangle(x, y, down, up) # --- Message handlers --- def on_touchdown(x, y): + global origin_x, origin_y if point_in_rect(drawing_rect, x, y): - origin_x = x; - origin_y = y; + origin_x = x + origin_y = y rubberband_rectangle(x, y, True, False) def on_touchmove(x, y):