說明
檢查 PImage 對象的寬度。
用法
image.width();
參數
空
返回
int:圖像的寬度(以像素為單位)
示例
// this example looks for a file named "logo.bmp"
// on the SD card, and renders it to the screen
#include <Esplora.h>
#include <SD.h>
#include <SPI.h>
#include <TFT.h> // Arduino TFT library
#define SD_CS 8 // Chip select line for SD card in Esplora
PImage logo;
void setup() {
// initialize the screen
EsploraTFT.begin();
// initialize the SD card
SD.begin(SD_CS);
// set the background the black
EsploraTFT.background(0, 0, 0);
// load the image into the named instance of PImage
logo = EsploraTFT.loadImage("arduino.bmp");
// if it is a valid image file, turn the Esplora's LED green
if (logo.isValid()) {
Esplora.writeGreen(255);
}
else{
// if it is not valid, turn the LED red
Esplora.writeRed(255);
}
}
void loop() {
// randomly draw the image on screen
int x = random(EsploraTFT.width() - logo.width());
int y = random(EsploraTFT.height() - logo.height());
EsploraTFT.image(logo, x, y);
delay(1500);
}
相關用法
- Arduino TFT - PImage.height()用法及代碼示例
- Arduino TFT - PImage.isValid()用法及代碼示例
- Arduino TFT - PImage用法及代碼示例
- Arduino TFT - height()用法及代碼示例
- Arduino TFT - background()用法及代碼示例
- Arduino TFT - line()用法及代碼示例
- Arduino TFT - EsploraTFT用法及代碼示例
- Arduino TFT - loadImage()用法及代碼示例
- Arduino TFT - width()用法及代碼示例
- Arduino TFT - TFT用法及代碼示例
- Arduino TFT - image()用法及代碼示例
- Arduino TFT - point()用法及代碼示例
- Arduino TFT - rect()用法及代碼示例
- Arduino TFT - begin()用法及代碼示例
- Arduino TFT - stroke()用法及代碼示例
- Arduino TFT - circle()用法及代碼示例
- Arduino TFT - noStroke()用法及代碼示例
- Arduino TFT - fill()用法及代碼示例
- Arduino TFT - setTextSize()用法及代碼示例
- Arduino TFT - noFill()用法及代碼示例
- Arduino TFT - text()用法及代碼示例
- Arduino long用法及代碼示例
- Arduino Arduino_EMBRYO_2 - setLengthXY()用法及代碼示例
- Arduino ~用法及代碼示例
- Arduino ArduinoBLE - bleDevice.advertisedServiceUuidCount()用法及代碼示例
注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 TFT - PImage.width()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。