コード例 #1
0
        public void PineHLine(int xc, int yc, int xp1, int yp1, int xp2, int yp2,
                              int xh1, int yh1, int xh2)
        {
            if (doClipping && ClipLiangBarsky.Flags(xc, yc, clippingRectangle) != 0)
            {
                return;
            }
            byte[] covers             = new byte[MAX_HALF_WIDTH * 2 + 4];
            int    index0             = 0;
            int    index1             = 0;
            int    x                  = xh1 << LineAA.SUBPIXEL_SHIFT;
            int    y                  = yh1 << LineAA.SUBPIXEL_SHIFT;
            int    w                  = SubPixelWidth;
            DistanceInterpolator00 di = new DistanceInterpolator00(xc, yc, xp1, yp1, xp2, yp2, x, y);

            x += LineAA.SUBPIXEL_SCALE / 2;
            y += LineAA.SUBPIXEL_SCALE / 2;
            int xh0 = xh1;
            int dx  = x - xc;
            int dy  = y - yc;

            do
            {
                int d = (int)(AggMath.fast_sqrt(dx * dx + dy * dy));
                covers[index1] = 0;
                if (di.Distance1 <= 0 && di.Distance2 > 0 && d <= w)
                {
                    covers[index1] = (byte)GetCover(d);
                }
                ++index1;
                dx += LineAA.SUBPIXEL_SCALE;
                di.IncX();
            }while (++xh1 <= xh2);
            destImageSurface.BlendSolidHSpan(xh0, yh1, index1 - index0, Color, covers, index0);
        }
コード例 #2
0
        public override void SemiDot(CompareFunction cmp, int xc1, int yc1, int xc2, int yc2)
        {
            if (doClipping && ClipLiangBarsky.Flags(xc1, yc1, clippingRectangle) != 0)
            {
                return;
            }
            int r = ((SubPixelWidth + LineAA.SUBPIXEL_MARK) >> LineAA.SUBPIXEL_SHIFT);

            if (r < 1)
            {
                r = 1;
            }
            EllipseBresenhamInterpolator ei = new EllipseBresenhamInterpolator(r, r);
            int dx  = 0;
            int dy  = -r;
            int dy0 = dy;
            int dx0 = dx;
            int x   = xc1 >> LineAA.SUBPIXEL_SHIFT;
            int y   = yc1 >> LineAA.SUBPIXEL_SHIFT;

            do
            {
                dx += ei.Dx;
                dy += ei.Dy;
                if (dy != dy0)
                {
                    SemiDotHLine(cmp, xc1, yc1, xc2, yc2, x - dx0, y + dy0, x + dx0);
                    SemiDotHLine(cmp, xc1, yc1, xc2, yc2, x - dx0, y - dy0, x + dx0);
                }
                dx0 = dx;
                dy0 = dy;
                ei.Next();
            }while (dy < 0);
            SemiDotHLine(cmp, xc1, yc1, xc2, yc2, x - dx0, y + dy0, x + dx0);
        }
コード例 #3
0
 public void MoveTo(int x1, int y1)
 {
     m_x1 = x1;
     m_y1 = y1;
     if (m_clipping)
     {
         m_f1 = ClipLiangBarsky.Flags(x1, y1, clipBox);
     }
 }
