stimuli.visuals.MovingBar¶
- class stimuli.visuals.MovingBar(window_name='Visual', window_size=None)¶
Class to display a centered moving bar along an axis.
- Parameters:
Attributes
Axis on which the bar is moving.
Background color in BGR color space.
Color of the bar in BGR color space.
Image array.
Length of the bar in pixel.
Position between -1 and 1 of the bar on the given axis.
Width of the bar in pixel.
Window's center position.
Window's name.
Window's size (width x height).
Methods
close
()Close the visual.
draw_background
(color)Draw a uniform single color background.
putBar
(length, width, color[, position, axis])Draw the bar on top of the current visual.
show
([wait])Show the visual with
cv2.imshow()
andcv2.waitKey()
.- close()¶
Close the visual.
- draw_background(color)¶
Draw a uniform single color background.
Replace all the pixels with this color, thus this method erases any prior work.
Notes
A color is provided as matplotlib string or as
(B, G, R)
tuple of int8 set between 0 and 255.
- putBar(length, width, color, position=0, axis=0)¶
Draw the bar on top of the current visual.
- Parameters:
- length
int
Number of pixels used to draw the length of the bar.
- width
int
Number of pixels used to draw the width of the bar.
- color
str
|tuple
Color used to draw the bar.
- position
float
Relative position of the bar along the given axis. Along the vertical axis:
-1
: corresponds to the top of the window.1
: corresponds to the bottom of the window.
Along the horizontal axis:
-1
: corresponds to the left of the window.1
: corresponds to the right of the window.
0
corresponds to the center of the window.- axis
int
|str
Axis along which the bar is moving:
0
|'vertical'
|'v'
- horizontal bar along vertical axis.1
|'horizontal'
|'h'
- vertical bar along horizontal axis.
- length
Notes
A color is provided as matplotlib string or as
(B, G, R)
tuple of int8 set between 0 and 255.
- show(wait=1)¶
Show the visual with
cv2.imshow()
andcv2.waitKey()
.- Parameters:
- wait
int
Wait timer passed to
cv2.waitKey()
[ms].
- wait
- property axis¶
Axis on which the bar is moving.
- This property is a binary integer:
0: Horizontal bar along vertical axis.
1: Vertical bar along horizontal axis.
- property background¶
Background color in BGR color space.
- property color¶
Color of the bar in BGR color space.
- property img¶
Image array.
- property length¶
Length of the bar in pixel.
- property position¶
Position between -1 and 1 of the bar on the given axis.
- property width¶
Width of the bar in pixel.
- property window_center¶
Window’s center position.
- property window_name¶
Window’s name.
- property window_size¶
Window’s size (width x height).