A class implementing a single text line.
Methods
Create a text line stimulus.
NOTE: text_font can be both, a name or path to a font file! When text_font is a name, Expyriment will try to find a font that best matches the given name. If no matching font can be found, or if the given font file cannot be found, the Pygame system default will be used. In any case the value of the attribute text_font will always resemble the font that is actually in use!
Parameters : | text : str
position : (int, int), optional
text_font : str, optional
text_size : int, optional
text_bold : bool, optional
text_italic : bool, optional
text_underline : bool, optional
text_colour : (int, int, int), optional
background_colour : (int, int, int), optional
|
---|
Getter for absolute_position.
Add visual noise on top of the stimulus.
This function might take very long for large stimuli.
Parameters : | grain_size : int
percentage : int
colour : (int, int, int)
|
---|---|
Returns : | time : int
|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Getter for background_colour.
Blur the stimulus.
This blurs the stimulus, by scaling it down and up by the factor of ‘level’.
Parameters : | level : int
|
---|---|
Returns : | time : int
|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Clear the stimulus surface.
Surfaces are automatically created after any surface operation (presenting, plotting, rotating, scaling, flipping etc.) and preloading. If the stimulus was preloaded, this method unloads the stimulus. This method is functionally equivalent with unload(keep_surface=False).
Returns : | time : int
|
---|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
“Compress the stimulus.
This will create a temporary file on the disk where the surface of the stimululs is written to. The surface will now be read from the disk to free memory. Compressed stimuli cannot do surface operations! Preloading comressed stimuli is possible and highly recommended. Depending on the size of the stimulus, this method may take some time to compute!
Returns : | time : int
|
---|
Deep copy of the visual stimulus.
Returns : | copy : deep copy of self |
---|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Decompress the stimulus.
This will decompress the stimulus. The surface will now be read from memory again. Depending on the size of the stimulus, this method may take some time to compute!
Returns : | time : int
|
---|
Surface center distance.
This method computes the distance between the surface center of this and another visual stimulus.
Parameters : | other : stimulus
|
---|---|
Returns : | dist : float
|
Flip the stimulus.
This is a surface operation. After this, a surface will be present!
Parameters : | booleans : (bool, bool)
|
---|---|
Returns : | time : int
|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Getter for has_surface.
Getter for id.
Check if stimulus is inside another stimulus.
Parameters : | stimulus : expyriment stimulus
mode : mode (str), optional
|
---|---|
Returns : | out : bool |
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Getter for is_compressed.
Getter for is_preloaded.
Moves the stimulus in 2D space.
When using OpenGL, this can take longer then 1ms!
Parameters : | offset : list, optional
|
---|---|
Returns : | time : int
|
Check if stimulus is overlapping with a certain position.
Parameters : | position : (int, int)
mode : mode (str), optional
|
---|---|
Returns : | out: bool : |
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Check if stimulus is overlapping with another stimulus.
Parameters : | stimulus : expyriment stimulus
mode : mode (str), optional
|
---|---|
Returns : | overlapping : bool
overlap : pygame surface
|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Return the stimulus as Picture stimulus.
This will create a temporary file on the hard disk where the image is saved to.
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Plot the stimulus on the surface of another stimulus.
Use this to plot more than one stimulus and to present them at the same time afterwards by presenting the stimulus on which they were plotted on.
Parameters : | stimulus : expyriment stimulus
|
---|---|
Returns : | time : int
|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Getter for position.
Preload the stimulus to memory.
This will prepare the stimulus for a fast presentation. In OpenGL mode this method creates an OpenGL texture based on the surface of the stimulus. When OpenGL is switched off, this method will create a surface if it doesn’t exists yet. If stimuli are not preloaded manually, this will happen automatically during presentation. However, stimulus presentation will take some time then!
Always preload your stimuli when a timing acurate presentation is needed!
Parameters : | inhibit_ogl_compress : bool, optional
|
---|---|
Returns : | time : int
|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Present the stimulus on the screen.
This clears and updates the screen automatically. When not preloaded, depending on the size of the stimulus, this method can take some time to compute!
Parameters : | clear : bool, optional
update : bool, optional
|
---|---|
Returns : | time : int
|
Rotate the stimulus.
This is a surface operation. After this, a surface will be present! Rotating goes along with a quality loss. Thus, rotating an already rotated stimulus is not a good idea.
Parameters : | degree : int
|
---|---|
Returns : | time : int
|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Save the stimulus as image.
Parameters : | filename : str
|
---|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Scale the stimulus.
This is a surface operation. After this, a surface will be present! Negative scaling values will flip the stimulus. Scaling goes along with a quality loss. Thus, scaling an already scaled stimulus is not a good idea.
Parameters : | factors : (int, int) or float
|
---|---|
Returns : | time : int
|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Scramble the stimulus.
Attention: If the surface size is not a multiple of the grain size, you may loose some pixels on the edge.
Parameters : | grain_size : int or (int, int)
|
---|---|
Returns : | time : int
|
Notes
Depending on the size of the stimulus, this method may take some time to compute!
Getter for surface_size.
Getter for text.
Getter for text_bold.
Getter for text_colour.
Getter for text_font.
Getter for text_italic.
Getter for text_size.
Getter for text_underline.
Unload the stimulus from memory.
This will unload preloaded stimuli. In OpenGL mode, this method will remove the reference to the OpenGL texture and the surface (when ‘keep_surface’ is False). When OpenGL is switched off, the reference to the surface will be removed (when ‘keep_surface’ is False).
Parameters : | keep_surface : bool, optional
|
---|---|
Returns : | time : int
|
See also
clear_surface.
Notes
Depending on the size of the stimulus, this method may take some time to compute!