6. 显示文字

Posted qiyuexin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了6. 显示文字相关的知识,希望对你有一定的参考价值。

6.1 基本例程

GUI_DispString("Hello world!");

6.2 绘图模式

GUI_SetColor()         // 设置前景颜色
GUI_SetBkColor()      // 设置背景颜色
GUI_SetTextMode()    // 选择文字模式
  • Normal text    // GUI_TM_NORMAL 
  • Reverse text    // GUI_TM_NORMAL 
  • Transparent text   // GUI_TM_TRANS
  • XOR texttext   // GUI_TM_XOR

Example

GUI_SetFont(&GUI_Font8x16);
GUI_SetBkColor(GUI_BLUE);
GUI_Clear();
GUI_SetPenSize(10);
GUI_SetColor(GUI_RED);
GUI_DrawLine(80, 10, 240, 90);
GUI_DrawLine(80, 90, 240, 10);
GUI_SetBkColor(GUI_BLACK);
GUI_SetColor(GUI_WHITE);
GUI_SetTextMode(GUI_TM_NORMAL);
GUI_DispStringHCenterAt("GUI_TM_NORMAL" , 160, 10);
GUI_SetTextMode(GUI_TM_REV);
GUI_DispStringHCenterAt("GUI_TM_REV" , 160, 26);
GUI_SetTextMode(GUI_TM_TRANS);
GUI_DispStringHCenterAt("GUI_TM_TRANS" , 160, 42);
GUI_SetTextMode(GUI_TM_XOR);
GUI_DispStringHCenterAt("GUI_TM_XOR" , 160, 58);
GUI_SetTextMode(GUI_TM_TRANS | GUI_TM_REV);
GUI_DispStringHCenterAt("GUI_TM_TRANS | GUI_TM_REV", 160, 74);

 Screenshot of above example

技术图片

 6.3  位置

GUI_GotoX()        
GUI_GotoY()
GUI_GotoXY()

 

 

6.4 文本API

 

Routine

Description

Displaying text

GUI_DispCEOL()

Clears the current line from the current position to the end.

GUI_DispChar()

Displays a single character.

GUI_DispCharAt()

Displays a single character at the specified position.

GUI_DispChars()

Displays a character a specified number of times.

GUI_DispString()

Displays a string.

GUI_DispStringAt()

Displays a string at the specified position.

GUI_DispStringAtCEOL()

Displays a string at the specified position and clears the cur-rent line to the end.

GUI_DispStringHCenterAt()

Displays a string centered horizontally at the given position.

GUI_DispStringInRect()

Displays a string in the specified rectangle.

GUI_DispStringInRectEx()

Displays a string rotated in the specified rectangle.

GUI_DispStringInRectWrap()

Displays a string wrapped in the specified rectangle.

GUI_DispStringinRectWrapEx()

Displays a string rotated and wrapped in the specified rectan-gle.

GUI_DispStringLen()

Displays a string at the current position with specified number of characters.

GUI_WrapGetNumLines()

Returns the number lines required to display the given stringusing the given wrap mode at the given size.

Drawing modes

GUI_GetTextMode()

Returns the currently set drawing mode.

GUI_SetTextMode()

Sets the drawing mode.

GUI_SetTextStyle()

Sets the style to be used.

GUI_SetClearTextRectMode()

Enables clear rect mode when displaying a string in a rectan-gle.

Alignment

GUI_GetTextAlign()

Returns the currently set text alignment.

GUI_SetLBorder()

Sets the size of the left border to be used after line feeds.

GUI_SetTextAlign()

Sets the text alignment.

Position

GUI_DispNextLine()

Moves the cursor to the beginning of the next line.

GUI_GotoX()

Sets the X-position.

GUI_GotoXY()

Sets the X- and Y-position.

GUI_GotoY()

Sets the Y-position.

GUI_GetDispPosX()

Returns the current X-position.

GUI_GetDispPosY()

Returns the current Y-position.

 

以上是关于6. 显示文字的主要内容,如果未能解决你的问题,请参考以下文章

Android Place自动填充片段:无法设置文字

如何组合绑定片段而不将它们包装在 XML 文字中

VSCode自定义代码片段6——CSS选择器

在片段部分使用YoutubePlayerView

Google地图摘要会显示更多文字

bootstrap 的栅格怎么让里面的文字居中显示...