Drawing Circles Program in figure 15.52, will deal with drawing circles. This is Java1530.java, much more complicated that drawing lines or rectangles from a programming point of view. Think of what you need to do to draw a circle with a paint program. You use your cursor to find the center of the circle and press down the button. Instead of calling this location (startX, startY) we will call it (centerX, As you drag the mouse you make the circle larger as you increase its centerY). and then release the button when finished. Since the is the distance radius radius from the to any point on the of the circle, we will call the release point center rim (rimX, rimY) instead of (endX, endY). Well, we have 2 points just like we did for the lines and the rectangles. In the case of the circle we need to do a little math. The will be the radius distance these 2 points. The math required to compute this is explained below. If between you are in a higher-level math class you should recognize the Pythagorean and the If not, just accept that I had to write a special Theorem distance formula. getRadius method for this to work and that the method is based on the following mathematical information: c a b Given that the triangle above is a if you know the lengths of sides right triangle, and you can compute side this formula: a b c
Drawing Circles Program Java1530.java, in figure 15.52, will deal with drawing circles. This is much more complicated that drawing lines or rectangles from a programming point of view. Think of what you need to do to draw a circle with a paint program. You use your cursor to find the center of the circle and press down the button. Instead of calling this location (startX, startY) we will call it (centerX, centerY). As you drag the mouse you make the circle larger as you increase its radius and then release the button when finished. Since the radius is the distance from the center to any point on the rim of the circle, we will call the release point (rimX, rimY) instead of (endX, endY). Well, we have 2 points just like we did for the lines and the rectangles. In the case of the circle we need to do a little math. The radius will be the distance between these 2 points. The math required to compute this is explained below. If you are in a higher-level math class you should recognize the Pythagorean Theorem and the distance formula. If not, just accept that I had to write a special getRadius method for this to work and that the method is based on the following mathematical information: c a b Given that the triangle above is a right triangle, if you know the lengths of sides a and b you can compute side c this formula:
Text15-IntermediateGFX.docx