當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Arduino TFT - setTextSize()用法及代碼示例

說明

設置後麵的文本大小。默認大小為“1”。每次更改大小都會使文本的高度增加 10 個像素。也就是說,尺寸 1 = 10 像素,尺寸 2 = 20 像素,依此類推。

用法

screen.setTextSize(size);

參數

尺寸:int1-5

返回

示例

#include <SPI.h>
#include <TFT.h>            // Arduino TFT library

#define cs   10
#define dc   9
#define rst  8

TFT screen = TFT(cs, dc, rst);

void setup() {
  // initialize the screen
  screen.begin();

  // make the background black
  screen.background(0,0,0);

  // set the stroke color to white
  screen.fill(255,255,255);

  // default text size
  screen.setTextSize(1);
  // write text to the screen in the top left corner
  screen.text("Testing!", 0, 0);
  // increase text size
  screen.setTextSize(5);
  // write text to the screen below
  screen.text("BIG!", 0, 10);
}

void loop() {

}

相關用法


注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 TFT - setTextSize()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。