// used to do circles and roundrects! void TFTLCD::fillCircleHelper(uint16_t x0, uint16_t y0, uint16_t r, uint8_t cornername, uint16_t delta, uint16_t color) { int16_t f = 1 - r; int16_t ddF_x = 1; int16_t ddF_y = -2 * r; int16_t x = 0; int16_t y = r; while (x<y) { if (f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x; if (cornername & 0x1) { drawVerticalLine(x0+x, y0-y, 2*y+1+delta, color); drawVerticalLine(x0+y, y0-x, 2*x+1+delta, color); } if (cornername & 0x2) { drawVerticalLine(x0-x, y0-y, 2*y+1+delta, color); drawVerticalLine(x0-y, y0-x, 2*x+1+delta, color); } } }
/********************************************************************************************************* ** Function name: drawRectangle ** Descriptions: drawRectangle *********************************************************************************************************/ void ePaper::drawRectangle(int poX, int poY, int len, int width) { drawHorizontalLine(poX, poY, len); drawHorizontalLine(poX, poY+width, len); drawVerticalLine(poX, poY, width); drawVerticalLine(poX + len, poY, width); }
// fill a circle void GL_ST7735::fillCircle(uint8_t x0, uint8_t y0, uint8_t r, uint16_t color) { int16_t f = 1 - r; int16_t ddF_x = 1; int16_t ddF_y = -2 * r; int16_t x = 0; int16_t y = r; drawVerticalLine(x0, y0-r, 2*r+1, color); while (x<y) { if (f >= 0) { y--; ddF_y += 2; f += ddF_y; } x++; ddF_x += 2; f += ddF_x; drawVerticalLine(x0+x, y0-y, 2*y+1, color); drawVerticalLine(x0-x, y0-y, 2*y+1, color); drawVerticalLine(x0+y, y0-x, 2*x+1, color); drawVerticalLine(x0-y, y0-x, 2*x+1, color); } }
void TFT::drawRectangle(INT16U poX, INT16U poY, INT16U length, INT16U width,INT16U color) { drawHorizontalLine(poX, poY, length, color); drawHorizontalLine(poX, poY+width, length, color); drawVerticalLine(poX, poY, width,color); drawVerticalLine(poX + length, poY, width,color); }
// draw a rectangle void TFTLCD::drawRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color) { // smarter version drawHorizontalLine(x, y, w, color); drawHorizontalLine(x, y+h-1, w, color); drawVerticalLine(x, y, h, color); drawVerticalLine(x+w-1, y, h, color); }
void TFT::drawRectangle(unsigned int poX, unsigned int poY, unsigned int length, unsigned int width,unsigned int color) { drawHorizontalLine(poX, poY, length, color); drawHorizontalLine(poX, poY+width-1, length, color); drawVerticalLine(poX, poY, width,color); drawVerticalLine(poX + length-1, poY, width,color); }
void DirectXHook::drawBox(int x, int y, int width, int height, D3DCOLOR BorderColor, D3DCOLOR FillColor) { drawRect(x, y, width, height, FillColor); drawHorizontalLine(x, y, width, BorderColor); drawVerticalLine(x, y, height, BorderColor); drawVerticalLine(x + width, y, height, BorderColor); drawHorizontalLine(x, y + height, width, BorderColor); }
void DungeonUtil::drawRect(int x1, int y1, int x2, int y2, const SelectiveDungeonTile& tile) { orderAscending(x1, x2); orderAscending(y1, y2); drawHorizontalLine(x1, x2, y1, tile); drawHorizontalLine(x1, x2, y2, tile); drawVerticalLine(x1, y1 + 1, y2 - 1, tile); drawVerticalLine(x2, y1 + 1, y2 - 1, tile); }
void showBoxes () { screenRegion * huntRegion = allScreenRegions; while (huntRegion) { drawVerticalLine (huntRegion -> x1, huntRegion -> y1, huntRegion -> y2); drawVerticalLine (huntRegion -> x2, huntRegion -> y1, huntRegion -> y2); drawHorizontalLine (huntRegion -> x1, huntRegion -> y1, huntRegion -> x2); drawHorizontalLine (huntRegion -> x1, huntRegion -> y2, huntRegion -> x2); huntRegion = huntRegion -> next; } }
// 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); }
void drawMovingBlocks(int row, int col, Direction d, int spaces) { int r = TOP_MARGIN + (BLOCK_SIZE + 1)*row + 1; int c = LEFT_MARGIN + (BLOCK_SIZE + 1)*col + 1; int length = 0; switch (d) { case UP: length = (size - row)*(BLOCK_SIZE + 1) - 1; for (int i = 0; i < spaces; i++) { for (int j = 0; j < BLOCK_NUM_MOVES; j++) { shiftRectVertical(r + BLOCK_SPEED, c, BLOCK_SIZE, length, -BLOCK_SPEED); } waitForVblank(); drawHorizontalLine(r + length, c, BLOCK_SIZE, WHITE); } break; case DOWN: r = TOP_MARGIN + 1; length = (row + 1)*(BLOCK_SIZE + 1) - 1; for (int i = 0; i < spaces; i++) { for (int j = 0; j < BLOCK_NUM_MOVES; j++) { shiftRectVertical(r, c, BLOCK_SIZE, length - BLOCK_SPEED, BLOCK_SPEED); } waitForVblank(); drawHorizontalLine(r + BLOCK_SIZE, c, BLOCK_SIZE, WHITE); } break; case LEFT: length = (size - col)*(BLOCK_SIZE + 1) - 1; for (int i = 0; i < spaces; i++) { for (int j = 0; j < BLOCK_NUM_MOVES; j++) { shiftRectHorizontal(r, c + BLOCK_SPEED, length, BLOCK_SIZE, -BLOCK_SPEED); } waitForVblank(); drawVerticalLine(r, c + length, BLOCK_SIZE, WHITE); } break; case RIGHT: c = LEFT_MARGIN + 1; length = (col + 1)*(BLOCK_SIZE + 1) - 1; for (int i = 0; i < spaces; i++) { for (int j = 0; j < BLOCK_NUM_MOVES; j++) { shiftRectHorizontal(r, c, length - BLOCK_SPEED, BLOCK_SIZE, BLOCK_SPEED); } waitForVblank(); drawVerticalLine(r, c + BLOCK_SIZE, BLOCK_SIZE, WHITE); } break; } }
void drawBoard() { int length = (BLOCK_SIZE + 1)*size + 1; for (int i = 0; i <= size; i++) { drawHorizontalLine(TOP_MARGIN + (BLOCK_SIZE + 1)*i, LEFT_MARGIN, length, WHITE); drawVerticalLine(TOP_MARGIN, LEFT_MARGIN + (BLOCK_SIZE + 1)*i, length, WHITE); } }
void TFT::fillCircle(int poX, int poY, int r,INT16U color) { int x = -r, y = 0, err = 2-2*r, e2; do { drawVerticalLine(poX-x, poY-y, 2*y, color); drawVerticalLine(poX+x, poY-y, 2*y, color); e2 = err; if (e2 <= y) { err += ++y*2+1; if (-x == y && e2 <= x) e2 = 0; } if (e2 > x) err += ++x*2+1; } while (x <= 0); }
void DungeonUtil::drawFilledRect(int x1, int y1, int x2, int y2, const SelectiveDungeonTile& innerTile, const SelectiveDungeonTile& borderTile) { orderAscending(x1, x2); orderAscending(y1, y2); // draw the interior: shamelessly stolen from the other drawFilledRect() for(int j = y1 + 1; j < y2; j++) { for(int i = x1 + 1; i < x2; i++) { mDungeon->setTile(i, j, innerTile); } } // draw the border: stolen from drawRect() drawHorizontalLine(x1, x2, y1, borderTile); drawHorizontalLine(x1, x2, y2, borderTile); drawVerticalLine(x1, y1, y2, borderTile); drawVerticalLine(x2, y1, y2, borderTile); }
void testfastlines(uint16_t color1, uint16_t color2) { uint16_t x,y; fillScreen(BLACK); for ( y=0; y < height(); y+=5) { drawHorizontalLine(0, y, width(), color1); } for ( x=0; x < width(); x+=5) { drawVerticalLine(x, 0, height(), color2); } }
// // _drawSampledIndicator() // void DrawingCanvas:: _drawSampledIndicator(double x, double y){ double offset = DrawingMetrics::getIconRadius(); double padding = 1.0*DrawingMetrics::getScalingFactor(); double symbolDiameter = 2.5*DrawingMetrics::getScalingFactor(); double symbolRadius = 0.5*symbolDiameter; double ax = x - offset - padding - symbolRadius; double ay = y - offset + symbolRadius; drawHorizontalLine (ay, ax - symbolRadius , ax + symbolRadius ); drawVerticalLine (ax, ay - symbolRadius , ay + symbolRadius ); }
void SettingsSetModeScreen::render() { uint16_t setcolor = color565(35,142,35); fillScreen(BLACK); makeRectangle(5,5, 230,310, setcolor, 2); drawPgmString(225,50 , PSTR("SET MODE"), setcolor, BLACK, 2); makeRectangle(35, 20, 35, 280, WHITE, 3); makeRectangle(85, 20, 35, 280, WHITE, 3); makeRectangle(135, 20, 35, 280, WHITE, 3); makeRectangle(185, 20, 35, 280, WHITE, 3); //drawVerticalLine(0,50, 239, BLACK, 4); drawVerticalLine(0, 270, 239, BLACK, 4); drawPgmString(200, 55, PSTR("1. SCHEDULE"), WHITE, BLACK, 2); drawPgmString(150, 55, PSTR("2. MOTION"), WHITE, BLACK, 2); drawPgmString(100, 55, PSTR("3. COMBINATION"), WHITE, BLACK, 2); drawPgmString(50, 55, PSTR("4. VACATION"), WHITE, BLACK, 2); // makeRectangle(10, 60, 20, 160, GREEN, 3); // drawString( 15, 100, "CONFIRM", setcolor, WHITE, 2); }
// fill a circle void TFTLCD::fillCircle(uint16_t x0, uint16_t y0, uint16_t r, uint16_t color) { writeRegister(TFTLCD_ENTRY_MOD, 0x1030); drawVerticalLine(x0, y0-r, 2*r+1, color); fillCircleHelper(x0, y0, r, 3, 0, color); }
void SettingsSetTimeScreen::render() { uint16_t setcolor = color565(35,142,35); fillScreen(BLACK); makeRectangle(5,5, 230,310, setcolor, 3); drawPgmString(225,50 , PSTR("SET TIME"), setcolor, BLACK, 2); drawVerticalLine(0,160,235, setcolor, 3); makeRectangle(190, 30, 30,100, WHITE, 3); makeRectangle(190, 190, 30, 100, WHITE, 3); drawPgmString(195, 60, PSTR("DATE"), WHITE, BLACK, 2); drawPgmString(195, 220, PSTR("TIME"), WHITE , BLACK, 2); drawPgmString(175, 10, PSTR("MONTH"), WHITE, BLACK, 1); drawPgmString(175, 63, PSTR("DAY"), WHITE, BLACK, 1); drawPgmString(175, 107, PSTR("YEAR"), WHITE, BLACK, 1); drawPgmString(175, 165, PSTR("HOUR"), WHITE, BLACK, 1); drawPgmString(175, 213, PSTR("MINUTE"), WHITE, BLACK, 1); drawPgmString(175, 276, PSTR("AM/PM"), WHITE, BLACK, 1); makeRectangle(135, 10, 35, 33, BLUE, 3); makeRectangle(135, 63, 35, 34, BLUE, 3); makeRectangle(135, 117, 35, 33, BLUE, 3); makeRectangle(135, 170, 35, 33, BLUE, 3); makeRectangle(135, 223, 35, 34, BLUE, 3); makeRectangle(135, 277, 35, 33, BLUE, 3); drawChar(110, 45, '/', WHITE, BLACK, 2); drawChar(110, 95, '/', WHITE, BLACK, 2); drawChar(110, 205, ':', WHITE, BLACK, 2); drawHorizontalLine(105, 0, 319, WHITE, 3); drawHorizontalLine(125, 0, 319, WHITE, 3); makeRectangle(60, 10, 35, 33, RED, 3); makeRectangle(60, 63, 35, 34, RED, 3); makeRectangle(60, 117, 35, 33, RED, 3); makeRectangle(60, 170, 35, 33, RED, 3); makeRectangle(60, 223, 35, 34, RED, 3); makeRectangle(60, 277, 35, 33, RED, 3); drawChar(150, 20, '+', BLUE, BLACK, 2); drawChar(150, 73, '+', BLUE, BLACK, 2); drawChar(150, 127, '+', BLUE, BLACK, 2); drawChar(150, 180, '+', BLUE, BLACK, 2); drawChar(150, 233, '+', BLUE, BLACK, 2); drawChar(150, 287, '+', BLUE, BLACK, 2); drawChar(75, 20, '-', RED, BLACK, 2); drawChar(75, 73, '-', RED, BLACK, 2); drawChar(75, 127, '-', RED, BLACK, 2); drawChar(75, 180, '-', RED, BLACK, 2); drawChar(75, 233, '-', RED, BLACK, 2); drawChar(75, 287, '-', RED, BLACK, 2); // makeRectangle(10, 20, 20, 120, GREEN, 3); // drawString(12, 30, "CONFIRM", BLACK, WHITE, 2); renderMonth(); renderDay(); renderYear(); renderHour(); renderMinute(); renderAMPM(); }
void BresLine(glm::vec2 p1, glm::vec2 p2, GLubyte rgb[]) { if (p1.x == p2.x) { drawVerticalLine(p1,p2,rgb); } else if (p1.y == p2.y) { drawHorizontalLine(p1,p2,rgb); } else if (p1.x == p1.y && p2.x == p2.y) { drawDiagonalLine(p1,p2,rgb); } double m = (p2.y - p1.y) / (p2.x - p1.x); bool slope = m < 0; m = abs(m); if (m > 1) { std::swap(p1.x, p1.y); std::swap(p2.x, p2.y); } if (p1.x > p2.x) { std::swap(p1,p2); } int x = p1.x, y = p1.y; int dx = p2.x - p1.x, dy = p2.y - p1.y; int dT = 2 * (dy-dx); int dS = 2 * dy; int d = 2 * (dy - dx); if (slope) { x = p2.x, y = p2.y; dx = p2.x - p1.x, dy = p1.y - p2.y; dT = 2 * (dy-dx); dS = 2 * dy; d = 2 * (dy - dx); while (x > p1.x) { x--; if (d < 0) { d = d + dS; } else { y++; d = d + dT; } if (m > 1) { setPixel(y,x,rgb); } else { setPixel(x, y, rgb); } } } else { while (x < p2.x) { x++; if (d < 0) { d = d + dS; } else { y++; d = d + dT; } if (m > 1) { setPixel(y,x,rgb); } else { setPixel(x, y, rgb); } } } }
/// /// Draw a vertical line a the position of /// the best solution. /// For the getDrawSolution() code, see OptParser, --ps. /// void OneMinusClPlot::drawSolutions() { m_mainCanvas->cd(); m_mainCanvas->Update(); float ymin = gPad->GetUymin(); float ymax = gPad->GetUymax(); float xmin = gPad->GetUxmin(); float xmax = gPad->GetUxmax(); int iDrawn = 0; for ( int i = 0; i < scanners.size(); i++ ) { if ( scanners[i]->getDrawSolution()==0 ) continue; if ( arg->debug ) cout << "OneMinusClPlot::drawSolutions() : adding solution for scanner " << i << " ..." << endl; float xCentral = scanners[i]->getScanVar1Solution(arg->plotsoln[i]); float xCLmin = scanners[i]->getCLinterval(arg->plotsoln[i]).min; float xCLmax = scanners[i]->getCLinterval(arg->plotsoln[i]).max; int color = scanners[i]->getTextColor(); // draw vertical lines at central value and // upper/lower errors if ( ! arg->isQuickhack(19) ) { drawVerticalLine(xCentral, color, kSolid); if ( ! arg->isQuickhack(20) ) { drawVerticalLine(xCLmin, color, kDashed); drawVerticalLine(xCLmax, color, kDashed); } } // draw text box with numerical values after the lines, // so that it doesn't get covered // compute y position of the printed central value float yNumberMin = 0.6 - 0.13*(float)iDrawn; float yNumberMax = yNumberMin+0.1; if ( arg->plotlog ) { float yNumberMinFirst = 0.1; if ( arg->isQuickhack(1) ) yNumberMinFirst = 0.175; yNumberMin = yNumberMinFirst / pow(3.0, iDrawn); // move down by a constant shift on log scale yNumberMax = yNumberMin*2.; } // if printsoly option then move a bit if ( arg->printSolY > 0. ) { yNumberMin += arg->printSolY; yNumberMax += arg->printSolY; } // compute x position of the printed central value float xNumberMin, xNumberMax; if ( scanners[i]->getDrawSolution()==1 ) { xNumberMin = xCentral+(xmax-xmin)*0.20; // draw at central value xNumberMax = xCentral+(xmax-xmin)*0.0; } else if ( scanners[i]->getDrawSolution()==2 ) { xNumberMin = xCLmin+(xmax-xmin)*0.0; // draw at left CL boundary xNumberMax = xCLmin+(xmax-xmin)*0.25; } else if ( scanners[i]->getDrawSolution()==3 ) { xNumberMin = xCLmax+(xmax-xmin)*0.0; // draw at right CL boundary xNumberMax = xCLmax+(xmax-xmin)*0.25; } else if ( scanners[i]->getDrawSolution()==4 ) { xNumberMin = xCLmin+(xmax-xmin)*-0.20; // draw a little left of the left CL boundary xNumberMax = xCLmin+(xmax-xmin)*0.0; } else { cout << "OneMinusClPlot::drawSolutions() : ERROR : --ps code "; cout << scanners[i]->getDrawSolution() << " not found! Use [0,1,2,3]." << endl; continue; } // move number a bit to the left so it doesn't cover the right plot border anymore if ( arg->isQuickhack(4) ) { xNumberMin -= (xmax-xmin)*0.225; xNumberMax -= (xmax-xmin)*0.225; } // if print solution argument given then over write if ( arg->printSolX > 0. ) { float diff = xNumberMax - xNumberMin; xNumberMin = arg->printSolX; xNumberMax = arg->printSolX + diff; } TPaveText *t1 = new TPaveText(xNumberMin, yNumberMin, xNumberMax, yNumberMax, "BR"); t1->SetBorderSize(0); t1->SetFillStyle(0); t1->SetTextAlign(13); t1->SetTextFont(font); t1->SetTextColor(color); if ( isAngle(scanners[i]->getScanVar1()) ){ xCentral = RadToDeg(xCentral); xCLmin = RadToDeg(xCLmin); xCLmax = RadToDeg(xCLmax); } Rounder myRounder(arg, xCLmin, xCLmax, xCentral); int d = myRounder.getNsubdigits(); float xCentralRd = myRounder.central(); if ( arg->isQuickhack(3) ) xCentralRd += 180.; ///< see documentation of --qh option in OptParser.cpp t1->AddText(Form("%.*f^{+%.*f}_{#font[122]{-}%.*f}", d, xCentralRd, d, myRounder.errPos(), d, myRounder.errNeg()))->SetTextSize(labelsize); t1->Draw(); iDrawn += 1; } }