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))
def test_region_mask_spot(self): spot_graphic = Graphics.SpotGraphic() spot_graphic.bounds = (0.2, 0.2), (0.1, 0.1) mask = spot_graphic.get_mask((1000, 1000)) self.assertEqual(mask.data[200, 200], 0) # top left self.assertEqual(mask.data[200, 300], 0) # bottom left self.assertEqual(mask.data[300, 300], 0) # bottom right self.assertEqual(mask.data[300, 200], 0) # bottom left self.assertEqual(mask.data[250, 200], 1) # center top self.assertEqual(mask.data[300, 250], 1) # center right self.assertEqual(mask.data[250, 300], 1) # center bottom self.assertEqual(mask.data[200, 250], 1) # center left self.assertEqual(mask.data[800, 800], 0) # top left self.assertEqual(mask.data[800, 700], 0) # bottom left self.assertEqual(mask.data[700, 700], 0) # bottom right self.assertEqual(mask.data[700, 800], 0) # bottom left self.assertEqual(mask.data[750, 800], 1) # center top self.assertEqual(mask.data[700, 750], 1) # center right self.assertEqual(mask.data[750, 700], 1) # center bottom self.assertEqual(mask.data[800, 750], 1) # center left