Fix y-axis mapping incorrect for images

This commit is contained in:
Kovid Goyal
2017-10-04 19:34:34 +05:30
parent e9bc64205e
commit 46bb482e96
2 changed files with 11 additions and 11 deletions

View File

@@ -175,8 +175,8 @@ class TestGraphics(BaseTest):
cmd = 'a=p,i=%d,%s' % (iid, put_cmd(**kw))
send_command(screen, cmd)
def layers(screen, scrolled_by=0, xstart=0, ystart=0):
dx, dy = (2 - xstart) / s.columns, (2 - ystart) / s.lines
def layers(screen, scrolled_by=0, xstart=-1, ystart=1):
dx, dy = 2 / s.columns, 2 / s.lines
return screen.grman.update_layers(scrolled_by, xstart, ystart, dx, dy, screen.columns, screen.lines)
def rect_eq(r, left, top, right, bottom):
@@ -190,16 +190,16 @@ class TestGraphics(BaseTest):
l = layers(s)
self.ae(len(l), 1)
rect_eq(l[0]['src_rect'], 0, 0, 1, 1)
rect_eq(l[0]['dest_rect'], 0, 0, dx, dy)
rect_eq(l[0]['dest_rect'], -1, 1, -1 + dx, 1 - dy)
self.ae(l[0]['group_count'], 1)
self.ae(s.cursor.x, 1), self.ae(s.cursor.y, 0)
put_ref(s, iid, num_cols=s.columns, x_off=2, y_off=1, width=3, height=5, cell_x_off=3, cell_y_off=1, z=-1)
l = layers(s)
self.ae(len(l), 2)
rect_eq(l[0]['src_rect'], 2 / 10, 1 / 20, (2 + 3) / 10, (1 + 5)/20)
left, top = dx + 3 * dx / cw, 1 * dy / ch
rect_eq(l[0]['dest_rect'], left, top, (1 + s.columns) * dx, top + dy * 5 / ch)
left, top = -1 + dx + 3 * dx / cw, 1 - 1 * dy / ch
rect_eq(l[0]['dest_rect'], left, top, -1 + (1 + s.columns) * dx, top - dy * 5 / ch)
rect_eq(l[1]['src_rect'], 0, 0, 1, 1)
rect_eq(l[1]['dest_rect'], 0, 0, dx, dy)
rect_eq(l[1]['dest_rect'], -1, 1, -1 + dx, 1 - dy)
self.ae(l[0]['group_count'], 1), self.ae(l[1]['group_count'], 1)
self.ae(s.cursor.x, 0), self.ae(s.cursor.y, 1)