public override void DrawArc(double x1, double y1, double x2, double y2, double bulge) { if (thinlinemode != ThinLineModeFlag.OwnThinLines) { base.DrawArc(x1, y1, x2, y2, bulge); return; } stipplebit = 0x8000; int clipres = Clipper.ClipArc(x1, y1, x2, y2, bulge, clipbuffer, clipMinX, clipMinY, clipMaxX, clipMaxY); 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); Line_Internal(cx, cy, nx, ny, x2 == x && y2 == y); //set last point if last segment cx = nx; cy = ny; }); } }
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; } }); } }