Difference between revisions of "Tft.drawTriangle()"

From Microduino Wiki
Jump to: navigation, search
 
Line 52: Line 52:
  
  
[[https://wiki.microduino.cc/index.php/TFT_ST7735_Grammar_Handbook Return to TFT_ST7735 Grammar Handbook]]
+
[[https://wiki.microduino.cc/index.php/TFT_ST7735_Syntax_Manual Return to TFT_ST7735 Syntax Manual]]

Latest revision as of 03:33, 4 August 2016

tft.drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
  • Effect:

Draw a triangle outline on the TFT screen


  • Parameters:

x0:x coordinate of the apex

y0:y coordinate of the apex

x1:x coordinate of the left bottom point

y1:y coordinate of the left bottom point

x2:x coordinate of the right bottom point

y2:y coordinate of the right bottom point

color:color of the triangle


  • Example:
#define sclk 13
#define mosi 11
#define cs   5
#define dc   4
#define rst  -1  // you can also connect this to the Arduino reset

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#if defined(__SAM3X8E__)
    #undef __FlashStringHelper::F(string_literal)
    #define F(string_literal) string_literal
#endif

Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);

void setup(void) {
  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
  tft.fillScreen(ST7735_BLACK);
  tft.drawTriangle(43, 30, 40, 90, 80, 120, ST7735_RED);
}

void loop() {  }


[Return to TFT_ST7735 Syntax Manual]