now try rubberbanding lines

This commit is contained in:
Amy Bowersox 2019-12-11 12:59:45 -07:00
parent 2c0a1374d9
commit b7e9de7d7e

View File

@ -42,6 +42,18 @@ def rubberband_rectangle(x, y, down, up):
if not up: 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)) hdc.rectangle(min(origin_x, current_x), min(origin_y, current_y), max(origin_x, current_x), max(origin_y, current_y))
def rubberband_line(x, y, down, up):
global current_x, current_y
hdc.text_color = YELLOW
hdc.rop2 = upiwin.R2_XORPEN
if not down:
hdc.move_to(origin_x, origin_y)
hdc_line_to(current_x, current_y)
current_x = x
current_y = y
if not up:
hdc.move_to(origin_x, origin_y)
hdc_line_to(current_x, current_y)
@ -54,15 +66,15 @@ def on_touchdown(x, y):
if point_in_rect(drawing_rect, x, y): if point_in_rect(drawing_rect, x, y):
origin_x = x origin_x = x
origin_y = y origin_y = y
rubberband_rectangle(x, y, True, False) rubberband_line(x, y, True, False)
def on_touchmove(x, y): def on_touchmove(x, y):
if point_in_rect(drawing_rect, x, y): if point_in_rect(drawing_rect, x, y):
rubberband_rectangle(x, y, False, False) rubberband_line(x, y, False, False)
def on_touchup(x, y): def on_touchup(x, y):
if point_in_rect(drawing_rect, x, y): if point_in_rect(drawing_rect, x, y):
rubberband_rectangle(x, y, False, True) rubberband_line(x, y, False, True)
def on_touchclick(x, y): def on_touchclick(x, y):
print("Click at {0},{1}".format(x, y)) print("Click at {0},{1}".format(x, y))