Esempio n. 1
0
        public override void DrawEllipse(double cx, double cy, double aradius, double bradius, double tilt)
        {
            if (thinlinemode != ThinLineModeFlag.OwnThinLines)
            {
                base.DrawEllipse(cx, cy, aradius, bradius, tilt);
                return;
            }

            /*stipplebit = 0x8000;
             *
             * int px = 0, py = 0, nx, ny;
             * bool first = true;
             *
             * GeomUtil.FlattenEllipse(cx, cy, aradius, bradius, tilt, flattentol, true, (x, y, moveto) =>
             * {
             *  nx = GFXUtil.RealToInt(x);
             *  ny = GFXUtil.RealToInt(y);
             *  if (!first)
             *      Line_Internal(px, py, nx, ny, true); //TODO: can we skip last pixel except on last segment?
             *  else
             *      first = false;
             *  px = nx;
             *  py = ny;
             * });*/



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

            int num = Clipper.ClipEllipse(cx, cy, aradius, bradius, tilt, clipbuffer, clipMinX, clipMinY, clipMaxX, clipMaxY);

            if (num == 1)
            { //entire arc visible
                stipplebit = 0x8000;

                GeomUtil.FlattenEllipse(cx, cy, aradius, bradius, tilt, flattentol, true, (x, y, moveto) =>
                {
                    nx = GFXUtil.FloatToInt(x);
                    ny = GFXUtil.FloatToInt(y);
                    if (!moveto)
                    {
                        Line_Internal(px, py, nx, ny, true); //TODO: can we skip last pixel except on last segment?
                    }
                    px = nx;
                    py = ny;
                });
            }
            else
            { //arc is clipped (or possibly invisble when nnum==0)
                for (int l = 0; l < num; l += 2)
                {
                    stipplebit = 0x8000;

                    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)
                        {
                            Line_Internal(px, py, nx, ny, true);
                        }
                        px = nx;
                        py = ny;
                    });
                }
            }
        }