disp_textT_disp_textDispTextDispTextdisp_text(算子)
名称
disp_textT_disp_textDispTextDispTextdisp_text — 在窗口中显示文本。
签名
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)
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)
static void HOperatorSet.DispText(HTuple windowHandle, HTuple stringVal, HTuple coordSystem, HTuple row, HTuple column, HTuple color, HTuple genParamName, HTuple genParamValue)
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)
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
描述
disp_textdisp_textDispTextDispTextDispTextdisp_text displays text in the graphics window WindowHandleWindowHandleWindowHandleWindowHandlewindowHandlewindow_handle
at the position (RowRowRowRowrowrow,ColumnColumnColumnColumncolumncolumn).
如果只定义了一个位置,则对于字符串 StringStringStringStringstringValstring 中的每个元素都会显示一行文本。此外,'\n'"\n""\n""\n""\n""\n" 将被解释为换行符,即执行换行操作。
如果定义了多个位置,则 StringStringStringStringstringValstring 中只能包含一个字符串,或者每个位置对应一个字符串。在这种情况下,必须使用 '\n'"\n""\n""\n""\n""\n" 强制换行。
StringStringStringStringstringValstring 末尾的换行符 ('\n'"\n""\n""\n""\n""\n") 将被忽略。
文本的位置可以使用窗口坐标(CoordSystemCoordSystemCoordSystemCoordSystemcoordSystemcoord_system = 'window'"window""window""window""window""window")或图像坐标(CoordSystemCoordSystemCoordSystemCoordSystemcoordSystemcoord_system = 'image'"image""image""image""image""image")来指定,这在使用缩放后的图像时非常有用。
除了提供 (RowRowRowRowrowrow,ColumnColumnColumnColumncolumncolumn) 坐标外,还可以向 RowRowRowRowrowrow 和 ColumnColumnColumnColumncolumncolumn
传递预定义的值,以便将文本显示在窗口中的固定位置(仅当 CoordSystemCoordSystemCoordSystemCoordSystemcoordSystemcoord_system = 'window'"window""window""window""window""window" 时有效):
|
'top'"top""top""top""top""top", 'left'"left""left""left""left""left" |
'top'"top""top""top""top""top", 'center'"center""center""center""center""center" |
'top'"top""top""top""top""top", 'right'"right""right""right""right""right" |
|
'center'"center""center""center""center""center", 'left'"left""left""left""left""left" |
'center'"center""center""center""center""center", 'center'"center""center""center""center""center" |
'center'"center""center""center""center""center", 'right'"right""right""right""right""right" |
|
'bottom'"bottom""bottom""bottom""bottom""bottom", 'left'"left""left""left""left""left" |
'bottom'"bottom""bottom""bottom""bottom""bottom", 'center'"center""center""center""center""center" |
'bottom'"bottom""bottom""bottom""bottom""bottom", 'right'"right""right""right""right""right"
|
The parameter ColorColorColorColorcolorcolor 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.
泛型参数
disp_textdisp_textDispTextDispTextDispTextdisp_text 可能会将 StringStringStringStringstringValstring 串显示在框内(默认)。此行为以及框的外观由 GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name 和 GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value 中的泛型参数定义。
- 'box'
-
If 'box'"box""box""box""box""box" is set to 'true'"true""true""true""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.
possible values: 'true'"true""true""true""true""true" 和
'false'"false""false""false""false""false"
default value: 'true'"true""true""true""true""true"
- 'box_color'
-
Sets the color of the box.
possible values: a string containing the color name (e.g., 'white'"white""white""white""white""white",
'red'"red""red""red""red""red", or '#aa00bba0'"#aa00bba0""#aa00bba0""#aa00bba0""#aa00bba0""#aa00bba0")
default value: '#fce9d4'"#fce9d4""#fce9d4""#fce9d4""#fce9d4""#fce9d4" (which is a light orange)
- 'shadow'
-
If 'shadow'"shadow""shadow""shadow""shadow""shadow" is set to 'true'"true""true""true""true""true", an additional shadow
is displayed beneath the box (if 'box'"box""box""box""box""box" is 'true'"true""true""true""true""true").
possible values: 'true'"true""true""true""true""true" 和
'false'"false""false""false""false""false"
default value: 'true'"true""true""true""true""true" if 'box_color'"box_color""box_color""box_color""box_color""box_color" is set to a color
without alpha value, 'false'"false""false""false""false""false" otherwise
- 'shadow_color'
-
Sets the color of the shadow if 'shadow'"shadow""shadow""shadow""shadow""shadow" is 'true'"true""true""true""true""true"。
possible values: a string containing the color name (e.g., 'black'"black""black""black""black""black",
'red'"red""red""red""red""red", or '#aa00bba0'"#aa00bba0""#aa00bba0""#aa00bba0""#aa00bba0""#aa00bba0")
default value: '#f28d26'"#f28d26""#f28d26""#f28d26""#f28d26""#f28d26" (which is a darker orange) if
'box_color'"box_color""box_color""box_color""box_color""box_color" is not set, 'white'"white""white""white""white""white"
otherwise
- 'border_radius'
-
Controls the roundness of the box's corners. For sharp corners set it to
0, for smoother corners to higher values.
possible values: positive real numbers or 0
default value: 2
- 'box_padding'
-
Controls to which amount in pixels the box is extended around the text.
possible values: positive real number
default value: 0
- 'shadow_sigma'
-
Controls to which amount the shadow beneath the box is blurred. Set it to
0 for a sharp shadow.
possible values: positive real number or 0
default value: 1.5
- 'shadow_dx' and 'shadow_dy'
-
Controls the offset of the shadow in column ('shadow_dx'"shadow_dx""shadow_dx""shadow_dx""shadow_dx""shadow_dx") and
row ('shadow_dy'"shadow_dy""shadow_dy""shadow_dy""shadow_dy""shadow_dy") direction in pixels.
possible values: any real number
default_value: 2
注意
disp_textdisp_textDispTextDispTextDispTextdisp_text 依赖于 libcanvas 库,该库在嵌入式系统上可能不可用。
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
参数
WindowHandleWindowHandleWindowHandleWindowHandlewindowHandlewindow_handle (输入控制) window → HWindow, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
窗口句柄。
StringStringStringStringstringValstring (输入控制) string(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
A tuple of strings containing the text message to be
displayed.
Each value of the tuple will be displayed in a single line.
默认值:
'hello'
"hello"
"hello"
"hello"
"hello"
"hello"
CoordSystemCoordSystemCoordSystemCoordSystemcoordSystemcoord_system (输入控制) string → HTuplestrHTupleHtuple (string) (string) (HString) (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).
默认值:
'window'
"window"
"window"
"window"
"window"
"window"
值列表:
'image'"image""image""image""image""image", 'window'"window""window""window""window""window"
RowRowRowRowrowrow (输入控制) point.y(-array) → HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (integer / real / string) (int / long / double / string) (Hlong / double / HString) (Hlong / double / char*)
The vertical text alignment or the row coordinate of the
desired text position.
默认值:
12
值列表:
12, 'bottom'"bottom""bottom""bottom""bottom""bottom", 'center'"center""center""center""center""center", 'top'"top""top""top""top""top"
ColumnColumnColumnColumncolumncolumn (输入控制) point.x(-array) → HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (integer / real / string) (int / long / double / string) (Hlong / double / HString) (Hlong / double / char*)
The horizontal text alignment or the column coordinate of
the desired text position.
默认值:
12
值列表:
12, 'center'"center""center""center""center""center", 'left'"left""left""left""left""left", 'right'"right""right""right""right""right"
ColorColorColorColorcolorcolor (输入控制) string(-array) → HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)
A tuple of strings defining the colors of the texts.
默认值:
'black'
"black"
"black"
"black"
"black"
"black"
值列表:
'black'"black""black""black""black""black", 'blue'"blue""blue""blue""blue""blue", 'coral'"coral""coral""coral""coral""coral", 'cyan'"cyan""cyan""cyan""cyan""cyan", 'forest green'"forest green""forest green""forest green""forest green""forest green", 'green'"green""green""green""green""green", 'lime green'"lime green""lime green""lime green""lime green""lime green", 'magenta'"magenta""magenta""magenta""magenta""magenta", 'red'"red""red""red""red""red", 'slate blue'"slate blue""slate blue""slate blue""slate blue""slate blue", 'yellow'"yellow""yellow""yellow""yellow""yellow"
GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (输入控制) attribute.name-array → HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)
Generic parameter names.
默认值:
[]
值列表:
'border_radius'"border_radius""border_radius""border_radius""border_radius""border_radius", 'box'"box""box""box""box""box", 'box_color'"box_color""box_color""box_color""box_color""box_color", 'box_padding'"box_padding""box_padding""box_padding""box_padding""box_padding", 'shadow'"shadow""shadow""shadow""shadow""shadow", 'shadow_color'"shadow_color""shadow_color""shadow_color""shadow_color""shadow_color", 'shadow_dx'"shadow_dx""shadow_dx""shadow_dx""shadow_dx""shadow_dx", 'shadow_dy'"shadow_dy""shadow_dy""shadow_dy""shadow_dy""shadow_dy", 'shadow_sigma'"shadow_sigma""shadow_sigma""shadow_sigma""shadow_sigma""shadow_sigma"
GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (输入控制) attribute.value-array → HTupleSequence[Union[str, int, float]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)
Generic parameter values.
默认值:
[]
值列表:
5.0, 'black'"black""black""black""black""black", 'blue'"blue""blue""blue""blue""blue", 'false'"false""false""false""false""false", 'forest green'"forest green""forest green""forest green""forest green""forest green", 'red'"red""red""red""red""red", 'true'"true""true""true""true""true", 'white'"white""white""white""white""white"
示例(HDevelop)
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
disp_text (WindowHandle, 'Display some text in a box', 'window', 12, 12, \
'black', [], [])
可能的前趋
open_windowopen_windowOpenWindowOpenWindowOpenWindowopen_window,
set_fontset_fontSetFontSetFontSetFontset_font,
get_string_extentsget_string_extentsGetStringExtentsGetStringExtentsGetStringExtentsget_string_extents
替代
write_stringwrite_stringWriteStringWriteStringWriteStringwrite_string
另见
get_string_extentsget_string_extentsGetStringExtentsGetStringExtentsGetStringExtentsget_string_extents,
set_fontset_fontSetFontSetFontSetFontset_font
模块
基础