setTextSize()
描述
设定文字的大小。预设值是 1。每增加 1 代表文字的高度会增加 10 像素,1 = 10 像素,2 = 20 像素,以此类推。
语法
screen.setTextSize(size);
参数
size
: 1~5,型态为 int
回传
无回传值
范例
#include <SPI.h> #include <TFT.h> #define cs 10 #define dc 9 #define rst 8 TFT screen = TFT(cs, dc, rst); void setup() { // 初始化 TFT 物件 screen.begin(); // 设定背景色为黑色 screen.background(0,0,0); // 用白色填满显示的图形 screen.fill(255,255,255); // 设定文字大小 screen.setTextSize(1); // 在左上角显示文字 screen.text("Testing!", 0, 0); // 设定文字大小 screen.setTextSize(5); // 在底部显示文字 screen.text("BIG!", 0, 10); } void loop() { }
See also
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.