virtual void onDrawContent(SkCanvas* canvas) { SkMSec now = SampleCode::GetAnimTime(); if (fNow != now) { fNow = now; this->randPts(); this->inval(NULL); } // fProcIndex = test0(fPts, &fClip); SkPaint paint, paint1; drawVLine(canvas, fClip.fLeft + SK_ScalarHalf, paint); drawVLine(canvas, fClip.fRight - SK_ScalarHalf, paint); drawHLine(canvas, fClip.fTop + SK_ScalarHalf, paint); drawHLine(canvas, fClip.fBottom - SK_ScalarHalf, paint); paint.setColor(SK_ColorLTGRAY); canvas->drawRect(fClip, paint); paint.setAntiAlias(true); paint.setColor(SK_ColorBLUE); paint.setStyle(SkPaint::kStroke_Style); // paint.setStrokeWidth(SkIntToScalar(3)); paint.setStrokeCap(SkPaint::kRound_Cap); paint1.setAntiAlias(true); paint1.setColor(SK_ColorRED); paint1.setStyle(SkPaint::kStroke_Style); gProcs[fProcIndex](fPts, fClip, canvas, paint, paint1); this->inval(NULL); }
void ITDB02::drawRoundRect(int x1, int y1, int x2, int y2) { int tmp; if (x1>x2) { tmp=x1; x1=x2; x2=tmp; } if (y1>y2) { tmp=y1; y1=y2; y2=tmp; } if ((x2-x1)>4 && (y2-y1)>4) { drawPixel(x1+1,y1+1); drawPixel(x2-1,y1+1); drawPixel(x1+1,y2-1); drawPixel(x2-1,y2-1); drawHLine(x1+2, y1, x2-x1-4); drawHLine(x1+2, y2, x2-x1-4); drawVLine(x1, y1+2, y2-y1-4); drawVLine(x2, y1+2, y2-y1-4); } }
void Grid::draw() { int i, j; int vCountNum = round(_vCount*MAX(1, _width*_resolution)); int hCountNum = round(_hCount*MAX(1, _height*_resolution)); int vColors = MAX(1, round(_vColors * 255*_colorRes)); int hColors = MAX(1, round(_hColors * 255*_colorRes)); for (i=0; i<vCountNum; i=i+2) { drawVLine(i, vCountNum, vColors); } for (i=0; i<hCountNum; i=i+2) { drawHLine(i, hCountNum, hColors); } for (i=1; i<vCountNum; i=i+2) { drawVLine(i, vCountNum, vColors); } for (i=1; i<hCountNum; i=i+2) { drawHLine(i, hCountNum, hColors); } }
void ITDB02::fillRect(int x1, int y1, int x2, int y2) { int tmp; if (x1>x2) { tmp=x1; x1=x2; x2=tmp; } if (y1>y2) { tmp=y1; y1=y2; y2=tmp; } if (orient==PORTRAIT) { for (int i=0; i<((y2-y1)/2)+1; i++) { drawHLine(x1, y1+i, x2-x1); drawHLine(x1, y2-i, x2-x1); } } else { for (int i=0; i<((x2-x1)/2)+1; i++) { drawVLine(x1+i, y1, y2-y1); drawVLine(x2-i, y1, y2-y1); } } }
void renderGridHLine(screen scr, u16 row, color clr) { u16 rowStart = (0.5 * scr.w) - 107; u16 rowEnd = (0.5 * scr.w) + 107; drawHLine(scr, row, rowStart, rowEnd, clr); drawHLine(scr, row+1, rowStart+1, rowEnd-1, clr); drawHLine(scr, row-1, rowStart+1, rowEnd-1, clr); }
/* * Draws the F-pentomino (also known as R-pentomino). * During this early research, Conway discovered that the F-pentomino * (which he called the "R-pentomino") failed to stabilize in a small * number of generations. * In fact, it takes 1103 generations to stabilize, by which time it has * a population of 116 and has fired six escaping gliders * (these were the first gliders ever discovered). * * The initial state is like that: * * ** * ** * * * * http://www.conwaylife.com/wiki/F-pentomino */ int drawFpentomino(int intX, int intY) { drawHLine(intX, intY, 2, FG_color, fb); drawHLine(intX - 1, intY + 1, 2, FG_color, fb); drawHLine(intX, intY + 2, 1, FG_color, fb); return 0; }
/* * Draws the initial state that develops into the period 3 oscillator * called "pulsar". * The "pulsar" is the most common period 3 oscillator. * * The initial state is like that: * * ***** * (empty line) * *** * (empty line) * ***** * * http://www.conwaylife.com/wiki/Pulsar */ int drawPulsar(int intX, int intY) { drawHLine(intX, intY, 5, FG_color, fb); drawHLine(intX + 1, intY + 2, 3, FG_color, fb); drawHLine(intX, intY + 4, 5, FG_color, fb); return 0; }
/* * Draws the Acorn * It takes 5206 generations to generate 633 cells including 13 escaped gliders * * The initial state is like that: * * * * * * ** *** * * http://www.conwaylife.com/wiki/Acorn */ int drawAcorn(int intX, int intY) { drawHLine(intX, intY, 1, FG_color, fb); drawHLine(intX + 2, intY + 1, 1, FG_color, fb); drawHLine(intX - 1, intY + 2, 2, FG_color, fb); drawHLine(intX + 3, intY + 2, 3, FG_color, fb); return 0; }
void UTFT::fillCircle(int x, int y, int radius) { for(int y1=-radius; y1<=0; y1++) for(int x1=-radius; x1<=0; x1++) if(x1*x1+y1*y1 <= radius*radius) { drawHLine(x+x1, y+y1, 2*(-x1)); drawHLine(x+x1, y-y1, 2*(-x1)); break; } }
// // Draw a box in the image in the frame of width, height // starting at startx, starty, and of thickness pixels // void drawBox(frame_t *frame, int startx, int starty, int width, int height, int thickness, unsigned char L, unsigned char A, unsigned char B) { int i; for (i=0;i<thickness;i++) { drawVLine(frame, startx+i, starty, height, L, A, B); drawVLine(frame, startx+width-i, starty, height, L, A, B); drawHLine(frame, startx, starty+i, width, L, A, B); drawHLine(frame, startx, starty+height-i, width, L, A, B); } }
void Terminal::drawBox(int x0, int y0, int x1, int y1, Color c) { fill(x0, y0, x1, y1, black); drawHLine(x0 + 1, x1 - 1, y0, c); drawHLine(x0 + 1, x1 - 1, y1, c); drawVLine(y0 + 1, y1 - 1, x0, c); drawVLine(y0 + 1, y1 - 1, x1, c); write(218, x0, y0, c); // nw corner write(191, x1, y0, c); // ne corner write(192, x0, y1, c); // sw corner write(217, x1, y1, c); // se corner }
// 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 }
void COCOS2DXGraphics::drawRectangle(const Rectangle& rectangle) { int x1 = rectangle.x; int x2 = rectangle.x + rectangle.width - 1; int y1 = rectangle.y; int y2 = rectangle.y + rectangle.height - 1; drawHLine(x1, y1, x2); drawHLine(x1, y2, x2); drawVLine(x1, y1, y2); drawVLine(x2, y1, y2); }
void SSD1306::drawRectangle(uint8_t row, uint8_t col, int8_t width, int8_t height, uint8_t thickness) { if(!thickness || !width || !height) return; while((thickness--) > 0 && width > 0 && height > 0) { drawHLine(row, col, width); drawVLine(row, col + width, height); drawHLine(row + height, col + width, -width); drawVLine(row + height, col, -height); row++;col++;width-=2;height-=2; } }
void UTFT::drawRect(int x1, int y1, int x2, int y2) { if (x1>x2) { swap(int, x1, x2); } if (y1>y2) { swap(int, y1, y2); } drawHLine(x1, y1, x2-x1); drawHLine(x1, y2, x2-x1); drawVLine(x1, y1, y2-y1); drawVLine(x2, y1, y2-y1); }
// Draw a 3d rounded rectangle void graphics_api::draw3dRoundRect(MWCOORD x, MWCOORD y, MWCOORD w, MWCOORD h, MWCOORD r, MWCOLORVAL crTop, MWCOLORVAL crBottom) { stroke(crTop); drawHLine(x+r , y , w-2*r); // Top drawVLine(x , y+r , h-2*r); // Left draw3dCircleHelper(x+r , y+r , r, 1, crTop, crTop); // top left stroke(crBottom); drawHLine(x+r , y+h-1, w-2*r); // Bottom drawVLine(x+w-1, y+r , h-2*r); // Right draw3dCircleHelper(x+w-r-1, y+h-r-1, r, 4, crBottom, crBottom); // bottom right draw3dCircleHelper(x+r , y+h-r-1, r, 8, crTop, crBottom); // bottom left draw3dCircleHelper(x+w-r-1, y+r , r, 2, crTop, crBottom); // top right }
void main() { lcdInit(); spiOn(); spiOff(); sendByte(out); sendArray(array); lcdOn(); lcdOff(); sendBuffer(); sendPart(3, 7, LCD_Buffer); clear(); clearPart(5, 76); clearPartColor(5, 76, clBLACK); setPenColor(clBLACK); setBackColor(clWHITE); delay_nsek(40); scsOn(); scsOff(); i = getValue(LCD_Buffer, 23, 266); setValue(LCD_Buffer, 23, 266, 0x3F); setCharge(); resetCharge(); drawPixel(5, 5, LCD_Buffer); drawVLine(5, 5, 5, LCD_Buffer); drawHLine(5, 5, 5, LCD_Buffer); drawLine(5, 5, 55, 55, LCD_Buffer); drawRect(5, 5, 55, 55, LCD_Buffer); drawFillRect(5, 5, 55, 55, clWHITE, LCD_Buffer); drawCircle(10, 10, 5, LCD_Buffer); }
void WirechamberCalibrator::drawWires(Side s, AxisDirection p, TVirtualPad* C, Int_t color, AxisDirection onAxis) const { smassert(C); smassert(s<=WEST && p<=Y_DIRECTION); for(std::vector<double>::const_iterator it = wirePos[s][p].begin(); it != wirePos[s][p].end(); it++) if(onAxis==X_DIRECTION) drawVLine(*it,C,color); else drawHLine(*it,C,color); }
/** * drawGrid * Draws a grid on the screen according to global constants in the specified * color. **/ void drawGrid(char color){ int i; for (i=1; i<COLUMNS; i++) //draws all vertical lines drawVLine(XOFF+(i*SQWID), YOFF+1, ROWS*SQWID-1, color); for (i=1; i<ROWS; i++) //draws all horizontal lines drawHLine(XOFF+1, YOFF+(i*SQWID), COLUMNS*SQWID-1, color); }
int paintTriangularCell(int intPosX, int intPosY, unsigned short color, unsigned short* framebuffer) { if ((intPosX % 2 == 0 and intPosY % 2 == 0) or (intPosX % 2 != 0 and intPosY % 2 != 0)) { drawHLine(intPosX -1, intPosY, 3, color, framebuffer); drawHLine(intPosX, intPosY + 1, 1, color, framebuffer); } else if ((intPosX % 2 != 0 and intPosY % 2 == 0) or (intPosX % 2 == 0 and intPosY % 2 != 0)) { drawHLine(intPosX, intPosY, 1, color, framebuffer); drawHLine(intPosX - 1, intPosY + 1, 3, color, framebuffer); } return 0; }
/** * Draws a square at the specified location and with the specified color using * global constants for offsets and such. **/ void drawSquare(int x, int y, char color) { x = x*SQWID+XOFF+1; y = y*SQWID+YOFF+1; int i; for (i=1; i<SQWID-2; i++) { drawHLine(x+1,y+i,SQWID-3,color); } }
void UTFT::fillRect(int x1, int y1, int x2, int y2) { if (x1>x2) { swap(int, x1, x2); } if (y1>y2) { swap(int, y1, y2); } if (display_transfer_mode==16) { cbi(P_CS, B_CS); setXY(x1, y1, x2, y2); sbi(P_RS, B_RS); _fast_fill_16(fch,fcl,((long(x2-x1)+1)*(long(y2-y1)+1))); sbi(P_CS, B_CS); } else if ((display_transfer_mode==8) and (fch==fcl)) { cbi(P_CS, B_CS); setXY(x1, y1, x2, y2); sbi(P_RS, B_RS); _fast_fill_8(fch,((long(x2-x1)+1)*(long(y2-y1)+1))); sbi(P_CS, B_CS); } else { if (orient==PORTRAIT) { for (int i=0; i<((y2-y1)/2)+1; i++) { drawHLine(x1, y1+i, x2-x1); drawHLine(x1, y2-i, x2-x1); } } else { for (int i=0; i<((x2-x1)/2)+1; i++) { drawVLine(x1+i, y1, y2-y1); drawVLine(x2-i, y1, y2-y1); } } } }
void Terminal::drawBoxWithTitle(int x0, int y0, int x1, int y1, Color const& boxColor, std::string const& title, Color const& titleColor) { drawBox(x0, y0, x1, y1, boxColor); writeCenter(title, y0 + 1, titleColor); drawHLine(x0 + 1, x1 - 1, y0 + 2, boxColor); write(195, x0, y0 + 2); write(180, x1, y0 + 2); }
/* * draw3dBox * * TTTTTTTTTTTTTTB * T B * T B * BBBBBBBBBBBBBBB */ void graphics_api::draw3dBox(MWCOORD x, MWCOORD y, MWCOORD w, MWCOORD h, MWCOLORVAL crTop, MWCOLORVAL crBottom) { //MoveToEx( hDC, x, y+h-2, NULL); //LineTo( hDC, x, y); // left side //MoveToEx( hDC, x, y, NULL); //LineTo( hDC, x+w-1, y); // top side stroke(crTop); drawVLine(x, y+1, h-2); // left side drawHLine(x, y, w-1); // top side //MoveToEx( hDC, x+w-1, y, NULL); //LineTo( hDC, x+w-1, y+h-1); // right side //LineTo( hDC, x-1, y+h-1); // bottom side stroke(crBottom); drawVLine(x+w-1, y, h-1); // right side drawHLine(x, y+h-1, w); // bottom side }
void printHeader() { int lineHeight = getFontHeight(); BYTE color = 0x00; lcdMoveCrsr(3, 2); lcdPrintln("System Information"); lcdMoveCrsr(0, -2); drawHLine(lineHeight+3, 0, RESX-1, color); lcdNl(); }
void drawRect(int x1, int y1, int x2, int y2){ int tmp; if (x1>x2) { tmp=x1; x1=x2; x2=tmp; } if (y1>y2) { tmp=y1; y1=y2; y2=tmp; } drawHLine(x1, y1, x2-x1); drawHLine(x1, y2, x2-x1); drawVLine(x1, y1, y2-y1); drawVLine(x2, y1, y2-y1); }
void UTFT::fillRoundRect(int x1, int y1, int x2, int y2) { if (x1>x2) { swap(int, x1, x2); } if (y1>y2) { swap(int, y1, y2); } if ((x2-x1)>4 && (y2-y1)>4) { for (int i=0; i<((y2-y1)/2)+1; i++) { switch(i) { case 0: drawHLine(x1+2, y1+i, x2-x1-4); drawHLine(x1+2, y2-i, x2-x1-4); break; case 1: drawHLine(x1+1, y1+i, x2-x1-2); drawHLine(x1+1, y2-i, x2-x1-2); break; default: drawHLine(x1, y1+i, x2-x1); drawHLine(x1, y2-i, x2-x1); } } } }
void UTFT::drawRoundRect(int x1, int y1, int x2, int y2) { if (x1>x2) { swap(int, x1, x2); } if (y1>y2) { swap(int, y1, y2); } if ((x2-x1)>4 && (y2-y1)>4) { drawPixel(x1+1,y1+1); drawPixel(x2-1,y1+1); drawPixel(x1+1,y2-1); drawPixel(x2-1,y2-1); drawHLine(x1+2, y1, x2-x1-4); drawHLine(x1+2, y2, x2-x1-4); drawVLine(x1, y1+2, y2-y1-4); drawVLine(x2, y1+2, y2-y1-4); } }
void drawCommonThings(int charging) { lcdClear(); lcdNl(); lcdPrintln(" Battery status"); // Draw battery frame. drawHLine(63, 14, 112, 0b00000011); drawHLine(93, 14, 112, 0b00000011); drawVLine(14, 63, 93, 0b00000011); drawVLine(112, 63, 73, 0b00000011); drawVLine(112, 83, 93, 0b00000011); drawHLine(73, 112, 116, 0b00000011); drawHLine(83, 112, 116, 0b00000011); drawVLine(116, 73, 83, 0b00000011); // Print if not charging. lcdSetCrsr(0, 40); if(!charging){ lcdPrintln(" (not charging)"); }; lcdSetCrsr(0, 30); }
// Draw a line using fast vertical or horizontal driver routine, else Bresenham // always draws last point at x1,y1 void graphics_api::drawLine(MWCOORD x0, MWCOORD y0, MWCOORD x1, MWCOORD y1) { if (x0 == x1) { if (y0 > y1) swap(y0, y1); drawVLine(x0, y0, y1 - y0 + 1); return; } else if(y0 == y1) { if (x0 > x1) swap(x0, x1); drawHLine(x0, y0, x1 - x0 + 1); return; } MWCOORD steep = abs(y1 - y0) > abs(x1 - x0); if (steep) { swap(x0, y0); swap(x1, y1); } if (x0 > x1) { swap(x0, x1); swap(y0, y1); } MWCOORD dx, dy; dx = x1 - x0; dy = abs(y1 - y0); MWCOORD err = dx / 2; MWCOORD ystep; if (y0 < y1) { ystep = 1; } else { ystep = -1; } for (; x0<=x1; x0++) { if (steep) { drawPoint(y0, x0); } else { drawPoint(x0, y0); } err -= dy; if (err < 0) { y0 += ystep; err += dx; } } }