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);
	}
}
Example #2
0
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);
		}
	}
}
Example #3
0
    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);
    }
Example #4
0
// Used to fill circles and roundrects
void graphics_api::fillCircleHelper(MWCOORD x0, MWCOORD y0, MWCOORD r, int cornername, MWCOORD delta)
{
    MWCOORD f     = 1 - r;
    MWCOORD ddF_x = 1;
    MWCOORD ddF_y = -2 * r;
    MWCOORD x     = 0;
    MWCOORD y     = r;

    while (x<y) {			// fill downward stepping x right until 45 degrees
        if (f >= 0) {
            y--;
            ddF_y += 2;
            f     += ddF_y;
        }
        x++;
        ddF_x += 2;
        f     += ddF_x;

        if (cornername & 0x1) {				// right side fill
            drawVLine(x0+x, y0-y, 2*y+1+delta);	// right center top vertical
            drawVLine(x0+y, y0-x, 2*x+1+delta);	// top right center vertical
        }
        if (cornername & 0x2) {				// left side fill
            drawVLine(x0-x, y0-y, 2*y+1+delta);	// left center top vertical
            drawVLine(x0-y, y0-x, 2*x+1+delta);	// top left center vertical
        }
    }
}
Example #5
0
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);
	}
}
//
// 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);
    }
}
Example #7
0
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
}
    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);
    }
Example #9
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
}
Example #10
0
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;
  }
}
Example #11
0
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);
}
Example #12
0
File: MAIN.C Project: ahelwer/UofC
/**
 * 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);
}
Example #13
0
File: UTFT.cpp Project: joyqi/UTFT
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);
}
Example #14
0
File: main.c Project: sphincs/LCD
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);
}
Example #15
0
void drawUsage(double usage)
{
	int lineHeight = getFontHeight();
	int y1 = lcdGetCrsrY();
	int y2 = y1 + lineHeight;
	static const int frameSize = 1;
	BYTE color_frame = 0x00;

	// Colors: green - yellow - red
	static const BYTE colors[] = {
		0x1C, 0x3C, 0x5C, 0x7C, 0x9C, 0xBC, 0xDC, 0xFC,
		0xF8, 0xF4, 0xF0, 0xEC, 0xE8, 0xE4, 0xE0
	};

	drawRectFill(0, y1+frameSize, frameSize, lineHeight-2*frameSize, color_frame);
	drawRectFill(0, y1, 3*frameSize, frameSize, color_frame);
	drawRectFill(0, y2-frameSize, 3*frameSize, frameSize, color_frame);

	drawRectFill(RESX-frameSize, y1+frameSize, frameSize, lineHeight-2*frameSize, color_frame);
	drawRectFill(RESX-3*frameSize, y1, 3*frameSize, frameSize, color_frame);
	drawRectFill(RESX-3*frameSize, y2-frameSize, 3*frameSize, frameSize, color_frame);

	int lines = (RESX - 2*frameSize - 1) * usage + 0.5;
	for(int i = 0; i < lines; ++i)
		drawVLine(frameSize + i, y1 + frameSize, y2 - frameSize - 1, colors[(int)((double)i / (RESX-2*frameSize) * sizeof(colors) + 0.5)]);

	lcdNl();
}
Example #16
0
// 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
}
Example #17
0
void Shape::fillRect(QPointF p1, QPointF p2, QColor c)// p1: topleft, p2: bottomright
{
    for (int x = p1.x(); x < p2.x(); x++) {
        QPointF up = QPointF(x, p1.y());
        QPointF dn = QPointF(x, p2.y());
        drawVLine(up, dn, c, 1);
    }
}
Example #18
0
File: UTFT.cpp Project: joyqi/UTFT
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);
			}
		}
	}
}
Example #19
0
/*
 * 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 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);
}
Example #21
0
void Shape::drawColorBar()
{
    // *** draw color map bar indicating time old / new ***
    // ***x->right, y->down***
    int space       = width()/16;
    int bar_txt_y   = (height()-space)*7/8;
    int bar_txt_h   = 20;
    int bar_txt_w   = width()/8;
    //float rto   = float(maxIndex)/float(maxFrame) >= 1.0 ? 1.0 : float(maxIndex)/float(maxFrame);
    //float rto   = float(maxIndex)/5000. >= 1.0 ? 1.0 : float(maxIndex)/5000.;
    float rto   = float(maxIndex - begin)/MAXFRAMELEN >= 1.0 ? 1.0 : float(maxIndex - begin)/MAXFRAMELEN;
    int bar_h   = /*bar_txt_h*/10;
    int bar_len = width() - 2*(bar_txt_w + space)/**rto*/;

    int bar1frm_w   = bar_len/(maxIndex - begin) < 1 ? 1: bar_len/(maxIndex - begin);

    //int bar_x   = -(bar_txt_y + (bar_txt_h-bar_h+bar_txt_h)/2);
    //int bar_y   = -(halfW - bar_txt_w - space);
    int bar_x   = (width() - bar_len)/2;
    int bar_y   = bar_txt_y + (bar_txt_h-bar_h+bar_txt_h)/2;

//    QRect rect_empty = QRect(QPoint(bar_x+bar_len*rto, bar_y), QSize( bar_len*(1.0-rto), bar_h+1));
    QPointF empty_topleft  = QPoint(bar_x+bar_len*rto, bar_y);
    QPointF empty_botright = QPoint(bar_x+bar_len*rto + bar_len*(1.0-rto), bar_y+bar_h+1);
    fillRect(empty_topleft, empty_botright, QColor(220, 220, 220, 64));

    for(int n = 0; n < bar_len*rto; n+= bar1frm_w) {
        CubicYFColorMap colorMap;
        QColor c = colorMap.cubicYFmap(Shape_COLOR_START, Shape_COLOR_RANGE, 0, bar_len, n);
        //QRect rect(QPoint(bar_x+n, bar_y), QSize(1, bar_h));
        drawVLine(QPoint(bar_x+n, bar_y), QPoint(bar_x+n, bar_y+bar_h), c, bar1frm_w);
    }

//    float   posRto = float(maxFrame)/5000. >= 1.0 ? 1.0 : float(maxFrame)/5000.;
    QColor posColor = QColor(128, 128, 128);
//    drawVLine(QPoint(bar_x+bar_len*posRto, bar_y-2), QPoint(bar_x+bar_len*posRto, bar_y+bar_h+2), posColor, 1);
    drawVLine(QPoint(bar_x+bar_len*maxTimeRatio, bar_y-2), QPoint(bar_x+bar_len*maxTimeRatio, bar_y+bar_h+2), posColor, 1);
    drawVLine(QPoint(bar_x+bar_len*minTimeRatio, bar_y-2), QPoint(bar_x+bar_len*minTimeRatio, bar_y+bar_h+2), posColor, 1);

}
Example #22
0
File: UTFT.cpp Project: joyqi/UTFT
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);
	}
}
Example #23
0
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);
}
Example #24
0
// 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;
        }
    }
}
Example #25
0
void drawLine(int x1, int y1, int x2, int y2, uint8_t color) {
	if(x1==x2) {
		drawVLine(x1, y1, y2, color);
		return;
	}
	if(y1==y2) {
		drawHLine(y1, x1, x2, color);
		return;
	}
	bool xSwap = x1 > x2;
	bool ySwap = y1 > y2;
	if(xSwap){
		x1 = -x1;
		x2 = -x2;
	}
	if(ySwap){
		y1 = -y1;
		y2 = -y2;
	}
	bool mSwap = ABS(x2-x1) < ABS(y2-y1);
	if(mSwap) {
		SWAP(x1,y1);
		SWAP(x2,y2);
	}
	int dx = x2-x1;
	int dy = y2-y1;
	int D = 2*dy - dx;
	
	lcdSetPixel(x1, y1, color);
	int y = y1;
	for(int x = x1+1; x < x2; x++) {
		if(D > 0) {
			y++;
			D += 2 * dy - 2 * dx;
		} else {
			D += 2 * dy;
		}
		int px = mSwap ? y : x;
		if(xSwap) {
			px = -px;
		}
		int py = mSwap ? x : y;
		if(ySwap) {
			py = -py;
		}
		lcdSetPixel(px, py, color);
	}
}
Example #26
0
File: main.c Project: zx96/xt3ds
void renderGridVLine(screen scr, u16 col, color clr)
{
	drawVLine(scr, col, 12, 227, clr);
	drawVLine(scr, col+1, 13, 226, clr);
	drawVLine(scr, col-1, 13, 226, clr);
}
Example #27
0
// Yep, fill a circle
void graphics_api::fillCircle(MWCOORD x0, MWCOORD y0, MWCOORD r)
{
    drawVLine(x0, y0-r, 2*r+1);			// center top vertical
    fillCircleHelper(x0, y0, r, 3, 0);		// left and right vertical sides
}
Example #28
0
File: MAIN.C Project: ahelwer/UofC
void drawBorder(char color) {
	drawVLine(XOFF, YOFF, ROWS*SQWID, color);
	drawVLine(XOFF+(COLUMNS*SQWID), YOFF, ROWS*SQWID, color);
	drawHLine(XOFF, YOFF, COLUMNS*SQWID, color);
	drawHLine(XOFF, YOFF+ROWS*SQWID, COLUMNS*SQWID, color);
}
Example #29
0
void drawRect(uint16 x, uint16 y, uint16 width, uint16 heigh) {
   drawHLine(x, y, width);
   drawHLine(x, y + heigh - 1, width);
   drawVLine(x, y, heigh);
   drawVLine(x + width - 1, y, heigh);
}