Пример #1
0
    def test_from_threshold(self):
        """ Does mask.from_threshold() work correctly?
        """

        a = [16, 24, 32]

        for i in a:
            surf = surface.Surface((70, 70), 0, i)
            surf.fill((100, 50, 200), (20, 20, 20, 20))
            my_mask = mask.from_threshold(surf, (100, 50, 200, 255),
                                          (10, 10, 10, 255))

            self.assertEqual(my_mask.count(), 400)
            self.assertEqual(my_mask.get_bounding_rects(),
                             [Rect((20, 20, 20, 20))])

        for i in a:
            surf = surface.Surface((70, 70), 0, i)
            surf2 = surface.Surface((70, 70), 0, i)
            surf.fill((100, 100, 100))
            surf2.fill((150, 150, 150))
            surf2.fill((100, 100, 100), (40, 40, 10, 10))
            my_mask = mask.from_threshold(surf, (0, 0, 0, 0),
                                          (10, 10, 10, 255), surf2)

            self.assertEqual(my_mask.count(), 100)
            self.assertEqual(my_mask.get_bounding_rects(),
                             [Rect((40, 40, 10, 10))])
Пример #2
0
 def cargar_anims(ruta_imgs,seq,alpha=False):
     dicc = {}
     spritesheet = split_spritesheet(ruta_imgs)
     idx = -1
     for L in seq:
         for D in ['abajo','arriba','izquierda','derecha']:
             key = L+D
             idx += 1
             if not alpha:
                 dicc[key] = spritesheet[idx]
             else:
                 dicc[key] = mask.from_threshold(spritesheet[idx], C.COLOR_COLISION, (1,1,1,255))
     return dicc
Пример #3
0
    def test_from_threshold(self):
        """ Does mask.from_threshold() work correctly?
        """

        a = [16, 24, 32]

        for i in a:
            surf = surface.Surface((70,70), 0, i)
            surf.fill((100,50,200),(20,20,20,20))
            my_mask = mask.from_threshold(surf,(100,50,200,255),(10,10,10,255))

            self.assertEqual(my_mask.count(), 400)
            self.assertEqual(my_mask.get_bounding_rects(), [Rect((20,20,20,20))])

        for i in a:
            surf = surface.Surface((70,70), 0, i)
            surf2 = surface.Surface((70,70), 0, i)
            surf.fill((100,100,100))
            surf2.fill((150,150,150))
            surf2.fill((100,100,100), (40,40,10,10))
            my_mask = mask.from_threshold(surf, (0,0,0,0), (10,10,10,255), surf2)

            self.assertEqual(my_mask.count(), 100)
            self.assertEqual(my_mask.get_bounding_rects(), [Rect((40,40,10,10))])
Пример #4
0
    ruta = path.join(getcwd(), 'engine', 'frontend', 'graphs', 'graph', 'data')

graph = image.load(path.join(ruta, 'graph.png'))
gas_drawf = image.load(path.join(ruta, 'gas_dwarves.png'))
exes = [
    59, 93, 114, 128, 139, 148, 156, 162, 169, 173, 209, 229, 244, 254, 263,
    271, 278, 284, 288, 325, 345, 360, 370, 380, 387, 394, 400, 405, 440, 460,
    475, 485, 495, 502, 509, 515, 520, 555, 575, 589
]
yes = [
    478, 453, 431, 412, 395, 379, 279, 221, 179, 147, 121, 99, 79, 62, 47, 1
]

_lineas = abrir_json(path.join(ruta, 'lineas.json'))
composiciones = abrir_json(path.join(ruta, 'compositions.json'))
mascara = mask.from_threshold(image.load(path.join(ruta, 'mask.png')),
                              (255, 0, 255), (250, 1, 250))


def graph_loop(mass_lower_limit=0.0,
               mass_upper_limit=0.0,
               radius_lower_limit=0.0,
               radius_upper_limit=0.0,
               is_gas_drwaf=False):
    m_lo_l = mass_lower_limit
    m_hi_l = mass_upper_limit
    r_lo_l = radius_lower_limit
    r_hi_l = radius_upper_limit

    fondo = display.set_mode((witdh, height), SCALED)
    rect = Rect(60, 2, 529, 476)
    lineas = LayeredUpdates()