Logo Search packages:      
Sourcecode: javamorph version File versions  Download package

void javamorph::CPolygonDecorator::genClip (  )  [inline]

Provide the clip matrix. Calculates Ratio matrix of row / column.

Definition at line 165 of file CPolygonDecorator.java.

References clip(), drawLine(), f_clip, fill(), polygon, and smoothLine().

                         {
        /* Set all clip matrix pixels to zero. */
        for(int x = 0; x < clip.length; ++x){
            for(int y = 0; y < clip[0].length; ++y){
                clip[x][y] = 0.0;
            }
        }
        /* Draw lines connecting the polygon pixels. */
        for(int i = 0; i < polygon.size(); ++i){
            drawLine(polygon.get(i), polygon.get((i +1) % polygon.size()));
        }
        /* Fill the polygon. */
        fill();
        /* Smooth the edges of the polygon depending on the configuration. */
        for(int i = 0; i < polygon.size(); ++i){
            smoothLine(polygon.get(i), polygon.get((i +1) % polygon.size()));
        }
        /* Save the debug copy. */
        try{
            BufferedImage im = new BufferedImage(clip.length,clip[0].length, 
                        BufferedImage.TYPE_INT_ARGB);
            for(int x = 0; x < clip.length; ++x){
                for(int y = 0; y < clip[0].length; ++y){
                    int rgb =
                        0xff000000 |
                        (int)(clip[x][y] * 255) << 16 |
                        (int)(clip[x][y] * 255) << 8 |
                        (int)(clip[x][y] * 255);
                    im.setRGB(x, y, rgb);
                }
            }
            ImageIO.write(im, "png", f_clip);
        }catch(Exception e){
            System.err.println(e.getMessage());
            e.printStackTrace();
        }
    }


Generated by  Doxygen 1.6.0   Back to index