Home java Build a circle from points

Build a circle from points

Author

Date

Category

Hello! It is necessary to build a circle from the points (filled), each point will have its own value and because of this its shade of color, as a result there should be a certain drawing in the circle. Now I am primitive, from the center around the corner of the tilt, and the drawing with JFreeChar, it turns out there are few points (acc. Malaya drawing accuracy) and degrees need to score into the code. The question arose, maybe someone knows how easier and more efficiently do? Something like matrix points fill


Answer 1, Authority 100%

For drawing lines and circles use Bonezenham algorithm .

When working the algorithm you will get all the circumference points in the first quadrant. Reflecting them with respect to the vertical axis, you can fill out the upper semi-friendly, such as solid color. If not solid color, but the pattern, you need to take the coordinate of each point and convert it into color.

Example.

Breasenham algorithm builds a circle around the coordinate center (0, 0) . Having received the following coordinate in the next step (x i , y i ) , we can spend lines from (- X I , y i ) to (x i , y i ) and from (- x i ,y i ) to (x i ,y i ) it will give a filled circle.

for pattern when drawing a line from (- x i , y i ) to (x i , Y I ) We must take each separate point for x j from -x i to x i and calculate its color according to your formula.

c = f (x j , y i )

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions