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

void javamorph::CPolygonDecorator::drawLine ( Point  p1,
Point  p2 
) [inline, private]

Draw a line between two polygon points into the clip matrix.

Parameters:
p1 First point.
p2 Second point.

|x| |x1| |x2 - x1| 0.0 <= p <= 1.0 | | = | | + p * | | resolution depends on longer |y| |y1| |y2 - y1| orthogonal difference.

Line is orthogonal pixel proof.

Definition at line 333 of file CPolygonDecorator.java.

References clip().

Referenced by genClip().

                                             {
        if(p1.equals(p2))return;
        int 
            x1 = p1.x,
            x2 = p2.x,
            y1 = p1.y,
            y2 = p2.y,
            dx = x2 - x1,
            dy = y2 - y1,
            param = Math.max(Math.abs(dx), Math.abs(dy)),
            x,
            y;
        for(int p = 0; p <= param; ++p){
            x = (int)(x1 + (double)p * dx / (double)param);
            y = (int)(y1 + (double)p * dy / (double)param);
            clip
                [Math.max(0, Math.min(x, clip.length) - 1)]
                [Math.max(0, Math.min(y, clip[0].length) - 1)] = 1.0;
        }
    }    


Generated by  Doxygen 1.6.0   Back to index