Java 2D Graphics The better method for filling
Java 2D Graphics The better method for filling a shape involves a little more work. The basic idea is to calculate the intersection of the shape with each pixel of the output device. Pixels are colored in proportion to the amount they are covered by the shape. This reduces the jaggies that are symptomatic of aliased rendering. Not surprisingly, this technique is called antialiasing. Figure 2.4 shows the same shape as Figure 2.3, but rendered with antialiasing. The pixels on the edge aren’t just black or white; they’re varying shades of gray. Figure 2.4. Antialiased rendering Fortunately, the 2D API takes care of all the details for you. You just need to specify whether you want antialiasing, using rendering hints. 2.3.2 The Rasterizer Inside the rendering pipeline, a rasterizer takes ideal shapes and produces coverage values for each pixel. The coverage values represent how much of each pixel is covered by the shape. These coverage values are called alpha values. Each pixel has its own alpha value. The collection of all alpha values in an image is sometimes called the alpha channel. A pixel, then, is defined by a color and an alpha value. Intuitively, the alpha value indicates the transparency of the pixel. You can even think of the alpha value as part of the pixel’s color. As you’ll find out, colors are sometimes defined with an associated alpha value. In this context, the alpha value indicates the transparency of the color itself. Alpha values typically range from 0.0, for no coverage, to 1.0, which represents full coverage. In Figure 2.3, the rasterizer did not use antialiasing and produced either 0.0 or 1.0 for the alpha values. In Figure 2.4, antialiasing was used and the rasterizer produced a range of alpha values from 0.0 on the outside of the shape to 1.0 in the interior of the shape. Figure 2.5 shows the alpha values for page 22
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Tomcat Web Hosting services