TFT.rect()

名称

TFT.rect()

説明

TFTスクリーンに長方形を描く。rect()は4つの引数をとる。最初の2つは左上の頂点の座標、残りの2つは幅と高さである。

書式

void Adafruit_GFX::rect(int16_t x, int16_t y, int16_t width, int16_t height);

引数

x長方形の水平位置。
y 長方形の垂直位置。
width 長方形の幅。
height長方形の高さ。

戻り値

なし。

使用例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#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);

  // set the fill color to grey
  screen.fill(127,127,127);

  // draw a rectangle in the center of screen
  screen.rect(screen.width()/2-5, screen.height()/2-5, 10, 10);
}

void loop() {

}

オリジナルのページ

https://www.arduino.cc/reference/en/libraries/tft/rect/

最終更新日

January 8, 2024

inserted by FC2 system