tailieunhanh - J2ME in a Nutshell phần 4

Bởi vì một phác thảo chạm vào các điểm ảnh tại mỗi đầu, hình chữ nhật này bao gồm các điểm (0, 0), (4, 0), (0, 2), và (4, 2). Ngược lại, một hình chữ nhật đầy tạo ra bằng cách sử dụng các đối số tương tự sử dụng các giá trị chiều rộng và chiều cao để mô tả các khu vực chính xác để được lấp đầy: | J2ME in a Nutshell Figure 5-7. Outline differences between drawn and filled rectangles t nwRect 0 Ũ 4 Ĩ 0 3 1 01 t The rectangle at the top of Figure 5-7 was drawn using this code 0 0 4 2 Because an outline touches the pixels at each end this rectangle includes the points 0 0 4 0 0 2 and 4 2 . By contrast a filled rectangle created using the same arguments uses the width and height values to describe the exact area to be filled 4 pixels wide and 2 pixels down as shown at the bottom in Figure 5-7. You can see that a drawn rectangle occupies one more pixel each to the right and at the bottom than a filled rectangle. You can see this for yourself by selecting the RectangleFills example from GraphicsMiDiet. This creates a rectangle drawn with a dotted outline and a filled rectangle using identical arguments for each. Magnified versions of the top left and bottom right corners of these rectangles are shown in Figure 5-8. The figure clearly shows that the color fill does not reach the right side or the bottom of the drawn rectangle but it does cover the top and left of it. Figure 5-8. Drawn and filled rectangles Arcs Elliptical or circular arcs including complete circles and ellipses can be drawn either in outline or filled using the following methods public void drawArc int x int y int width int height int startAngle int arcAngle 151 J2ME in a Nutshell public void fillArc int x int y int width int height int startAngle int arcAngle The overall shape of the arc is determined by its bounding rectangle specified by the x y width and height arguments if the width and height values are the same the arc is a circle or part of a circle. The portion of the ellipse or circle to be drawn is controlled by the startAngle and arcAngle arguments both of which are measured in degrees. The startAngle argument specifies where the arc begins it is measured relative to the the three o clock position on the bounding rectangle. The angle through which the .