// Rounded rectangles
void FramebufferGFX::drawRoundRect(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t r, uint16_t color) {
  // From Adafruit library (modified)
  int16_t w = x1 - x0;
  int16_t h = y1 - y0;
  int16_t x = x0;
  int16_t y = y0;
  if (x0 > x1) {
    x = x1;
    w = -w;
  }
  if (y0 > y1) {
    y = y1;
    h = -h;
  }
  
  // smarter version
  drawFastHLine(x+r  , y    , w-2*r, color); // Top
  drawFastHLine(x+r  , y+h-1, w-2*r, color); // Bottom
  drawFastVLine(x    , y+r  , h-2*r, color); // Left
  drawFastVLine(x+w-1, y+r  , h-2*r, color); // Right
  // draw four corners
  drawCircleHelper(x+r    , y+r    , r, 1, color);
  drawCircleHelper(x+w-r-1, y+r    , r, 2, color);
  drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);
  drawCircleHelper(x+r    , y+h-r-1, r, 8, color);  
}
Beispiel #2
0
// draw a rounded rectangle!
void GOFi2cOLED::drawRoundRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t r, uint8_t color) {
  // smarter version
  drawFastHLine(x+r  , y    , w-2*r, color); // Top
  drawFastHLine(x+r  , y+h-1, w-2*r, color); // Bottom
  drawFastVLine(  x    , y+r  , h-2*r, color); // Left
  drawFastVLine(  x+w-1, y+r  , h-2*r, color); // Right
  // draw four corners
  drawCircleHelper(x+r    , y+r    , r, 1, color);
  drawCircleHelper(x+w-r-1, y+r    , r, 2, color);
  drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);
  drawCircleHelper(x+r    , y+h-r-1, r, 8, color);
}
Beispiel #3
0
void    G2BsumotoyRA8875::DrawRoundedRect(int16_t XPos,int16_t YPos,int16_t Width,int16_t Height,int16_t CornerRadius,uint16_t ButtonBorder,uint16_t CornersToSkip)
{
  if (CornersToSkip==0)
    sumoTFT->drawRoundRect(XPos, YPos, Width, Height, CornerRadius, ButtonBorder);
  else
  {
      //draw in lines from rounded corner to rounded corner
      sumoTFT->drawFastHLine(XPos+CornerRadius  , YPos    , Width-2*CornerRadius, ButtonBorder); // Top
      sumoTFT->drawFastHLine(XPos+CornerRadius  , YPos+Height-1, Width-2*CornerRadius, ButtonBorder); // Bottom
      sumoTFT->drawFastVLine(XPos    , YPos+CornerRadius  , Height-2*CornerRadius, ButtonBorder); // Left
      sumoTFT->drawFastVLine(XPos+Width-1, YPos+CornerRadius  , Height-2*CornerRadius, ButtonBorder); // Right
      
      if (CornersToSkip&1)  //top left
      {
        sumoTFT->drawFastHLine(XPos  , YPos    , CornerRadius, ButtonBorder); // Top
        sumoTFT->drawFastVLine(XPos, YPos  , Height-CornerRadius-1, ButtonBorder); // Left
      }
      else
      {
        drawCircleHelper(XPos+CornerRadius, YPos+CornerRadius    ,CornerRadius,1, ButtonBorder);
      }
      
      if (CornersToSkip&2)  //top right
      {
        sumoTFT->drawFastHLine(XPos+CornerRadius  , YPos    , Width-CornerRadius-1, ButtonBorder); // Top
        sumoTFT->drawFastVLine(XPos+Width-1, YPos  , Height-CornerRadius-1, ButtonBorder); // Right
      }
      else
      {
        drawCircleHelper(XPos+Width-CornerRadius-1, YPos+CornerRadius    , CornerRadius, 2, ButtonBorder);
      }

      if (CornersToSkip&4)  //bottom right
      {
        sumoTFT->drawFastHLine(XPos+CornerRadius  , YPos +Height   , Width-CornerRadius-1, ButtonBorder); // Bottom
        sumoTFT->drawFastVLine(XPos+Width-1, YPos +CornerRadius, Height-CornerRadius-1, ButtonBorder); // Right
      }
      else
      {
        drawCircleHelper(XPos+Width-CornerRadius-1, YPos+Height-CornerRadius-1    , CornerRadius, 4, ButtonBorder);
      }

      if (CornersToSkip&8)  //bottom left
      {
        sumoTFT->drawFastHLine(XPos , YPos +Height, Width-CornerRadius-1, ButtonBorder); // Bottom
        sumoTFT->drawFastVLine(XPos, YPos +CornerRadius, Height-CornerRadius-1, ButtonBorder); // Left
      }
      else
      {
        drawCircleHelper(XPos+CornerRadius, YPos+Height-CornerRadius-1    , CornerRadius, 8, ButtonBorder);
      }
  }
}
// Draw a rounded rectangle
void Adafruit_GFX_AS::drawRoundRect(int16_t x, int16_t y, int16_t w,
		int16_t h, int16_t r, uint16_t color) {
	// smarter version
	drawFastHLine(x+r  , y    , w-2*r, color); // Top
	drawFastHLine(x+r  , y+h-1, w-2*r, color); // Bottom
	drawFastVLine(x    , y+r  , h-2*r, color); // Left
	drawFastVLine(x+w-1, y+r  , h-2*r, color); // Right
	// draw four corners
	drawCircleHelper(x+r    , y+r    , r, 1, color);
	drawCircleHelper(x+w-r-1, y+r    , r, 2, color);
	drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);
	drawCircleHelper(x+r    , y+h-r-1, r, 8, color);
}
Beispiel #5
0
// draw a rounded rectangle
void TFTLCD::drawRoundRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t r,
			   uint16_t color) {
  // smarter version
  drawHorizontalLine(x+r, y, w-2*r, color);
  drawHorizontalLine(x+r, y+h-1, w-2*r, color);
  drawVerticalLine(x, y+r, h-2*r, color);
  drawVerticalLine(x+w-1, y+r, h-2*r, color);
  // draw four corners
  drawCircleHelper(x+r, y+r, r, 1, color);
  drawCircleHelper(x+w-r-1, y+r, r, 2, color);
  drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);
  drawCircleHelper(x+r, y+h-r-1, r, 8, color);
}
Beispiel #6
0
// Draw a rounded rectangle
void graphics_api::drawRoundRect(MWCOORD x, MWCOORD y, MWCOORD w, MWCOORD h, MWCOORD r)
{
    drawHLine(x+r  , y    , w-2*r); // Top
    drawHLine(x+r  , y+h-1, w-2*r); // Bottom
    drawVLine(x    , y+r  , h-2*r); // Left
    drawVLine(x+w-1, y+r  , h-2*r); // Right

    // draw four corners
    drawCircleHelper(x+r    , y+r    , r, 1);	// top left
    drawCircleHelper(x+w-r-1, y+r    , r, 2);	// top right
    drawCircleHelper(x+w-r-1, y+h-r-1, r, 4);	// bottom right
    drawCircleHelper(x+r    , y+h-r-1, r, 8);	// bottom left
}
Beispiel #7
0
// draw a rounded rectangle!
void LCD_DrawRoundRect(u16 x, u16 y, u16 w, u16 h, u16 r, u16 color)
{
  // smarter version
  LCD_DrawFastHLine(x+r  , y    , w-2*r, color); // Top
  LCD_DrawFastHLine(x+r  , y+h-1, w-2*r, color); // Bottom
  LCD_DrawFastVLine(  x    , y+r  , h-2*r, color); // Left
  LCD_DrawFastVLine(  x+w-1, y+r  , h-2*r, color); // Right
  // draw four corners
  drawCircleHelper(x+r    , y+r    , r, 1, color);
  drawCircleHelper(x+w-r-1, y+r    , r, 2, color);
  drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);
  drawCircleHelper(x+r    , y+h-r-1, r, 8, color);
}
Beispiel #8
0
//==============================================================================
// Draw a rounded rectangle
//==============================================================================
void ICACHE_FLASH_ATTR tft_drawRoundRect(unsigned int x, unsigned int y,
                       unsigned int w, unsigned int h, 
                       unsigned int r, unsigned long color) 
{
  // smarter version
  tft_drawFastHLine(x+r  , y    , w-2*r, color); // Top
  tft_drawFastHLine(x+r  , y+h-1, w-2*r, color); // Bottom
  tft_drawFastVLine(x    , y+r  , h-2*r, color); // Left
  tft_drawFastVLine(x+w-1, y+r  , h-2*r, color); // Right
  // draw four corners
  drawCircleHelper(x+r    , y+r    , r, 1, color);
  drawCircleHelper(x+w-r-1, y+r    , r, 2, color);
  drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);
  drawCircleHelper(x+r    , y+h-r-1, r, 8, color);
}
Beispiel #9
0
void TFTLCD::drawCircle(uint16_t x0, uint16_t y0, uint16_t r, 
			uint16_t color) {
  drawPixel(x0, y0+r, color);
  drawPixel(x0, y0-r, color);
  drawPixel(x0+r, y0, color);
  drawPixel(x0-r, y0, color);

  drawCircleHelper(x0, y0, r, 0xF, color);
}