

So, for these pixels, we know that Xj = Xi + 1 for both blue and red pixels, Yj = Yi for the blue pixel, and Yj = Yi - 1 for the red pixel. The red pixel then, is at (Xi + 1, Yi - 1). If the current pixel is at (Xi, Yi) then the blue pixel is at (Xi + 1, Yi). To name the next pixel location we use the letter j with the coordinate. To note the location of the current pixel we use the letter i added to the cooridinate names of (X, Y) so that they look like (Xi, Yi). The decision parameter is the combination of the two radius errors and becomes either a negative or positive number. These lengths compared to the circle radius to give a radius error for the two pixel choices. You see that the lengths of the blue and red lines are different than the length of the radius line. To decide which of the two choices is best for the next pixel location, something called a decision parameter is created. The goal is to choose the pixel that is closest to the edge of the real circle. You can see in the picture below that a pixel on the left is plotted and there are two choices for plotting the next pixel, the blue pixel above the line or the red pixel below it. The problem is the real value for Y isn’t always an integer and a we need to decide what integer value would be the best to use for Y. Y = Math.sqrt(RADIUS ** 2 - X ** 2) The Decision Parameter Of course, for every X we can find what Y is using these blocks: let X = 0 You might remember that the circle equation is: X^2 + Y^2 = RADIUS^2 In the case of circles, a circle function might generate Y values from X values that start at the circle’s center an continue until X equals the circle’s radius. The method decides on where to place a pixel based on finding out what screen location is the best guess, or approximation, for a point on a line.
Pixen circle how to#
Bresenham AlgorithmĮarly in the history of computer graphics, a method of deciding how to plot pixels for points on a real line was created. The placement of pixels is limited to the available locations in the rows and columns of the screen. To show a line on the screen generated by a mathematical function, it’s necessary to make a pixel approximation for the real point on a line.

Also, there are no partial, or fractional, pixels to draw part of a line with coordinates that aren’t integer values. In computer graphics there are only so many pixels available to represent shapes and objects.
