Take a “screen-shot” (full or partial), save to a PatchStim()-like RBGA object.
The class returns a screen-shot, i.e., a single collage image composed of static elements, ones that you want to treat as effectively a single stimulus. The screen-shot can be of the visible screen (front buffer) or hidden (back buffer).
BufferImageStim aims to provide fast rendering, while still allowing dynamic orientation, position, and opacity. Its fast to draw but slow to init: ~75ms for a 1024 x 512 capture; init time is proportional to image size (as for PatchStim). There is no support for dynamic depth or color.
You specify the part of the screen to capture (in norm units), and optionally the stimuli themselves (as a list of items to be drawn). You get a screenshot of those pixels. If your OpenGL does not support arbitrary sizes, the image will be larger, using square powers of two if needed, with the excess image being invisible (using alpha). The aim is to preserve the buffer contents as rendered.
Checks for OpenGL 2.1+, or uses square-power-of-2 images.
Example:
# define lots of stimuli, make a list:
mySimpleImageStim = ...
myTextStim = ...
stimList = [mySimpleImageStim, myTextStim]
# draw stim list items & capture everything (slow):
screenshot = visual.BufferImageStim(myWin, stim=stimList)
# render to screen (fast):
while <conditions>:
screenshot.draw() # fast; can vary .ori, ._position, .opacity
other_stuff.draw() # dynamic
myWin.flip()
See coder Demos > stimuli > bufferImageStim.py for a demo.
| Author : |
|
|---|---|
| Parameters : |
|
streamlined version of draw. limitations / bugs: not sure what happens with shaders & self._updateList()