stimupy.components.texts#

Demos#

Functions#

text

Draw given text into a (numpy) image-array

text(text, visual_size=None, ppd=None, shape=None, intensity_text=0.0, intensity_background=0.5, fontsize=36, align='center')[source]#

Draw given text into a (numpy) image-array

If no shape is provided / can be resolved, tightly fits the bounding box of the drawn text.

Parameters:
  • text (str) – Text to draw

  • visual_size (Sequence[Number, Number], Number, or None (default)) – visual size [height, width] of image, in degrees visual angle

  • ppd (Sequence[Number, Number], Number, or None (default)) – pixels per degree [vertical, horizontal]

  • shape (Sequence[Number, Number], Number, or None (default)) – shape [height, width] of image, in pixels

  • intensity_text (float, optional) – intensity of text in range (0.0; 1.0), by default 0.0

  • intensity_background (float, optional) – intensity value of background in range (0.0; 1.0), by default 0.5

  • fontsize (int, optional) – font size, by default 36

  • align ("left", "center" (default), "right") – alignment of text, by default “center”

Returns:

dict with the stimulus (key: “img”), mask with integer index for the text (key: “text_mask”), and additional keys containing stimulus parameters

Return type:

dict[str, Any]