Skip to content

disp_textDispTextDispTextdisp_textT_disp_text🔗

Short description🔗

disp_textDispTextDispTextdisp_textT_disp_text — Display text in a window.

Signature🔗

disp_text( window WindowHandle, string String, string CoordSystem, point.y Row, point.x Column, string Color, attribute.name GenParamName, attribute.value GenParamValue )void DispText( const HTuple& WindowHandle, const HTuple& String, const HTuple& CoordSystem, const HTuple& Row, const HTuple& Column, const HTuple& Color, const HTuple& GenParamName, const HTuple& GenParamValue )static void HOperatorSet.DispText( HTuple windowHandle, HTuple stringVal, HTuple coordSystem, HTuple row, HTuple column, HTuple color, HTuple genParamName, HTuple genParamValue )def disp_text( window_handle: HHandle, string: MaybeSequence[str], coord_system: str, row: MaybeSequence[Union[int, float, str]], column: MaybeSequence[Union[int, float, str]], color: MaybeSequence[str], gen_param_name: Sequence[str], gen_param_value: Sequence[Union[str, int, float]] ) -> None

Herror T_disp_text( const Htuple WindowHandle, const Htuple String, const Htuple CoordSystem, const Htuple Row, const Htuple Column, const Htuple Color, const Htuple GenParamName, const Htuple GenParamValue )

void HWindow::DispText( const HTuple& String, const HString& CoordSystem, const HTuple& Row, const HTuple& Column, const HTuple& Color, const HTuple& GenParamName, const HTuple& GenParamValue ) const

void HWindow::DispText( const HString& String, const HString& CoordSystem, Hlong Row, Hlong Column, const HString& Color, const HTuple& GenParamName, const HTuple& GenParamValue ) const

void HWindow::DispText( const char* String, const char* CoordSystem, Hlong Row, Hlong Column, const char* Color, const HTuple& GenParamName, const HTuple& GenParamValue ) const

void HWindow::DispText( const wchar_t* String, const wchar_t* CoordSystem, Hlong Row, Hlong Column, const wchar_t* Color, const HTuple& GenParamName, const HTuple& GenParamValue ) const (Windows only)

void HWindow.DispText( HTuple stringVal, string coordSystem, HTuple row, HTuple column, HTuple color, HTuple genParamName, HTuple genParamValue )

void HWindow.DispText( string stringVal, string coordSystem, int row, int column, string color, HTuple genParamName, HTuple genParamValue )

Description🔗

disp_textDispText displays text in the graphics window WindowHandlewindowHandlewindow_handle at the position (Rowrowrow,Columncolumncolumn).

If only a single position is defined, one text line is displayed for each element of StringstringValstring. Also, ‘n‘ will be interpreted as a newline character, i.e., a line break is performed.

If multiple positions are defined, only a single string or one string for each position is allowed in StringstringValstring. In this case, line breaks have to be forced with ‘n‘.

Newlines (‘n‘) at the end of StringstringValstring are ignored.

The position of the text may be specified in window coordinates (CoordSystemcoordSystemcoord_system = 'window'"window") or in image coordinates (CoordSystemcoordSystemcoord_system = 'image'"image"), which is useful when using zoomed images.

In addition to supplying (Rowrowrow,Columncolumncolumn) coordinates, it is also possible to pass predefined values to Rowrowrow and Columncolumncolumn to display the text at a fixed Position in the window (only if CoordSystemcoordSystemcoord_system = 'window'"window").:

'top'"top", 'left'"left" 'top'"top", 'center'"center" 'top'"top", 'right'"right"
'center'"center", 'left'"left" 'center'"center", 'center'"center" 'center'"center", 'right'"right"
'bottom'"bottom", 'left'"left" 'bottom'"bottom", 'center'"center" 'bottom'"bottom", 'right'"right"

The parameter Colorcolorcolor also accepts tuples of values. In that case, the specified colors are used cyclically for every new text position or for every new text line if a single position is used.

Generic Parameters

