def _rotate_cell(self, angle, rect, back=False):
        """Rotates and translates cell if angle in [90, -90, 180]"""

        if angle == 90 and not back:
            self.context.rotate(-math.pi / 2.0)
            self.context.translate(-rect[2] + 4, 0)

        elif angle == 90 and back:
            self.context.translate(rect[2] - 4, 0)
            self.context.rotate(math.pi / 2.0)

        elif angle == -90 and not back:
            self.context.rotate(math.pi / 2.0)
            self.context.translate(0, -rect[3] + 2)

        elif angle == -90 and back:
            self.context.translate(0, rect[3] - 2)
            self.context.rotate(-math.pi / 2.0)

        elif angle == 180 and not back:
            self.context.rotate(math.pi)
            self.context.translate(-rect[2] + 4, -rect[3] + 2)

        elif angle == 180 and back:
            self.context.translate(rect[2] - 4, rect[3] - 2)
            self.context.rotate(-math.pi)
Rotates and translates cell if angle in [90, -90, 180]