def controlee():
        def line(tf):
            np.random.seed(0)
            x = np.linspace(-2, 2, 10000)
            y = np.cumsum(np.random.rand(len(x)) - 0.5) / 100
            return c.draw.polyline(np.stack([x, y]).T, (0, 0, 1, 1), tf=tf)

        frame = c.Frame((-1, 1), (1, -1))
        while True:
            _, frame = yield from c.frame("Frame", frame, line)
            yield
Beispiel #2
0
def app():
    view = c.Frame((-1, -1), (1, 1), keep_aspect=True)
    style = imgui.get_style()
    style.anti_aliased_lines = False

    while True:
        tag, value = yield from c.orr([
            c.window("Graph", c.frame("Frame", view, content_gen=graph)),
            c.window("Controls", c.checkbox("Antialiasing", style.anti_aliased_lines)),
            ])
        if tag == "Frame":
            view = value
        elif tag == "Antialiasing":
            style.anti_aliased_lines = value
        yield
def animation(tester):
    from time import monotonic as t

    def graph(tf):
        ts = np.linspace(t(), t() + 1 / 2, 100)
        pts = np.stack([np.sin(ts * 4), np.cos(ts * 5)]).T
        return c.draw.polyline(pts, (0, 0, 1, 1), tf=tf)

    view = c.Frame((-1.5, 1.5), (1.5, -1.5))
    t0 = t()
    while True:
        key, value = yield from c.orr([
            c.frame("Frame", view, graph),
            c.event(("Tick", None)),  # refresh every frame
        ])
        if key == "Frame":
            view = value
        if t() - t0 >= 2 * np.pi:
            break
        yield
Beispiel #4
0
def app():
    view = c.Frame((0, 0), (512, 512), keep_aspect=True)
    arr = np.array(Image.open("examples/lenna.png"))
    tex = c.integrations.opengl.texture(arr)

    while True:
        tag, value = yield from c.orr([
            c.window(
                "Graph",
                c.frame("Frame",
                        view,
                        content_gen=c.partial(graph, tex, arr.shape[0],
                                              arr.shape[1]))),
            c.window("Controls", c.button("Reset View")),
        ])
        if tag == "Frame":
            view = value
        elif tag == "Reset View":
            view.reset_view()
        yield
Beispiel #5
0
def app():
    view = c.Frame((-1, 2), (1, -2), keep_aspect=False, fix_axis='y')
    while True:
        _, view = yield from c.frame("Frame", view, content_gen=graph)
        yield
Beispiel #6
0
def test_frame_events(tester):
    frame = c.Frame((0, 0), (150, 150))
    return _test_events_generic(tester, frame, c.frame)
Beispiel #7
0
def app():
    view = c.Frame((-1.5, 1.5), (1.5, -1.5))
    while True:
        _, view = yield from c.frame("Frame", view, content_gen=graph)
        yield