Exemplo n.º 1
0
 public override void Line0(LineParameters lp)
 {
     if (doClipping)
     {
         int x1    = lp.x1;
         int y1    = lp.y1;
         int x2    = lp.x2;
         int y2    = lp.y2;
         int flags = ClipLiangBarsky.ClipLineSegment(ref x1, ref y1, ref x2, ref y2, clippingRectangle);
         if ((flags & 4) == 0)
         {
             if (flags != 0)
             {
                 LineParameters lp2 = new LineParameters(x1, y1, x2, y2,
                                                         AggBasics.uround(AggMath.calc_distance(x1, y1, x2, y2)));
                 Line0NoClip(lp2);
             }
             else
             {
                 Line0NoClip(lp);
             }
         }
     }
     else
     {
         Line0NoClip(lp);
     }
 }
Exemplo n.º 2
0
 public override void Line3(LineParameters lp,
                            int sx, int sy, int ex, int ey)
 {
     if (doClipping)
     {
         int x1    = lp.x1;
         int y1    = lp.y1;
         int x2    = lp.x2;
         int y2    = lp.y2;
         int flags = ClipLiangBarsky.ClipLineSegment(ref x1, ref y1, ref x2, ref y2, clippingRectangle);
         if ((flags & 4) == 0)
         {
             if (flags != 0)
             {
                 LineParameters lp2 = new LineParameters(x1, y1, x2, y2,
                                                         AggBasics.uround(AggMath.calc_distance(x1, y1, x2, y2)));
                 if ((flags & 1) != 0)
                 {
                     sx = x1 + (y2 - y1);
                     sy = y1 - (x2 - x1);
                 }
                 else
                 {
                     while (Math.Abs(sx - lp.x1) + Math.Abs(sy - lp.y1) > lp2.len)
                     {
                         sx = (lp.x1 + sx) >> 1;
                         sy = (lp.y1 + sy) >> 1;
                     }
                 }
                 if ((flags & 2) != 0)
                 {
                     ex = x2 + (y2 - y1);
                     ey = y2 - (x2 - x1);
                 }
                 else
                 {
                     while (Math.Abs(ex - lp.x2) + Math.Abs(ey - lp.y2) > lp2.len)
                     {
                         ex = (lp.x2 + ex) >> 1;
                         ey = (lp.y2 + ey) >> 1;
                     }
                 }
                 Line3NoClip(lp2, sx, sy, ex, ey);
             }
             else
             {
                 Line3NoClip(lp, sx, sy, ex, ey);
             }
         }
     }
     else
     {
         Line3NoClip(lp, sx, sy, ex, ey);
     }
 }