当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。