disp_textDispText may display the StringstringValstring within a box (default). This behavior and the look of the box are defined with the generic parameters in GenParamNamegenParamNamegen_param_name and GenParamValuegenParamValuegen_param_value.

  • ‘box’ If 'box'"box" is set to 'true'"true", the text is written within a box. The look of the box and its optional shadow can be configured with the generic parameters below.

    List of values: 'true'"true" and 'false'"false"

    Default: 'true'"true"

  • ‘box_color’ Sets the color of the box.

    List of values: a string containing the color name (e.g., 'white'"white", 'red'"red", or '#aa00bba0'"#aa00bba0")

    Default: '#fce9d4'"#fce9d4" (which is a light orange)

  • ‘shadow’ If 'shadow'"shadow" is set to 'true'"true", an additional shadow is displayed beneath the box (if 'box'"box" is 'true'"true").

    List of values: 'true'"true" and 'false'"false"

    Default: 'true'"true" if 'box_color'"box_color" is set to a color without alpha value, 'false'"false" otherwise

  • ‘shadow_color’ Sets the color of the shadow if 'shadow'"shadow" is 'true'"true".

    List of values: a string containing the color name (e.g., 'black'"black", 'red'"red", or '#aa00bba0'"#aa00bba0")

    Default: '#f28d26'"#f28d26" (which is a darker orange) if 'box_color'"box_color" is not set, 'white'"white" otherwise

  • ‘border_radius’ Controls the roundness of the box’s corners. For sharp corners set it to 00, for smoother corners to higher values.

    List of values: positive real numbers or 00

    Default: 2

  • ‘box_padding’ Controls to which amount in pixels the box is extended around the text.

    List of values: positive real number

    Default: 0

  • ‘shadow_sigma’ Controls to which amount the shadow beneath the box is blurred. Set it to 00 for a sharp shadow.

    List of values: positive real number or 00

    Default: 1.5

  • ‘shadow_dx’ and ‘shadow_dy’ Controls the offset of the shadow in column ('shadow_dx'"shadow_dx") and row ('shadow_dy'"shadow_dy") direction in pixels.

    List of values: any real number

    Default: 2

  • ‘backdrop_blur_sigma’ Controls to which amount the background of the box is blurred. s only an effect if 'box'"box" is 'true'"true" and 'box_color'"box_color" is not opaque (i.e. alpha is not 255). It is recommended to use 'backdrop_blur_sigma'"backdrop_blur_sigma" with 'shadow'"shadow" set to 'false'"false".

    List of values: positive real number or 00

    Default: 0

  • ‘rotate_phi’ Angle in degrees to rotate the displayed text.

    List of values: any real number

    Default: 0

  • ‘rotate_col’ Column coordinate of the rotation center if 'rotate_phi'"rotate_phi" is different to zero. Choose either a column coordinate by setting a real number or determine the rotation center on the left edge ('text_left'"text_left"), the right edge ('text_right'"text_right"), or in the center ('text_center'"text_center") of the text box.

    List of values: any real number or 'text_left'"text_left", 'text_center'"text_center", 'text_right'"text_right"

    Default: 'text_center'"text_center"

  • ‘rotate_row’ Row coordinate of the rotation center if 'rotate_phi'"rotate_phi" is different to zero. Choose either a row coordinate by setting a real number or determine the rotation center on the top edge ('text_top'"text_top"), the bottom edge ('text_bottom'"text_bottom"), or in the center ('text_center'"text_center") of the text box.

    List of values: any real number or 'text_top'"text_top", 'text_center'"text_center", 'text_bottom'"text_bottom"

    Default: 'text_center'"text_center"

  • ‘border_color’ Sets the color of the border of the text box.

    List of values: a string containing the color name (e.g., 'black'"black", 'red'"red", or '#aa00bba0'"#aa00bba0")

    Default: '#ffffff'"#ffffff"

  • ‘border_width’ Controls the width of the text box border.

    List of values: positive real numbers or 00

    Default: 0

Attention🔗

disp_textDispText depends on the library libhcanvas, which might not be available on embedded systems.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

WindowHandlewindowHandlewindow_handle (input_control) window → (handle)HTuple (HHandle)HWindow, HTuple (IntPtr)HHandleHtuple (handle)

Window handle.

StringstringValstring (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

A tuple of strings containing the text message to be displayed. Each value of the tuple will be displayed in a single line.

Default: 'hello'"hello"

CoordSystemcoordSystemcoord_system (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

If set to ‘window’, the text position is given with respect to the window coordinate system. If set to ‘image’, image coordinates are used (this may be useful in zoomed images).

Default: 'window'"window"
List of values: 'image', 'window'"image", "window"

Rowrowrow (input_control) point.y(-array) → (integer / real / string)HTuple (Hlong / double / HString)HTuple (int / long / double / string)MaybeSequence[Union[int, float, str]]Htuple (Hlong / double / char*)

The vertical text alignment or the row coordinate of the desired text position.

Default: 1212
List of values: 12, 'bottom', 'center', 'top'12, "bottom", "center", "top"

Columncolumncolumn (input_control) point.x(-array) → (integer / real / string)HTuple (Hlong / double / HString)HTuple (int / long / double / string)MaybeSequence[Union[int, float, str]]Htuple (Hlong / double / char*)

The horizontal text alignment or the column coordinate of the desired text position.

Default: 1212
List of values: 12, 'center', 'left', 'right'12, "center", "left", "right"

Colorcolorcolor (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

A tuple of strings defining the colors of the texts.

Default: 'black'"black"
List of values: 'black', 'blue', 'coral', 'cyan', 'forest green', 'green', 'lime green', 'magenta', 'red', 'slate blue', 'yellow'"black", "blue", "coral", "cyan", "forest green", "green", "lime green", "magenta", "red", "slate blue", "yellow"

GenParamNamegenParamNamegen_param_name (input_control) attribute.name-array → (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

Generic parameter names.

Default: [][]
List of values: 'backdrop_blur_sigma', 'border_color', 'border_radius', 'border_width', 'box', 'box_color', 'box_padding', 'rotate_col', 'rotate_phi', 'rotate_row', 'shadow', 'shadow_color', 'shadow_dx', 'shadow_dy', 'shadow_sigma'"backdrop_blur_sigma", "border_color", "border_radius", "border_width", "box", "box_color", "box_padding", "rotate_col", "rotate_phi", "rotate_row", "shadow", "shadow_color", "shadow_dx", "shadow_dy", "shadow_sigma"

GenParamValuegenParamValuegen_param_value (input_control) attribute.value-array → (string / integer / real)HTuple (HString / Hlong / double)HTuple (string / int / long / double)Sequence[Union[str, int, float]]Htuple (char* / Hlong / double)

Generic parameter values.

Default: [][]
List of values: 5.0, 'black', 'blue', 'false', 'forest green', 'red', 'true', 'white'5.0, "black", "blue", "false", "forest green", "red", "true", "white"

Example🔗

(HDevelop)

dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
disp_text (WindowHandle, 'Display some text in a box', 'window', 12, 12, \
           'black', [], [])

Combinations with other operators🔗

Combinations

Possible predecessors

open_windowOpenWindow, set_fontSetFont, get_string_extentsGetStringExtents

Alternatives

write_stringWriteString

See also

get_string_extentsGetStringExtents, set_fontSetFont

Module🔗

Foundation