def test_region_mask_wedge(self): rect_graphic = Graphics.WedgeGraphic() rect_graphic.angle_interval = -math.pi / 2, 0 mask = rect_graphic.get_mask((1000, 1000)) self.assertTrue(mask.data[600, 600]) # bottom right self.assertFalse(mask.data[600, 400]) # top right self.assertTrue(mask.data[400, 400]) # top left self.assertFalse(mask.data[400, 600]) # bottom left
def test_region_mask_wedge(self): wedge_graphic = Graphics.WedgeGraphic() with contextlib.closing(wedge_graphic): wedge_graphic.angle_interval = -math.pi / 2, 0 mask = wedge_graphic.get_mask((1000, 1000)) self.assertTrue(mask.data[600, 600]) # bottom right self.assertFalse(mask.data[600, 400]) # top right self.assertTrue(mask.data[400, 400]) # top left self.assertFalse(mask.data[400, 600]) # bottom left
def slow_test_wedge_angles(self): wedge_graphic = Graphics.WedgeGraphic() with contextlib.closing(wedge_graphic): start_angles = [i * math.pi / 12 for i in range(-24, 24, 3)] end_angles = [i * math.pi / 12 for i in range(-24, 24, 4)] zeros = numpy.zeros((1000, 1000)) ones = numpy.ones((1000, 1000)) for start_angle in start_angles: for end_angle in end_angles: if start_angle % math.pi != 0 or end_angle % math.pi != 0: with self.subTest(start_angle=start_angle, end_angle=end_angle): wedge_graphic.angle_interval = start_angle, end_angle mask = wedge_graphic.get_mask((1000, 1000)) self.assertFalse(numpy.array_equal(mask, zeros)) self.assertFalse(numpy.array_equal(mask, ones))
def test_region_mask_with_different_types_of_graphics(self): line_graphic = Graphics.LineGraphic() line_graphic.start = (0.25, 0.25) line_graphic.end = (0.75, 0.75) spot_graphic = Graphics.SpotGraphic() spot_graphic.bounds = (0.2, 0.2), (0.1, 0.1) ellipse_graphic = Graphics.EllipseGraphic() ellipse_graphic.bounds = (0.2, 0.2), (0.1, 0.1) rect_graphic = Graphics.RectangleGraphic() rect_graphic.bounds = (0.25, 0.25), (0.5, 0.5) point_graphic = Graphics.PointGraphic() point_graphic.position = (0.25, 0.25) wedge_graphic = Graphics.WedgeGraphic() line_graphic.get_mask((256, 256)) spot_graphic.get_mask((256, 256)) ellipse_graphic.get_mask((256, 256)) rect_graphic.get_mask((256, 256)) point_graphic.get_mask((256, 256))