/// <summary> /// draw the path to a target /// </summary> /// <param name="target">the draw target</param> /// <param name="strokeSize">the stroke size, 0-1</param> public void DrawTo(IDrawTarget target, float strokeSize = 1) { // set the color and stroke target.SetPrimaryColor(color); target.SetStroke(strokeSize); // draw the path target.DrawPoly(Vertices); }
/// <summary> /// Draw the dotmap to a target /// </summary> /// <param name="target">where to draw to</param> /// <param name="firstColorFill">should the first color be drawn using flood- fill? (canvas has to be empty for this to work well)</param> /// <param name="strokeSize">the stroke size, 0-1</param> /// <param name="mode">the draw mode</param> public void DrawTo(IDrawTarget target, bool firstColorFill, float strokeSize = 1, DrawMode mode = DrawMode.Dots) { strokeSize = Math.Clamp(strokeSize, 0, 1); double totalDots = TotalDots; double dotsDrawn = 0; bool useFill = firstColorFill; // set stroke size target.SetStroke(strokeSize); // draw colors in batches foreach (Color c in dotMap.Keys.OrderByDescending(cx => dotMap[cx].Count)) { if (dotMap[c].Count > 0) { // select the color target.SetPrimaryColor(c); // fill the first color using bucket tool if enabled if (useFill) { // bucket in the center of the image target.Fill(new PointF(.5f, .5f)); // add dots drawn to total dotsDrawn += dotMap[c].Count; useFill = false; continue; } // draw all dots if (mode == DrawMode.Dots) { dotsDrawn += DrawUsingDots(target, dotMap[c], totalDots, dotsDrawn); } else { dotsDrawn += DrawUsingPolys(target, dotMap[c], totalDots, dotsDrawn); } ReportProgress(dotsDrawn / totalDots); } } }