stimuli.visuals.FillingBar¶
- class stimuli.visuals.FillingBar(window_name='Visual', window_size=None)¶
Class to display a centered bar that can fill/unfill along a given axis.
The filling process starts from the center of the bar and fills both sides simultaneously.
- Parameters:
Attributes
Axis on which the bar is moving.
Background color in BGR color space.
Color used for the bar background in BGR color space.
Color used to fill the bar in BGR color space.
Length filled in percent between 0 and 1.
Image array.
Length of the bar in pixel.
Margin in pixel between the bar and its filled content.
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, margin, color, fill_color)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, margin, color, fill_color, fill_perc=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.
- margin
int
Margin in pixel between the filling bar and the containing bar. The containing bar
(length x width)
is set as(length+margin, width+margin)
.- color
str
|tuple
Color used to draw the bar background.
- fill_color
str
|tuple
Color used to fill the bar.
- fill_perc
float
Percentage between 0 and 1 of bar filling.
0
: not filled1
: fully filled
As the bar fills on both side simultaneously, the percentage filled is
length//2 * fill_perc
.- axis
int
|str
Axis along which the bar is moving:
0
|'vertical'
|'v'
- vertical bar1
|'horizontal'
|'h'
- horizontal bar
- 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: Vertical bar filling along the vertical axis.
1: Horizontal bar filling along the horizontal axis.
- property background¶
Background color in BGR color space.
- property color¶
Color used for the bar background in BGR color space.
- property fill_color¶
Color used to fill the bar in BGR color space.
- property fill_perc¶
Length filled in percent between 0 and 1.
- property img¶
Image array.
- property length¶
Length of the bar in pixel.
- property margin¶
Margin in pixel between the bar and its filled content.
- 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).