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


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

            int buffersize = Clipper.ClipCircle(cx, cy, radius, clipbuffer, clipMinX, clipMinY, clipMaxX, clipMaxY);

            if (buffersize <= 0)
            {
                return;
            }

            if (buffersize >= 5) //circle is clipped to arcs
            {                    //the circle is divided into arc(s)
                double bulge, x1, y1, x2, y2;
                for (int l = 0; l < buffersize; l += 5)
                {
                    x1    = clipbuffer[l];
                    y1    = clipbuffer[l + 1];
                    x2    = clipbuffer[l + 2];
                    y2    = clipbuffer[l + 3];
                    bulge = clipbuffer[l + 4];

                    //draw arc here instead of calling DrawArc to avoid arc clipping because we already clipped!
                    GeomUtil.FlattenArc(x1, y1, x2, y2, bulge, true, flattentol, (x, y, moveto) =>
                    {
                        if (moveto)
                        {
                            px = GFXUtil.FloatToInt(x);
                            py = GFXUtil.FloatToInt(y);
                        }
                        else
                        {
                            nx = GFXUtil.FloatToInt(x);
                            ny = GFXUtil.FloatToInt(y);
                            Line_Internal(px, py, nx, ny, false);
                            px = nx;
                            py = ny;
                        }
                    });
                }

                return;
            }


            for (double l = -1; l <= 1.0001; l += 2)
            { //2 arcs gives circle  //TODO: make flatten circle in GeomUtil instead
                GeomUtil.FlattenArc(cx + radius * l, cy, cx - radius * l, cy, 1.0, true, flattentol, (x, y, moveto) =>
                {
                    if (moveto)
                    {
                        px = GFXUtil.FloatToInt(x);
                        py = GFXUtil.FloatToInt(y);
                    }
                    else
                    {
                        nx = GFXUtil.FloatToInt(x);
                        ny = GFXUtil.FloatToInt(y);
                        Line_Internal(px, py, nx, ny, false);
                        px = nx;
                        py = ny;
                    }
                });
            }
        }