Last active
July 13, 2018 18:46
-
-
Save larsoner/4899d1812ff53aefe4cf1a074bd01618 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import time | |
import numpy as np | |
from scipy.misc import ascent | |
from expyfun import ExperimentController | |
from expyfun.visual import RawImage | |
with ExperimentController('foo', participant='', session='', | |
output_dir=None, version='dev') as ec: | |
ascent = ascent().astype(np.uint8) | |
ascent = np.tile(ascent, (3, 4))[:1080, :1920] | |
assert ascent.shape == (1080, 1920) | |
ascent = np.tile(ascent[:, :, np.newaxis], (1, 1, 3)) | |
mod = 0 | |
img = RawImage(ec, ascent[28:-28]) | |
while True: | |
m = int(4 * time.time()) % 2 | |
if m != mod: | |
mod = m | |
ascent[:, :, 1] = np.uint8(255) - ascent[:, :, 1] | |
img.set_image(ascent[28:-28]) | |
img.set_pos([np.sin(time.time()) * 0.5, | |
np.cos(time.time()) * 0.5]) | |
img.draw() | |
ec.flip() | |
ec.check_force_quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment