Beispiel #1
0
void Circle::Draw(QImage &img)
{
    int error = -Radius;
    int x = Radius;
    int y = 0;

    // The following while loop may be altered to 'while (x > y)' for a
    // performance benefit, as long as a call to 'plot4points' follows
    // the body of the loop. This allows for the elimination of the
    // '(x != y)' test in 'plot8points', providing a further benefit.
    //
    // For the sake of clarity, this is not shown here.
    while (x >= y)
    {
      plot8points(Centre.x(), Centre.y(), x, y, lineColor ,img);

      error += y;
      ++y;
      error += y;

      // The following test may be implemented in assembly language in
      // most machines by testing the carry flag after adding 'y' to
      // the value of 'error' in the previous step, since 'error'
      // nominally has a negative value.
      if (error >= 0)
      {
        error -= x;
        --x;
        error -= x;
      }
    }
}
Beispiel #2
0
/**
 * Midpoint circle algorithm:
 * http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
 */
void fgui_draw_circle(uint16_t cx, uint16_t cy, uint16_t radius, uint32_t color)
{
	int16_t error = -radius;
	int16_t x = radius;
	int16_t y = 0;

	// The following while loop may altered to 'while (x > y)' for a
	// performance benefit, as long as a call to 'plot4points' follows
	// the body of the loop. This allows for the elimination of the
	// '(x != y)' test in 'plot8points', providing a further benefit.
	//
	// For the sake of clarity, this is not shown here.
	while (x >= y) {
		plot8points(cx, cy, x, y, color);

		error += y;
		y++;
		error += y;

		// The following test may be implemented in assembly language in
		// most machines by testing the carry flag after adding 'y' to
		// the value of 'error' in the previous step, since 'error'
		// nominally has a negative value.
		if (error >= 0) {
			error -= x;
			x--;
			error -= x;
		}
	}
}
Beispiel #3
0
/*
Example: lcd.createCircle(30, 30, 30, 1);
cx and cy mark the distance from the origin point.
*/
void easyT6963::drawCircle(uint8_t cx, uint8_t cy, uint8_t radius, bool color){
	int error = -radius;
	uint8_t x = radius;
	uint8_t y = 0;
	while (x >= y){
		plot8points(cx, cy, x, y, color);
		error += y;
		++y;
		error += y;
		if (error >= 0){
			--x;
			error -= x;
			error -= x;
		}
	}
}
Beispiel #4
0
// Draw circle using Bresenham's midpoint circle algorithm
// From http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
void Draw_Circle(int x0, int y0, int radius, int borderColor) {
    int error = -radius;
    int x = radius;
    int y = 0;

    while (x >= y) {
        plot8points(x0, y0, x, y, borderColor);
        error += y;
        ++y;
        error += y;
        if (error >= 0) {
            error -= x;
            --x;
            error -= x;
        }
    }
}
void T6963::createCircle(int cx, int cy, int radius) //cx and cy mark the distance from the origin point.
{
	int error = -radius;
	int x = radius;
	int y = 0;
 
	while (x >= y){
		plot8points(cx, cy, x, y);
 
		error += y;
		++y;
		error += y;
 
		if (error >= 0){
			--x;
			error -= x;
			error -= x;
		}
	}
}
Beispiel #6
0
void Circle::drawCircle(QImage *img)
{
    QPoint startPoint(controlPoints[0]), endPoint(controlPoints[1]);
    int cx(startPoint.x()), cy(endPoint.y());
    int radius = round(sqrt(pow(endPoint.x() - startPoint.x(), 2) + pow(endPoint.y() - startPoint.y(), 2)));
    int error = -radius;
    int x = radius;
    int y = 0;

    while (x >= y) {
        plot8points(cx, cy, x, y, img, fill);

        error += y;
        ++y;
        error += y;

        if (error >= 0) {
            --x;
            error -= x;
            error -= x;
        }
    }
}