So, we have a DrawPoint (x, y) function that draws a point, we need to draw a certain number of points that will look like a circle. How to create one for(i=0; i<numberOfIterations; i++)for drawing a circle?
for(i=0; i<numberOfIterations; i++)
// (cx, cy) is the center of the circle // r is the circle radius // the smaller the granularity, the better the circle will look // to draw only numberOfIterations points, granularity // should be 2*pi / numberOfIterations for(i=0; i<2*pi; i+=granularity) DrawPoint(cx + r*sin(i), cy + r*cos(i));
One of the best algorithms for getting a decent circle is the Bresenham circle algorithm, also called the Midpoint circle algorithm .
, , , for(;;), .
for(;;)
Source: https://habr.com/ru/post/1781764/More articles:How to save a map and create a graph with BFS in Ruby - ruby | fooobar.comWhat a nice, thread-safe way to pass error strings from the C shared library - c ++остановить каскадное свойство фильтра CSS - htmlPreventing a mouse click event when starting items at a specific z-index - javascriptHow to create different user roles in Rails3 using Devise? - authenticationWhere can I find the HBase cascade module for hbase-0.89.20100924 + 28? - hbaseSilverlight: button template with texttrimming disabled - buttonAnti-Alias vs High Density Screen? - graphicsEasy way to add info buttons (?) - javascriptHelp me understand these general method warnings - javaAll Articles