Пример #1
0
 public override void DrawLine(double x1, double y1, double x2, double y2)
 {
     if (Clipper.ClipLine(ref x1, ref y1, ref x2, ref y2, Clip.XMin, Clip.YMin, Clip.XMax, Clip.YMax))
     {
         target.Add(GFXUtil.FloatToInt(x1), GFXUtil.FloatToInt(y1), GFXUtil.FloatToInt(x2), GFXUtil.FloatToInt(y2), currentobject);
     }
 }
Пример #2
0
        public override void DrawPolyLine(bool close, params double[] xy)
        {
            if (xy.Length < 1)
            {
                return;
            }

            int prevx = GFXUtil.FloatToInt(xy[0]);
            int prevy = GFXUtil.FloatToInt(xy[1]);
            int startx = prevx, starty = prevy;
            int nextx, nexty;

            if (xy.Length == 1)
            {
                DrawLine(prevx, prevy, prevx, prevy);
                return;
            }

            for (int l = 2; l < xy.Length; l += 2)
            {
                nextx = GFXUtil.FloatToInt(xy[l]);
                nexty = GFXUtil.FloatToInt(xy[l + 1]);
                DrawLine(prevx, prevy, nextx, nexty);
                prevx = nextx;
                prevy = nexty;
            }

            if (close)
            {
                DrawLine(prevx, prevy, startx, starty);
            }
        }
Пример #3
0
        private void MarkEllipsisDot(double rx, double ry)
        {
            int x = GFXUtil.FloatToInt(rx);
            int y = GFXUtil.FloatToInt(ry);

            SetPixel(x, y, Color);
            SetPixel(x + 1, y, Color);
            SetPixel(x + 1, y + 1, Color);
            SetPixel(x, y + 1, Color);
        }
Пример #4
0
        public override void FillRectangle(double x1, double y1, double x2, double y2)
        {
            int ix1 = GFXUtil.FloatToInt(x1);
            int iy1 = GFXUtil.FloatToInt(y1);
            int ix2 = GFXUtil.FloatToInt(x2);
            int iy2 = GFXUtil.FloatToInt(y2);

            DrawLine(ix1, iy1, ix2, iy1);
            DrawLine(ix2, iy1, ix2, iy2);
            DrawLine(ix2, iy2, ix1, iy2);
            DrawLine(ix1, iy2, ix1, iy1);
        }
Пример #5
0
        /// <summary>
        /// Strokes a path using GDI
        /// </summary>
        /// <param name="trans"></param>
        public void InternalStrokePath(GFXPath path, Transform2d trans, bool forceclosed, bool allowmodifypath)
        {
            int cx = 0, cy = 0, nx, ny;

            if (trans == null || trans.IsIdentity)
            {
                path.Flatten(flattentol, (x, y, moveto) =>
                {
                    if (moveto)
                    {
                        cx = GFXUtil.FloatToInt(x);
                        cy = GFXUtil.FloatToInt(y);
                    }
                    else
                    {
                        nx = GFXUtil.FloatToInt(x);
                        ny = GFXUtil.FloatToInt(y);
                        DrawLine(nx, ny, cx, cy);
                        //target.Add(nx, ny, cx, cy, currentobject);
                        cx = nx;
                        cy = ny;
                    }
                });
            }
            else
            {
                path.TransformFlatten(flattentol, trans, (x, y, moveto) =>
                {
                    if (moveto)
                    {
                        cx = GFXUtil.FloatToInt(x);
                        cy = GFXUtil.FloatToInt(y);
                    }
                    else
                    {
                        nx = GFXUtil.FloatToInt(x);
                        ny = GFXUtil.FloatToInt(y);
                        //target.Add(nx, ny, cx, cy, currentobject);
                        DrawLine(nx, ny, cx, cy);
                        cx = nx;
                        cy = ny;
                    }
                });
            }
        }
Пример #6
0
        public override void DrawEllipticArc(double cx, double cy, double aradius, double bradius, double tilt, double startangle, double sweepangle)
        {
            /*  int prevx=0,prevy=0;
             * int nextx,nexty;
             * bool first=true;
             *
             * GeomUtil.FlattenEllipticArc(cx, cy, aradius, bradius, tilt, startangle, sweepangle, flattentol, true, (x, y,moveto) =>
             * {
             *    if (first)
             *    {
             *        prevx = GFXUtil.RealToInt(x);
             *        prevy = GFXUtil.RealToInt(y);
             *        first = false;
             *    }
             *    else
             *    {
             *        nextx = GFXUtil.RealToInt(x);
             *        nexty = GFXUtil.RealToInt(y);
             *        DrawLine(prevx,prevy,nextx,nexty);
             *        //target.Add(prevx, prevy, nextx, nexty, currentobject);
             *        prevx = nextx;
             *        prevy = nexty;
             *    }
             * });*/

            int px = 0, py = 0, nx, ny;

            int num = Clipper.ClipEllipticArc(cx, cy, aradius, bradius, tilt, startangle, sweepangle, clipbuffer, Clip.XMin, Clip.YMin, Clip.XMax, Clip.YMax);

            for (int l = 0; l < num; l += 2)
            {
                GeomUtil.FlattenEllipticArc(cx, cy, aradius, bradius, tilt, clipbuffer[l], clipbuffer[l + 1] - clipbuffer[l], flattentol, true, (x, y, moveto) =>
                {
                    nx = GFXUtil.FloatToInt(x);
                    ny = GFXUtil.FloatToInt(y);
                    if (!moveto)
                    {
                        DrawLine(px, py, nx, ny);
                    }
                    px = nx;
                    py = ny;
                });
            }
        }
