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


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

說明

在屏幕上繪製對象之前調用,它設置形狀和文本的填充顏色。

fill() 要求紅色、綠色和藍色通道中的每一個都具有 8 位值,但屏幕不會以這種保真度顯示。紅色和藍色值縮放為 5 位顏色(32 個離散步驟),綠色為 6 位顏色(64 個離散步驟)。

用法

screen.fill(red, green, blue);

參數

紅色:int 0-255 綠色:int 0-255 藍色:int 0-255

返回

示例

#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);

  // draw a white box in the screen center
  screen.rect(screen.width()/2+10,screen.height()/2+10,screen.width()/2-10,screen.height()/2-10);
}

void loop() {

}

相關用法


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