expyfun.visual.RawImage

class expyfun.visual.RawImage(ec, image_buffer, pos=(0, 0), scale=1.0, units='norm')[source]

Create image from array for on-screen display.

Parameters:
ecinstance of ExperimentController

Parent EC.

image_bufferarray

Array, shape (N, M[, 3/4]). Color values should range between 0 and 1.

posarray-like

2-element array-like with X, Y (center) arguments.

scalefloat

The scale factor. 1 is native size (pixel-to-pixel), 2 is twice as large, etc.

unitsstr

Units to use for the position. See check_units for options.

Returns:
imginstance of RawImage

The image object.

property bounds

Left, Right, Bottom, Top (in pixels) of the image.

draw()[source]

Draw the image to the buffer

get_rect(units='norm')[source]

X, Y center, Width, Height of image.

Parameters:
unitsstr

Units to use for the position. See check_units for options.

Returns:
rectndarray

The rect.

set_image(image_buffer)[source]

Set image buffer data

Parameters:
image_bufferarray

N x M x 3 (or 4) array. Can be type np.float64 or np.uint8. If np.float64, color values must range between 0 and 1. np.uint8 is slightly more efficient.

set_pos(pos, units='norm')[source]

Set image position.

Parameters:
posarray-like

2-element array-like with X, Y (center) arguments.

unitsstr

Units to use. See check_units for options.

set_scale(scale)[source]

Create image from array for on-screen display.

Parameters:
scalefloat

The scale factor. 1 is native size (pixel-to-pixel), 2 is twice as large, etc.

Examples using expyfun.visual.RawImage

Experiment drawing methods

Experiment drawing methods