示例#1
0
def _test_transparency_mask():
    mask = np.ones((100, 100), dtype=bool)
    mask[:, :50] = 0
    img = pp.mat_to_surface(np.random.randint(0, 255, (100, 100)))
    pp.display(
        pp.compose(pp.empty_surface(0))(pp.make_transparent_by_mask(img,
                                                                    mask)))
示例#2
0
def test_extras():
    pp.init((800, 600))
    el = pp.EventListener()
    arr = np.arange(1, 101).reshape(10, 10)
    pp.display(
        pp.compose(pp.empty_surface(0))(pp.Surface(scale=1)(
            pp.mat_to_surface(arr))))
    el.wait_for_seconds(1)
    pp.display(
        pp.compose(pp.empty_surface(0))(pp.Surface(scale=1)(pp.mat_to_surface(
            arr, pp.apply_color_map("autumn")))))
    el.wait_for_seconds(1)
    _test_transparency_mask()
    el.wait_for_seconds(1)
    _test_transparency_colorkey()
    el.wait_for_seconds(1)
示例#3
0
def display_text(text, bg_color):
    pp.display(
        pp.compose(pp.empty_surface(bg_color))(pp.Text(text,
                                                       pp.Font(size=60),
                                                       color=pp.rgba(white))))
示例#4
0
def _bg():
    # short for background
    return empty_surface(0xFFFFFF)
示例#5
0
def _test_transparency_colorkey():
    tra_img = pp.compose(pp.empty_surface(0))(pp.empty_surface(20, (200, 200)))
    tra_img = pp.make_transparent_by_colorkey(tra_img, 20)
    pp.display(pp.compose(pp.empty_surface(0xFF0000))(tra_img))