コード例 #4
0
            //--------------------------------------------------------------------
            public void LineTo(int x2, int y2)
            {
                if (m_clipping)
                {
                    int f2 = ClipLiangBarsky.Flags(x2, y2, clipBox);
                    if ((m_f1 & 10) == (f2 & 10) && (m_f1 & 10) != 0)
                    {
                        // Invisible by Y
                        m_x1 = x2;
                        m_y1 = y2;
                        m_f1 = f2;
                        return;
                    }

                    int x1 = m_x1;
                    int y1 = m_y1;
                    int f1 = m_f1;
                    int y3, y4;
                    int f3, f4;
                    switch (((f1 & 5) << 1) | (f2 & 5))
                    {
                    case 0:     // Visible by X
                        LineClipY(x1, y1, x2, y2, f1, f2);
                        break;

                    case 1:     // x2 > clip.x2
                        y3 = y1 + MulDiv(clipBox.Right - x1, y2 - y1, x2 - x1);
                        f3 = ClipLiangBarsky.GetFlagsY(y3, clipBox);
                        LineClipY(x1, y1, clipBox.Right, y3, f1, f3);
                        LineClipY(clipBox.Right, y3, clipBox.Right, y2, f3, f2);
                        break;

                    case 2:     // x1 > clip.x2
                        y3 = y1 + MulDiv(clipBox.Right - x1, y2 - y1, x2 - x1);
                        f3 = ClipLiangBarsky.GetFlagsY(y3, clipBox);
                        LineClipY(clipBox.Right, y1, clipBox.Right, y3, f1, f3);
                        LineClipY(clipBox.Right, y3, x2, y2, f3, f2);
                        break;

                    case 3:     // x1 > clip.x2 && x2 > clip.x2
                        LineClipY(clipBox.Right, y1, clipBox.Right, y2, f1, f2);
                        break;

                    case 4:     // x2 < clip.x1
                        y3 = y1 + MulDiv(clipBox.Left - x1, y2 - y1, x2 - x1);
                        f3 = ClipLiangBarsky.GetFlagsY(y3, clipBox);
                        LineClipY(x1, y1, clipBox.Left, y3, f1, f3);
                        LineClipY(clipBox.Left, y3, clipBox.Left, y2, f3, f2);
                        break;

                    case 6:     // x1 > clip.x2 && x2 < clip.x1
                        y3 = y1 + MulDiv(clipBox.Right - x1, y2 - y1, x2 - x1);
                        y4 = y1 + MulDiv(clipBox.Left - x1, y2 - y1, x2 - x1);
                        f3 = ClipLiangBarsky.GetFlagsY(y3, clipBox);
                        f4 = ClipLiangBarsky.GetFlagsY(y4, clipBox);
                        LineClipY(clipBox.Right, y1, clipBox.Right, y3, f1, f3);
                        LineClipY(clipBox.Right, y3, clipBox.Left, y4, f3, f4);
                        LineClipY(clipBox.Left, y4, clipBox.Left, y2, f4, f2);
                        break;

                    case 8:     // x1 < clip.x1
                        y3 = y1 + MulDiv(clipBox.Left - x1, y2 - y1, x2 - x1);
                        f3 = ClipLiangBarsky.GetFlagsY(y3, clipBox);
                        LineClipY(clipBox.Left, y1, clipBox.Left, y3, f1, f3);
                        LineClipY(clipBox.Left, y3, x2, y2, f3, f2);
                        break;

                    case 9:      // x1 < clip.x1 && x2 > clip.x2
                        y3 = y1 + MulDiv(clipBox.Left - x1, y2 - y1, x2 - x1);
                        y4 = y1 + MulDiv(clipBox.Right - x1, y2 - y1, x2 - x1);
                        f3 = ClipLiangBarsky.GetFlagsY(y3, clipBox);
                        f4 = ClipLiangBarsky.GetFlagsY(y4, clipBox);
                        LineClipY(clipBox.Left, y1, clipBox.Left, y3, f1, f3);
                        LineClipY(clipBox.Left, y3, clipBox.Right, y4, f3, f4);
                        LineClipY(clipBox.Right, y4, clipBox.Right, y2, f4, f2);
                        break;

                    case 12:     // x1 < clip.x1 && x2 < clip.x1
                        LineClipY(clipBox.Left, y1, clipBox.Left, y2, f1, f2);
                        break;
                    }
                    m_f1 = f2;
                }
                else
                {
                    ras.DrawLine(m_x1, m_y1,
                                 x2, y2);
                }
                m_x1 = x2;
                m_y1 = y2;
            }