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

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

Create a default polygon, depending on configuration coordinates, when initialization by file isn't possible of isn't intended.

Definition at line 263 of file CPolygonDecorator.java.

References image, and polygon.

Referenced by CPolygonDecorator(), and javamorph::CFrame::initPolygon().

                      {
        int 
            w = image.getWidth(), 
            h = image.getHeight(), 
            pts = CConfig.POINTS_OF_POLYGON;
        /* Clear the point collection. */
        polygon.clear();
        for(int i = 0; i < pts; ++i){
            Point p = new Point();
            /* Set all points into a circle. */
            double r = Math.sqrt(w * w + h * h) / 4.0;
            p.x = (int)(Math.cos(2.0 * Math.PI * i / (double)pts) * r); 
            p.y = (int)(Math.sin(2.0 * Math.PI * i / (double)pts) * r); 
            p.x += w / 2;
            p.y += h / 2;
            polygon.add(p);
        }
    }


Generated by  Doxygen 1.6.0   Back to index