def test_regular_rectangle_scaled(self): x, y = 10, 20 w, h = 7, 20 scale_x = 2 scale_y = 3 rect = Rectangle(width=str(w), height=str(h), x=str(x), y=str(y)) rect.transform = Transform(scale=(scale_x, scale_y)) self.assert_bounding_box_is_equal(rect, (scale_x * x, scale_x * (x + w)), (scale_y * y, scale_y * (y + h)))
def test_regular_rectangle_with_stroke_scaled(self): x, y = 10, 20 w, h = 7, 20 stroke_half_width = 1 scale_x = 2 scale_y = 3 rect = Rectangle(width=str(w), height=str(h), x=str(x), y=str(y)) rect.style = Style("stroke-width:{};stroke:red".format(stroke_half_width * 2)) rect.transform = Transform(scale=(scale_x, scale_y)) self.assert_bounding_box_is_equal(rect, (scale_x * (x - stroke_half_width), scale_x * (x + w + stroke_half_width)), (scale_y * (y - stroke_half_width), scale_y * (y + h + stroke_half_width)))
def test_group_nested_transform(self): group = Group() x, y = 10, 20 w, h = 7, 20 scale = 2 rect = Rectangle(width=str(w), height=str(h), x=str(x), y=str(y)) rect.transform = Transform(rotate=45, scale=scale) group.add(rect) group.transform = Transform(rotate=-45) # rotation is compensated, but scale is not a = rect.composed_transform() self.assert_bounding_box_is_equal(group, (scale * x, scale * (x + w)), (scale * y, scale * (y + h)))