public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { int delta = 1 - 1 * r; int x = 0; int y = r; while (y >= 0) { PutPixel(pixelSet, x0 + x, y0 + y); PutPixel(pixelSet, x0 + x, y0 - y); PutPixel(pixelSet, x0 - x, y0 + y); PutPixel(pixelSet, x0 - x, y0 - y); int error = 2 * (delta + y) - 1; if (delta < 0 && error <= 0) { ++x; delta += 2 * x + 1; continue; } error = 2 * (delta - x) - 1; if (delta > 0 && error > 0) { --y; delta += 1 - 2 * y; continue; } ++x; delta += 2 * (x - y); --y; } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { if (cutted && Otsechenie.Vne(cutArgs, x0, y0, x1, y1)) return; var deltaX = Math.Abs(x1 - x0); var deltaY = Math.Abs(y1 - y0); var signX = x0 < x1 ? 1 : -1; var signY = y0 < y1 ? 1 : -1; // int error = deltaX - deltaY; // pixelSet.DrawPixel(x1, y1); int x2 = x0; int y2 = y0; while (x2 != x1 || y2 != y1) { if (!cutted || !Otsechenie.Vne(cutArgs, x2, y2)) pixelSet.DrawPixel(x2, y2); int error2 = error * 2; // if (error2 > -deltaY) { error -= deltaY; x2 += signX; } if (error2 < deltaX) { error += deltaX; y2 += signY; } } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { int a = y1 - y0; int b = x0 - x1; int c = x1 * y0 - x0 * y1; if (Math.Abs(x0 - x1) > Math.Abs(y0 - y1)) { int dx = x0 > x1 ? -1 : 1; for (int i = x0; i != x1; i += dx) { int x = i; int y = (b == 0) ? y0 : (-c - a * i) / b; pixelSet.DrawPixel(x, y); } } else { int dy = y0 > y1 ? -1 : 1; for (int i = y0; i != y1; i += dy) { int x = (a == 0) ? x0 : (-c - b * i) / a; int y = i; pixelSet.DrawPixel(x, y); } } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { var deltaX = Math.Abs(x1 - x0); var deltaY = Math.Abs(y1 - y0); var signX = x0 < x1 ? 1 : -1; var signY = y0 < y1 ? 1 : -1; // int error = deltaX - deltaY; // pixelSet.DrawPixel(x1, y1); int x2 = x0; int y2 = y0; while (x2 != x1 || y2 != y1) { pixelSet.DrawPixel(x2, y2); int error2 = error * 2; // if (error2 > -deltaY) { error -= deltaY; x2 += signX; } if (error2 < deltaX) { error += deltaX; y2 += signY; } } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { int a = y1 - y0; int b = x0 - x1; int c = x1 * y0 - x0 * y1; if (Math.Abs(x0 - x1) > Math.Abs(y0-y1)) { int dx = x0 > x1 ? -1 : 1; for (int i = x0; i != x1; i += dx) { int x = i; int y = (b == 0) ? y0 : (-c - a * i) / b ; pixelSet.DrawPixel(x, y); } } else { int dy = y0 > y1 ? -1 : 1; for (int i = y0; i != y1; i += dy) { int x = (a == 0) ? x0 : (-c - b * i) / a; int y = i; pixelSet.DrawPixel(x, y); } } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { var cut = new CuttingArguments { MinX = Math.Min(x0, x1), MinY = Math.Min(y0, y1), MaxX = Math.Max(x0, x1), MaxY = Math.Max(y0, y1), }; IPaintTool line1 = Line2Tool.Build(); line1.OnMouseClick(cut.MinX, cut.MinY); line1.OnMouseClicked(cut.MinX, cut.MaxY); line1.Draw(pixelSet, drawingArea); IPaintTool line2 = Line2Tool.Build(); line2.OnMouseClick(cut.MinX, cut.MaxY); line2.OnMouseClicked(cut.MaxX, cut.MaxY); line2.Draw(pixelSet, drawingArea); IPaintTool line3 = Line2Tool.Build(); line3.OnMouseClick(cut.MaxX, cut.MaxY); line3.OnMouseClicked(cut.MaxX, cut.MinY); line3.Draw(pixelSet, drawingArea); IPaintTool line4 = Line2Tool.Build(); line4.OnMouseClick(cut.MaxX, cut.MinY); line4.OnMouseClicked(cut.MinX, cut.MinY); line4.Draw(pixelSet, drawingArea); foreach (IPaintTool paintTool in drawingArea) { paintTool.Cutting(cut); } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { this.pixelSet = pixelSet; this.drawingArea = drawingArea; if (afterClick) { if (list == null) { list = new List <Point>(); if (!afterMove) { thread = new Thread(Fill) { }; thread.Start(); } else { Fill(); drawingArea.Redraw(); } } else { DrawStack(pixelSet); } } }
public override void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { if (!afterMouseClick) { return; } base.Draw(pixelSet, drawingArea); }
private void DrawStack(IPixelSet pixelSet) { lock (list) foreach (var item in list) { pixelSet.FillCell(item.X, item.Y); } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { this.drawingArea = drawingArea; if (dragAndDropPoints.Count != 4) return; SplineHelper.Splaynn spline = new SplineHelper.Splaynn(); spline.splayn(dragAndDropPoints.Select(x => (double)x.X).ToArray(), dragAndDropPoints.Select(x => (double)x.Y).ToArray()); for (double i = dragAndDropPoints.Min(x => x.X); i <= dragAndDropPoints.Max(x => x.X); i += 0.01 ) { pixelSet.DrawPixel((int)i, (int)spline.func(i)); } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { if (cuttingMode) { foreach (var line in lines) line.Cutting(cutArgs); } foreach (var line in lines) line.Draw(pixelSet, drawingArea); if (currentLine != null) currentLine.Draw(pixelSet, drawingArea); }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { this.drawingArea = drawingArea; if (dragAndDropPoints.Count != 4) { return; } SplineHelper.Splaynn spline = new SplineHelper.Splaynn(); spline.splayn(dragAndDropPoints.Select(x => (double)x.X).ToArray(), dragAndDropPoints.Select(x => (double)x.Y).ToArray()); for (double i = dragAndDropPoints.Min(x => x.X); i <= dragAndDropPoints.Max(x => x.X); i += 0.01) { pixelSet.DrawPixel((int)i, (int)spline.func(i)); } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { this.drawingArea = drawingArea; if (dragAndDropPoints.Count != 4) return; for (double t = 0; t <= 1; t += 0.001) { var x = (int) ((2*t*t*t - 3*t*t + 1)*dragAndDropPoints[0].X + (t*t*t - 2*t*t + t)*dragAndDropPoints[1].X + (-2*t*t*t + 3*t*t)*dragAndDropPoints[2].X + (t*t*t - t*t)*dragAndDropPoints[3].X); var y = (int) ((2*t*t*t - 3*t*t + 1)*dragAndDropPoints[0].Y + (t*t*t - 2*t*t + t)*dragAndDropPoints[1].Y + (-2*t*t*t + 3*t*t)*dragAndDropPoints[2].Y + (t*t*t - t*t)*dragAndDropPoints[3].Y); if (pixelSet.IsNotFilled(x, y)) pixelSet.DrawPixel(x, y); } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { this.drawingArea = drawingArea; if (dragAndDropPoints.Count != 4) return; for (double t = 0; t <= 1; t += 0.001) { int x = (int) ((1 - t) * (1 - t) * (1 - t) * dragAndDropPoints[0].X + 3 * t * (1 - t) * (1 - t)*dragAndDropPoints[1].X +3 * t * t * (1 - t) * dragAndDropPoints[2].X + t*t*t*dragAndDropPoints[3].X); int y = (int) ((1 - t)*(1 - t)*(1 - t)*dragAndDropPoints[0].Y + 3*t*(1 - t)*(1 - t)*dragAndDropPoints[1].Y + 3*t*t*(1 - t)*dragAndDropPoints[2].Y + t*t*t*dragAndDropPoints[3].Y); if (pixelSet.IsNotFilled(x, y)) pixelSet.DrawPixel(x, y); } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { if (cuttingMode) { foreach (var line in lines) { line.Cutting(cutArgs); } } foreach (var line in lines) { line.Draw(pixelSet, drawingArea); } if (currentLine != null) { currentLine.Draw(pixelSet, drawingArea); } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { int col, i, row, bnew; long a_square, b_square, two_a_square, two_b_square, four_a_square, four_b_square, d; b_square = b * b; a_square = a * a; row = b; col = 0; two_a_square = a_square << 1; four_a_square = a_square << 2; four_b_square = b_square << 2; two_b_square = b_square << 1; d = two_a_square * ((row - 1) * (row)) + a_square + two_b_square * (1 - a_square); while (a_square * (row) > b_square * (col)) { PutPixel(pixelSet, col + x, row + y); PutPixel(pixelSet, col + x, y - row); PutPixel(pixelSet, x - col, row + y); PutPixel(pixelSet, x - col, y - row); if (d >= 0) { row--; d -= four_a_square * (row); } d += two_b_square * (3 + (col << 1)); col++; } d = two_b_square * (col + 1) * col + two_a_square * (row * (row - 2) + 1) + (1 - two_a_square) * b_square; while ((row + 1) > 0) { PutPixel(pixelSet, col + x, row + y); PutPixel(pixelSet, col + x, y - row); PutPixel(pixelSet, x - col, row + y); PutPixel(pixelSet, x - col, y - row); if (d <= 0) { col++; d += four_b_square * col; } row--; d += two_a_square * (3 - (row << 1)); } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { this.drawingArea = drawingArea; if (dragAndDropPoints.Count != 4) { return; } for (double t = 0; t <= 1; t += 0.001) { var x = (int)((2 * t * t * t - 3 * t * t + 1) * dragAndDropPoints[0].X + (t * t * t - 2 * t * t + t) * dragAndDropPoints[1].X + (-2 * t * t * t + 3 * t * t) * dragAndDropPoints[2].X + (t * t * t - t * t) * dragAndDropPoints[3].X); var y = (int)((2 * t * t * t - 3 * t * t + 1) * dragAndDropPoints[0].Y + (t * t * t - 2 * t * t + t) * dragAndDropPoints[1].Y + (-2 * t * t * t + 3 * t * t) * dragAndDropPoints[2].Y + (t * t * t - t * t) * dragAndDropPoints[3].Y); if (pixelSet.IsNotFilled(x, y)) { pixelSet.DrawPixel(x, y); } } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { this.drawingArea = drawingArea; if (dragAndDropPoints.Count != 4) { return; } for (double t = 0; t <= 1; t += 0.001) { int x = (int)((1 - t) * (1 - t) * (1 - t) * dragAndDropPoints[0].X + 3 * t * (1 - t) * (1 - t) * dragAndDropPoints[1].X + 3 * t * t * (1 - t) * dragAndDropPoints[2].X + t * t * t * dragAndDropPoints[3].X); int y = (int)((1 - t) * (1 - t) * (1 - t) * dragAndDropPoints[0].Y + 3 * t * (1 - t) * (1 - t) * dragAndDropPoints[1].Y + 3 * t * t * (1 - t) * dragAndDropPoints[2].Y + t * t * t * dragAndDropPoints[3].Y); if (pixelSet.IsNotFilled(x, y)) { pixelSet.DrawPixel(x, y); } } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { if (cutted && Otsechenie.Vne(cutArgs, x0, y0, x1, y1)) { return; } var deltaX = Math.Abs(x1 - x0); var deltaY = Math.Abs(y1 - y0); var signX = x0 < x1 ? 1 : -1; var signY = y0 < y1 ? 1 : -1; // int error = deltaX - deltaY; // pixelSet.DrawPixel(x1, y1); int x2 = x0; int y2 = y0; while (x2 != x1 || y2 != y1) { if (!cutted || !Otsechenie.Vne(cutArgs, x2, y2)) { pixelSet.DrawPixel(x2, y2); } int error2 = error * 2; // if (error2 > -deltaY) { error -= deltaY; x2 += signX; } if (error2 < deltaX) { error += deltaX; y2 += signY; } } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { if (!afterClick) { return; } if (allPoints == null) { this.pixelSet = pixelSet; allPoints = new HashSet <KeyValuePair <int, int> >(new Comparer()); drawingPoints = new HashSet <KeyValuePair <int, int> >(new Comparer()); this.drawingArea = drawingArea; startFill(); minY = allPoints.Min(x => x.Value); maxY = allPoints.Max(x => x.Value); ThreadPool.QueueUserWorkItem(fedos); } lock (drawingPoints) foreach (var x in drawingPoints) { pixelSet.FillCell(x.Key, x.Value); } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { this.pixelSet = pixelSet; this.drawingArea = drawingArea; if (afterClick) if (list == null) { list = new List<Point>(); if (!afterMove) { thread = new Thread(Fill) {}; thread.Start(); } else { Fill(); drawingArea.Redraw(); } } else { DrawStack(pixelSet); } }
private void PutPixel(IPixelSet g, int x, int y) { g.DrawPixel(x, y); }
public virtual void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { PaintTool.Draw(pixelSet, drawingArea); }
public override void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { if (!afterMouseClick) return; base.Draw(pixelSet, drawingArea); }
private void DrawStack(IPixelSet pixelSet) { lock (list) foreach (var item in list) pixelSet.FillCell(item.X, item.Y); }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { }