Ejemplo n.º 1
0
def load_flags_file(name):
    img = graphics.load_image('data/flags/%s-output.png' % name)
    for line in osutil.open_res('data/flags/%s.index' % name):
        name, rect = line.split(' ', 1)
        rect = map(int, rect.split())
        flag = graphics.create_surface_small(rect[2], rect[3])
        flag.blit(img, (0, 0), rect)
        flag_index[name] = flag
Ejemplo n.º 2
0
def load_flags_file(name):
    img = graphics.load_image('data/flags/%s-output.png' % name)
    for line in osutil.open_res('data/flags/%s.index' % name):
        name, rect = line.split(' ', 1)
        rect = map(int, rect.split())
        flag = graphics.create_surface_small(rect[2], rect[3])
        flag.blit(img, (0, 0), rect)
        flag_index[name] = flag
Ejemplo n.º 3
0
def crop_sprite(img, x, y, w, h, mask=None, mask_x=0, mask_y=0):
    surf = graphics.create_surface_small(w, h)
    surf.blit(img, (0, 0), (x, y, w, h))
    surf.filename = '%s%s[%d,%d,%d,%d]' % (img.filename, ',masked'
                                           if mask else '', x, y, w, h)
    if mask:
        return mask_sprite(surf, mask, x - mask_x, y - mask_y)
    else:
        return surf
Ejemplo n.º 4
0
def crop_sprite(img, x, y, w, h, mask=None, mask_x=0, mask_y=0):
    surf = graphics.create_surface_small(w, h)
    surf.blit(img, (0, 0), (x, y, w, h))
    surf.filename = '%s%s[%d,%d,%d,%d]' % (img.filename,
                                           ',masked' if mask else '', x, y, w, h)
    if mask:
        return mask_sprite(surf, mask, x - mask_x, y - mask_y)
    else:
        return surf
Ejemplo n.º 5
0
def mask_sprite(surf, mask, mx, my):
    mask = get_white_mask(mask)
    newsurf = graphics.create_surface_small(*surf.get_size())
    newsurf.blit(surf)
    newsurf.blit(mask, src=(mx, my) + surf.get_size(), blend=graphics.MODE_MOD)
    return newsurf
Ejemplo n.º 6
0
def mask_sprite(surf, mask, mx, my):
    mask = get_white_mask(mask)
    newsurf = graphics.create_surface_small(*surf.get_size())
    newsurf.blit(surf)
    newsurf.blit(mask, src=(mx, my) + surf.get_size(), blend=graphics.MODE_MOD)
    return newsurf