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


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

說明

在兩點之間畫一條線。使用stroke() 更改用line() 繪製的東西的顏色。

用法

screen.line(xStart, yStart, xEnd, yEnd);

參數

xStart: int, 行開始的水平位置 yStart: int, 行開始的垂直位置 xEnd: int, 行結束的水平位置 yEnd: int, 行結束的垂直位置

返回

示例

#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.stroke(255,255,255);

  // draw a diagonal line across the screen's center
  screen.line(0, 0, 160, 124);
}

void loop() {

}

相關用法


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