Пример #7
0
        public override void DrawArc(double x1, double y1, double x2, double y2, double bulge)
        {
            int prevx = GFXUtil.FloatToInt(x1);
            int prevy = GFXUtil.FloatToInt(y1);

            int clipres = Clipper.ClipArc(x1, y1, x2, y2, bulge, clipbuffer, Clip.XMin, Clip.YMin, Clip.XMax, Clip.YMax);

            for (int idx = 0; idx < clipres; idx += 5)
            {
                int cx = GFXUtil.FloatToInt(clipbuffer[idx]), cy = GFXUtil.FloatToInt(clipbuffer[idx + 1]), nx, ny;
                GeomUtil.FlattenArc(clipbuffer[idx], clipbuffer[idx + 1], clipbuffer[idx + 2], clipbuffer[idx + 3], clipbuffer[idx + 4], false, flattentol, (x, y, moveto) =>
                {
                    nx = GFXUtil.FloatToInt(x);
                    ny = GFXUtil.FloatToInt(y);
                    target.Add(cx, cy, nx, ny, currentobject);
                    cx = nx;
                    cy = ny;
                });
            }
        }
Пример #8
0
        private void InternalDrawBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
        {
            int n = Clipper.ClipBezier(x1, y1, x2, y2, x3, y3, x4, y4, clipbuffer, Clip.XMin, Clip.YMin, Clip.XMax, Clip.YMax);
            int penx = 0, peny = 0;

            for (int l = 0; l < n; l += 2)
            {
                GeomUtil.FlattenBezier(x1, y1, x2, y2, x3, y3, x4, y4, true, flattentol, (x, y, moveto) =>
                {
                    int nextx = GFXUtil.FloatToInt(x);
                    int nexty = GFXUtil.FloatToInt(y);

                    if (!moveto)
                    {
                        DrawLine(penx, peny, nextx, nexty);
                    }

                    penx = nextx;
                    peny = nexty;
                }, clipbuffer[l], clipbuffer[l + 1]);
            }
        }
Пример #9
0
        public virtual void DrawMark(double x, double y, MarkType type, int size)
        {
            double sz = (double)size;

            FillStyle oldfill = FillStyle;

            if ((type & MarkType.LargeCross) != 0)
            {
                double sd = sz * 1.414213562; //ie. sqrt(2)
                DrawLine(x, y - sd, x, y + sd);
                DrawLine(x - sd, y, x + sd, y);
            }
            else if ((type & MarkType.Cross) != 0)
            {
                DrawLine(x, y - sz, x, y + sz);
                DrawLine(x - sz, y, x + sz, y);
            }
            else if ((type & MarkType.Slit) != 0)
            {
                DrawLine(x, y, x, y + sz);
            }
            else if ((type & MarkType.Pixel) != 0)
            {
                SetPixel(GFXUtil.FloatToInt(x), GFXUtil.FloatToInt(y), Color);
            }


            if ((type & MarkType.DiagonalCross) != 0)
            {
                DrawLine(x - sz, y - sz, x + sz, y + sz);
                DrawLine(x - sz, y + sz, x + sz, y - sz);
            }


            if ((type & MarkType.Triangle) != 0)
            {
                DrawLine(x - sz, y - sz, x + sz, y - sz);
                DrawLine(x + sz, y - sz, x, y + sz);
                DrawLine(x, y + sz, x - sz, y - sz);
            }

            if ((type & MarkType.Roof) != 0)
            {
                DrawLine(x - sz, y + sz, x + sz, y + sz);
            }

            if ((type & MarkType.Floor) != 0)
            {
                DrawLine(x - sz, y - sz, x + sz, y - sz);
            }

            if ((type & MarkType.Circle) != 0)
            {
                DrawCircle(x, y, sz);
            }


            if ((type & MarkType.Diamond) != 0)
            {
                DrawPolyLine(true, x + sz, y, x, y - sz, x - sz, y, x, y + sz);
            }


            if ((type & MarkType.FilledRectangle) != 0)
            {
                FillStyle = FillStyle.Solid;
                FillRectangle(x - sz, y - sz, x + sz, y + sz);
            }
            else if ((type & MarkType.Rectangle) != 0)
            {
                DrawRectangle(x - sz, y - sz, x + sz, y + sz);
            }


            if (type.HasFlag(MarkType.Perpendicular))
            {
                DrawLine(x - sz, y + sz, x - sz, y - sz);
                DrawLine(x - sz, y - sz, x + sz, y - sz);
                DrawLine(x - sz, y, x, y);
                DrawLine(x, y, x, y - sz);
            }

            if (type.HasFlag(MarkType.Ellipsis))
            {
                MarkEllipsisDot(x - sz, y - sz);
                MarkEllipsisDot(x, y - sz);
                MarkEllipsisDot(x + sz, y - sz);
            }


            FillStyle = oldfill;
        }