2019-12-10 13:04:24 -07:00
|
|
|
# Test of line clipping
|
|
|
|
import upiwin
|
|
|
|
|
|
|
|
hdc = upiwin.DevCtxt(type='screen')
|
|
|
|
hdc.text_color = 0xFFFFFF # white
|
|
|
|
hdc.rectangle(100, 100, 199, 199)
|
|
|
|
|
2019-12-10 13:25:36 -07:00
|
|
|
clip = hdc.get_clip_rect()
|
|
|
|
hdc.set_clip_rect(100, 100, 200, 200)
|
2019-12-10 13:04:24 -07:00
|
|
|
|
2019-12-10 13:25:36 -07:00
|
|
|
hdc.text_color = 0x0000FF # red
|
|
|
|
hdc.move_to(50, 199)
|
|
|
|
hdc.line_to(199, 50)
|
2019-12-10 13:04:24 -07:00
|
|
|
|
2019-12-10 13:25:36 -07:00
|
|
|
hdc.text_color = 0x00FF00 # green
|
|
|
|
hdc.move_to(250, 199)
|
|
|
|
hdc.line_to(100, 50)
|
|
|
|
|
|
|
|
hdc.set_clip_rect(clip[0], clip[1], clip[2], clip[3])
|
2019-12-10 13:04:24 -07:00
|
|
|
|
|
|
|
msg = {}
|
|
|
|
while upiwin.get_message(msg):
|
|
|
|
if msg['message'] == upiwin.WM_HWBUTTONUP:
|
|
|
|
bn = msg['attrs'][0]
|
|
|
|
if bn == 4:
|
|
|
|
print("Quitting the application.")
|
|
|
|
upiwin.post_quit_message(0)
|