Ejemplo n.º 1
0
def api_text_live_change(width=320, height=240):
    import zlib

    ctx = ngl.Context()
    capture_buffer = bytearray(width * height * 4)
    ret = ctx.configure(offscreen=1, width=width, height=height, backend=_backend, capture_buffer=capture_buffer)
    assert ret == 0

    # An empty string forces the text node to deal with a pipeline with nul
    # attributes, this is what we exercise here, along with a varying up and
    # down number of characters
    text_strings = ["foo", "", "foobar", "world", "hello\nworld", "\n\n", "last"]

    # Exercise the diamond-form/prepare mechanism
    text_node = ngl.Text()
    assert ctx.set_scene(autogrid_simple([text_node] * 4)) == 0

    ctx.draw(0)
    last_crc = zlib.crc32(capture_buffer)
    for i, s in enumerate(text_strings, 1):
        text_node.set_text(s)
        ctx.draw(i)
        crc = zlib.crc32(capture_buffer)
        assert crc != last_crc
        last_crc = crc
Ejemplo n.º 2
0
def shape_diamond_colormask(cfg):
    color_write_masks = ('r+g+b+a', 'r+g+a', 'g+b+a', 'r+b+a')
    geometry = ngl.Circle(npoints=5)
    prog = ngl.Program(vertex=cfg.get_vert('color'), fragment=cfg.get_frag('color'))
    render = ngl.Render(geometry, prog)
    render.update_frag_resources(color=ngl.UniformVec4(value=COLORS['white']))
    scenes = [ngl.GraphicConfig(render, color_write_mask=cwm) for cwm in color_write_masks]
    return autogrid_simple(scenes)
Ejemplo n.º 3
0
def shape_diamond_colormask(_):
    color_write_masks = ("r+g+b+a", "r+g+a", "g+b+a", "r+b+a")
    geometry = ngl.Circle(npoints=5)
    render = ngl.RenderColor(COLORS.white, geometry=geometry)
    scenes = [
        ngl.GraphicConfig(render, color_write_mask=cwm)
        for cwm in color_write_masks
    ]
    return autogrid_simple(scenes)
Ejemplo n.º 4
0
def compositing_all_operators(cfg):
    scenes = []
    for op in _OPERATORS:
        scene = _get_compositing_scene(cfg, op, show_label=True)
        scenes.append(scene)
    return autogrid_simple(scenes)
Ejemplo n.º 5
0
def blending_all_diamond(cfg, show_dbg_points=True, show_labels=True):
    scenes = _get_blending_scenes(cfg)
    scene = autogrid_simple(scenes)
    return _debug_overlay(cfg, scene, _BLENDINGS, show_dbg_points, show_labels)